Updated onDeleteDocument and dematerialize methods. Managed

`ignore_errors` parameter
This commit is contained in:
Francesco Mangiacrapa 2024-05-10 11:39:26 +02:00
parent 47331ea209
commit 9a563d578e
2 changed files with 16 additions and 3 deletions

View File

@ -34,6 +34,7 @@ import org.gcube.application.geoportal.common.model.plugins.OperationDescriptor;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.utils.Files;
import lombok.extern.slf4j.Slf4j;
@ -187,6 +188,9 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
return super.onUpdateDocument(report);
}
/**
* Updated by Francesco M.
*/
@Override
protected EventExecutionReport onDeleteDocument(EventExecutionReport report) throws ConfigurationException, InvalidPluginRequestException, MaterializationException, EventException {
// Block non draft only if not force
@ -197,8 +201,17 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
JSONPathWrapper wrapper = new JSONPathWrapper(report.getTheRequest().getDocument().getTheDocument().toJson());
for (String s : wrapper.getMatchingPaths("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]")){
log.info("Requesting dematerialization for {} ",s);
for(MaterializationPlugin mat : getMaterializers(report.getTheRequest()))
report = deMaterialize(report,mat,new Document("fileSetPath",s));
for(MaterializationPlugin mat : getMaterializers(report.getTheRequest())) {
Document params = new Document("fileSetPath",s);
Boolean ignoreErrors = false;
try {
ignoreErrors = (Boolean) report.getTheRequest().getCallParameters().get(InterfaceConstants.Parameters.IGNORE_ERRORS);
}catch (Exception e) {
ignoreErrors = false;
}
params.append(InterfaceConstants.Parameters.IGNORE_ERRORS, ignoreErrors);
report = deMaterialize(report,mat, params);
}
if(!report.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
break;
}

View File

@ -224,7 +224,7 @@ public class SDIMaterializerPlugin extends AbstractPlugin implements Materializa
ignoreErrors = (Boolean) request.getCallParameters().get(InterfaceConstants.Parameters.IGNORE_ERRORS);
log.info("Serving DeMaterialize with {} as: {} ",InterfaceConstants.Parameters.IGNORE_ERRORS, ignoreErrors);
}catch (Exception e) {
ignoreErrors = false;
}
try{
SDIManagerWrapper sdi=getSDIManager();