use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class EditorProcessDefinitionDetailPanel method deployModelerModel.
protected void deployModelerModel(final ObjectNode modelNode) {
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
ExplorerApp.get().getViewManager().showDeploymentPage(deployment.getId());
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class SecureScriptingBaseTest method shutdownProcessEngine.
@After
public void shutdownProcessEngine() {
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
this.taskService = null;
this.repositoryService = null;
this.runtimeService = null;
this.processEngine.close();
this.processEngine = null;
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class SimpleWorkflowResource method createWorkflow.
@RequestMapping(value = "/simple-workflow", method = RequestMethod.POST, produces = "application/json")
public SimpleWorkflowSuccessResponse createWorkflow(@RequestBody String json) {
// Convert json to simple workflow definition
SimpleWorkflowJsonConverter jsonConverter = new SimpleWorkflowJsonConverter();
WorkflowDefinition workflowDefinition = jsonConverter.readWorkflowDefinition(json.getBytes());
WorkflowDefinitionConversionFactory conversionFactory = new WorkflowDefinitionConversionFactory();
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(workflowDefinition);
conversion.convert();
// Deploy process
BpmnModel bpmnModel = conversion.getBpmnModel();
Deployment deployment = repositoryService.createDeployment().addBpmnModel(bpmnModel.getProcesses().get(0).getName() + ".bpmn20.xml", bpmnModel).deploy();
// Fetch process definition id
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
return new SimpleWorkflowSuccessResponse(processDefinition.getId());
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class BaseDeploymentResourceDataResource method getDeploymentResourceData.
protected byte[] getDeploymentResourceData(String deploymentId, String resourceId, HttpServletResponse response) {
if (deploymentId == null) {
throw new ActivitiIllegalArgumentException("No deployment id provided");
}
if (resourceId == null) {
throw new ActivitiIllegalArgumentException("No resource id provided");
}
// 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);
if (resourceList.contains(resourceId)) {
final InputStream resourceStream = repositoryService.getResourceAsStream(deploymentId, resourceId);
String contentType = contentTypeResolver.resolveContentType(resourceId);
response.setContentType(contentType);
try {
return IOUtils.toByteArray(resourceStream);
} catch (Exception e) {
throw new ActivitiException("Error converting resource stream", e);
}
} else {
// Resource not found in deployment
throw new ActivitiObjectNotFoundException("Could not find a resource with id '" + resourceId + "' in deployment '" + deploymentId + "'.", String.class);
}
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class DeploymentCollectionResource method uploadDeployment.
@RequestMapping(value = "/repository/deployments", method = RequestMethod.POST, produces = "application/json")
public DeploymentResponse uploadDeployment(@RequestParam(value = "tenantId", required = false) String tenantId, HttpServletRequest request, HttpServletResponse response) {
if (request instanceof MultipartHttpServletRequest == false) {
throw new ActivitiIllegalArgumentException("Multipart request is required");
}
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
if (multipartRequest.getFileMap().size() == 0) {
throw new ActivitiIllegalArgumentException("Multipart request with file content is required");
}
MultipartFile file = multipartRequest.getFileMap().values().iterator().next();
try {
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
String fileName = file.getOriginalFilename();
if (StringUtils.isEmpty(fileName) || !(fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn") || fileName.toLowerCase().endsWith(".bar") || fileName.toLowerCase().endsWith(".zip"))) {
fileName = file.getName();
}
if (fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn")) {
deploymentBuilder.addInputStream(fileName, file.getInputStream());
} else if (fileName.toLowerCase().endsWith(".bar") || fileName.toLowerCase().endsWith(".zip")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(file.getInputStream()));
} else {
throw new ActivitiIllegalArgumentException("File must be of type .bpmn20.xml, .bpmn, .bar or .zip");
}
deploymentBuilder.name(fileName);
if (tenantId != null) {
deploymentBuilder.tenantId(tenantId);
}
Deployment deployment = deploymentBuilder.deploy();
response.setStatus(HttpStatus.CREATED.value());
return restResponseFactory.createDeploymentResponse(deployment);
} catch (Exception e) {
if (e instanceof ActivitiException) {
throw (ActivitiException) e;
}
throw new ActivitiException(e.getMessage(), e);
}
}
Aggregations