use of org.activiti.engine.ActivitiException in project carbon-business-process by wso2.
the class HistoricDetailService method getVariableData.
@GET
@Path("/{detailId}/data")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getVariableData(@PathParam("detailId") String detailId) {
try {
byte[] result = null;
RestVariable variable = getVariableFromRequest(true, detailId);
Response.ResponseBuilder response = Response.ok();
if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
result = (byte[]) variable.getValue();
response.type("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.type("application/x-java-serialized-object");
} else {
throw new ActivitiObjectNotFoundException("The variable does not have a binary data stream.", null);
}
return response.entity(result).build();
} catch (IOException ioe) {
// Re-throw IOException
throw new ActivitiException("Unexpected exception getting variable data", ioe);
}
}
use of org.activiti.engine.ActivitiException in project carbon-business-process by wso2.
the class FormDataService method submitForm.
@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response submitForm(SubmitFormRequest submitRequest) {
if (submitRequest == null) {
throw new ActivitiException("A request body was expected when executing the form submit.");
}
if (submitRequest.getTaskId() == null && submitRequest.getProcessDefinitionId() == null) {
throw new ActivitiIllegalArgumentException("The taskId or processDefinitionId property has to be provided");
}
Map<String, String> propertyMap = new HashMap<String, String>();
if (submitRequest.getProperties() != null) {
for (RestFormProperty formProperty : submitRequest.getProperties()) {
propertyMap.put(formProperty.getId(), formProperty.getValue());
}
}
FormService formService = BPMNOSGIService.getFormService();
Response.ResponseBuilder response = Response.ok();
if (submitRequest.getTaskId() != null) {
formService.submitTaskFormData(submitRequest.getTaskId(), propertyMap);
response.status(Response.Status.NO_CONTENT);
return response.build();
} else {
ProcessInstance processInstance = null;
if (submitRequest.getBusinessKey() != null) {
processInstance = formService.submitStartFormData(submitRequest.getProcessDefinitionId(), submitRequest.getBusinessKey(), propertyMap);
} else {
processInstance = formService.submitStartFormData(submitRequest.getProcessDefinitionId(), propertyMap);
}
ProcessInstanceResponse processInstanceResponse = new RestResponseFactory().createProcessInstanceResponse(processInstance, uriInfo.getBaseUri().toString());
return response.entity(processInstanceResponse).build();
}
}
use of org.activiti.engine.ActivitiException in project tutorials-java by Artister.
the class ModelSaveRestResource method saveModel.
@RequestMapping(value = "/model/{modelId}/save", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.OK)
public void saveModel(@PathVariable String modelId, @RequestParam("name") String name, @RequestParam("json_xml") String json_xml, @RequestParam("svg_xml") String svg_xml, @RequestParam("description") String description) {
// 对接收参数进行了修改
try {
Model model = repositoryService.getModel(modelId);
ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo());
modelJson.put(MODEL_NAME, name);
modelJson.put(MODEL_DESCRIPTION, description);
model.setMetaInfo(modelJson.toString());
model.setName(name);
repositoryService.saveModel(model);
repositoryService.addModelEditorSource(model.getId(), json_xml.getBytes("utf-8"));
InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("utf-8"));
TranscoderInput input = new TranscoderInput(svgStream);
PNGTranscoder transcoder = new PNGTranscoder();
// Setup output
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
TranscoderOutput output = new TranscoderOutput(outStream);
// Do the transformation
transcoder.transcode(input, output);
final byte[] result = outStream.toByteArray();
repositoryService.addModelEditorSourceExtra(model.getId(), result);
outStream.close();
} catch (Exception e) {
LOGGER.error("Error saving model", e);
throw new ActivitiException("Error saving model", e);
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DefaultActivityBehaviorFactory method createMuleActivityBehavior.
protected ActivityBehavior createMuleActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions) {
try {
Class<?> theClass = Class.forName("org.activiti.mule.MuleSendActivitiBehavior");
List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions);
return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(theClass, fieldDeclarations);
} catch (ClassNotFoundException e) {
throw new ActivitiException("Could not find org.activiti.mule.MuleSendActivitiBehavior: ", e);
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DefaultActivityBehaviorFactory method createBusinessRuleTaskActivityBehavior.
public ActivityBehavior createBusinessRuleTaskActivityBehavior(BusinessRuleTask businessRuleTask) {
BusinessRuleTaskDelegate ruleActivity = null;
if (StringUtils.isNotEmpty(businessRuleTask.getClassName())) {
try {
Class<?> clazz = Class.forName(businessRuleTask.getClassName());
ruleActivity = (BusinessRuleTaskDelegate) clazz.newInstance();
} catch (Exception e) {
throw new ActivitiException("Could not instantiate businessRuleTask (id:" + businessRuleTask.getId() + ") class: " + businessRuleTask.getClassName(), e);
}
} else {
// no default behavior
}
for (String ruleVariableInputObject : businessRuleTask.getInputVariables()) {
ruleActivity.addRuleVariableInputIdExpression(expressionManager.createExpression(ruleVariableInputObject.trim()));
}
for (String rule : businessRuleTask.getRuleNames()) {
ruleActivity.addRuleIdExpression(expressionManager.createExpression(rule.trim()));
}
ruleActivity.setExclude(businessRuleTask.isExclude());
if (businessRuleTask.getResultVariableName() != null && businessRuleTask.getResultVariableName().length() > 0) {
ruleActivity.setResultVariable(businessRuleTask.getResultVariableName());
} else {
ruleActivity.setResultVariable("org.activiti.engine.rules.OUTPUT");
}
return ruleActivity;
}
Aggregations