use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class HistoricDetailDataResource method getVariableFromRequest.
public RestVariable getVariableFromRequest(boolean includeBinary, String detailId, HttpServletRequest request) {
Object value = null;
HistoricVariableUpdate variableUpdate = null;
HistoricDetail detailObject = historyService.createHistoricDetailQuery().id(detailId).singleResult();
if (detailObject instanceof HistoricVariableUpdate) {
variableUpdate = (HistoricVariableUpdate) detailObject;
value = variableUpdate.getValue();
}
if (value == null) {
throw new ActivitiObjectNotFoundException("Historic detail '" + detailId + "' doesn't have a variable value.", VariableInstanceEntity.class);
} else {
return restResponseFactory.createRestVariable(variableUpdate.getVariableName(), value, null, detailId, RestResponseFactory.VARIABLE_HISTORY_DETAIL, includeBinary);
}
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class HistoricDetailDataResource method getVariableData.
@RequestMapping(value = "/history/historic-detail/{detailId}/data", method = RequestMethod.GET)
@ResponseBody
public byte[] getVariableData(@PathVariable("detailId") String detailId, HttpServletRequest request, HttpServletResponse response) {
try {
byte[] result = null;
RestVariable variable = getVariableFromRequest(true, detailId, request);
if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
result = (byte[]) variable.getValue();
response.setContentType("application/octet-stream");
} else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
outputStream.writeObject(variable.getValue());
outputStream.close();
result = buffer.toByteArray();
response.setContentType("application/x-java-serialized-object");
} else {
throw new ActivitiObjectNotFoundException("The variable does not have a binary data stream.", null);
}
return result;
} catch (IOException ioe) {
// Re-throw IOException
throw new ActivitiException("Unexpected exception getting variable data", ioe);
}
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class HistoricProcessInstanceCommentResource method getComment.
@RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/comments/{commentId}", method = RequestMethod.GET, produces = "application/json")
public CommentResponse getComment(@PathVariable("processInstanceId") String processInstanceId, @PathVariable("commentId") String commentId, HttpServletRequest request) {
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
Comment comment = taskService.getComment(commentId);
if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) {
throw new ActivitiObjectNotFoundException("Process instance '" + instance.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
}
return restResponseFactory.createRestComment(comment);
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class HistoricProcessInstanceVariableDataResource method getVariableFromRequest.
public RestVariable getVariableFromRequest(boolean includeBinary, String processInstanceId, String variableName, HttpServletRequest request) {
HistoricProcessInstance processObject = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult();
if (processObject == null) {
throw new ActivitiObjectNotFoundException("Historic process instance '" + processInstanceId + "' couldn't be found.", HistoricProcessInstanceEntity.class);
}
Object value = processObject.getProcessVariables().get(variableName);
if (value == null) {
throw new ActivitiObjectNotFoundException("Historic process instance '" + processInstanceId + "' variable value for " + variableName + " couldn't be found.", VariableInstanceEntity.class);
} else {
return restResponseFactory.createRestVariable(variableName, value, null, processInstanceId, RestResponseFactory.VARIABLE_HISTORY_PROCESS, includeBinary);
}
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class DeploymentResourceCollectionResource method getDeploymentResources.
@RequestMapping(value = "/repository/deployments/{deploymentId}/resources", method = RequestMethod.GET, produces = "application/json")
public List<DeploymentResourceResponse> getDeploymentResources(@PathVariable String deploymentId, HttpServletRequest request) {
// Check if deployment exists
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (deployment == null) {
throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", Deployment.class);
}
List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
return restResponseFactory.createDeploymentResourceResponseList(deploymentId, resourceList, contentTypeResolver);
}
Aggregations