Add libcommons-codec-java to Debian dependencies.
3 * see AUTHORS for the list of contributors
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package org.sonews.feed;
21 import java.io.IOException;
22 import java.util.List;
23 import java.util.concurrent.ConcurrentLinkedQueue;
24 import org.sonews.daemon.AbstractDaemon;
25 import org.sonews.storage.Article;
26 import org.sonews.storage.Headers;
27 import org.sonews.storage.StorageBackendException;
28 import org.sonews.storage.StorageManager;
29 import org.sonews.util.Log;
30 import org.sonews.util.io.ArticleWriter;
33 * Pushes new articles to remote newsservers. This feeder sleeps until a new
34 * message is posted to the sonews instance.
35 * @author Christian Lins
38 class PushFeeder extends AbstractDaemon
41 private ConcurrentLinkedQueue<Article> articleQueue =
42 new ConcurrentLinkedQueue<Article>();
53 List<Subscription> subscriptions = StorageManager.current().getSubscriptions(FeedManager.TYPE_PUSH);
55 Article article = this.articleQueue.poll();
56 String[] groups = article.getHeader(Headers.NEWSGROUPS)[0].split(",");
57 Log.get().info("PushFeed: " + article.getMessageID());
58 for (Subscription sub : subscriptions) {
60 if (article.getHeader(Headers.PATH)[0].contains(sub.getHost())) {
61 Log.get().info(article.getMessageID() + " skipped for host "
67 for (String group : groups) {
68 if (sub.getGroup().equals(group)) {
69 // Delete headers that may cause problems
70 article.removeHeader(Headers.NNTP_POSTING_DATE);
71 article.removeHeader(Headers.NNTP_POSTING_HOST);
72 article.removeHeader(Headers.X_COMPLAINTS_TO);
73 article.removeHeader(Headers.X_TRACE);
74 article.removeHeader(Headers.XREF);
76 // POST the message to remote server
77 ArticleWriter awriter = new ArticleWriter(sub.getHost(), sub.getPort());
78 awriter.writeArticle(article);
82 } catch (IOException ex) {
83 Log.get().warning(ex.toString());
86 } catch (StorageBackendException ex) {
87 Log.get().severe(ex.toString());
88 } catch (InterruptedException ex) {
89 Log.get().warning("PushFeeder interrupted: " + ex);
94 public void queueForPush(Article article)
96 this.articleQueue.add(article);