DeIndexing have been separated for Simple and Default3Phase Manager

This commit is contained in:
Francesco Mangiacrapa 2023-03-03 14:38:11 +01:00
parent c9ef00c108
commit 4cf6d1e5d4
2 changed files with 43 additions and 10 deletions

View File

@ -13,8 +13,10 @@ import org.gcube.application.cms.plugins.implementations.executions.GuardedStepE
import org.gcube.application.cms.plugins.reports.EventExecutionReport;
import org.gcube.application.cms.plugins.reports.StepExecutionReport;
import org.gcube.application.cms.plugins.requests.BaseRequest;
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
import org.gcube.application.geoportal.common.model.configuration.Configuration;
import org.gcube.application.geoportal.common.model.configuration.Index;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
import org.gcube.application.geoportal.common.model.plugins.OperationDescriptor;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
@ -98,7 +100,7 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life
});
//Updated by Francesco
setStep(super.unPublishStep());
setStep(d3PhaseUnPublishStep());
}
public Default3PhaseManager() {
@ -107,6 +109,40 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life
DESCRIPTOR.setVersion(new Semver("1.0.0"));
DESCRIPTOR.setLabel("Default 3-Phase");
}
//Updated by Francesco. DeIndexing (only) from PublicIndex and InternalIndex (GIS-CENTROIDS plugin with 'public' and "internal" flag)
protected GuardedStepExecution d3PhaseUnPublishStep() {
return new GuardedStepExecution(STEPS.UNPUBLISH) {
@Override
protected StepExecutionReport run() throws Exception {
log.info( STEPS.UNPUBLISH+ " running...");
//DeMaterialize
JSONPathWrapper wrapper = new JSONPathWrapper(theReport.getTheRequest().getDocument().getTheDocument().toJson());
for (String s : wrapper.getMatchingPaths("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]")){
log.info("Requesting dematerialization for {} ",s);
for(MaterializationPlugin mat : getMaterializers(theReport.getTheRequest()))
theReport = deMaterialize(theReport,mat,new Document("fileSetPath",s));
if(!theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
break;
}
//DeIndex
if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) {
for(IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) {
log.info("Requesting deindexing for {} ",indexer.getDescriptor());
theReport = deIndex(theReport,indexer,getPublicIndexParams(theReport.getTheRequest()));
theReport = deIndex(theReport,indexer,getInternalIndexParams(theReport.getTheRequest()));
}
}
if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
theReport.getToSetLifecycleInformation().setPhase(LifecycleInformation.CommonPhases.DRAFT_PHASE);
return theReport;
}
};
}
@Override
@ -129,6 +165,8 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life
}
return toReturn;
}
protected Document getInternalIndexParams(BaseRequest req){
Document callParameters = new Document();

View File

@ -134,13 +134,8 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
}
});
setStep(unPublishStep());
}
//Updated by Francesco
protected GuardedStepExecution unPublishStep() {
return new GuardedStepExecution(Steps.UNPUBLISH) {
//Updated by Francesco. DeIndexing (only) from PublicIndexParams (GIS-CENTROIDS plugin with 'public' flag)
setStep(new GuardedStepExecution(Steps.UNPUBLISH) {
@Override
protected StepExecutionReport run() throws Exception {
log.info(Steps.UNPUBLISH+ " running...");
@ -167,9 +162,9 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
return theReport;
}
};
});
}
protected void blockNonDraft(EventExecutionReport report) throws InvalidPluginRequestException {
Boolean force = false;
try {