@Test public void testCompleteReset() throws Throwable { rerunAgendaRequest.setParams(Collections.singletonList(RerunAgendaParameter.RESET_ALL.getParameterName())); doReturn(TestUtil.createDataObjectResponse(agenda)).when(mockAgendaRequestProcessor).handleGET(any()); progressResetResult.setOperationsToReset(new HashSet<>()); progressResetResult.setOperationsToDelete(new HashSet<>()); AgendaProgress agendaProgress = TestUtil.createAgendaProgress(ProcessingState.COMPLETE, CompleteStateMessage.FAILED.name()); agendaProgress.setOperationProgress(new OperationProgress[] { TestUtil.createOperationProgress(ProcessingState.COMPLETE, CompleteStateMessage.FAILED.name()), TestUtil.createOperationProgress(ProcessingState.WAITING, null) }); doReturn(TestUtil.createDataObjectResponse(agendaProgress)).when(mockAgendaProgressRequestProcessor).handleGET(any()); doReturn(new DefaultDataObjectResponse<>()).when(mockAgendaProgressRequestProcessor).handlePUT(any()); requestProcessor.processPOST(new DefaultServiceRequest<>(rerunAgendaRequest)); verify(mockAgendaProgressRequestProcessor, times(1)).handlePUT(any()); verify(mockReadyAgendaPersister, times(1)).persist(any()); }
@Override public RerunAgendaResponse processPOST(ServiceRequest<RerunAgendaRequest> serviceRequest) { RerunAgendaRequest rerunAgendaRequest = serviceRequest.getPayload(); Map<RerunAgendaParameter, String> agendaRetryParams = RerunAgendaParameter.getParametersMap(rerunAgendaRequest.getParams()); AgendaRequestProcessor agendaRequestProcessor = requestProcessorFactory.createAgendaRequestProcessor(agendaPersister, agendaProgressPersister, readyAgendaPersister, operationProgressPersister, insightPersister, customerPersister); AgendaProgressRequestProcessor agendaProgressRequestProcessor = requestProcessorFactory.createAgendaProgressRequestProcessor(agendaProgressPersister, agendaPersister, operationProgressPersister); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.GET, new NoOpVisibilityFilter<>()); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); ServiceDataRequestResult<Agenda, RerunAgendaResponse> agendaRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaRequestProcessor, rerunAgendaRequest.getAgendaId(), Agenda.class); if(agendaRequestResult.getServiceResponse() != null) return agendaRequestResult.getServiceResponse(); Agenda agenda = agendaRequestResult.getDataObjectResponse().getFirst(); ServiceDataRequestResult<AgendaProgress, RerunAgendaResponse> agendaProgressRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaProgressRequestProcessor, agenda.getProgressId(), AgendaProgress.class); if(agendaProgressRequestResult.getServiceResponse() != null) return agendaProgressRequestResult.getServiceResponse(); AgendaProgress agendaProgress = agendaProgressRequestResult.getDataObjectResponse().getFirst(); ProgressResetResult progressResetResult = progressResetProcessor.resetProgress(agenda, agendaProgress, agendaRetryParams); try { DataObjectResponse<AgendaProgress> updateAgendaProgressResponse = agendaProgressRequestProcessor.handlePUT(new DefaultDataObjectRequest<>(null, agendaProgress.getId(), agendaProgress)); if(updateAgendaProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaProgressResponse.getErrorResponse(), "Failed to update AgendaProgress."); } catch (Exception e) { logger.error("Failed to update progress for reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } if(progressResetResult.getOperationsToDelete().size() > 0) { try { agendaRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); DataObjectResponse<Agenda> updateAgendaResponse = agendaRequestProcessor.handlePUT(new DefaultDataObjectRequest<>( null, agenda.getId(), createAgendaWithRemovedOperations(agenda, progressResetResult.getOperationsToDelete()))); if(updateAgendaResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaResponse.getErrorResponse(), "Failed to update Agenda."); } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } try { OperationProgressRequestProcessor operationProgressRequestProcessor = requestProcessorFactory.createOperationProgressRequestProcessor(operationProgressPersister); operationProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.DELETE, new NoOpVisibilityFilter<>()); for (String opName : progressResetResult.getOperationsToDelete()) { DataObjectResponse<OperationProgress> operationProgressResponse = operationProgressRequestProcessor.handleDELETE(new DefaultDataObjectRequest<>( null, OperationProgress.generateId(agendaProgress.getId(), opName), null)); if(operationProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, operationProgressResponse.getErrorResponse(), "Failed to delete OperationProgress."); } } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } } boolean skipExecution = agendaRetryParams.containsKey(RerunAgendaParameter.SKIP_EXECUTION) || (agenda.getParams() != null && agenda.getParams().containsKey(GeneralParamKey.doNotRun)); if(!skipExecution) { DataObjectResponse<ReadyAgenda> readyAgendaResponse = persistReadyAgenda(agenda.getAgendaInsight().getInsightId(), agenda.getId(), agenda.getCustomerId(), serviceRequest.getCID()); if (readyAgendaResponse.isError()) { return createReigniteAgendaResponse(serviceRequest, readyAgendaResponse.getErrorResponse(), null); } } return createReigniteAgendaResponse(serviceRequest, null, null); }
RerunAgendaServiceRequestProcessor extends AbstractServiceRequestProcessor<RerunAgendaResponse, ServiceRequest<RerunAgendaRequest>> { @Override public RerunAgendaResponse processPOST(ServiceRequest<RerunAgendaRequest> serviceRequest) { RerunAgendaRequest rerunAgendaRequest = serviceRequest.getPayload(); Map<RerunAgendaParameter, String> agendaRetryParams = RerunAgendaParameter.getParametersMap(rerunAgendaRequest.getParams()); AgendaRequestProcessor agendaRequestProcessor = requestProcessorFactory.createAgendaRequestProcessor(agendaPersister, agendaProgressPersister, readyAgendaPersister, operationProgressPersister, insightPersister, customerPersister); AgendaProgressRequestProcessor agendaProgressRequestProcessor = requestProcessorFactory.createAgendaProgressRequestProcessor(agendaProgressPersister, agendaPersister, operationProgressPersister); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.GET, new NoOpVisibilityFilter<>()); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); ServiceDataRequestResult<Agenda, RerunAgendaResponse> agendaRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaRequestProcessor, rerunAgendaRequest.getAgendaId(), Agenda.class); if(agendaRequestResult.getServiceResponse() != null) return agendaRequestResult.getServiceResponse(); Agenda agenda = agendaRequestResult.getDataObjectResponse().getFirst(); ServiceDataRequestResult<AgendaProgress, RerunAgendaResponse> agendaProgressRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaProgressRequestProcessor, agenda.getProgressId(), AgendaProgress.class); if(agendaProgressRequestResult.getServiceResponse() != null) return agendaProgressRequestResult.getServiceResponse(); AgendaProgress agendaProgress = agendaProgressRequestResult.getDataObjectResponse().getFirst(); ProgressResetResult progressResetResult = progressResetProcessor.resetProgress(agenda, agendaProgress, agendaRetryParams); try { DataObjectResponse<AgendaProgress> updateAgendaProgressResponse = agendaProgressRequestProcessor.handlePUT(new DefaultDataObjectRequest<>(null, agendaProgress.getId(), agendaProgress)); if(updateAgendaProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaProgressResponse.getErrorResponse(), "Failed to update AgendaProgress."); } catch (Exception e) { logger.error("Failed to update progress for reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } if(progressResetResult.getOperationsToDelete().size() > 0) { try { agendaRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); DataObjectResponse<Agenda> updateAgendaResponse = agendaRequestProcessor.handlePUT(new DefaultDataObjectRequest<>( null, agenda.getId(), createAgendaWithRemovedOperations(agenda, progressResetResult.getOperationsToDelete()))); if(updateAgendaResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaResponse.getErrorResponse(), "Failed to update Agenda."); } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } try { OperationProgressRequestProcessor operationProgressRequestProcessor = requestProcessorFactory.createOperationProgressRequestProcessor(operationProgressPersister); operationProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.DELETE, new NoOpVisibilityFilter<>()); for (String opName : progressResetResult.getOperationsToDelete()) { DataObjectResponse<OperationProgress> operationProgressResponse = operationProgressRequestProcessor.handleDELETE(new DefaultDataObjectRequest<>( null, OperationProgress.generateId(agendaProgress.getId(), opName), null)); if(operationProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, operationProgressResponse.getErrorResponse(), "Failed to delete OperationProgress."); } } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } } boolean skipExecution = agendaRetryParams.containsKey(RerunAgendaParameter.SKIP_EXECUTION) || (agenda.getParams() != null && agenda.getParams().containsKey(GeneralParamKey.doNotRun)); if(!skipExecution) { DataObjectResponse<ReadyAgenda> readyAgendaResponse = persistReadyAgenda(agenda.getAgendaInsight().getInsightId(), agenda.getId(), agenda.getCustomerId(), serviceRequest.getCID()); if (readyAgendaResponse.isError()) { return createReigniteAgendaResponse(serviceRequest, readyAgendaResponse.getErrorResponse(), null); } } return createReigniteAgendaResponse(serviceRequest, null, null); } }
RerunAgendaServiceRequestProcessor extends AbstractServiceRequestProcessor<RerunAgendaResponse, ServiceRequest<RerunAgendaRequest>> { @Override public RerunAgendaResponse processPOST(ServiceRequest<RerunAgendaRequest> serviceRequest) { RerunAgendaRequest rerunAgendaRequest = serviceRequest.getPayload(); Map<RerunAgendaParameter, String> agendaRetryParams = RerunAgendaParameter.getParametersMap(rerunAgendaRequest.getParams()); AgendaRequestProcessor agendaRequestProcessor = requestProcessorFactory.createAgendaRequestProcessor(agendaPersister, agendaProgressPersister, readyAgendaPersister, operationProgressPersister, insightPersister, customerPersister); AgendaProgressRequestProcessor agendaProgressRequestProcessor = requestProcessorFactory.createAgendaProgressRequestProcessor(agendaProgressPersister, agendaPersister, operationProgressPersister); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.GET, new NoOpVisibilityFilter<>()); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); ServiceDataRequestResult<Agenda, RerunAgendaResponse> agendaRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaRequestProcessor, rerunAgendaRequest.getAgendaId(), Agenda.class); if(agendaRequestResult.getServiceResponse() != null) return agendaRequestResult.getServiceResponse(); Agenda agenda = agendaRequestResult.getDataObjectResponse().getFirst(); ServiceDataRequestResult<AgendaProgress, RerunAgendaResponse> agendaProgressRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaProgressRequestProcessor, agenda.getProgressId(), AgendaProgress.class); if(agendaProgressRequestResult.getServiceResponse() != null) return agendaProgressRequestResult.getServiceResponse(); AgendaProgress agendaProgress = agendaProgressRequestResult.getDataObjectResponse().getFirst(); ProgressResetResult progressResetResult = progressResetProcessor.resetProgress(agenda, agendaProgress, agendaRetryParams); try { DataObjectResponse<AgendaProgress> updateAgendaProgressResponse = agendaProgressRequestProcessor.handlePUT(new DefaultDataObjectRequest<>(null, agendaProgress.getId(), agendaProgress)); if(updateAgendaProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaProgressResponse.getErrorResponse(), "Failed to update AgendaProgress."); } catch (Exception e) { logger.error("Failed to update progress for reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } if(progressResetResult.getOperationsToDelete().size() > 0) { try { agendaRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); DataObjectResponse<Agenda> updateAgendaResponse = agendaRequestProcessor.handlePUT(new DefaultDataObjectRequest<>( null, agenda.getId(), createAgendaWithRemovedOperations(agenda, progressResetResult.getOperationsToDelete()))); if(updateAgendaResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaResponse.getErrorResponse(), "Failed to update Agenda."); } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } try { OperationProgressRequestProcessor operationProgressRequestProcessor = requestProcessorFactory.createOperationProgressRequestProcessor(operationProgressPersister); operationProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.DELETE, new NoOpVisibilityFilter<>()); for (String opName : progressResetResult.getOperationsToDelete()) { DataObjectResponse<OperationProgress> operationProgressResponse = operationProgressRequestProcessor.handleDELETE(new DefaultDataObjectRequest<>( null, OperationProgress.generateId(agendaProgress.getId(), opName), null)); if(operationProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, operationProgressResponse.getErrorResponse(), "Failed to delete OperationProgress."); } } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } } boolean skipExecution = agendaRetryParams.containsKey(RerunAgendaParameter.SKIP_EXECUTION) || (agenda.getParams() != null && agenda.getParams().containsKey(GeneralParamKey.doNotRun)); if(!skipExecution) { DataObjectResponse<ReadyAgenda> readyAgendaResponse = persistReadyAgenda(agenda.getAgendaInsight().getInsightId(), agenda.getId(), agenda.getCustomerId(), serviceRequest.getCID()); if (readyAgendaResponse.isError()) { return createReigniteAgendaResponse(serviceRequest, readyAgendaResponse.getErrorResponse(), null); } } return createReigniteAgendaResponse(serviceRequest, null, null); } RerunAgendaServiceRequestProcessor(ObjectPersister<Agenda> agendaPersister, ObjectPersister<AgendaProgress> agendaProgressPersister,
        ObjectPersister<OperationProgress> operationProgressPersister, ObjectPersister<ReadyAgenda> readyAgendaPersister, ObjectPersister<Insight> insightPersister,
        ObjectPersister<Customer> customerPersister); }
