@ -35,6 +35,7 @@ import net.yacy.cora.document.id.MultiProtocolURL;
import net.yacy.cora.protocol.Domains ;
import net.yacy.cora.protocol.RequestHeader ;
import net.yacy.cora.util.ConcurrentLog ;
import net.yacy.data.TransactionManager ;
import net.yacy.data.WorkTables ;
import net.yacy.kelondro.blob.Tables ;
import net.yacy.kelondro.blob.Tables.Row ;
@ -46,7 +47,7 @@ import net.yacy.server.serverSwitch;
public class Table_API_p {
public static serverObjects respond ( @SuppressWarnings ( "unused" ) final RequestHeader header , final serverObjects post , final serverSwitch env ) {
public static serverObjects respond ( final RequestHeader header , final serverObjects post , final serverSwitch env ) {
final Switchboard sb = ( Switchboard ) env ;
final serverObjects prop = new serverObjects ( ) ;
@ -85,6 +86,10 @@ public class Table_API_p {
current_pk = post . get ( "current_pk" , "" ) ;
}
if ( post ! = null & & scheduleeventaction & & ! current_pk . isEmpty ( ) ) {
/* Check this is a valid transaction */
TransactionManager . checkPostTransaction ( header , post ) ;
try {
Tables . Row row = sb . tables . select ( WorkTables . TABLE_API_NAME , current_pk . getBytes ( ) ) ;
if ( row ! = null ) {
@ -150,6 +155,10 @@ public class Table_API_p {
}
if ( post ! = null & & ! post . get ( "deleterows" , "" ) . isEmpty ( ) ) {
/* Check this is a valid transaction */
TransactionManager . checkPostTransaction ( header , post ) ;
for ( final Map . Entry < String , String > entry : post . entrySet ( ) ) {
if ( entry . getValue ( ) . startsWith ( "mark_" ) ) {
try {
@ -162,6 +171,10 @@ public class Table_API_p {
}
if ( post ! = null & & ! post . get ( "deleteold" , "" ) . isEmpty ( ) ) {
/* Check this is a valid transaction */
TransactionManager . checkPostTransaction ( header , post ) ;
int days = post . getInt ( "deleteoldtime" , 365 ) ;
try {
Iterator < Row > ri = sb . tables . iterator ( WorkTables . TABLE_API_NAME ) ;
@ -199,6 +212,10 @@ public class Table_API_p {
}
if ( post ! = null & & ! post . get ( "execrows" , "" ) . isEmpty ( ) ) {
/* Check this is a valid transaction */
TransactionManager . checkPostTransaction ( header , post ) ;
// create a time-ordered list of events to execute
final Set < String > pks = new TreeSet < String > ( ) ;
for ( final Map . Entry < String , String > entry : post . entrySet ( ) ) {
@ -235,6 +252,11 @@ public class Table_API_p {
prop . put ( "showtable" , 1 ) ;
prop . put ( "showtable_inline" , inline ? 1 : 0 ) ;
/* Acquire a transaction token for the next POST form submission */
final String nextTransactionToken = TransactionManager . getTransactionToken ( header ) ;
prop . put ( TransactionManager . TRANSACTION_TOKEN_PARAM , nextTransactionToken ) ;
prop . put ( "showtable_" + TransactionManager . TRANSACTION_TOKEN_PARAM , nextTransactionToken ) ;
// insert rows
final List < Tables . Row > table = new ArrayList < Tables . Row > ( maximumRecords ) ;
int count = 0 ;