summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@gentoo.org>2005-09-06 13:51:40 +0000
committerGunnar Wrobel <wrobel@gentoo.org>2005-09-06 13:51:40 +0000
commit977b5d72af8f95bcac54212e7e9ef5dc64276a6b (patch)
treee2764c36ca0903420d3c937d4d3a7810f58d89f8 /net-news
parentFixed digests (diff)
downloadoverlay-977b5d72af8f95bcac54212e7e9ef5dc64276a6b.tar.gz
overlay-977b5d72af8f95bcac54212e7e9ef5dc64276a6b.tar.bz2
overlay-977b5d72af8f95bcac54212e7e9ef5dc64276a6b.zip
Added item expiration patch
svn path=/; revision=364
Diffstat (limited to 'net-news')
-rw-r--r--net-news/nntprss/files/item_expiration.patch441
-rw-r--r--net-news/nntprss/nntprss-0.5.1_beta.ebuild1
2 files changed, 442 insertions, 0 deletions
diff --git a/net-news/nntprss/files/item_expiration.patch b/net-news/nntprss/files/item_expiration.patch
new file mode 100644
index 0000000..7b2ec09
--- /dev/null
+++ b/net-news/nntprss/files/item_expiration.patch
@@ -0,0 +1,441 @@
+--- org/methodize/nntprss/admin/AdminServlet.java 13 Feb 2005 21:54:57 -0000 1.17
++++ org/methodize/nntprss/admin/AdminServlet.java 30 Jul 2005 01:44:52 -0000 1.18
+@@ -83,7 +83,7 @@
+
+ /**
+ * @author Jason Brome <jason@methodize.org>
+- * @version $Id: AdminServlet.java,v 1.17 2005/02/13 21:54:57 jasonbrome Exp $
++ * @version $Id: AdminServlet.java,v 1.18 2005/07/30 01:44:52 jasonbrome Exp $
+ *
+ * Web Administration interface for nntp//rss
+ *
+@@ -1117,45 +1117,45 @@
+ writeOption(
+ writer,
+ "Keep items for 1 day",
+- (1000 * 60 * 60 * 24 * 1),
++ (1000L * 60 * 60 * 24 * 1),
+ expiration);
+ writeOption(
+ writer,
+ "Keep items for 2 days",
+- (1000 * 60 * 60 * 24 * 2),
++ (1000L * 60 * 60 * 24 * 2),
+ expiration);
+ writeOption(
+ writer,
+ "Keep items for 4 days",
+- (1000 * 60 * 60 * 24 * 4),
++ (1000L * 60 * 60 * 24 * 4),
+ expiration);
+ writeOption(
+ writer,
+ "Keep items for 1 week",
+- (1000 * 60 * 60 * 24 * 7),
++ (1000L * 60 * 60 * 24 * 7),
+ expiration);
+ writeOption(
+ writer,
+ "Keep items for 2 weeks",
+- (1000 * 60 * 60 * 24 * 14),
++ (1000L * 60 * 60 * 24 * 14),
+ expiration);
+ writeOption(
+ writer,
+ "Keep items for 4 weeks",
+- (1000 * 60 * 60 * 24 * 28),
++ (1000L * 60 * 60 * 24 * 28),
+ expiration);
+
+ writeOption(
+ writer,
+ "Keep items for 6 months",
+- ((1000 * 60 * 60 * 24) * 180),
++ ((1000L * 60 * 60 * 24) * 180),
+ expiration);
+
+ writeOption(
+ writer,
+ "Keep items for 1 year",
+- ((1000 * 60 * 60 * 24) * 365),
++ ((1000L * 60 * 60 * 24) * 365),
+ expiration);
+
+ writer.write("</select></td></tr>");
+--- org/methodize/nntprss/feed/Channel.java 13 Feb 2005 21:56:24 -0000 1.15
++++ org/methodize/nntprss/feed/Channel.java 30 Jul 2005 01:46:10 -0000 1.16
+@@ -87,7 +87,7 @@
+
+ /**
+ * @author Jason Brome <jason@methodize.org>
+- * @version $Id: Channel.java,v 1.15 2005/02/13 21:56:24 jasonbrome Exp $
++ * @version $Id: Channel.java,v 1.16 2005/07/30 01:46:10 jasonbrome Exp $
+ */
+ public class Channel
+ extends ItemContainer
+@@ -518,9 +518,9 @@
+ rootElm,
+ this,
+ channelDAO,
+- keepExpiration != 0);
+- channelDAO.updateChannel(this); //ALEK
++ keepExpiration < 0);
++ channelDAO.updateChannel(this);
+ } // end if docParser != null
+
+ }
+--- org/methodize/nntprss/feed/db/ChannelDAO.java 13 Feb 2005 21:59:19 -0000 1.9
++++ org/methodize/nntprss/feed/db/ChannelDAO.java 30 Jul 2005 01:47:42 -0000 1.10
+@@ -61,14 +61,14 @@
+
+ /**
+ * @author Jason Brome <jason@methodize.org>
+- * @version $Id: ChannelDAO.java,v 1.9 2005/02/13 21:59:19 jasonbrome Exp $
++ * @version $Id: ChannelDAO.java,v 1.10 2005/07/30 01:47:42 jasonbrome Exp $
+ */
+ public abstract class ChannelDAO {
+
+ public static final int LIMIT_NONE = -1;
+
+- static final int DBVERSION = 5;
++ static final int DBVERSION = 6;
+
+ Logger log = Logger.getLogger(ChannelDAO.class);
+
+--- org/methodize/nntprss/feed/db/DerbyChannelDAO.java 13 Feb 2005 21:59:44 -0000 1.4
++++ org/methodize/nntprss/feed/db/DerbyChannelDAO.java 30 Jul 2005 01:49:26 -0000 1.5
+@@ -50,12 +50,12 @@
+
+ /**
+ * @author Jason Brome <jason@methodize.org>
+- * @version $Id: DerbyChannelDAO.java,v 1.4 2005/02/13 21:59:44 jasonbrome Exp $
++ * @version $Id: DerbyChannelDAO.java,v 1.5 2005/07/30 01:49:26 jasonbrome Exp $
+ */
+
+ public class DerbyChannelDAO extends JdbcChannelDAO {
+
+- private static final int DBVERSION = 5;
++ private static final int DBVERSION = 6;
+ private static final int DERBY_FALSE = 0;
+ private static final int DERBY_TRUE = 1;
+
+@@ -96,6 +96,7 @@
+ + "description clob, "
+ + "lastArticle int not null, "
+ + "lastPolled timestamp, "
++ + "lastCleaned timestamp, "
+ + "created timestamp, "
+ + "lastModified bigint, "
+ + "lastETag varchar(255), "
+@@ -478,7 +479,13 @@
+ + TABLE_ITEMS
+ + " (channel)");
+
++ case 5 :
++ stmt.executeUpdate(
++ "ALTER TABLE "
++ + TABLE_CHANNELS
++ + " ADD COLUMN lastCleaned timestamp");
++
+ default :
+ // Force re-poll of all channels after DB upgrade...
+ stmt.executeUpdate(
+--- org/methodize/nntprss/feed/db/JdbcChannelDAO.java 13 Feb 2005 21:59:19 -0000 1.12
++++ org/methodize/nntprss/feed/db/JdbcChannelDAO.java 30 Jul 2005 01:48:52 -0000 1.13
+@@ -50,7 +50,7 @@
+
+ /**
+ * @author Jason Brome <jason@methodize.org>
+- * @version $Id: JdbcChannelDAO.java,v 1.12 2005/02/13 21:59:19 jasonbrome Exp $
++ * @version $Id: JdbcChannelDAO.java,v 1.13 2005/07/30 01:48:52 jasonbrome Exp $
+ */
+
+ public abstract class JdbcChannelDAO extends ChannelDAO {
+@@ -164,11 +164,10 @@
+
+ public Map loadChannels(ChannelManager channelManager) {
+ Map channels = new TreeMap();
++ Map channelsById = new TreeMap();
+ Connection conn = null;
+ Statement stmt = null;
+- PreparedStatement ps = null;
+ ResultSet rs = null;
+- ResultSet rs2 = null;
+
+ if (log.isInfoEnabled()) {
+ log.info("Loading channel configuration");
+@@ -180,11 +179,6 @@
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("SELECT * FROM " + TABLE_CHANNELS);
+ if (rs != null) {
+- ps =
+- conn.prepareStatement(
+- "SELECT MIN(articleNumber), COUNT(articleNumber), MAX(articleNumber) FROM "
+- + TABLE_ITEMS
+- + " WHERE channel = ?");
+ while (rs.next()) {
+ String name = rs.getString("name");
+ String url = rs.getString("url");
+@@ -203,26 +197,8 @@
+ channel.setTitle(rs.getString("title"));
+ channel.setLink(rs.getString("link"));
+ channel.setDescription(rs.getString("description"));
+-
+- ps.setInt(1, channel.getId());
+- rs2 = ps.executeQuery();
+- if (rs2 != null) {
+- if (rs2.next()) {
+- int firstArticleNumber = rs2.getInt(1);
+- if (firstArticleNumber != 0) {
+- channel.setFirstArticleNumber(
+- firstArticleNumber);
+- } else {
+- channel.setFirstArticleNumber(1);
+- }
+-
+- channel.setTotalArticles(rs2.getInt(2));
+- channel.setLastArticleNumber(rs2.getInt(3));
+- }
+- rs2.close();
+- }
+-
+ channel.setLastPolled(rs.getTimestamp("lastPolled"));
++ channel.setLastCleaned(rs.getTimestamp("lastCleaned"));
+ channel.setLastModified(rs.getLong("lastModified"));
+ channel.setLastETag(rs.getString("lastETag"));
+ channel.setRssVersion(rs.getString("rssVersion"));
+@@ -243,6 +219,7 @@
+ channel.setExpiration(rs.getLong("expiration"));
+
+ channels.put(channel.getName(), channel);
++ channelsById.put(new Integer(channel.getId()), channel);
+
+ int categoryId = rs.getInt("category");
+
+@@ -255,6 +232,32 @@
+ channel.setCategory(category);
+ }
+ }
++
++ rs.close();
++ rs = stmt.executeQuery("SELECT channel, MIN(articleNumber), COUNT(articleNumber), MAX(articleNumber) FROM "
++ + TABLE_ITEMS
++ + " GROUP BY channel");
++
++ if (rs != null) {
++ while (rs.next()) {
++ int channelId = rs.getInt(1);
++ Channel channel = (Channel)channelsById.get(new Integer(channelId));
++ if(channel != null)
++ {
++ int firstArticleNumber = rs.getInt(2);
++ if (firstArticleNumber != 0) {
++ channel.setFirstArticleNumber(
++ firstArticleNumber);
++ } else {
++ channel.setFirstArticleNumber(2);
++ }
++
++ channel.setTotalArticles(rs.getInt(3));
++ channel.setLastArticleNumber(rs.getInt(4));
++ }
++ }
++ }
++
+ }
+ } catch (SQLException se) {
+ throw new RuntimeException(se);
+@@ -265,21 +268,11 @@
+ } catch (SQLException se) {
+ }
+ try {
+- if (rs2 != null)
+- rs2.close();
+- } catch (SQLException se) {
+- }
+- try {
+ if (stmt != null)
+ stmt.close();
+ } catch (SQLException se) {
+ }
+ try {
+- if (ps != null)
+- ps.close();
+- } catch (SQLException se) {
+- }
+- try {
+ if (conn != null)
+ conn.close();
+ } catch (SQLException se) {
+@@ -639,7 +632,7 @@
+ + "SET author = ?, name = ?, url = ?, "
+ + "title = ?, link = ?, description = ?, "
+ + "lastArticle = ?, "
+- + "lastPolled = ?, lastModified = ?, lastETag = ?, rssVersion = ?, "
++ + "lastPolled = ?, lastCleaned = ?, lastModified = ?, lastETag = ?, rssVersion = ?, "
+ + "enabled = ?, "
+ + "postingEnabled = ?, "
+ + "publishAPI = ?, "
+@@ -669,6 +662,14 @@
+ ps.setNull(paramCount++, java.sql.Types.TIMESTAMP);
+ }
+
++ if (channel.getLastCleaned() != null) {
++ ps.setTimestamp(
++ paramCount++,
++ new Timestamp(channel.getLastCleaned().getTime()));
++ } else {
++ ps.setNull(paramCount++, java.sql.Types.TIMESTAMP);
++ }
++
+ ps.setLong(paramCount++, channel.getLastModified());
+ ps.setString(paramCount++, channel.getLastETag());
+ ps.setString(paramCount++, trim(channel.getRssVersion(), FIELD_CHANNEL_VERSION_LENGTH));
+@@ -1343,7 +1344,7 @@
+ // TODO: only really need to do this if first article number is not in set...
+ ps =
+ conn.prepareStatement(
+- "SELECT MIN(articleNumber) as firstArticleNumber FROM "
++ "SELECT MIN(articleNumber) as firstArticleNumber, COUNT(articleNumber) as totalArticles FROM "
+ + TABLE_ITEMS
+ + " WHERE channel = ?");
+ int paramCount = 1;
+@@ -1366,6 +1367,7 @@
+ } else {
+ channel.setFirstArticleNumber(firstArticle);
+ }
++ channel.setTotalArticles(rs.getInt("totalArticles"));
+ }
+
+ }
+@@ -1431,7 +1433,7 @@
+ // TODO: only really need to do this if first article number is not in set...
+ ps =
+ conn.prepareStatement(
+- "SELECT MIN(articleNumber) as firstArticleNumber FROM "
++ "SELECT MIN(articleNumber) as firstArticleNumber, COUNT(articleNumber) as totalArticles FROM "
+ + TABLE_ITEMS
+ + " WHERE channel = ?");
+ paramCount = 1;
+@@ -1454,6 +1456,8 @@
+ } else {
+ channel.setFirstArticleNumber(firstArticle);
+ }
++ int totalArticles = rs.getInt("totalArticles");
++ channel.setTotalArticles(totalArticles);
+ }
+
+ }
+@@ -1525,8 +1529,8 @@
+ }
+ }
+
+- // Perform set arithmatic to discover new items
++ // Perform set arithmetic to discover new items
+ newSignatures.addAll(itemSignatures);
+ newSignatures.removeAll(currentSignatures);
+
+--- org/methodize/nntprss/feed/db/MySQLChannelDAO.java 13 Feb 2005 21:59:19 -0000 1.12
++++ org/methodize/nntprss/feed/db/MySQLChannelDAO.java 30 Jul 2005 01:49:26 -0000 1.13
+@@ -50,12 +50,12 @@
+
+ /**
+ * @author Jason Brome <jason@methodize.org>
+- * @version $Id: MySQLChannelDAO.java,v 1.12 2005/02/13 21:59:19 jasonbrome Exp $
++ * @version $Id: MySQLChannelDAO.java,v 1.13 2005/07/30 01:49:26 jasonbrome Exp $
+ */
+
+ public class MySQLChannelDAO extends JdbcChannelDAO {
+
+- private static final int DBVERSION = 5;
++ private static final int DBVERSION = 6;
+ private static final int MYSQL_FALSE = 0;
+ private static final int MYSQL_TRUE = 1;
+
+@@ -90,6 +90,7 @@
+ + "description text, "
+ + "lastArticle int not null, "
+ + "lastPolled timestamp, "
++ + "lastCleaned timestamp, "
+ + "created timestamp, "
+ + "lastModified bigint, "
+ + "lastETag varchar(255), "
+@@ -470,7 +471,13 @@
+ + TABLE_ITEMS
+ + " (channel)");
+
++ case 5 :
++ stmt.executeUpdate(
++ "ALTER TABLE "
++ + TABLE_CHANNELS
++ + " ADD COLUMN lastCleaned timestamp");
++
+ default :
+ // Force re-poll of all channels after DB upgrade...
+ stmt.executeUpdate(
+--- org/methodize/nntprss/feed/parser/AtomParser.java 13 Feb 2005 22:00:52 -0000 1.9
++++ org/methodize/nntprss/feed/parser/AtomParser.java 30 Jul 2005 01:47:12 -0000 1.10
+@@ -57,7 +57,7 @@
+
+ /**
+ * @author Jason Brome <jason@methodize.org>
+- * @version $Id: AtomParser.java,v 1.9 2005/02/13 22:00:52 jasonbrome Exp $
++ * @version $Id: AtomParser.java,v 1.10 2005/07/30 01:47:12 jasonbrome Exp $
+ */
+
+ public class AtomParser extends GenericParser {
+@@ -343,18 +343,18 @@
+ if (currentSignatures.size() > 0) {
+ if (channel.getExpiration() == 0) {
+ channelDAO.deleteItemsNotInSet(channel, currentSignatures);
++ channel.setTotalArticles(currentSignatures.size());
+ } else if (
+ channel.getExpiration() > 0
+- && channel.getLastCleaned().before(
+- new Date(
+- System.currentTimeMillis()
+- - Channel.CLEANING_INTERVAL))) {
++ && (channel.getLastCleaned() == null || channel.getLastCleaned().before(
++ new Date(
++ System.currentTimeMillis()
++ - Channel.CLEANING_INTERVAL)))) {
+ channelDAO.deleteExpiredItems(channel, currentSignatures);
+ channel.setLastCleaned(new Date());
+ }
+ }
+- channel.setTotalArticles(currentSignatures.size());
+ }
+ }
+
+--- org/methodize/nntprss/feed/parser/RSSParser.java 13 Feb 2005 22:00:53 -0000 1.9
++++ org/methodize/nntprss/feed/parser/RSSParser.java 30 Jul 2005 01:47:13 -0000 1.10
+@@ -61,7 +61,7 @@
+
+ /**
+ * @author Jason Brome <jason@methodize.org>
+- * @version $Id: RSSParser.java,v 1.9 2005/02/13 22:00:53 jasonbrome Exp $
++ * @version $Id: RSSParser.java,v 1.10 2005/07/30 01:47:13 jasonbrome Exp $
+ */
+
+ public class RSSParser extends GenericParser {
+@@ -371,17 +371,17 @@
+ if (currentSignatures.size() > 0) {
+ if (channel.getExpiration() == 0) {
+ channelDAO.deleteItemsNotInSet(channel, currentSignatures);
++ channel.setTotalArticles(currentSignatures.size());
+ } else if (
+ channel.getExpiration() > 0
+- && channel.getLastCleaned().before(
++ && (channel.getLastCleaned() == null || channel.getLastCleaned().before(
+ new Date(
+ System.currentTimeMillis()
+- - Channel.CLEANING_INTERVAL))) {
++ - Channel.CLEANING_INTERVAL)))) {
+ channelDAO.deleteExpiredItems(channel, currentSignatures);
+ channel.setLastCleaned(new Date());
+ }
+ }
+- channel.setTotalArticles(currentSignatures.size());
+ }
+ }
+
diff --git a/net-news/nntprss/nntprss-0.5.1_beta.ebuild b/net-news/nntprss/nntprss-0.5.1_beta.ebuild
index 42ffd36..38ea87e 100644
--- a/net-news/nntprss/nntprss-0.5.1_beta.ebuild
+++ b/net-news/nntprss/nntprss-0.5.1_beta.ebuild
@@ -51,6 +51,7 @@ src_unpack() {
## Fixes for removed systray and gentoo
## java package structure
epatch ${FILESDIR}/nntprss-sanitize.patch
+ epatch ${FILESDIR}/item-expiration.patch
}