RerunAgendaServiceRequestProcessor extends AbstractServiceRequestProcessor<RerunAgendaResponse, ServiceRequest<RerunAgendaRequest>> { @Override public RerunAgendaResponse processPOST(ServiceRequest<RerunAgendaRequest> serviceRequest) { RerunAgendaRequest rerunAgendaRequest = serviceRequest.getPayload(); Map<RerunAgendaParameter, String> agendaRetryParams = RerunAgendaParameter.getParametersMap(rerunAgendaRequest.getParams()); AgendaRequestProcessor agendaRequestProcessor = requestProcessorFactory.createAgendaRequestProcessor(agendaPersister, agendaProgressPersister, readyAgendaPersister, operationProgressPersister, insightPersister, customerPersister); AgendaProgressRequestProcessor agendaProgressRequestProcessor = requestProcessorFactory.createAgendaProgressRequestProcessor(agendaProgressPersister, agendaPersister, operationProgressPersister); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.GET, new NoOpVisibilityFilter<>()); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); ServiceDataRequestResult<Agenda, RerunAgendaResponse> agendaRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaRequestProcessor, rerunAgendaRequest.getAgendaId(), Agenda.class); if(agendaRequestResult.getServiceResponse() != null) return agendaRequestResult.getServiceResponse(); Agenda agenda = agendaRequestResult.getDataObjectResponse().getFirst(); ServiceDataRequestResult<AgendaProgress, RerunAgendaResponse> agendaProgressRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaProgressRequestProcessor, agenda.getProgressId(), AgendaProgress.class); if(agendaProgressRequestResult.getServiceResponse() != null) return agendaProgressRequestResult.getServiceResponse(); AgendaProgress agendaProgress = agendaProgressRequestResult.getDataObjectResponse().getFirst(); ProgressResetResult progressResetResult = progressResetProcessor.resetProgress(agenda, agendaProgress, agendaRetryParams); try { DataObjectResponse<AgendaProgress> updateAgendaProgressResponse = agendaProgressRequestProcessor.handlePUT(new DefaultDataObjectRequest<>(null, agendaProgress.getId(), agendaProgress)); if(updateAgendaProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaProgressResponse.getErrorResponse(), "Failed to update AgendaProgress."); } catch (Exception e) { logger.error("Failed to update progress for reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } if(progressResetResult.getOperationsToDelete().size() > 0) { try { agendaRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); DataObjectResponse<Agenda> updateAgendaResponse = agendaRequestProcessor.handlePUT(new DefaultDataObjectRequest<>( null, agenda.getId(), createAgendaWithRemovedOperations(agenda, progressResetResult.getOperationsToDelete()))); if(updateAgendaResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaResponse.getErrorResponse(), "Failed to update Agenda."); } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } try { OperationProgressRequestProcessor operationProgressRequestProcessor = requestProcessorFactory.createOperationProgressRequestProcessor(operationProgressPersister); operationProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.DELETE, new NoOpVisibilityFilter<>()); for (String opName : progressResetResult.getOperationsToDelete()) { DataObjectResponse<OperationProgress> operationProgressResponse = operationProgressRequestProcessor.handleDELETE(new DefaultDataObjectRequest<>( null, OperationProgress.generateId(agendaProgress.getId(), opName), null)); if(operationProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, operationProgressResponse.getErrorResponse(), "Failed to delete OperationProgress."); } } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } } boolean skipExecution = agendaRetryParams.containsKey(RerunAgendaParameter.SKIP_EXECUTION) || (agenda.getParams() != null && agenda.getParams().containsKey(GeneralParamKey.doNotRun)); if(!skipExecution) { DataObjectResponse<ReadyAgenda> readyAgendaResponse = persistReadyAgenda(agenda.getAgendaInsight().getInsightId(), agenda.getId(), agenda.getCustomerId(), serviceRequest.getCID()); if (readyAgendaResponse.isError()) { return createReigniteAgendaResponse(serviceRequest, readyAgendaResponse.getErrorResponse(), null); } } return createReigniteAgendaResponse(serviceRequest, null, null); } RerunAgendaServiceRequestProcessor(ObjectPersister<Agenda> agendaPersister, ObjectPersister<AgendaProgress> agendaProgressPersister,
        ObjectPersister<OperationProgress> operationProgressPersister, ObjectPersister<ReadyAgenda> readyAgendaPersister, ObjectPersister<Insight> insightPersister,
        ObjectPersister<Customer> customerPersister); @Override RerunAgendaResponse processPOST(ServiceRequest<RerunAgendaRequest> serviceRequest); void setProgressResetProcessor(ProgressResetProcessor progressResetProcessor); void setRequestProcessorFactory(RequestProcessorFactory requestProcessorFactory); }
