use of org.camunda.bpm.engine.exception.NotValidException 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;
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class FilterResourceImpl method updateFilter.
public void updateFilter(FilterDto filterDto) {
Filter filter = getDbFilter();
try {
filterDto.updateFilter(filter, processEngine);
} catch (NotValidException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "Unable to update filter with invalid content");
}
filterService.saveFilter(filter);
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class DecisionDefinitionResourceImpl method evaluateDecision.
@Override
public List<Map<String, VariableValueDto>> evaluateDecision(UriInfo context, EvaluateDecisionDto parameters) {
DecisionService decisionService = engine.getDecisionService();
Map<String, Object> variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);
try {
DmnDecisionResult decisionResult = decisionService.evaluateDecisionById(decisionDefinitionId).variables(variables).evaluate();
return createDecisionResultDto(decisionResult);
} catch (AuthorizationException e) {
throw e;
} catch (NotFoundException e) {
String errorMessage = String.format("Cannot evaluate decision %s: %s", decisionDefinitionId, e.getMessage());
throw new InvalidRequestException(Status.NOT_FOUND, e, errorMessage);
} catch (NotValidException e) {
String errorMessage = String.format("Cannot evaluate decision %s: %s", decisionDefinitionId, e.getMessage());
throw new InvalidRequestException(Status.BAD_REQUEST, e, errorMessage);
} catch (ProcessEngineException e) {
String errorMessage = String.format("Cannot evaluate decision %s: %s", decisionDefinitionId, e.getMessage());
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
} catch (DmnEngineException e) {
String errorMessage = String.format("Cannot evaluate decision %s: %s", decisionDefinitionId, e.getMessage());
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
}
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class DecisionDefinitionResourceImpl method getDecisionDefinition.
@Override
public DecisionDefinitionDto getDecisionDefinition() {
RepositoryService repositoryService = engine.getRepositoryService();
DecisionDefinition definition = null;
try {
definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
} 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 DecisionDefinitionDto.fromDecisionDefinition(definition);
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class DeploymentResourceImpl method redeploy.
public DeploymentDto redeploy(UriInfo uriInfo, RedeploymentDto redeployment) {
DeploymentWithDefinitions deployment = null;
try {
deployment = tryToRedeploy(redeployment);
} catch (NotFoundException e) {
throw createInvalidRequestException("redeploy", Status.NOT_FOUND, e);
} catch (NotValidException e) {
throw createInvalidRequestException("redeploy", Status.BAD_REQUEST, e);
}
DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment);
URI uri = uriInfo.getBaseUriBuilder().path(relativeRootResourcePath).path(DeploymentRestService.PATH).path(deployment.getId()).build();
// GET /
deploymentDto.addReflexiveLink(uri, HttpMethod.GET, "self");
return deploymentDto;
}
Aggregations