added and managed ignore_erros on deleteLayers

This commit is contained in:
Francesco Mangiacrapa 2024-05-10 10:52:19 +02:00
parent 6bc860470a
commit 5a4d79b7d6
1 changed files with 18 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import org.gcube.application.geoportal.common.model.plugins.MaterializerPluginDe
import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import com.vdurmont.semver4j.Semver;
@ -210,12 +211,21 @@ public class SDIMaterializerPlugin extends AbstractPlugin implements Materializa
* @return the materialization report
* @throws MaterializationException the materialization exception
* @throws InvalidPluginRequestException the invalid plugin request exception
*
* Updated by Francesco
*/
@Override
public MaterializationReport dematerialize(MaterializationRequest request) throws MaterializationException, InvalidPluginRequestException {
log.info("Serving DeMaterialize {} : request CallParameters {}, request Context {}: ",this.getDescriptor().getId(), request.getCallParameters(), request.getContext());
log.debug("DeMaterialize request {}",request);
MaterializationReport report= new MaterializationReport(request);
Boolean ignoreErrors = false;
try {
ignoreErrors = (Boolean) request.getCallParameters().get(InterfaceConstants.Parameters.IGNORE_ERRORS);
log.info("Serving DeMaterialize with {} as: {} ",InterfaceConstants.Parameters.IGNORE_ERRORS, ignoreErrors);
}catch (Exception e) {
}
try{
SDIManagerWrapper sdi=getSDIManager();
JSONPathWrapper wrapper = new JSONPathWrapper(request.getDocument().getTheDocument().toJson());
@ -228,7 +238,14 @@ public class SDIMaterializerPlugin extends AbstractPlugin implements Materializa
Materialization mat = Serialization.convert(matObj,Materialization.class);
if(mat.getType().equals(GCubeSDILayer.GCUBE_SDY_LAYER_TYPE)) {
log.debug("Deleting Layer {} ",mat);
sdi.deleteLayer(Serialization.convert(matObj, GCubeSDILayer.class));
try {
sdi.deleteLayer(Serialization.convert(matObj, GCubeSDILayer.class));
}catch (Exception e) {
if(ignoreErrors) {
log.warn("Skipping error: ", e.getMessage());
}else
throw e;
}
}else toKeep.add(matObj);
}
// Resetting remaining materializations