diff --git a/default-lc-managers/CHANGELOG.md b/default-lc-managers/CHANGELOG.md index bd9d68d..aa6639e 100644 --- a/default-lc-managers/CHANGELOG.md +++ b/default-lc-managers/CHANGELOG.md @@ -3,6 +3,7 @@ ## [v1.2.0-SNAPSHOT] - Integrated the field 'geov_link' (Geoportal GisViewer link) in the centroid layer [#24859] +- Fixed Draft execution step executing dematerialization and de-indexing actions [#24877] ## [v1.1.1] - 2023-03-06 diff --git a/default-lc-managers/src/main/java/org/gcube/application/cms/plugins/implementations/Default3PhaseManager.java b/default-lc-managers/src/main/java/org/gcube/application/cms/plugins/implementations/Default3PhaseManager.java index 019c490..c99e911 100644 --- a/default-lc-managers/src/main/java/org/gcube/application/cms/plugins/implementations/Default3PhaseManager.java +++ b/default-lc-managers/src/main/java/org/gcube/application/cms/plugins/implementations/Default3PhaseManager.java @@ -177,37 +177,62 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life return callParameters; } - protected StepExecutionReport executeSubmit(StepExecutionReport theReport) throws Exception { - // Materialize + protected StepExecutionReport executeSubmit(StepExecutionReport theReport) throws Exception { + log.info(STEPS.SUBMIT + " running..."); - for(MaterializationPlugin mat : getMaterializers(theReport.getTheRequest())) - theReport = materializeDocument(theReport,mat,getMaterializationParameters(theReport.getTheRequest())); - if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)){ - // Index - for(IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) - theReport = index(theReport,indexer,getInternalIndexParams(theReport.getTheRequest())); - // setPhase - if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) - theReport.getToSetLifecycleInformation().setPhase(Phases.PENDING_APPROVAL); - } - return theReport; - } + // Materialize + for (MaterializationPlugin mat : getMaterializers(theReport.getTheRequest())) + theReport = materializeDocument(theReport, mat, getMaterializationParameters(theReport.getTheRequest())); + if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) { + // Index + for (IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) + theReport = index(theReport, indexer, getInternalIndexParams(theReport.getTheRequest())); + // setPhase + if (theReport.getToSetLifecycleInformation().getLastOperationStatus() + .equals(LifecycleInformation.Status.OK)) + theReport.getToSetLifecycleInformation().setPhase(Phases.PENDING_APPROVAL); + } + return theReport; + } - protected StepExecutionReport executeApprove(StepExecutionReport theReport) throws Exception { - // Index - for(IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) - theReport = index(theReport,indexer,getPublicIndexParams(theReport.getTheRequest())); - // setPhase - if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) - theReport.getToSetLifecycleInformation().setPhase(Phases.PUBLISHED); - return theReport; - } + protected StepExecutionReport executeApprove(StepExecutionReport theReport) throws Exception { + log.info(STEPS.APPROVE + " running..."); - protected StepExecutionReport executeReject(StepExecutionReport theReport) throws Exception { - if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) - theReport.getToSetLifecycleInformation().setPhase(LifecycleInformation.CommonPhases.DRAFT_PHASE); - return theReport; - } + // Index + for (IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) + theReport = index(theReport, indexer, getPublicIndexParams(theReport.getTheRequest())); + // setPhase + if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) + theReport.getToSetLifecycleInformation().setPhase(Phases.PUBLISHED); + return theReport; + } + + protected StepExecutionReport executeReject(StepExecutionReport theReport) throws Exception { + log.info(STEPS.REJECT + " running..."); + + // DeMaterialize + JSONPathWrapper wrapper = new JSONPathWrapper( + theReport.getTheRequest().getDocument().getTheDocument().toJson()); + for (String s : wrapper.getMatchingPaths("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]")) { + log.info("Requesting dematerialization for {} ", s); + for (MaterializationPlugin mat : getMaterializers(theReport.getTheRequest())) + theReport = deMaterialize(theReport, mat, new Document("fileSetPath", s)); + if (!theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) + break; + } + // DeIndexing + if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) { + for (IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) { + log.info("Requesting deindexing for {} ", indexer.getDescriptor()); + theReport = deIndex(theReport, indexer, getInternalIndexParams(theReport.getTheRequest())); + } + } + + if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) + theReport.getToSetLifecycleInformation().setPhase(LifecycleInformation.CommonPhases.DRAFT_PHASE); + + return theReport; + } }