当前位置: 首页>>代码示例>>Java>>正文


Java RepositoryService.getResourceAsStream方法代码示例

本文整理汇总了Java中org.activiti.engine.RepositoryService.getResourceAsStream方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryService.getResourceAsStream方法的具体用法?Java RepositoryService.getResourceAsStream怎么用?Java RepositoryService.getResourceAsStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.activiti.engine.RepositoryService的用法示例。


在下文中一共展示了RepositoryService.getResourceAsStream方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: viewXml

import org.activiti.engine.RepositoryService; //导入方法依赖的package包/类
/**
 * 显示流程定义的xml.
 */
@RequestMapping("console-viewXml")
public void viewXml(
        @RequestParam("processDefinitionId") String processDefinitionId,
        HttpServletResponse response) throws Exception {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    ProcessDefinition processDefinition = repositoryService
            .createProcessDefinitionQuery()
            .processDefinitionId(processDefinitionId).singleResult();
    String resourceName = processDefinition.getResourceName();
    InputStream resourceAsStream = repositoryService.getResourceAsStream(
            processDefinition.getDeploymentId(), resourceName);
    response.setContentType("text/xml;charset=UTF-8");
    IOUtils.copy(resourceAsStream, response.getOutputStream());
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:19,代码来源:ConsoleController.java

示例2: getImage

import org.activiti.engine.RepositoryService; //导入方法依赖的package包/类
@Test
public void getImage() throws IOException {
    ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
    logger.info("### ============= 创建Activiti流程引擎实例, {}", processEngine);

    RepositoryService repositoryService = processEngine.getRepositoryService();

    //通过流程ID(XML上写的)找到流程
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId("请假流程:2:10004")
            .singleResult();
    String diagramResourceName = processDefinition.getDiagramResourceName();
    logger.info(diagramResourceName);
    InputStream imageStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), diagramResourceName);

    FileUtils.writeByteArrayToFile(new File("F:\\123456.png"),IOUtils.toByteArray(imageStream));
    imageStream.close();

    processEngine.close();
}
 
开发者ID:Lzw2016,项目名称:study,代码行数:21,代码来源:Test01.java

示例3: getProcessDiagram

import org.activiti.engine.RepositoryService; //导入方法依赖的package包/类
public String getProcessDiagram(String processId) throws BPSFault {
        Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        try {
            RepositoryService repositoryService = BPMNServerHolder.getInstance().getEngine().getRepositoryService();
            ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionTenantId(tenantId.toString())
                    .processDefinitionId(processId)
                    .singleResult();
            String diagramResourceName = processDefinition.getDiagramResourceName();
            InputStream imageStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), diagramResourceName);
            BufferedImage bufferedImage = ImageIO.read(imageStream);
            return encodeToString(bufferedImage, "png");
        }
        catch (IOException e) {
            String msg = "Failed to create the diagram for process: " + processId;
//            log.error(msg, e);
            throw new BPSFault(msg, e);
        }
    }
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:19,代码来源:BPMNDeploymentService.java

示例4: readXml

import org.activiti.engine.RepositoryService; //导入方法依赖的package包/类
public String readXml(String processDefinitionId) throws Exception {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    ProcessDefinition processDefinition = repositoryService
            .createProcessDefinitionQuery()
            .processDefinitionId(processDefinitionId).singleResult();
    String resourceName = processDefinition.getResourceName();
    InputStream resourceAsStream = repositoryService.getResourceAsStream(
            processDefinition.getDeploymentId(), resourceName);

    return IOUtils.toString(resourceAsStream, "UTF-8");
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:13,代码来源:BpmProcessController.java

示例5: exportDiagramToFile

import org.activiti.engine.RepositoryService; //导入方法依赖的package包/类
/**
 * 导出图片文件到硬盘
 *
 * @return 文件的全路径
 */
public static String exportDiagramToFile(RepositoryService repositoryService, ProcessDefinition processDefinition, String exportDir) throws IOException {
    String diagramResourceName = processDefinition.getDiagramResourceName();
    String key = processDefinition.getKey();
    int version = processDefinition.getVersion();
    String diagramPath = "";

    InputStream resourceAsStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), diagramResourceName);
    byte[] b = new byte[resourceAsStream.available()];

    @SuppressWarnings("unused")
    int len = -1;
    resourceAsStream.read(b, 0, b.length);

    // create file if not exist
    String diagramDir = exportDir + "/" + key + "/" + version;
    File diagramDirFile = new File(diagramDir);
    if (!diagramDirFile.exists()) {
        diagramDirFile.mkdirs();
    }
    diagramPath = diagramDir + "/" + diagramResourceName;
    File file = new File(diagramPath);

    // 文件存在退出
    if (file.exists()) {
        // 文件大小相同时直接返回否则重新创建文件(可能损坏)
        logger.debug("diagram exist, ignore... : {}", diagramPath);
        return diagramPath;
    } else {
        file.createNewFile();
    }

    logger.debug("export diagram to : {}", diagramPath);

    // wirte bytes to file
    FileUtils.writeByteArrayToFile(file, b, true);
    return diagramPath;
}
 
开发者ID:batizhao,项目名称:microservice,代码行数:43,代码来源:WorkflowUtils.java

示例6: queryFlowImage

import org.activiti.engine.RepositoryService; //导入方法依赖的package包/类
@Test
public void queryFlowImage() throws Exception {
	
	String deploymentId = "10001";
	RepositoryService repositoryService = (RepositoryService) AppContext.getBean("repositoryService");
	List<String> names = repositoryService.getDeploymentResourceNames(deploymentId);
	for (String name : names) {
		System.out.println( name );
		if (name.endsWith(".png") || name.endsWith(".bmp")) {
			InputStream is = repositoryService.getResourceAsStream(deploymentId, name);
			FileUtils.copyInputStreamToFile(is, new File("/tmp/" + name));
		}
	}
	
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:16,代码来源:TestBPMN001.java

示例7: getDeploymentResourceData

import org.activiti.engine.RepositoryService; //导入方法依赖的package包/类
private byte[] getDeploymentResourceData(String deploymentId, String resourceId, RepositoryService
        repositoryService) {

    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);

        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);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:32,代码来源:ProcessDefinitionService.java

示例8: getDeploymentResourceData

import org.activiti.engine.RepositoryService; //导入方法依赖的package包/类
private byte[] getDeploymentResourceData(String deploymentId, String resourceId) {

        if (deploymentId == null) {
            throw new ActivitiIllegalArgumentException("No deployment id provided");
        }
        if (resourceId == null) {
            throw new ActivitiIllegalArgumentException("No resource id provided");
        }

        RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
        // 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);
            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);
        }
    }
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:31,代码来源:DeploymentService.java


注:本文中的org.activiti.engine.RepositoryService.getResourceAsStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。