[Lutinweb-commits] r92 - trunk/lutinrss/src/main/java/org/codelutin/rss
Author: tchemit Date: 2008-07-01 12:46:09 +0000 (Tue, 01 Jul 2008) New Revision: 92 Modified: trunk/lutinrss/src/main/java/org/codelutin/rss/RSSGenerator.java Log: update a feed from a given feed Modified: trunk/lutinrss/src/main/java/org/codelutin/rss/RSSGenerator.java =================================================================== --- trunk/lutinrss/src/main/java/org/codelutin/rss/RSSGenerator.java 2008-07-01 12:45:36 UTC (rev 91) +++ trunk/lutinrss/src/main/java/org/codelutin/rss/RSSGenerator.java 2008-07-01 12:46:09 UTC (rev 92) @@ -201,8 +201,16 @@ throw new IllegalStateException("could not delete feed " + f.getName()); } } - - public void updateFeed(URL url,Map<Field,Object> values) throws IOException, FeedException, ParseException { +/** + * + * @param url + * @param values + * @return <code>true</code> if link of feed has changed, <code>false</code> otherwise. + * @throws java.io.IOException + * @throws com.sun.syndication.io.FeedException + * @throws java.text.ParseException + */ + public boolean updateFeed(URL url,Map<Field,Object> values) throws IOException, FeedException, ParseException { if (url == null) { throw new NullPointerException("can not add a feed's entry with null url"); } @@ -220,10 +228,18 @@ FileLock lock = acquireLock(f); try { - + String newURL =(String) values.get(Field.LINK); + + SyndFeed feed =RSSIOUtil.readFeed(url); + + String oldURL =feed.getLink(); + + boolean linkChanged = !oldURL.equals(newURL); + //TODO Should be able to detect if at least one thing has changed... + // get updated nfeed - SyndFeed feed = RSSIOUtil.updateFeed(url,feedProperties, values); - + feed = RSSIOUtil.updateFeed(feed,feedProperties, values); + // save feed into a tmp file File tmpFile = new File(f.getAbsolutePath() + "-tmp_" + System.nanoTime()); @@ -231,6 +247,9 @@ // move tmpFile to real file tmpFile.renameTo(f); + + // feed link has changed + return linkChanged; } finally { releaseLock(f, lock); }
participants (1)
-
tchemit@users.labs.libre-entreprise.org