Author: janstey
Date: Mon Dec 8 10:33:47 2008
New Revision: 724439
URL: http://svn.apache.org/viewvc?rev=724439&view=rev
Log:
Change rss to sort by updated date, then pub date if no update. This is to
align with the atom component.
Added:
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
(with props)
Removed:
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/PublishedDateComparator.java
Modified:
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java
Added:
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java?rev=724439&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
(added)
+++
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
Mon Dec 8 10:33:47 2008
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.rss;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+
+import java.util.Comparator;
+import java.util.Date;
+
+public class RssDateComparator implements Comparator<SyndEntry> {
+
+ public int compare(SyndEntry s1, SyndEntry s2) {
+ return getUpdatedDate(s2).compareTo(getUpdatedDate(s1));
+ }
+
+ private Date getUpdatedDate(SyndEntry entry) {
+ Date date = entry.getUpdatedDate();
+ if (date == null) {
+ date = entry.getPublishedDate();
+ }
+ return date;
+ }
+}
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java?rev=724439&r1=724438&r2=724439&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
(original)
+++
activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
Mon Dec 8 10:33:47 2008
@@ -50,7 +50,7 @@
}
protected void sortEntries() {
- Collections.sort(list, new PublishedDateComparator());
+ Collections.sort(list, new RssDateComparator());
}
@Override
Modified:
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java?rev=724439&r1=724438&r2=724439&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java
(original)
+++
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java
Mon Dec 8 10:33:47 2008
@@ -67,7 +67,11 @@
public Date getPubDate(@Body Object body) {
SyndFeed feed = (SyndFeed) body;
SyndEntry syndEntry = (SyndEntry) feed.getEntries().get(0);
- return syndEntry.getPublishedDate();
+ Date date = syndEntry.getUpdatedDate();
+ if (date == null) {
+ date = syndEntry.getPublishedDate();
+ }
+ return date;
}
}
}