コード例 #1
0
  /**
   * 查看流程定义图
   *
   * @param request
   * @param processDefId 流程定义id
   * @return
   */
  @RequestMapping(value = "/viewprocessDefImage.do")
  public String viewprocessDefImage(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam("processDefId") String processDefId)
      throws Exception {
    // 根据流程定义id查询流程定义
    ProcessDefinition processDefinition =
        repositoryService
            .createProcessDefinitionQuery()
            .processDefinitionId(processDefId)
            .singleResult();

    InputStream inputStream =
        repositoryService.getResourceAsStream(
            processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName());

    //        // 输出资源内容到相应对象
    //        byte[] b = new byte[1024];
    //        int len;
    //        while ((len = inputStream.read(b, 0, 1024)) != -1) {
    //        	response.getOutputStream().write(b, 0, len);
    //        }

    response.getOutputStream().write(IoUtil.readInputStream(inputStream, "processDefInputStream"));

    return null;
  }