|
From: <jbo...@li...> - 2006-05-31 15:21:23
|
Author: adamw Date: 2006-05-31 11:21:16 -0400 (Wed, 31 May 2006) New Revision: 4523 Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/InformaBasedFeed.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/RomeBasedFeed.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-36 Improved date handling Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/InformaBasedFeed.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/InformaBasedFeed.java 2006-05-31 14:37:46 UTC (rev 4522) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/InformaBasedFeed.java 2006-05-31 15:21:16 UTC (rev 4523) @@ -3,10 +3,7 @@ import java.io.File; import java.io.IOException; import java.net.URL; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.List; +import java.util.*; import de.nava.informa.core.ChannelExporterIF; import de.nava.informa.core.ChannelIF; @@ -35,10 +32,11 @@ newChannel.setCreator(author); newChannel.setPublisher(author); newChannel.setLocation(new URL(link)); - newChannel.setPubDate(Calendar.getInstance().getTime()); List<ItemIF> newItems = new ArrayList<ItemIF>(); + long pubDate = 0; + for (Feed feed : feeds) { ChannelIF childChannel; try { @@ -51,9 +49,16 @@ ItemIF nextItem = (ItemIF) o; nextItem.setCreator(childChannel.getCreator()); newItems.add(nextItem); + + long itemDate = nextItem.getDate().getTime(); + if (itemDate > pubDate) { + pubDate = itemDate; + } } } + newChannel.setPubDate(new Date(pubDate)); + Collections.sort(newItems, new ItemComparator(true)); for (ItemIF newItem : newItems) { Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/RomeBasedFeed.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/RomeBasedFeed.java 2006-05-31 14:37:46 UTC (rev 4522) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/data/RomeBasedFeed.java 2006-05-31 15:21:16 UTC (rev 4523) @@ -62,6 +62,8 @@ List entries = new ArrayList(); syndFeed.setEntries(entries); + long pubDate = 0; + for (Feed feed : feeds) { SyndFeedInput input = new SyndFeedInput(); SyndFeed inFeed; @@ -78,10 +80,17 @@ SyndEntry entry = (SyndEntry) o; entry.setAuthor(inFeed.getAuthor()); entries.add(entry); + + long entryDate = entry.getPublishedDate().getTime(); + if (entryDate > pubDate) { + pubDate = entryDate; + } } } } + syndFeed.setPublishedDate(new Date(pubDate)); + Collections.sort(entries, new Comparator<SyndEntry>() { public int compare(SyndEntry o1, SyndEntry o2) { Date date1 = o1.getPublishedDate(); Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java 2006-05-31 14:37:46 UTC (rev 4522) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java 2006-05-31 15:21:16 UTC (rev 4523) @@ -158,6 +158,17 @@ vc.put(searchNameAttr, list); + // Calculating the age of the youngest node and putting it into the context. + long youngestNode = 0; + for (org.jboss.shotoku.Node n : list) { + long nodeCreated = n.getCreated(); + if (nodeCreated > youngestNode) { + youngestNode = nodeCreated; + } + } + + vc.put(searchNameAttr + "Youngest", new Date(youngestNode)); + break; } catch (Exception e) { log.error("Error generating shotoku feed " + getFeedName() + ".", e); |