Force support on delete
This commit is contained in:
parent
9536379efb
commit
166ea432c3
|
@ -136,8 +136,10 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
|
||||||
|
|
||||||
@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
|
||||||
|
if(!Boolean.parseBoolean(report.getTheRequest().getWithDefault("force","false")))
|
||||||
|
blockNonDraft(report);
|
||||||
// dematerialize all
|
// dematerialize all
|
||||||
blockNonDraft(report);
|
|
||||||
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);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ser.Serializers;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||||
|
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||||
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
||||||
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
@ -28,6 +29,14 @@ public class BaseRequest {
|
||||||
return getMandatory(param,callParameters);
|
return getMandatory(param,callParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final String getWithDefault(String param,String defaultValue) {
|
||||||
|
try{
|
||||||
|
return getMandatory(param,callParameters);
|
||||||
|
}catch (InvalidPluginRequestException e){
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final String getMandatory(String param,Document params) throws InvalidPluginRequestException {
|
public static final String getMandatory(String param,Document params) throws InvalidPluginRequestException {
|
||||||
if(!params.containsKey(param)) throw new InvalidPluginRequestException("Missing mandatory parameter "+param);
|
if(!params.containsKey(param)) throw new InvalidPluginRequestException("Missing mandatory parameter "+param);
|
||||||
return params.getString(param);
|
return params.getString(param);
|
||||||
|
|
Loading…
Reference in New Issue