From: <jbo...@li...> - 2005-11-21 12:20:09
|
Author: wrzep Date: 2005-11-21 07:20:01 -0500 (Mon, 21 Nov 2005) New Revision: 1612 Modified: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java Log: Warnings when feed adress is incorrect or we are unable to parse the feed. http://jira.jboss.com/jira/browse/JBLAB-406 Pawel Modified: trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java =================================================================== --- trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java 2005-11-21 11:08:10 UTC (rev 1611) +++ trunk/forge/portal-extensions/forge-podcast/src/java/org/jboss/forge/podcast/Podcast.java 2005-11-21 12:20:01 UTC (rev 1612) @@ -34,6 +34,8 @@ import java.util.SimpleTimeZone; import java.net.URL; +import java.net.MalformedURLException; +import java.io.IOException; import org.jboss.forge.common.XmlTools; import org.jboss.forge.common.projects.AbstractDescriptor; @@ -44,6 +46,8 @@ import org.jboss.portal.common.context.DelegateContext; import org.jboss.shotoku.ContentManager; +import org.jboss.logging.Logger; + import org.apache.xerces.parsers.DOMParser; import org.xml.sax.InputSource; @@ -59,6 +63,7 @@ import de.nava.informa.core.ItemIF; import de.nava.informa.core.ItemEnclosureIF; import de.nava.informa.core.ImageIF; +import de.nava.informa.core.ParseException; /** * A class holding the podcast feeds. @@ -89,6 +94,8 @@ private String portalName; private String serverAdress; + private Logger log; + /** * <code>allItemsArr</code> - Array if ItemIF objects, containing items from all feeds. */ @@ -98,6 +105,8 @@ this.portalName = portalName; this.serverAdress = serverAdress; + log = Logger.getLogger(this.getClass()); + podcastsNumber = getPodcastsNumber(root); // Get the feeds nodes @@ -160,9 +169,6 @@ nodeContext.put("link", link.toString()); } - // TODO itunes tags - - // filling the context with enclosure information ItemEnclosureIF enclosure = item.getEnclosure(); @@ -193,6 +199,11 @@ nodeContext.put("channel-image", channelImage.getLocation().toString()); } + // TODO itunes tags + + System.out.println("channel / element value / author = " + channel.getElementValue("itunes:author")); + System.out.println("item / element value / image = " + item.getElementValue("itunes:image")); + context.append("podcast", nodeContext); } } @@ -253,13 +264,16 @@ private Set<ItemIF> getAllItems(Set<Map<String,Node>> nodes) { HashSet<ItemIF> ret = new HashSet<ItemIF>(); + Node urlNode = null; + String urlString = null; + for (Iterator iter = nodes.iterator(); iter.hasNext();) { try { Map nodeProperties = (Map<String,Node>) iter.next(); - Node urlNode = (Node) nodeProperties.get(URL_ELEMENT); + urlNode = (Node) nodeProperties.get(URL_ELEMENT); - String urlString = XmlTools.unmarshallText(urlNode); + urlString = XmlTools.unmarshallText(urlNode); if (urlString.charAt(0) == '/') { // local link urlString = serverAdress + urlString; } @@ -268,8 +282,10 @@ ChannelIF channel = FeedParser.parse(new ChannelBuilder(), url); ret.addAll(channel.getItems()); - } catch (Exception e) { - e.printStackTrace(); + } catch (IOException e) { + log.warn(urlString + " could not be found."); + } catch (ParseException e) { + log.warn("Parse error: " + urlString); } } return ret; |