Search in sources :

Example 16 with NotValidException

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

the class CaseExecutionResourceImpl method terminate.

public void terminate(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseExecutionId);
        initializeCommand(commandBuilder, triggerDto, "terminate");
        commandBuilder.terminate();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("terminate", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("terminate", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("terminate", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("terminate", 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 17 with NotValidException

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

the class CaseInstanceResourceImpl method terminate.

public void terminate(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId);
        initializeCommand(commandBuilder, triggerDto, "terminate");
        commandBuilder.terminate();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("terminate", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("terminate", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("terminate", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("terminate", 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 18 with NotValidException

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

the class CaseInstanceResourceImpl method complete.

public void complete(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId);
        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 19 with NotValidException

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

the class ParseUtil method parseHistoryTimeToLive.

/**
 * Parse History Time To Live in ISO-8601 format to integer and set into the given entity
 * @param historyTimeToLive
 */
public static Integer parseHistoryTimeToLive(String historyTimeToLive) {
    Integer timeToLive = null;
    if (historyTimeToLive != null && !historyTimeToLive.isEmpty()) {
        Matcher matISO = REGEX_TTL_ISO.matcher(historyTimeToLive);
        if (matISO.find()) {
            historyTimeToLive = matISO.group(1);
        }
        timeToLive = parseIntegerAttribute("historyTimeToLive", historyTimeToLive);
    }
    if (timeToLive != null && timeToLive < 0) {
        throw new NotValidException("Cannot parse historyTimeToLive: negative value is not allowed");
    }
    return timeToLive;
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) Matcher(java.util.regex.Matcher)

Example 20 with NotValidException

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

the class ProcessInstanceModificationTest method testStartBeforeNonExistingActivity.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testStartBeforeNonExistingActivity() {
    // given
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
    try {
        // when
        runtimeService.createProcessInstanceModification(instance.getId()).startBeforeActivity("someNonExistingActivity").execute();
        fail("should not succeed");
    } catch (NotValidException e) {
        // then
        assertTextPresentIgnoreCase("element 'someNonExistingActivity' does not exist in process ", e.getMessage());
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

NotValidException (org.camunda.bpm.engine.exception.NotValidException)121 Test (org.junit.Test)28 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)24 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)24 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)18 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)17 Deployment (org.camunda.bpm.engine.test.Deployment)12 CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)10 DecisionDefinitionQuery (org.camunda.bpm.engine.repository.DecisionDefinitionQuery)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 CaseService (org.camunda.bpm.engine.CaseService)9 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 RestException (org.camunda.bpm.engine.rest.exception.RestException)8 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 HashMap (java.util.HashMap)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 InputStream (java.io.InputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3