From e15e633a0128b8d31011283a65b4ef26a6dddcd8 Mon Sep 17 00:00:00 2001 From: reger Date: Thu, 23 Feb 2012 02:40:07 +0100 Subject: [PATCH] Bugfix for IE9 (doesn't accept html form within form) changes of API schedule row data changed form input form to unique field names using row pk. Fix for issue 96 http://bugs.yacy.net/view.php?id=96 IE9-64bit doesn't interprete iframe with align parameter as desired misaligns following content (in CrawlProfileEditor_p.html) --- htroot/CrawlProfileEditor_p.html | 4 +- htroot/Table_API_p.html | 29 ++--- htroot/Table_API_p.java | 199 ++++++++++++++++++------------- 3 files changed, 130 insertions(+), 102 deletions(-) diff --git a/htroot/CrawlProfileEditor_p.html b/htroot/CrawlProfileEditor_p.html index 8f2fbf8e7..378ebcc1a 100644 --- a/htroot/CrawlProfileEditor_p.html +++ b/htroot/CrawlProfileEditor_p.html @@ -12,7 +12,7 @@

Crawl Scheduler

Scheduled Crawls can be modified in this table

- +

Crawl Profile Editor

Crawl profiles hold information about a crawl process that is currently ongoing.

@@ -64,7 +64,7 @@ #(/deleteButton)# - #[startURL]# + #[startURL]# #[depth]# #[mustmatch]# #[mustnotmatch]# diff --git a/htroot/Table_API_p.html b/htroot/Table_API_p.html index eec66356b..704832daf 100644 --- a/htroot/Table_API_p.html +++ b/htroot/Table_API_p.html @@ -21,6 +21,8 @@ @@ -90,41 +92,26 @@ To see a list of all APIs, please visit the - - - - - - - - :: -
+ :: -
- #{scale}# #{/scale}# -
- - - - - - -
+ #(/scheduler)# #(inline)##[url]#::#(/inline)# @@ -134,6 +121,8 @@ 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 737befaed..5320f2deb 100644 --- a/htroot/Table_API_p.java +++ b/htroot/Table_API_p.java @@ -42,90 +42,116 @@ import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; public class Table_API_p { - + public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { final Switchboard sb = (Switchboard) env; final serverObjects prop = new serverObjects(); - + prop.put("showexec", 0); prop.put("showtable", 0); - + int startRecord = 0; int maximumRecords = 25; Pattern query = QueryParams.catchall_pattern; - if (post != null && post.containsKey("startRecord")) startRecord = post.getInt("startRecord", 0); - if (post != null && post.containsKey("maximumRecords")) maximumRecords = post.getInt("maximumRecords", 0); + if (post != null && post.containsKey("startRecord")) { + startRecord = post.getInt("startRecord", 0); + } + if (post != null && post.containsKey("maximumRecords")) { + maximumRecords = post.getInt("maximumRecords", 0); + } if (post != null && post.containsKey("query") && !post.get("query", "").isEmpty()) { query = Pattern.compile(".*" + post.get("query", "") + ".*"); startRecord = 0; maximumRecords = 1000; } - final boolean inline = (post != null && post.getBoolean("inline",false)); + final boolean inline = (post != null && post.getBoolean("inline", false)); prop.put("inline", (inline) ? 1 : 0); - + Pattern typefilter = QueryParams.catchall_pattern; if (post != null && post.containsKey("filter") && post.get("filter", "").length() > 0) { typefilter = Pattern.compile(post.get("filter", ".*")); } - + String pk; - if (post != null && post.containsKey("repeat_select") && ((pk = post.get("pk")) != null)) try { - final String action = post.get("repeat_select", "off"); - if (action.equals("on")) { - Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes()); - if (row != null) { - row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 7); - row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_UNIT, "days"); - WorkTables.calculateAPIScheduler(row, false); - sb.tables.update(WorkTables.TABLE_API_NAME, row); + boolean scheduleevent = false; // flag if schedule info of row changes + String current_schedule_pk = ""; // pk of changed schedule data row + if (post != null && post.containsKey("scheduleevent")) { + scheduleevent = post.get("scheduleevent", "false").equalsIgnoreCase("true"); + prop.put("scheduleevent", "false"); + current_schedule_pk = post.get("current_schedule_pk", ""); + } + if (scheduleevent && !current_schedule_pk.isEmpty()) { + if (post != null && post.containsKey("repeat_select_" + current_schedule_pk) ) { + try { + final String action = post.get("repeat_select_" + current_schedule_pk, "off"); + if (action.equals("on")) { + Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, current_schedule_pk.getBytes()); + if (row != null) { + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 7); + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_UNIT, "days"); + WorkTables.calculateAPIScheduler(row, false); + sb.tables.update(WorkTables.TABLE_API_NAME, row); + } + } + } catch (IOException e) { + Log.logException(e); + } catch (RowSpaceExceededException e) { + Log.logException(e); } } - } catch (IOException e) { - Log.logException(e); - } catch (RowSpaceExceededException e) { - Log.logException(e); - } - - if (post != null && post.containsKey("repeat_time") && ((pk = post.get("pk")) != null)) try { - final String action = post.get("repeat_time", "off"); - final Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes()); - if (row != null) { - if ("off".equals(action)) { - row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 0); - } else { - row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, Integer.parseInt(action)); + + if (post != null && post.containsKey("repeat_time_" + current_schedule_pk) ) { + try { + final String action = post.get("repeat_time_" + current_schedule_pk, "off"); + final Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, current_schedule_pk.getBytes()); + if (row != null) { + if ("off".equals(action)) { + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 0); + } else { + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, Integer.parseInt(action)); + } + WorkTables.calculateAPIScheduler(row, false); + sb.tables.update(WorkTables.TABLE_API_NAME, row); + } + } catch (IOException e) { + Log.logException(e); + } catch (RowSpaceExceededException e) { + Log.logException(e); } - WorkTables.calculateAPIScheduler(row, false); - sb.tables.update(WorkTables.TABLE_API_NAME, row); } - } catch (IOException e) { - Log.logException(e); - } catch (RowSpaceExceededException e) { - Log.logException(e); - } - - if (post != null && post.containsKey("repeat_unit") && ((pk = post.get("pk")) != null)) try { - final String action = post.get("repeat_unit", "seldays"); - final Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, pk.getBytes()); - if (row != null) { - int time = row.get(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 1); - row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_UNIT, action.substring(3)); - if (action.equals("selminutes") && time > 0 && time < 10) row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 10); - if (action.equals("selminutes") && time > 50) row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 50); - if (action.equals("selhours") && time > 23) row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 23); - if (action.equals("seldays") && time > 30) row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 30); - WorkTables.calculateAPIScheduler(row, false); - sb.tables.update(WorkTables.TABLE_API_NAME, row); + + if (post != null && post.containsKey("repeat_unit_" + current_schedule_pk) ) { + try { + final String action = post.get("repeat_unit_" + current_schedule_pk, "seldays"); + final Tables.Row row = sb.tables.select(WorkTables.TABLE_API_NAME, current_schedule_pk.getBytes()); + if (row != null) { + int time = row.get(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 1); + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_UNIT, action.substring(3)); + if (action.equals("selminutes") && time > 0 && time < 10) { + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 10); + } + if (action.equals("selminutes") && time > 50) { + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 50); + } + if (action.equals("selhours") && time > 23) { + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 23); + } + if (action.equals("seldays") && time > 30) { + row.put(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 30); + } + WorkTables.calculateAPIScheduler(row, false); + sb.tables.update(WorkTables.TABLE_API_NAME, row); + } + } catch (IOException e) { + Log.logException(e); + } catch (RowSpaceExceededException e) { + Log.logException(e); + } } - } catch (IOException e) { - Log.logException(e); - } catch (RowSpaceExceededException e) { - Log.logException(e); } - if (post != null && !post.get("deleterows", "").isEmpty()) { - for (final Map.Entry entry: post.entrySet()) { + for (final Map.Entry entry : post.entrySet()) { if (entry.getValue().startsWith("mark_")) { try { sb.tables.delete(WorkTables.TABLE_API_NAME, entry.getValue().substring(5).getBytes()); @@ -139,37 +165,40 @@ public class Table_API_p { if (post != null && !post.get("execrows", "").isEmpty()) { // create a time-ordered list of events to execute final Set pks = new TreeSet(); - for (final Map.Entry entry: post.entrySet()) { + for (final Map.Entry entry : post.entrySet()) { if (entry.getValue().startsWith("mark_")) { pks.add(entry.getValue().substring(5)); } } - + // now call the api URLs and store the result status final Map l = sb.tables.execAPICalls("localhost", (int) sb.getConfigLong("port", 8090), sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), pks); - + // construct result table prop.put("showexec", l.size() > 0 ? 1 : 0); - + final Iterator> resultIterator = l.entrySet().iterator(); Map.Entry record; int count = 0; boolean dark = true; while (resultIterator.hasNext()) { record = resultIterator.next(); - if (record == null) continue; - prop.put("showexec_list_" + count + "_dark", ((dark) ? 1 : 0) ); dark=!dark; + if (record == null) { + continue; + } + prop.put("showexec_list_" + count + "_dark", ((dark) ? 1 : 0)); + dark = !dark; prop.put("showexec_list_" + count + "_status", record.getValue()); prop.put("showexec_list_" + count + "_url", record.getKey()); count++; } prop.put("showexec_list", count); } - + // generate table prop.put("showtable", 1); prop.put("showtable_inline", inline ? 1 : 0); - + // insert rows final List table = new ArrayList(maximumRecords); int count = 0; @@ -186,17 +215,27 @@ public class Table_API_p { // first prepare a list while (mapIterator.hasNext()) { r = mapIterator.next(); - if (r == null) continue; + if (r == null) { + continue; + } type = UTF8.String(r.get(WorkTables.TABLE_API_COL_TYPE)); - if (!typefilter.matcher(type).matches()) continue; + if (!typefilter.matcher(type).matches()) { + continue; + } comment = UTF8.String(r.get(WorkTables.TABLE_API_COL_COMMENT)); - if (!query.matcher(comment).matches()) continue; - if (c >= startRecord) table.add(r); + if (!query.matcher(comment).matches()) { + continue; + } + if (c >= startRecord) { + table.add(r); + } c++; - if (table.size() >= maximumRecords) break; + if (table.size() >= maximumRecords) { + break; + } } // then work on the list - for (final Tables.Row row: table) { + for (final Tables.Row row : table) { final Date now = new Date(); final Date date = row.containsKey(WorkTables.TABLE_API_COL_DATE) ? row.get(WorkTables.TABLE_API_COL_DATE, now) : null; final Date date_recording = row.get(WorkTables.TABLE_API_COL_DATE_RECORDING, date); @@ -206,13 +245,14 @@ public class Table_API_p { final String unit = row.get(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_UNIT, "days"); final int time = row.get(WorkTables.TABLE_API_COL_APICALL_SCHEDULE_TIME, 0); prop.put("showtable_list_" + count + "_inline", inline ? 1 : 0); - prop.put("showtable_list_" + count + "_dark", dark ? 1 : 0); dark=!dark; + prop.put("showtable_list_" + count + "_dark", dark ? 1 : 0); + dark = !dark; prop.put("showtable_list_" + count + "_pk", UTF8.String(row.getPK())); prop.put("showtable_list_" + count + "_count", count); prop.put("showtable_list_" + count + "_callcount", callcount); prop.put("showtable_list_" + count + "_dateRecording", date_recording == null ? "-" : DateFormat.getDateTimeInstance().format(date_recording)); - prop.put("showtable_list_" + count + "_dateLastExec", date_last_exec == null ? "-" : DateFormat.getDateTimeInstance().format(date_last_exec)); - prop.put("showtable_list_" + count + "_dateNextExec", date_next_exec == null ? "-" : DateFormat.getDateTimeInstance().format(date_next_exec)); + prop.put("showtable_list_" + count + "_dateLastExec", date_last_exec == null ? "-" : DateFormat.getDateTimeInstance().format(date_last_exec)); + prop.put("showtable_list_" + count + "_dateNextExec", date_next_exec == null ? "-" : DateFormat.getDateTimeInstance().format(date_next_exec)); prop.put("showtable_list_" + count + "_selectedMinutes", unit.equals("minutes") ? 1 : 0); prop.put("showtable_list_" + count + "_selectedHours", unit.equals("hours") ? 1 : 0); prop.put("showtable_list_" + count + "_selectedDays", (unit.length() == 0 || unit.equals("days")) ? 1 : 0); @@ -233,7 +273,7 @@ public class Table_API_p { prop.put("showtable_list_" + count + "_scheduler_selectedHours", 0); prop.put("showtable_list_" + count + "_scheduler_selectedDays", 0); if (unit.equals("minutes")) { - for (int i = 1; i <= 5 ; i++) { + for (int i = 1; i <= 5; i++) { prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_time", i * 10); prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_selected", 0); } @@ -241,7 +281,7 @@ public class Table_API_p { prop.put("showtable_list_" + count + "_scheduler_scale", 6); prop.put("showtable_list_" + count + "_scheduler_selectedMinutes", 1); } else if (unit.equals("hours")) { - for (int i = 1; i <= 23 ; i++) { + for (int i = 1; i <= 23; i++) { prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_time", i); prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_selected", 0); } @@ -249,7 +289,7 @@ public class Table_API_p { prop.put("showtable_list_" + count + "_scheduler_scale", 24); prop.put("showtable_list_" + count + "_scheduler_selectedHours", 1); } else { - for (int i = 1; i <= 30 ; i++) { + for (int i = 1; i <= 30; i++) { prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_time", i); prop.put("showtable_list_" + count + "_scheduler_scale_" + i + "_selected", 0); } @@ -276,7 +316,7 @@ public class Table_API_p { } prop.put("showtable_list", count); prop.put("showtable_num", count); - + // write navigation details prop.put("showtable_startRecord", startRecord); prop.put("showtable_maximumRecords", maximumRecords); @@ -303,9 +343,8 @@ public class Table_API_p { } else { prop.put("showtable_navigation", 0); } - + // return rewrite properties return prop; } - }