Search in sources :

Example 16 with NotAllowedException

use of org.camunda.bpm.engine.exception.NotAllowedException in project camunda-bpm-platform by camunda.

the class Cmmn10CompatibilityTest method testRequiredRule.

@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/cmm10/Cmmn10CompatibilityTest.testRequiredRule.cmmn")
public void testRequiredRule() {
    CaseInstance caseInstance = createCaseInstanceByKey("case", Variables.createVariables().putValue("required", true));
    CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1");
    assertNotNull(taskExecution);
    assertTrue(taskExecution.isRequired());
    try {
        caseService.completeCaseExecution(caseInstance.getId());
        fail("completing the containing stage should not be allowed");
    } catch (NotAllowedException e) {
    // happy path
    }
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 17 with NotAllowedException

use of org.camunda.bpm.engine.exception.NotAllowedException in project camunda-bpm-platform by camunda.

the class CaseDefinitionResourceImpl method createCaseInstance.

public CaseInstanceDto createCaseInstance(UriInfo context, CreateCaseInstanceDto parameters) {
    CaseService caseService = engine.getCaseService();
    CaseInstance instance = null;
    try {
        String businessKey = parameters.getBusinessKey();
        VariableMap variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);
        instance = caseService.withCaseDefinition(caseDefinitionId).businessKey(businessKey).setVariables(variables).create();
    } catch (RestException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new InvalidRequestException(e.getStatus(), e, errorMessage);
    } catch (NotFoundException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new InvalidRequestException(Status.NOT_FOUND, e, errorMessage);
    } catch (NotValidException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new InvalidRequestException(Status.BAD_REQUEST, e, errorMessage);
    } catch (NotAllowedException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new InvalidRequestException(Status.FORBIDDEN, e, errorMessage);
    } catch (ProcessEngineException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
    }
    CaseInstanceDto result = CaseInstanceDto.fromCaseInstance(instance);
    URI uri = context.getBaseUriBuilder().path(rootResourcePath).path(CaseInstanceRestService.PATH).path(instance.getId()).build();
    result.addReflexiveLink(uri, HttpMethod.GET, "self");
    return result;
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) NotValidException(org.camunda.bpm.engine.exception.NotValidException) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) VariableMap(org.camunda.bpm.engine.variable.VariableMap) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CaseService(org.camunda.bpm.engine.CaseService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) CreateCaseInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.CreateCaseInstanceDto) CaseInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.CaseInstanceDto) URI(java.net.URI) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 18 with NotAllowedException

use of org.camunda.bpm.engine.exception.NotAllowedException in project camunda-bpm-platform by camunda.

the class CaseExecutionResourceImpl method manualStart.

public void manualStart(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseExecutionId);
        initializeCommand(commandBuilder, triggerDto, "start manually");
        commandBuilder.manualStart();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("manualStart", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("manualStart", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("manualStart", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("manualStart", Status.INTERNAL_SERVER_ERROR, e);
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CaseService(org.camunda.bpm.engine.CaseService) CaseExecutionCommandBuilder(org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 19 with NotAllowedException

use of org.camunda.bpm.engine.exception.NotAllowedException in project camunda-bpm-platform by camunda.

the class CaseExecutionResourceImpl method complete.

public void complete(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseExecutionId);
        initializeCommand(commandBuilder, triggerDto, "complete");
        commandBuilder.complete();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("complete", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("complete", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("complete", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("complete", Status.INTERNAL_SERVER_ERROR, e);
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CaseService(org.camunda.bpm.engine.CaseService) CaseExecutionCommandBuilder(org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 20 with NotAllowedException

use of org.camunda.bpm.engine.exception.NotAllowedException in project camunda-bpm-platform by camunda.

the class CaseInstanceResourceImpl method close.

public void close(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId);
        initializeCommand(commandBuilder, triggerDto, "close");
        commandBuilder.close();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("close", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("close", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("close", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("close", Status.INTERNAL_SERVER_ERROR, e);
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CaseService(org.camunda.bpm.engine.CaseService) CaseExecutionCommandBuilder(org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)22 Deployment (org.camunda.bpm.engine.test.Deployment)13 CaseService (org.camunda.bpm.engine.CaseService)9 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)9 NotValidException (org.camunda.bpm.engine.exception.NotValidException)9 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)9 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)5 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)2 URI (java.net.URI)1 CaseInstanceDto (org.camunda.bpm.engine.rest.dto.runtime.CaseInstanceDto)1 CreateCaseInstanceDto (org.camunda.bpm.engine.rest.dto.runtime.CreateCaseInstanceDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 RestException (org.camunda.bpm.engine.rest.exception.RestException)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1