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

pull/154/head
luccioman 7 years ago
parent 36e9b1c5b3
commit fab6e54fec

@ -12,6 +12,7 @@
<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 @@
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.cora.sorting.OrderedScoreMap;
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;
@ -35,11 +35,18 @@ public class IndexReIndexMonitor_p {
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 class IndexReIndexMonitor_p {
}
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);
@ -94,6 +104,9 @@ public class IndexReIndexMonitor_p {
// 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()) {
sb.deployThread(RecrawlBusyThread.THREAD_NAME,

@ -60,6 +60,7 @@
</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.SchemaConfiguration;
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;
@ -101,6 +102,10 @@ public class IndexSchema_p {
}
}
/* 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

Loading…
Cancel
Save