本文整理汇总了Java中org.activiti.engine.repository.DeploymentBuilder.addInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java DeploymentBuilder.addInputStream方法的具体用法?Java DeploymentBuilder.addInputStream怎么用?Java DeploymentBuilder.addInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.repository.DeploymentBuilder
的用法示例。
在下文中一共展示了DeploymentBuilder.addInputStream方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deployProcessDefinition
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
protected String deployProcessDefinition(String... artifacts) {
DeploymentBuilder deploymentBuilder = activitiProcessEngine.getRepositoryService().createDeployment();
boolean firstArtifact = true;
for (String artifact : artifacts)
{
InputStream bpmnInputStream = getClass().getClassLoader().getResourceAsStream(artifact);
String name = artifact.substring(artifact.lastIndexOf("/") + 1);
if (firstArtifact)
{
deploymentBuilder.name(name);
}
deploymentBuilder.addInputStream(name, bpmnInputStream);
}
String deploymentId = deploymentBuilder.deploy().getId();
return deploymentId;
}
示例2: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* 部署流程资源
* 加载ZIP文件中的流程
*/
@PostMapping(value = "/deploy")
public ResponseMessage<Object> deploy(@RequestParam(value = "file") MultipartFile file) throws IOException {
// 获取上传的文件名
String fileName = file.getOriginalFilename();
// 得到输入流(字节流)对象
InputStream fileInputStream = file.getInputStream();
// 文件的扩展名
String extension = FilenameUtils.getExtension(fileName);
// zip或者bar类型的文件用ZipInputStream方式部署
DeploymentBuilder deployment = repositoryService.createDeployment();
if ("zip".equals(extension) || "bar".equals(extension)) {
ZipInputStream zip = new ZipInputStream(fileInputStream);
deployment.addZipInputStream(zip);
} else {
// 其他类型的文件直接部署
deployment.addInputStream(fileName, fileInputStream);
}
deployment.deploy();
return ResponseMessage.ok();
}
示例3: deployResources
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {
// Create a separate deployment for each resource using the resource
// name
for (final Resource resource : resources) {
final String resourceName = determineResourceName(resource);
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(resourceName);
try {
if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
} else {
deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
}
} catch (IOException e) {
throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
}
deploymentBuilder.deploy();
}
}
示例4: deployResources
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {
// Create a single deployment for all resources using the name hint as
// the literal name
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentNameHint);
for (final Resource resource : resources) {
final String resourceName = determineResourceName(resource);
try {
if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
} else {
deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
}
} catch (IOException e) {
throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
}
}
deploymentBuilder.deploy();
}
示例5: deployResources
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {
// Create a deployment for each distinct parent folder using the name
// hint
// as a prefix
final Map<String, Set<Resource>> resourcesMap = createMap(resources);
for (final Entry<String, Set<Resource>> group : resourcesMap.entrySet()) {
final String deploymentName = determineDeploymentName(deploymentNameHint, group.getKey());
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentName);
for (final Resource resource : group.getValue()) {
final String resourceName = determineResourceName(resource);
try {
if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
} else {
deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
}
} catch (IOException e) {
throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
}
}
deploymentBuilder.deploy();
}
}
示例6: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* 部署流程资源
*/
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {
// 获取上传的文件名
String fileName = file.getOriginalFilename();
try {
// 得到输入流(字节流)对象
InputStream fileInputStream = file.getInputStream();
// 文件的扩展名
String extension = FilenameUtils.getExtension(fileName);
// zip或者bar类型的文件用ZipInputStream方式部署
DeploymentBuilder deployment = repositoryService.createDeployment();
if (extension.equals("zip") || extension.equals("bar")) {
ZipInputStream zip = new ZipInputStream(fileInputStream);
deployment.addZipInputStream(zip);
} else {
// 其他类型的文件直接部署
deployment.addInputStream(fileName, fileInputStream);
}
deployment.deploy();
} catch (Exception e) {
logger.error("error on deploy process, because of file input stream");
}
return "redirect:process-list";
}
示例7: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* 部署流程资源
*/
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {
// 获取上传的文件名
String fileName = file.getOriginalFilename();
try {
// 得到输入流(字节流)对象
InputStream fileInputStream = file.getInputStream();
// 文件的扩展名
String extension = FilenameUtils.getExtension(fileName);
// zip或者bar类型的文件用ZipInputStream方式部署
DeploymentBuilder deployment = repositoryService.createDeployment();
if (extension.equals("zip") || extension.equals("bar")) {
ZipInputStream zip = new ZipInputStream(fileInputStream);
deployment.addZipInputStream(zip);
} else {
// 其他类型的文件直接部署
deployment.addInputStream(fileName, fileInputStream);
}
deployment.deploy();
} catch (Exception e) {
logger.error("error on deploy process, because of file input stream");
}
return "redirect:processes";
}
示例8: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* 发布模型为流程定义
*
* @param id
* @return
* @throws Exception
*/
@RequestMapping(value = "/model/deploy/{id}", method = RequestMethod.POST)
@ResponseBody
public Result deploy(@PathVariable("id") String id, HttpServletRequest request) throws Exception {
//获取模型
Model modelData = repositoryService.getModel(id);
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
if (bytes == null) {
return new Result(false, id, "模型数据为空,请先设计流程并成功保存,再进行发布。");
}
JsonNode modelNode = objectMapper.readTree(bytes);
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
if (model.getProcesses().size() == 0) {
return new Result(false, id, "数据模型不符要求,请至少设计一条主线流程。");
}
try {
//----------------生成zip文件-------------------------
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
Result xml = generateResource("xml", id, request);
Result image = generateResource("image", id, request);
if (xml.getData() == null || image.getData() == null) {
return new Result(false, "部署失败", "流程尚未定义或定义错误,不能生成有效的xml和png文件");
}
String basePath = request.getRealPath("/");
String fileName = modelData.getKey() + ".bpmn20.model.zip";
String zipFileName = DIR_PATH + File.separator + fileName;
File file = new File(basePath + File.separator + zipFileName);
if (file.exists()) {
file.delete();
}
String zipPath = FileUtil.generateZipFile(basePath, zipFileName, xml.getData().toString(),
image.getData().toString());
InputStream inputStream = new FileInputStream(zipPath);
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
//---------------------------------------------------
//发布流程
String processName = modelData.getKey() + ".bpmn20.xml";
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment()
.name(modelData.getName())
.category(modelData.getCategory())
.tenantId(modelData.getTenantId())
//使用addZipInputStream后可以预防flow连线文字丢失的问题
.addZipInputStream(zipInputStream);
//.addString(processName, new String(bpmnBytes, "UTF-8"))
List<JsonNode> forms=modelNode.findValues("formkeydefinition");
for (JsonNode form : forms) {
String formName=form.textValue();
if(!StrUtil.isEmpty(formName)){
InputStream stream=this.getClass().getClassLoader().getResourceAsStream(formName);
deploymentBuilder.addInputStream(formName,stream);
}
}
Deployment deployment=deploymentBuilder.deploy();
//更新流程定义类别,替换掉页面的定义
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId
(deployment.getId()).singleResult();
if (processDefinition != null)
repositoryService.setProcessDefinitionCategory(processDefinition.getId(), deployment.getCategory());
modelData.setDeploymentId(deployment.getId());
repositoryService.saveModel(modelData);
return new Result(true);
} catch (Exception ex) {
return new Result(false, "部署失败", ex.getMessage().toString());
}
}
示例9: checkBundle
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
private void checkBundle(Bundle bundle) {
LOGGER.log(Level.FINE, "Scanning bundle {} for activiti process", bundle.getSymbolicName());
try {
List<URL> pathList = new ArrayList<URL>();
String activitiHeader = (String) bundle.getHeaders().get(BUNDLE_ACTIVITI_HEADER);
if (activitiHeader == null) {
activitiHeader = "OSGI-INF/activiti/";
}
List<PathElement> paths = HeaderParser.parseHeader(activitiHeader);
for (PathElement path : paths) {
String name = path.getName();
if (name.endsWith("/")) {
addEntries(bundle, name, "*.*", pathList);
} else {
String baseName;
String filePattern;
int pos = name.lastIndexOf('/');
if (pos < 0) {
baseName = "/";
filePattern = name;
} else {
baseName = name.substring(0, pos + 1);
filePattern = name.substring(pos + 1);
}
if (hasWildcards(filePattern)) {
addEntries(bundle, baseName, filePattern, pathList);
} else {
addEntry(bundle, name, pathList);
}
}
}
if (!pathList.isEmpty()) {
LOGGER.log(Level.FINE, "Found activiti process in bundle " + bundle.getSymbolicName()
+ " with paths: " + pathList);
ProcessEngine engine = (ProcessEngine) engineServiceTracker.waitForService(timeout);
if (engine == null) {
throw new IllegalStateException("Unable to find a ProcessEngine service");
}
RepositoryService service = engine.getRepositoryService();
DeploymentBuilder builder = service.createDeployment();
builder.name(bundle.getSymbolicName());
for (URL url : pathList) {
InputStream is = url.openStream();
if (is == null) {
throw new IOException("Error opening url: " + url);
}
try {
builder.addInputStream(getPath(url), is);
} finally {
is.close();
}
}
builder.enableDuplicateFiltering();
builder.deploy();
} else {
LOGGER.log(Level.FINE, "No activiti process found in bundle {}", bundle.getSymbolicName());
}
} catch (Throwable t) {
LOGGER.log(Level.SEVERE, "Unable to deploy activiti bundle", t);
}
}
示例10: uploadDeployment
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Post
public void uploadDeployment(Representation entity) {
try {
if(authenticate(SecuredResource.ADMIN) == false) return;
RestletFileUpload upload = new RestletFileUpload(new DiskFileItemFactory());
List<FileItem> items = upload.parseRepresentation(entity);
FileItem uploadItem = null;
String successMethod = null;
for (FileItem fileItem : items) {
if(fileItem.getName() != null) {
uploadItem = fileItem;
} else if(fileItem.getFieldName().equals("success")){
successMethod = fileItem.getString();
}
}
DeploymentBuilder deploymentBuilder = ActivitiUtil.getRepositoryService().createDeployment();
String fileName = uploadItem.getName();
if (fileName.endsWith(".bpmn20.xml")) {
deploymentBuilder.addInputStream(fileName, uploadItem.getInputStream());
} else if (fileName.endsWith(".bar") || fileName.endsWith(".zip")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(uploadItem.getInputStream()));
} else {
throw new ActivitiException("File must be of type .bpmn20.xml, .bar or .zip");
}
deploymentBuilder.name(fileName);
deploymentBuilder.deploy();
StringBuilder html = new StringBuilder();
html.append("<html>\n");
html.append(" <script type=\"text/javascript\">\n");
html.append(" " + successMethod + "()\n");
html.append(" </script>\n");
html.append("</html>\n");
getResponse().setEntity(html.toString(), MediaType.TEXT_HTML);
} catch (Exception e) {
throw new ActivitiException(e.getMessage(), e);
}
}