RerunAgendaServiceRequestProcessor extends AbstractServiceRequestProcessor<RerunAgendaResponse, ServiceRequest<RerunAgendaRequest>> { @Override public RerunAgendaResponse processPOST(ServiceRequest<RerunAgendaRequest> serviceRequest) { RerunAgendaRequest rerunAgendaRequest = serviceRequest.getPayload(); Map<RerunAgendaParameter, String> agendaRetryParams = RerunAgendaParameter.getParametersMap(rerunAgendaRequest.getParams()); AgendaRequestProcessor agendaRequestProcessor = requestProcessorFactory.createAgendaRequestProcessor(agendaPersister, agendaProgressPersister, readyAgendaPersister, operationProgressPersister, insightPersister, customerPersister); AgendaProgressRequestProcessor agendaProgressRequestProcessor = requestProcessorFactory.createAgendaProgressRequestProcessor(agendaProgressPersister, agendaPersister, operationProgressPersister); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.GET, new NoOpVisibilityFilter<>()); agendaProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); ServiceDataRequestResult<Agenda, RerunAgendaResponse> agendaRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaRequestProcessor, rerunAgendaRequest.getAgendaId(), Agenda.class); if(agendaRequestResult.getServiceResponse() != null) return agendaRequestResult.getServiceResponse(); Agenda agenda = agendaRequestResult.getDataObjectResponse().getFirst(); ServiceDataRequestResult<AgendaProgress, RerunAgendaResponse> agendaProgressRequestResult = serviceDataObjectRetriever.performObjectRetrieve( serviceRequest, agendaProgressRequestProcessor, agenda.getProgressId(), AgendaProgress.class); if(agendaProgressRequestResult.getServiceResponse() != null) return agendaProgressRequestResult.getServiceResponse(); AgendaProgress agendaProgress = agendaProgressRequestResult.getDataObjectResponse().getFirst(); ProgressResetResult progressResetResult = progressResetProcessor.resetProgress(agenda, agendaProgress, agendaRetryParams); try { DataObjectResponse<AgendaProgress> updateAgendaProgressResponse = agendaProgressRequestProcessor.handlePUT(new DefaultDataObjectRequest<>(null, agendaProgress.getId(), agendaProgress)); if(updateAgendaProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaProgressResponse.getErrorResponse(), "Failed to update AgendaProgress."); } catch (Exception e) { logger.error("Failed to update progress for reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } if(progressResetResult.getOperationsToDelete().size() > 0) { try { agendaRequestProcessor.setVisibilityFilter(VisibilityMethod.PUT, new NoOpVisibilityFilter<>()); DataObjectResponse<Agenda> updateAgendaResponse = agendaRequestProcessor.handlePUT(new DefaultDataObjectRequest<>( null, agenda.getId(), createAgendaWithRemovedOperations(agenda, progressResetResult.getOperationsToDelete()))); if(updateAgendaResponse.isError()) return createReigniteAgendaResponse(serviceRequest, updateAgendaResponse.getErrorResponse(), "Failed to update Agenda."); } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } try { OperationProgressRequestProcessor operationProgressRequestProcessor = requestProcessorFactory.createOperationProgressRequestProcessor(operationProgressPersister); operationProgressRequestProcessor.setVisibilityFilter(VisibilityMethod.DELETE, new NoOpVisibilityFilter<>()); for (String opName : progressResetResult.getOperationsToDelete()) { DataObjectResponse<OperationProgress> operationProgressResponse = operationProgressRequestProcessor.handleDELETE(new DefaultDataObjectRequest<>( null, OperationProgress.generateId(agendaProgress.getId(), opName), null)); if(operationProgressResponse.isError()) return createReigniteAgendaResponse(serviceRequest, operationProgressResponse.getErrorResponse(), "Failed to delete OperationProgress."); } } catch (Exception e) { logger.error("Failed to remove operation progress due to progress reset. Agenda will not execute.", e); return createReigniteAgendaResponse(serviceRequest, ErrorResponseFactory.runtimeServiceException( new RuntimeServiceException("Failed to update progress for reset.", e, 500), serviceRequest.getCID()), null); } } boolean skipExecution = agendaRetryParams.containsKey(RerunAgendaParameter.SKIP_EXECUTION) || (agenda.getParams() != null && agenda.getParams().containsKey(GeneralParamKey.doNotRun)); if(!skipExecution) { DataObjectResponse<ReadyAgenda> readyAgendaResponse = persistReadyAgenda(agenda.getAgendaInsight().getInsightId(), agenda.getId(), agenda.getCustomerId(), serviceRequest.getCID()); if (readyAgendaResponse.isError()) { return createReigniteAgendaResponse(serviceRequest, readyAgendaResponse.getErrorResponse(), null); } } return createReigniteAgendaResponse(serviceRequest, null, null); } RerunAgendaServiceRequestProcessor(ObjectPersister<Agenda> agendaPersister, ObjectPersister<AgendaProgress> agendaProgressPersister,
        ObjectPersister<OperationProgress> operationProgressPersister, ObjectPersister<ReadyAgenda> readyAgendaPersister, ObjectPersister<Insight> insightPersister,
        ObjectPersister<Customer> customerPersister); @Override RerunAgendaResponse processPOST(ServiceRequest<RerunAgendaRequest> serviceRequest); void setProgressResetProcessor(ProgressResetProcessor progressResetProcessor); void setRequestProcessorFactory(RequestProcessorFactory requestProcessorFactory);  }