use of org.activiti.rest.service.api.engine.variable.RestVariable in project Activiti by Activiti.
the class HistoricProcessInstanceVariableDataResource method getVariableData.
@RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/variables/{variableName}/data", method = RequestMethod.GET)
@ResponseBody
public byte[] getVariableData(@PathVariable("processInstanceId") String processInstanceId, @PathVariable("variableName") String variableName, HttpServletRequest request, HttpServletResponse response) {
try {
byte[] result = null;
RestVariable variable = getVariableFromRequest(true, processInstanceId, variableName, 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.rest.service.api.engine.variable.RestVariable in project Activiti by Activiti.
the class RestResponseFactory method createBinaryRestVariable.
public RestVariable createBinaryRestVariable(String name, RestVariableScope scope, String type, String taskId, String executionId, String processInstanceId) {
RestUrlBuilder urlBuilder = createUrlBuilder();
RestVariable restVar = new RestVariable();
restVar.setVariableScope(scope);
restVar.setName(name);
restVar.setType(type);
if (taskId != null) {
restVar.setValueUrl(urlBuilder.buildUrl(RestUrls.URL_TASK_VARIABLE_DATA, taskId, name));
}
if (executionId != null) {
restVar.setValueUrl(urlBuilder.buildUrl(RestUrls.URL_EXECUTION_VARIABLE_DATA, executionId, name));
}
if (processInstanceId != null) {
restVar.setValueUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE_DATA, processInstanceId, name));
}
return restVar;
}
use of org.activiti.rest.service.api.engine.variable.RestVariable in project Activiti by Activiti.
the class HistoricTaskInstanceVariableDataResource method getVariableData.
@RequestMapping(value = "/history/historic-task-instances/{taskId}/variables/{variableName}/data", method = RequestMethod.GET)
@ResponseBody
public byte[] getVariableData(@PathVariable("taskId") String taskId, @PathVariable("variableName") String variableName, @RequestParam(value = "scope", required = false) String scope, HttpServletRequest request, HttpServletResponse response) {
try {
byte[] result = null;
RestVariable variable = getVariableFromRequest(true, taskId, variableName, scope, 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.rest.service.api.engine.variable.RestVariable in project Activiti by Activiti.
the class HistoricVariableInstanceDataResource method getVariableData.
@RequestMapping(value = "/history/historic-variable-instances/{varInstanceId}/data", method = RequestMethod.GET)
@ResponseBody
public byte[] getVariableData(@PathVariable("varInstanceId") String varInstanceId, HttpServletRequest request, HttpServletResponse response) {
try {
byte[] result = null;
RestVariable variable = getVariableFromRequest(true, varInstanceId, 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.rest.service.api.engine.variable.RestVariable 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);
}
}
Aggregations