use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class ProcessDefinitionResourceImpl method getProcessDefinitionBpmn20Xml.
@Override
public ProcessDefinitionDiagramDto getProcessDefinitionBpmn20Xml() {
InputStream processModelIn = null;
try {
processModelIn = engine.getRepositoryService().getProcessModel(processDefinitionId);
byte[] processModel = IoUtil.readInputStream(processModelIn, "processModelBpmn20Xml");
return ProcessDefinitionDiagramDto.create(processDefinitionId, new String(processModel, "UTF-8"));
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "No matching definition with id " + processDefinitionId);
} catch (UnsupportedEncodingException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
} finally {
IoUtil.closeSilently(processModelIn);
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class ProcessInstanceResourceImpl method getProcessInstance.
@Override
public ProcessInstanceDto getProcessInstance() {
RuntimeService runtimeService = engine.getRuntimeService();
ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (instance == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Process instance with id " + processInstanceId + " does not exist");
}
ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance);
return result;
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class ProcessInstanceResourceImpl method getActivityInstanceTree.
@Override
public ActivityInstanceDto getActivityInstanceTree() {
RuntimeService runtimeService = engine.getRuntimeService();
ActivityInstance activityInstance = null;
try {
activityInstance = runtimeService.getActivityInstance(processInstanceId);
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e, e.getMessage());
}
if (activityInstance == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Process instance with id " + processInstanceId + " does not exist");
}
ActivityInstanceDto result = ActivityInstanceDto.fromActivityInstance(activityInstance);
return result;
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class TaskCommentResourceImpl method getComment.
public CommentDto getComment(String commentId) {
ensureHistoryEnabled(Status.NOT_FOUND);
Comment comment = engine.getTaskService().getTaskComment(taskId, commentId);
if (comment == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Task comment with id " + commentId + " does not exist for task id '" + taskId + "'.");
}
return CommentDto.fromComment(comment);
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class TaskCommentResourceImpl method createComment.
public CommentDto createComment(UriInfo uriInfo, CommentDto commentDto) {
ensureHistoryEnabled(Status.FORBIDDEN);
ensureTaskExists(Status.BAD_REQUEST);
Comment comment;
try {
comment = engine.getTaskService().createComment(taskId, null, commentDto.getMessage());
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, "Not enough parameters submitted");
}
URI uri = uriInfo.getBaseUriBuilder().path(rootResourcePath).path(TaskRestService.PATH).path(taskId + "/comment/" + comment.getId()).build();
CommentDto resultDto = CommentDto.fromComment(comment);
// GET /
resultDto.addReflexiveLink(uri, HttpMethod.GET, "self");
return resultDto;
}
Aggregations