Fixes error management

This commit is contained in:
Fabio Sinibaldi 2022-10-27 17:31:30 +02:00
parent 8b25642459
commit 1f6512f105
2 changed files with 15 additions and 6 deletions

View File

@ -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 extends DocumentHandlingReport> T materializeDocument(T report,MaterializationPlugin plugin,Document parameters) throws InvalidPluginRequestException, MaterializationException {

View File

@ -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);
}
}