Permalink
Browse files

Enforced controls (HTTP method, token) on ReIndex and ReCrawl operations

  • Loading branch information...
luccioman committed Jan 7, 2018
1 parent 36e9b1c commit fab6e54fec74d71505f3715dcbd386951944652a
Showing with 23 additions and 2 deletions.
  1. +2 −0 htroot/IndexReIndexMonitor_p.html
  2. +14 −1 htroot/IndexReIndexMonitor_p.java
  3. +1 −0 htroot/IndexSchema_p.html
  4. +6 −1 htroot/IndexSchema_p.java
@@ -12,6 +12,7 @@ <h2>Field Re-Indexing</h2>
<p>In case that an index schema of the embedded/local index has changed, all documents with missing field entries can be indexed again with a reindex job.</p>
<form action="IndexReIndexMonitor_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<table><tr valign="top"><td>
<input type="hidden" name="transactionToken" value="#[transactionToken]#"/>
<fieldset>
<table>
<tr>
@@ -62,6 +63,7 @@ <h2>Re-Crawl Index Documents</h2>
This runs transparent as background job. Documents are added to the crawler only if no other crawls are active
and are added in small chunks.</p>
<form action="IndexReIndexMonitor_p.html?setup=recrawljob" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="hidden" name="transactionToken" value="#[transactionToken]#" />
<table><tr valign="top"><td>
<fieldset>
@@ -22,7 +22,7 @@
import net.yacy.kelondro.workflow.BusyThread;
import net.yacy.migration;
import net.yacy.crawler.RecrawlBusyThread;
import net.yacy.data.TransactionManager;
import net.yacy.search.Switchboard;
import net.yacy.search.index.ReindexSolrBusyThread;
import net.yacy.server.serverObjects;
@@ -34,12 +34,19 @@ public static serverObjects respond(@SuppressWarnings("unused") final RequestHea
final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects();
/* Acquire a transaction token for the next possible POST form submissions */
final String nextTransactionToken = TransactionManager.getTransactionToken(header);
prop.put(TransactionManager.TRANSACTION_TOKEN_PARAM, nextTransactionToken);
prop.put("docsprocessed", "0");
prop.put("currentselectquery","");
BusyThread reidxbt = sb.getThread(ReindexSolrBusyThread.THREAD_NAME);
if (reidxbt == null) {
if (post != null && post.containsKey("reindexnow") && sb.index.fulltext().connectedLocalSolr()) {
/* Check the transaction is valid */
TransactionManager.checkPostTransaction(header, post);
migration.reindexToschema(sb);
prop.put("querysize", "0");
prop.put("infomessage","reindex job started");
@@ -71,6 +78,9 @@ public static serverObjects respond(@SuppressWarnings("unused") final RequestHea
}
if (post != null && post.containsKey("stopreindex")) {
/* Check the transaction is valid */
TransactionManager.checkPostTransaction(header, post);
sb.terminateThread(ReindexSolrBusyThread.THREAD_NAME, false);
prop.put("infomessage", "reindex job stopped");
prop.put("reindexjobrunning",0);
@@ -93,6 +103,9 @@ public static serverObjects respond(@SuppressWarnings("unused") final RequestHea
// to signal that a setting shall change the form provides a fixed parameter setup=recrawljob, if not present return status only
if (post != null && "recrawljob".equals(post.get("setup"))) { // it's a command to recrawlThread
/* Check the transaction is valid */
TransactionManager.checkPostTransaction(header, post);
if (recrawlbt == null) {
if (post.containsKey("recrawlnow") && sb.index.fulltext().connectedLocalSolr()) {
@@ -60,6 +60,7 @@ <h2>Solr Schema Editor</h2>
</form>
<p><br /></p>
<form action="IndexReIndexMonitor_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="hidden" name="transactionToken" value="#[IndexReIndex_transactionToken]#"/>
<fieldset>
<legend><label>Reindex documents</label></legend>
<p>If you unselected some fields, old documents in the index still contain the unselected fields.
@@ -26,6 +26,7 @@
import net.yacy.cora.federate.solr.SchemaDeclaration;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.TransactionManager;
import net.yacy.search.Switchboard;
import net.yacy.search.schema.CollectionSchema;
import net.yacy.search.schema.WebgraphConfiguration;
@@ -39,7 +40,7 @@ public static serverObjects respond(@SuppressWarnings("unused") final RequestHea
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard) env;
String schemaName = CollectionSchema.CORE_NAME;
if (post != null) schemaName = post.get("core", schemaName);
SchemaConfiguration cs = schemaName.equals(CollectionSchema.CORE_NAME) ? sb.index.fulltext().getDefaultConfiguration() : sb.index.fulltext().getWebgraphConfiguration();
@@ -101,6 +102,10 @@ public static serverObjects respond(@SuppressWarnings("unused") final RequestHea
}
}
/* Acquire a transaction token for the next possible POST IndexReIndeMonitor_p form submission */
prop.put("IndexReIndex_" + TransactionManager.TRANSACTION_TOKEN_PARAM,
TransactionManager.getTransactionToken(header, "/IndexReIndexMonitor_p.html"));
int c = 0;
boolean dark = false;
// use enum SolrField to keep defined order

0 comments on commit fab6e54

Please sign in to comment.