diff --git a/apps/syndie/java/src/net/i2p/syndie/Updater.java b/apps/syndie/java/src/net/i2p/syndie/Updater.java index 1a0b49791531fab17914e146811b43f2e004d329..ae5d1d32aeccbe29e64a38030909902fade09e40 100644 --- a/apps/syndie/java/src/net/i2p/syndie/Updater.java +++ b/apps/syndie/java/src/net/i2p/syndie/Updater.java @@ -1,10 +1,10 @@ package net.i2p.syndie; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; +import java.util.*; import net.i2p.I2PAppContext; +import net.i2p.client.naming.PetName; +import net.i2p.client.naming.PetNameDB; import net.i2p.util.Log; import net.i2p.syndie.web.RemoteArchiveBean; @@ -15,6 +15,8 @@ public class Updater { private long _lastUpdate; private static boolean _woken; + private static boolean ALLOW_REMOTE_PUSH = false; + public void update() { BlogManager bm = BlogManager.instance(); if (_lastUpdate + bm.getUpdateDelay()*60*60*1000 > System.currentTimeMillis()) { @@ -31,17 +33,56 @@ public class Updater { } _log.debug("Done fetching archives"); List rssFeeds = bm.getRssFeeds(); + List allEntries = new ArrayList(); Iterator iter = rssFeeds.iterator(); while(iter.hasNext()) { String args[] = (String[])iter.next(); _log.debug("rss feed begin: " + args[0]); Sucker sucker = new Sucker(args); - sucker.suck(); + allEntries.addAll(sucker.suck()); _log.debug("rss feed end: " + args[0]); } + + if (ALLOW_REMOTE_PUSH && (allEntries.size() > 0) ) { + String pushedRemoteArchive = getAutomaticallyPushedArchive(); + if (pushedRemoteArchive != null) { + _log.debug("Pushing all of the new entries to " + pushedRemoteArchive + ": " + allEntries); + // push all of the new entries to the configured default archive + User user = new User(); + RemoteArchiveBean rab = new RemoteArchiveBean(); + + rab.fetchIndex(user, "web", pushedRemoteArchive, bm.getDefaultProxyHost(), bm.getDefaultProxyPort(), true); + if (rab.getRemoteIndex() != null) { + rab.postSelectedEntries(user, allEntries, pushedRemoteArchive); + _log.debug(rab.getStatus()); + } + } + } _log.debug("Done with all updating"); } + /** + * Pick the archive to which any posts imported from a feed should be pushed to, + * beyond the local archive. This currently pushes it to the first (alphabetically) + * syndie archive in the default user's addressbook that is marked as 'public'. + * + * @return archive location, or null if no archive should be used + */ + private String getAutomaticallyPushedArchive() { + BlogManager bm = BlogManager.instance(); + User user = bm.getDefaultUser(); + PetNameDB db = user.getPetNameDB(); + for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) { + String name = (String)iter.next(); + PetName pn = db.getByName(name); + String proto = pn.getProtocol(); + if ( (proto != null) && ("syndiearchive".equals(proto)) ) + if (pn.getIsPublic()) + return pn.getLocation(); + } + return null; + } + public void fetchArchive(String archive) { if ( (archive == null) || (archive.trim().length() <= 0) ) { _log.error("Fetch a null archive?" + new Exception("source")); diff --git a/router/java/src/net/i2p/router/tunnel/HopProcessor.java b/router/java/src/net/i2p/router/tunnel/HopProcessor.java index f758b502dbf0c1fc4b8ca5229e43796bee9c2220..6a3201e0ce57ef15a7d34829cf80697dcf921dcf 100644 --- a/router/java/src/net/i2p/router/tunnel/HopProcessor.java +++ b/router/java/src/net/i2p/router/tunnel/HopProcessor.java @@ -74,8 +74,8 @@ public class HopProcessor { boolean okIV = _validator.receiveIV(orig, offset, orig, offset + IV_LENGTH); if (!okIV) { - if (_log.shouldLog(Log.ERROR)) - _log.error("Invalid IV received on tunnel " + _config.getReceiveTunnelId()); + if (_log.shouldLog(Log.WARN)) + _log.warn("Invalid IV received on tunnel " + _config.getReceiveTunnelId()); return false; }