diff -r ed84c8bdd87b -r 7e24949b87b0 src/org/sonews/feed/PushFeeder.java --- a/src/org/sonews/feed/PushFeeder.java Sun Aug 29 17:28:58 2010 +0200 +++ b/src/org/sonews/feed/PushFeeder.java Sat Sep 10 18:18:05 2011 +0200 @@ -37,82 +37,65 @@ */ class PushFeeder extends AbstractDaemon { - - private ConcurrentLinkedQueue
articleQueue = - new ConcurrentLinkedQueue
(); - - @Override - public void run() - { - while(isRunning()) - { - try - { - synchronized(this) - { - this.wait(); - } - - List subscriptions = StorageManager.current() - .getSubscriptions(FeedManager.TYPE_PUSH); - Article article = this.articleQueue.poll(); - String[] groups = article.getHeader(Headers.NEWSGROUPS)[0].split(","); - Log.get().info("PushFeed: " + article.getMessageID()); - for(Subscription sub : subscriptions) - { - // Circle check - if(article.getHeader(Headers.PATH)[0].contains(sub.getHost())) - { - Log.get().info(article.getMessageID() + " skipped for host " - + sub.getHost()); - continue; - } + private ConcurrentLinkedQueue
articleQueue = + new ConcurrentLinkedQueue
(); - try - { - for(String group : groups) - { - if(sub.getGroup().equals(group)) - { - // Delete headers that may cause problems - article.removeHeader(Headers.NNTP_POSTING_DATE); - article.removeHeader(Headers.NNTP_POSTING_HOST); - article.removeHeader(Headers.X_COMPLAINTS_TO); - article.removeHeader(Headers.X_TRACE); - article.removeHeader(Headers.XREF); - - // POST the message to remote server - ArticleWriter awriter = new ArticleWriter(sub.getHost(), sub.getPort()); - awriter.writeArticle(article); - break; - } - } - } - catch(IOException ex) - { - Log.get().warning(ex.toString()); - } - } - } - catch(StorageBackendException ex) - { - Log.get().severe(ex.toString()); - } - catch(InterruptedException ex) - { - Log.get().warning("PushFeeder interrupted: " + ex); - } - } - } - - public void queueForPush(Article article) - { - this.articleQueue.add(article); - synchronized(this) - { - this.notifyAll(); - } - } - + @Override + public void run() + { + while (isRunning()) { + try { + synchronized (this) { + this.wait(); + } + + List subscriptions = StorageManager.current().getSubscriptions(FeedManager.TYPE_PUSH); + + Article article = this.articleQueue.poll(); + String[] groups = article.getHeader(Headers.NEWSGROUPS)[0].split(","); + Log.get().info("PushFeed: " + article.getMessageID()); + for (Subscription sub : subscriptions) { + // Circle check + if (article.getHeader(Headers.PATH)[0].contains(sub.getHost())) { + Log.get().info(article.getMessageID() + " skipped for host " + + sub.getHost()); + continue; + } + + try { + for (String group : groups) { + if (sub.getGroup().equals(group)) { + // Delete headers that may cause problems + article.removeHeader(Headers.NNTP_POSTING_DATE); + article.removeHeader(Headers.NNTP_POSTING_HOST); + article.removeHeader(Headers.X_COMPLAINTS_TO); + article.removeHeader(Headers.X_TRACE); + article.removeHeader(Headers.XREF); + + // POST the message to remote server + ArticleWriter awriter = new ArticleWriter(sub.getHost(), sub.getPort()); + awriter.writeArticle(article); + break; + } + } + } catch (IOException ex) { + Log.get().warning(ex.toString()); + } + } + } catch (StorageBackendException ex) { + Log.get().severe(ex.toString()); + } catch (InterruptedException ex) { + Log.get().warning("PushFeeder interrupted: " + ex); + } + } + } + + public void queueForPush(Article article) + { + this.articleQueue.add(article); + synchronized (this) { + this.notifyAll(); + } + } }