From a7280b0b1d04d768167c7eb47ade517bdd489172 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Mon, 2 May 2022 16:43:57 +0200 Subject: [PATCH] Logging --- .../implementations/Default3PhaseManager.java | 11 +++--- .../SimpleLifeCycleManager.java | 35 ++++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/Default3PhaseManager.java b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/Default3PhaseManager.java index bec4c41..c91a8f3 100644 --- a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/Default3PhaseManager.java +++ b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/Default3PhaseManager.java @@ -13,7 +13,6 @@ import org.gcube.application.cms.plugins.requests.*; import org.gcube.application.geoportal.common.model.configuration.Configuration; import org.gcube.application.geoportal.common.model.configuration.Index; import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation; -import org.gcube.application.geoportal.common.model.plugins.LifecycleManagerDescriptor; import org.gcube.application.geoportal.common.model.plugins.OperationDescriptor; import org.gcube.application.geoportal.common.model.rest.ConfigurationException; import org.gcube.application.geoportal.common.utils.Files; @@ -49,7 +48,7 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life @Override protected EventExecutionReport onDeleteDocument(EventExecutionReport report) throws ConfigurationException, InvalidPluginRequestException, MaterializationException, EventException { report = super.onDeleteDocument(report); - for(IndexerPluginInterface indexer : getIndexer(report.getTheRequest())) + for(IndexerPluginInterface indexer : getIndexers(report.getTheRequest())) report= deIndex(report,indexer,getInternalIndexParams(report.getTheRequest())); return report; } @@ -64,7 +63,7 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life if(phase.equals(Phases.PUBLISHED)) parameters = getPublicIndexParams(theReport.getTheRequest()); if(parameters!= null) - for(IndexerPluginInterface indexer : getIndexer(theReport.getTheRequest())) + for(IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) theReport = index(theReport,indexer,getPublicIndexParams(theReport.getTheRequest())); return theReport; } @@ -77,11 +76,11 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life protected StepExecutionReport run() throws Exception { // Materialize - for(MaterializationPlugin mat : getMaterializer(theReport.getTheRequest())) + 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 : getIndexer(theReport.getTheRequest())) + for(IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) theReport = index(theReport,indexer,getInternalIndexParams(theReport.getTheRequest())); // setPhase if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) @@ -96,7 +95,7 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life @Override protected StepExecutionReport run() throws Exception { // Index - for(IndexerPluginInterface indexer : getIndexer(theReport.getTheRequest())) + for(IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) theReport = index(theReport,indexer,getPublicIndexParams(theReport.getTheRequest())); // setPhase if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) diff --git a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/SimpleLifeCycleManager.java b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/SimpleLifeCycleManager.java index 632cace..dff7b64 100644 --- a/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/SimpleLifeCycleManager.java +++ b/cms-plugin-framework/src/main/java/org/gcube/application/cms/plugins/implementations/SimpleLifeCycleManager.java @@ -6,7 +6,6 @@ import org.gcube.application.cms.plugins.IndexerPluginInterface; import org.gcube.application.cms.plugins.LifecycleManager; import org.gcube.application.cms.plugins.MaterializationPlugin; import org.gcube.application.cms.plugins.faults.*; -import org.gcube.application.cms.plugins.implementations.executions.GuardedEventManager; import org.gcube.application.cms.plugins.implementations.executions.GuardedStepExecution; import org.gcube.application.cms.plugins.reports.*; import org.gcube.application.cms.plugins.requests.*; @@ -95,12 +94,12 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements // throw new StepException("Document is not in "+LifecycleInformation.CommonPhases.DRAFT_PHASE+" phase"); // Materialize - for(MaterializationPlugin mat : getMaterializer(theReport.getTheRequest())) + 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 : getIndexer(theReport.getTheRequest())) + for(IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) theReport = index(theReport,indexer,getPublicIndexParams(theReport.getTheRequest())); // setPhase if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) @@ -139,13 +138,13 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements JSONPathWrapper wrapper = new JSONPathWrapper(report.getTheRequest().getDocument().getTheDocument().toJson()); for (String s : wrapper.getMatchingPaths("..*[?(@." + RegisteredFileSet.PAYLOADS + ")]")){ log.info("Requesting dematerialization for {} ",s); - for(MaterializationPlugin mat : getMaterializer(report.getTheRequest())) + for(MaterializationPlugin mat : getMaterializers(report.getTheRequest())) report = deMaterialize(report,mat,new Document("fileSetPath",s)); if(!report.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) break; } if(report.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) { - for(IndexerPluginInterface indexer : getIndexer(report.getTheRequest())) + for(IndexerPluginInterface indexer : getIndexers(report.getTheRequest())) report = deIndex(report,indexer,getPublicIndexParams(report.getTheRequest())); } return report; @@ -155,11 +154,11 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements protected EventExecutionReport onDeleteFileSet(EventExecutionReport theReport) throws ConfigurationException, InvalidPluginRequestException, MaterializationException, EventException { // dematerialize selected blockNonDraft(theReport); - for(MaterializationPlugin mat : getMaterializer(theReport.getTheRequest())) + for(MaterializationPlugin mat : getMaterializers(theReport.getTheRequest())) deMaterialize(theReport,mat, theReport.getTheRequest().getCallParameters()); // de index - for(IndexerPluginInterface indexer : getIndexer(theReport.getTheRequest())) + for(IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) deIndex(theReport,indexer,getPublicIndexParams(theReport.getTheRequest())); return theReport; @@ -172,7 +171,8 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements } - protected List getIndexer(BaseRequest request) throws ConfigurationException { + protected List getIndexers(BaseRequest request) throws ConfigurationException { + log.trace("Looking for Indexers for {}",request); ArrayList toReturn=new ArrayList<>(); UseCaseDescriptor desc = request.getUseCaseDescriptor(); List indexers = desc.getHandlersMapByType().get(IndexerPluginDescriptor.INDEXER); @@ -182,15 +182,16 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements return toReturn; } - protected List getMaterializer(BaseRequest request) throws ConfigurationException { - ArrayList toReturn=new ArrayList<>(); - UseCaseDescriptor desc = request.getUseCaseDescriptor(); - List materializers = desc.getHandlersMapByType().get(MaterializerPluginDescriptor.MATERIALIZER); - log.debug("Found UCD [{}] Materializers : {}",desc.getId(),materializers.size()); - for (HandlerDeclaration handlerDeclaration : materializers) { - toReturn.add((MaterializationPlugin) pluginManager.getById(handlerDeclaration.getId())); - } - return toReturn; + protected List getMaterializers(BaseRequest request) throws ConfigurationException { + log.trace("Looking for materializers for {}",request); + ArrayList toReturn=new ArrayList<>(); + UseCaseDescriptor desc = request.getUseCaseDescriptor(); + List materializers = desc.getHandlersMapByType().get(MaterializerPluginDescriptor.MATERIALIZER); + log.debug("Found UCD [{}] Materializers : {}",desc.getId(),materializers.size()); + for (HandlerDeclaration handlerDeclaration : materializers) { + toReturn.add((MaterializationPlugin) pluginManager.getById(handlerDeclaration.getId())); + } + return toReturn; } protected T deIndex(T report, IndexerPluginInterface indexer, Document parameters) throws InvalidPluginRequestException {