Search in sources :

Example 11 with NotValidException

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

the class DecisionRequirementsDefinitionResourceImpl method getDecisionRequirementsDefinition.

@Override
public DecisionRequirementsDefinitionDto getDecisionRequirementsDefinition() {
    RepositoryService repositoryService = engine.getRepositoryService();
    DecisionRequirementsDefinition definition = null;
    try {
        definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e, e.getMessage());
    } catch (NotValidException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
    } catch (ProcessEngineException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
    }
    return DecisionRequirementsDefinitionDto.fromDecisionRequirementsDefinition(definition);
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 12 with NotValidException

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

the class DecisionRequirementsDefinitionResourceImpl method getDecisionRequirementsDefinitionDmnXml.

@Override
public DecisionRequirementsDefinitionXmlDto getDecisionRequirementsDefinitionDmnXml() {
    InputStream decisionRequirementsModelInputStream = null;
    try {
        decisionRequirementsModelInputStream = engine.getRepositoryService().getDecisionRequirementsModel(decisionRequirementsDefinitionId);
        byte[] decisionRequirementsModel = IoUtil.readInputStream(decisionRequirementsModelInputStream, "decisionRequirementsModelDmnXml");
        return DecisionRequirementsDefinitionXmlDto.create(decisionRequirementsDefinitionId, new String(decisionRequirementsModel, "UTF-8"));
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e, e.getMessage());
    } catch (NotValidException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
    } catch (ProcessEngineException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
    } catch (UnsupportedEncodingException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
    } finally {
        IoUtil.closeSilently(decisionRequirementsModelInputStream);
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) InputStream(java.io.InputStream) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 13 with NotValidException

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

the class DecisionDefinitionResourceImpl method getDecisionDefinitionDmnXml.

@Override
public DecisionDefinitionDiagramDto getDecisionDefinitionDmnXml() {
    InputStream decisionModelInputStream = null;
    try {
        decisionModelInputStream = engine.getRepositoryService().getDecisionModel(decisionDefinitionId);
        byte[] decisionModel = IoUtil.readInputStream(decisionModelInputStream, "decisionModelDmnXml");
        return DecisionDefinitionDiagramDto.create(decisionDefinitionId, new String(decisionModel, "UTF-8"));
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e, e.getMessage());
    } catch (NotValidException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
    } catch (ProcessEngineException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
    } catch (UnsupportedEncodingException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
    } finally {
        IoUtil.closeSilently(decisionModelInputStream);
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) InputStream(java.io.InputStream) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 14 with NotValidException

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

the class CaseExecutionResourceImpl method reenable.

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

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

the class CaseExecutionResourceImpl method disable.

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

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