String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage()); throw new InvalidRequestException(Status.FORBIDDEN, e, errorMessage);
protected void executeCommand(Command<?> command) { try { if(commandExecutor != null) { commandExecutor.execute(command); } else { command.execute(commandContext); } } catch (NullValueException e) { throw new NotValidException(e.getMessage(), e); } catch (CaseExecutionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (CaseDefinitionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (CaseIllegalStateTransitionException e) { throw new NotAllowedException(e.getMessage(), e); } }
String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage()); throw new InvalidRequestException(Status.FORBIDDEN, e, errorMessage);
protected void executeCommand(Command<?> command) { try { if(commandExecutor != null) { commandExecutor.execute(command); } else { command.execute(commandContext); } } catch (NullValueException e) { throw new NotValidException(e.getMessage(), e); } catch (CaseExecutionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (CaseDefinitionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (CaseIllegalStateTransitionException e) { throw new NotAllowedException(e.getMessage(), e); } }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testTerminateNonActiveCaseTask() { // given createCaseInstance(DEFINITION_KEY); CaseExecution caseTaskExecution = queryCaseExecutionByActivityId(CASE_TASK_KEY); try { // when caseService .terminateCaseExecution(caseTaskExecution.getId()); fail("It should not be possible to terminate a case task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
public CaseInstance create() { if (isTenantIdSet && caseDefinitionId != null) { throw LOG.exceptionCreateCaseInstanceByIdAndTenantId(); } try { CreateCaseInstanceCmd command = new CreateCaseInstanceCmd(this); if(commandExecutor != null) { return commandExecutor.execute(command); } else { return command.execute(commandContext); } } catch (CaseDefinitionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (NullValueException e) { throw new NotValidException(e.getMessage(), e); } catch (CaseIllegalStateTransitionException e) { throw new NotAllowedException(e.getMessage(), e); } }
@Provider public class NotAllowedExceptionHandler implements ExceptionMapper <NotAllowedException> { @Override public Response toResponse( NotAllowedException exception ) { String bodyOfResponse = exception.getMessage(); APIResponse response = new APIResponse( false , null , Status.METHOD_NOT_ALLOWED , HttpServletResponse.SC_METHOD_NOT_ALLOWED , bodyOfResponse ); return Response.status( response.getStatus() ).entity( response ).type(MediaType.APPLICATION_JSON).build(); } }
public CaseInstance create() { if (isTenantIdSet && caseDefinitionId != null) { throw LOG.exceptionCreateCaseInstanceByIdAndTenantId(); } try { CreateCaseInstanceCmd command = new CreateCaseInstanceCmd(this); if(commandExecutor != null) { return commandExecutor.execute(command); } else { return command.execute(commandContext); } } catch (CaseDefinitionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (NullValueException e) { throw new NotValidException(e.getMessage(), e); } catch (CaseIllegalStateTransitionException e) { throw new NotAllowedException(e.getMessage(), e); } }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testTerminateNonActiveProcessTask() { // given createCaseInstance(DEFINITION_KEY); CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY); assertTrue(processTask.isEnabled()); try { // when caseService.terminateCaseExecution(processTask.getId()); fail("It should not be possible to terminate a task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
protected void executeCommand(Command<?> command) { try { if(commandExecutor != null) { commandExecutor.execute(command); } else { command.execute(commandContext); } } catch (NullValueException e) { throw new NotValidException(e.getMessage(), e); } catch (CaseExecutionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (CaseDefinitionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (CaseIllegalStateTransitionException e) { throw new NotAllowedException(e.getMessage(), e); } }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"}) public void testTerminateNonActiveHumanTask() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1"); try { // when caseService.terminateCaseExecution(taskExecution.getId()); fail("It should not be possible to terminate a task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
public CaseInstance create() { if (isTenantIdSet && caseDefinitionId != null) { throw LOG.exceptionCreateCaseInstanceByIdAndTenantId(); } try { CreateCaseInstanceCmd command = new CreateCaseInstanceCmd(this); if(commandExecutor != null) { return commandExecutor.execute(command); } else { return command.execute(commandContext); } } catch (CaseDefinitionNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } catch (NullValueException e) { throw new NotValidException(e.getMessage(), e); } catch (CaseIllegalStateTransitionException e) { throw new NotAllowedException(e.getMessage(), e); } }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn"}) public void testTerminateWithNonActiveState() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecution stageExecution = queryCaseExecutionByActivityId("PI_Stage_1"); // when try { // when caseService.terminateCaseExecution(stageExecution.getId()); fail("It should not be possible to terminate a task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"}) public void testTerminateNonActiveCaseInstance() { // given: String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); assertNotNull(queryCaseExecutionByActivityId("CasePlanModel_1")); CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1"); assertTrue(taskExecution.isEnabled()); caseService.completeCaseExecution(caseInstanceId); try { // when caseService.terminateCaseExecution(caseInstanceId); fail("It should not be possible to terminate a task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage()); throw new InvalidRequestException(Status.FORBIDDEN, e, errorMessage);
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testTerminateNonActiveCaseTask() { // given createCaseInstance(DEFINITION_KEY); CaseExecution caseTaskExecution = queryCaseExecutionByActivityId(CASE_TASK_KEY); try { // when caseService .terminateCaseExecution(caseTaskExecution.getId()); fail("It should not be possible to terminate a case task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testTerminateNonActiveProcessTask() { // given createCaseInstance(DEFINITION_KEY); CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY); assertTrue(processTask.isEnabled()); try { // when caseService.terminateCaseExecution(processTask.getId()); fail("It should not be possible to terminate a task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"}) public void testTerminateNonActiveHumanTask() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1"); try { // when caseService.terminateCaseExecution(taskExecution.getId()); fail("It should not be possible to terminate a task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn"}) public void testTerminateWithNonActiveState() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecution stageExecution = queryCaseExecutionByActivityId("PI_Stage_1"); // when try { // when caseService.terminateCaseExecution(stageExecution.getId()); fail("It should not be possible to terminate a task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"}) public void testTerminateNonActiveCaseInstance() { // given: String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); assertNotNull(queryCaseExecutionByActivityId("CasePlanModel_1")); CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1"); assertTrue(taskExecution.isEnabled()); caseService.completeCaseExecution(caseInstanceId); try { // when caseService.terminateCaseExecution(caseInstanceId); fail("It should not be possible to terminate a task."); } catch (NotAllowedException e) { boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate"); assertTrue(result); } }