Browse Source

Lifecycleinformation in result

#22461
Fabio Sinibaldi 4 months ago
parent
commit
a4e8cb2f1e
  1. 3
      cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/ExecutionReport.java
  2. 13
      concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java
  3. 14
      geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/LifecycleInformation.java

3
cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/reports/ExecutionReport.java

@ -2,10 +2,11 @@ package org.gcube.application.cms.plugins.reports;
import lombok.Data;
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
import org.gcube.application.geoportal.common.model.document.LifecycleInformation;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
@Data
public class ExecutionReport extends Report{
public class ExecutionReport {
StepExecutionRequest request;

13
concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java

@ -1,7 +1,6 @@
package org.gcube.application.cms.concessioni.plugins;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.cms.Serialization;
import org.gcube.application.cms.custom.gna.concessioni.model.ProfiledConcessione;
import org.gcube.application.cms.plugins.LifecycleManager;
@ -11,11 +10,10 @@ import org.gcube.application.cms.plugins.faults.StepException;
import org.gcube.application.cms.plugins.model.PluginDescriptor;
import org.gcube.application.cms.plugins.reports.ExecutionReport;
import org.gcube.application.cms.plugins.reports.InitializationReport;
import org.gcube.application.cms.plugins.reports.Report;
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
import org.gcube.application.geoportal.common.model.document.LifecycleInformation;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.utils.JSONPathWrapper;
@Slf4j
public class ConcessioniLifeCycleManager implements LifecycleManager {
@ -46,9 +44,12 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
public ExecutionReport performStep(StepExecutionRequest request) throws StepException {
log.info("Serving Request {}",request);
ExecutionReport report=new ExecutionReport();
LifecycleInformation info=new LifecycleInformation();
info.setPhase(request.getStep());
info.setLastOperationStatus(LifecycleInformation.Status.OK);
report.setRequest(request);
report.setStatus(Report.Status.OK);
report.setResult(request.getDocument());
try {
switch (request.getStep()) {
case StepExecutionRequest.Steps.ON_INIT_DOCUMENT:
@ -80,8 +81,8 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
throw e;
}catch (Throwable t){
log.error("Unable to perform step "+request.getStep(),t);
report.setStatus(Report.Status.ERROR);
report.putMessage("Unable to execute Step "+request.getStep()+". Error was "+t.getMessage());
report.getResult().getLifecycleInformation().setLastOperationStatus(LifecycleInformation.Status.ERROR);
report.getResult().getLifecycleInformation().addErrorMessage("Unable to execute Step "+request.getStep()+". Error was "+t.getMessage());
}
return report;
}

14
geoportal-common/src/main/java/org/gcube/application/geoportal/common/model/document/LifecycleInformation.java

@ -2,6 +2,7 @@ package org.gcube.application.geoportal.common.model.document;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
@NoArgsConstructor
@ -18,7 +19,7 @@ public class LifecycleInformation {
public static final String CHILDREN="children";
public static enum Status{
PASSED,ERROR,WARNING
OK,ERROR,WARNING
}
@ -28,4 +29,15 @@ public class LifecycleInformation {
private List<String> warningMessages;
private List<LifecycleInformation> children;
public void addErrorMessage(String msg){
if(errorMessages==null)
errorMessages=new ArrayList<>();
errorMessages.add(msg);
}
public void addWarningMessage(String msg){
if(warningMessages==null)
warningMessages=new ArrayList<>();
warningMessages.add(msg);
}
}

Loading…
Cancel
Save