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.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration; import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; 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 org.gcube.application.geoportal.common.utils.Files;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -187,6 +188,9 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
return super.onUpdateDocument(report); return super.onUpdateDocument(report);
} }
/**
* Updated by Francesco M.
*/
@Override @Override
protected EventExecutionReport onDeleteDocument(EventExecutionReport report) throws ConfigurationException, InvalidPluginRequestException, MaterializationException, EventException { protected EventExecutionReport onDeleteDocument(EventExecutionReport report) throws ConfigurationException, InvalidPluginRequestException, MaterializationException, EventException {
// Block non draft only if not force // 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()); JSONPathWrapper wrapper = new JSONPathWrapper(report.getTheRequest().getDocument().getTheDocument().toJson());
for (String s : wrapper.getMatchingPaths("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]")){ for (String s : wrapper.getMatchingPaths("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]")){
log.info("Requesting dematerialization for {} ",s); log.info("Requesting dematerialization for {} ",s);
for(MaterializationPlugin mat : getMaterializers(report.getTheRequest())) for(MaterializationPlugin mat : getMaterializers(report.getTheRequest())) {
report = deMaterialize(report,mat,new Document("fileSetPath",s)); 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)) if(!report.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
break; break;
} }

View File

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