From 1f6512f1053187455ec3215231397fb2012b4c7a Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Thu, 27 Oct 2022 17:31:30 +0200 Subject: [PATCH] Fixes error management --- .../implementations/SimpleLifeCycleManager.java | 16 ++++++++++++---- .../plugins/ConcessioniLifeCycleManager.java | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) 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 87e07cf..64c371f 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 @@ -10,6 +10,7 @@ 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.EventException; +import org.gcube.application.cms.plugins.faults.IndexingException; import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException; import org.gcube.application.cms.plugins.faults.MaterializationException; import org.gcube.application.cms.plugins.implementations.executions.GuardedStepExecution; @@ -241,14 +242,21 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements IndexDocumentRequest indexRequest = new IndexDocumentRequest( request.getUseCaseDescriptor(),request.getCaller(), request.getContext(),request.getDocument()); - indexRequest.setCallParameters(evaluateAdditionalIndexParameters(indexRequest)); - IndexDocumentReport indexReport = indexer.index(indexRequest); - + IndexDocumentReport indexReport = null; + try { + indexRequest.setCallParameters(evaluateAdditionalIndexParameters(indexRequest)); + indexReport = indexer.index(indexRequest); + }catch (IndexingException e){ + log.error("Unable to serve index request.",e); + indexReport = new IndexDocumentReport(indexRequest); + indexReport.setStatus(Report.Status.ERROR); + indexReport.getMessages().add("Unable to evaluate centroids : "+e.getMessage()); + } return handleReport(indexReport,report); } - protected Document evaluateAdditionalIndexParameters(IndexDocumentRequest request) throws InvalidUserRoleException, RegistrationException, ProjectNotFoundException, ConfigurationException, UnauthorizedAccess {return request.getCallParameters();} + protected Document evaluateAdditionalIndexParameters(IndexDocumentRequest request) throws IndexingException {return request.getCallParameters();} protected T materializeDocument(T report,MaterializationPlugin plugin,Document parameters) throws InvalidPluginRequestException, MaterializationException { diff --git a/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java b/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java index 66297ec..fa89fc2 100644 --- a/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java +++ b/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java @@ -12,6 +12,7 @@ import org.gcube.application.cms.implementations.faults.RegistrationException; import org.gcube.application.cms.implementations.faults.UnauthorizedAccess; import org.gcube.application.cms.plugins.IndexerPluginInterface; import org.gcube.application.cms.plugins.LifecycleManager; +import org.gcube.application.cms.plugins.faults.IndexingException; import org.gcube.application.cms.plugins.implementations.Default3PhaseManager; import org.gcube.application.cms.plugins.reports.EventExecutionReport; import org.gcube.application.cms.plugins.reports.Report; @@ -192,7 +193,7 @@ public class ConcessioniLifeCycleManager extends Default3PhaseManager implements @Override - protected Document evaluateAdditionalIndexParameters(IndexDocumentRequest request) throws InvalidUserRoleException, RegistrationException, ProjectNotFoundException, ConfigurationException, UnauthorizedAccess { + protected Document evaluateAdditionalIndexParameters(IndexDocumentRequest request) throws IndexingException { Document toReturn = super.evaluateAdditionalIndexParameters(request); Project indexingProject = request.getDocument(); @@ -248,7 +249,7 @@ public class ConcessioniLifeCycleManager extends Default3PhaseManager implements return toReturn; } catch (Exception e) { log.error("Unable to evaluate to Hide and Display Ids ",e); - throw e; + throw new IndexingException("Unable to evaluate chain ids to hide / display",e); } }