From 179d0321818e090ebe81d0330f6d0433722887e8 Mon Sep 17 00:00:00 2001
From: Michael Peter Christen
Date: Mon, 27 May 2013 16:15:58 +0200
Subject: [PATCH] added a (badly formatted) delete button for process scheduler
entries
---
htroot/Table_API_p.html | 12 ++++++++++--
htroot/Table_API_p.java | 23 +++++++++++++++++++++++
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/htroot/Table_API_p.html b/htroot/Table_API_p.html
index b963ac4e3..c18e32585 100644
--- a/htroot/Table_API_p.html
+++ b/htroot/Table_API_p.html
@@ -171,8 +171,16 @@ To see a list of all APIs, please visit the
-
-
+
+
+
diff --git a/htroot/Table_API_p.java b/htroot/Table_API_p.java
index 1b8d86369..06a780a36 100644
--- a/htroot/Table_API_p.java
+++ b/htroot/Table_API_p.java
@@ -33,6 +33,7 @@ import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.data.WorkTables;
import net.yacy.kelondro.blob.Tables;
+import net.yacy.kelondro.blob.Tables.Row;
import net.yacy.kelondro.logging.Log;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
@@ -156,6 +157,28 @@ public class Table_API_p {
}
}
}
+
+ if (post != null && !post.get("deleteold", "").isEmpty()) {
+ int days = post.getInt("deleteoldtime", 365);
+ try {
+ Iterator ri = sb.tables.iterator(WorkTables.TABLE_API_NAME);
+ Row row;
+ Date now = new Date();
+ Date limit = new Date(now.getTime() - 1000L * 60L * 60L * 24L * days);
+ List pkl = new ArrayList();
+ while (ri.hasNext()) {
+ row = ri.next();
+ Date d = row.get(WorkTables.TABLE_API_COL_DATE_RECORDING, now);
+ if (d.before(limit)) {
+ pkl.add(row.getPK());
+ }
+ }
+ for (byte[] pk: pkl) {
+ sb.tables.delete(WorkTables.TABLE_API_NAME, pk);
+ }
+ } catch (IOException e1) {
+ }
+ }
if (post != null && !post.get("execrows", "").isEmpty()) {
// create a time-ordered list of events to execute