Added throw StepException

This commit is contained in:
Francesco Mangiacrapa 2023-03-02 12:16:13 +01:00
parent a6f9e5be9b
commit 0b8d2f3b4b
3 changed files with 5 additions and 4 deletions

View File

@ -143,7 +143,7 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
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 + ")]")){

View File

@ -29,14 +29,14 @@ public abstract class GuardedExecution<R extends BaseExecutionRequest,T extends
protected T theReport;
protected void checks() throws ConfigurationException, InsufficientPrivileges {
protected void checks() throws ConfigurationException, InsufficientPrivileges, StepException {
if(theReport.getTheRequest()==null) throw new RuntimeException("Unexpected state : request cannot be null");
// Check document phase
if(op.getAppliableToPhases()!=null&&!op.getAppliableToPhases().isEmpty()) {
String currentPhase = theReport.getTheRequest().getDocument().getLifecycleInformation().getPhase();
if(!op.getAppliableToPhases().contains(currentPhase))
new StepException("Document must be in one of the following phases : "+ op.getAppliableToPhases());
throw new StepException("Document must be in one of the following phases : "+ op.getAppliableToPhases());
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.application.cms.plugins.implementations.executions;
import org.gcube.application.cms.plugins.faults.InsufficientPrivileges;
import org.gcube.application.cms.plugins.faults.StepException;
import org.gcube.application.cms.plugins.implementations.RoleManager;
import org.gcube.application.cms.plugins.reports.StepExecutionReport;
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
@ -17,7 +18,7 @@ public abstract class GuardedStepExecution extends GuardedExecution<StepExecutio
}
@Override
protected void checks() throws ConfigurationException, InsufficientPrivileges {
protected void checks() throws ConfigurationException, InsufficientPrivileges, StepException {
super.checks();
RoleManager r = new RoleManager(config);
if(!r.canInvokeStep(theReport.getTheRequest().getStep(),theReport.getTheRequest().getCaller()))