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


Java IoUtil类代码示例

本文整理汇总了Java中org.activiti.engine.impl.util.IoUtil的典型用法代码示例。如果您正苦于以下问题:Java IoUtil类的具体用法?Java IoUtil怎么用?Java IoUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IoUtil类属于org.activiti.engine.impl.util包,在下文中一共展示了IoUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProcessDiagramResource

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
@Deployment(resources = {
        "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.bpmn20.xml",
        "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg"
})
public void testProcessDiagramResource() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();

    assertEquals("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.bpmn20.xml", processDefinition.getResourceName());
    assertTrue(processDefinition.hasStartFormKey());

    String diagramResourceName = processDefinition.getDiagramResourceName();
    assertEquals("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg", diagramResourceName);

    InputStream diagramStream = repositoryService.getResourceAsStream(deploymentIdFromDeploymentAnnotation, "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg");
    byte[] diagramBytes = IoUtil.readInputStream(diagramStream, "diagram stream");
    assertEquals(33343, diagramBytes.length);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:18,代码来源:BpmnDeploymentTest.java

示例2: serialize

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
public byte[] serialize(Object value, ValueFields valueFields) {
    if (value == null) {
        return null;
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = null;
    try {
        oos = createObjectOutputStream(baos);
        oos.writeObject(value);
    } catch (Exception e) {
        throw new ActivitiException("Couldn't serialize value '" + value + "' in variable '" + valueFields.getName() + "'", e);
    } finally {
        IoUtil.closeSilently(oos);
    }
    return baos.toByteArray();
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:17,代码来源:SerializableType.java

示例3: addZipInputStream

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
@Override
public DeploymentBuilder addZipInputStream(ZipInputStream zipInputStream) {
    try {
        ZipEntry entry = zipInputStream.getNextEntry();
        while (entry != null) {
            if (!entry.isDirectory()) {
                String entryName = entry.getName();
                byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);
                ResourceEntity resource = new ResourceEntity();
                resource.setName(entryName);
                resource.setBytes(bytes);
                deployment.addResource(resource);
            }
            entry = zipInputStream.getNextEntry();
        }
    } catch (Exception e) {
        throw new ActivitiException("problem reading zip input stream", e);
    }
    return this;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:21,代码来源:DeploymentBuilderImpl.java

示例4: generateImage

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
/**
 * Generates an image of what currently is drawn on the canvas.
 * <p/>
 * Throws an {@link ActivitiException} when {@link #close()} is already
 * called.
 */
public InputStream generateImage(String imageType) {
    if (closed) {
        throw new ActivitiException("ProcessDiagramGenerator already closed");
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        // Try to remove white space
        minX = (minX <= 5) ? 5 : minX;
        minY = (minY <= 5) ? 5 : minY;
        BufferedImage imageToSerialize = processDiagram;
        if (minX >= 0 && minY >= 0) {
            imageToSerialize = processDiagram.getSubimage(minX - 5, minY - 5, canvasWidth - minX + 5, canvasHeight - minY + 5);
        }
        ImageIO.write(imageToSerialize, imageType, out);
    } catch (IOException e) {
        throw new ActivitiException("Error while generating process image", e);
    } finally {
        IoUtil.closeSilently(out);
    }
    return new ByteArrayInputStream(out.toByteArray());
}
 
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:29,代码来源:ProcessDiagramCanvas.java

示例5: serialize

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
public static byte[] serialize(Object value, ValueFields valueFields) {
  if(value == null) {
    return null;
  }
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ObjectOutputStream ois = null;
  try {
    ois = new ObjectOutputStream(baos);
    ois.writeObject(value);
  } catch (Exception e) {
    throw new ActivitiException("coudn't deserialize value '"+value+"' in variable '"+valueFields.getName()+"'", e);
  } finally {
    IoUtil.closeSilently(ois);
  }
  return baos.toByteArray();
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:17,代码来源:SerializableType.java

示例6: addZipInputStream

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
public DeploymentBuilder addZipInputStream(ZipInputStream zipInputStream) {
  try {
    ZipEntry entry = zipInputStream.getNextEntry();
    while (entry != null) {
      if (!entry.isDirectory()) {
        String entryName = entry.getName();
        byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);
        ResourceEntity resource = new ResourceEntity();
        resource.setName(entryName);
        resource.setBytes(bytes);
        deployment.addResource(resource);
      }
      entry = zipInputStream.getNextEntry();
    }
  } catch (Exception e) {
    throw new ActivitiException("problem reading zip input stream", e);
  }
  return this;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:20,代码来源:DeploymentBuilderImpl.java

示例7: executeSchemaResource

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
public void executeSchemaResource(String operation, String component, String resourceName, boolean isOptional) {
  InputStream inputStream = null;
  try {
    inputStream = ReflectUtil.getResourceAsStream(resourceName);
    if (inputStream == null) {
      if (isOptional) {
        log.fine("no schema resource "+resourceName+" for "+operation);
      } else {
        throw new ActivitiException("resource '" + resourceName + "' is not available");
      }
    } else {
      executeSchemaResource(operation, component, resourceName, inputStream);
    }

  } finally {
    IoUtil.closeSilently(inputStream);
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:19,代码来源:DbSqlSession.java

示例8: generateImage

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
/**
 * Generates an image of what currently is drawn on the canvas.
 * 
 * Throws an {@link ActivitiException} when {@link #close()} is already
 * called.
 */
public InputStream generateImage(String imageType) {
  if (closed) {
    throw new ActivitiException("ProcessDiagramGenerator already closed");
  }

  ByteArrayOutputStream out = new ByteArrayOutputStream();
  try {
    // Try to remove white space
    minX = (minX <= 5) ? 5 : minX;
    minY = (minY <= 5) ? 5 : minY;
    BufferedImage imageToSerialize = processDiagram;
    if (minX >= 0 && minY >= 0) {
      imageToSerialize = processDiagram.getSubimage(minX - 5, minY - 5, canvasWidth - minX + 5, canvasHeight - minY + 5);
    }
    ImageIO.write(imageToSerialize, imageType, out);
  } catch (IOException e) {
    throw new ActivitiException("Error while generating process image", e);
  } finally {
    IoUtil.closeSilently(out);
  }
  return new ByteArrayInputStream(out.toByteArray());
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:29,代码来源:ProcessDiagramCanvas.java

示例9: testProcessDiagramResource

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
@Deployment(resources={
  "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.bpmn20.xml",
  "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg"
})
public void testProcessDiagramResource() {
  ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
  
  assertEquals("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.bpmn20.xml", processDefinition.getResourceName());
  assertTrue(processDefinition.hasStartFormKey());

  String diagramResourceName = processDefinition.getDiagramResourceName();
  assertEquals("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg", diagramResourceName);
  
  InputStream diagramStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg");
  byte[] diagramBytes = IoUtil.readInputStream(diagramStream, "diagram stream");
  assertEquals(33343, diagramBytes.length);
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:18,代码来源:BpmnDeploymentTest.java

示例10: testVersionUpgradeShouldCancelJobs

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
@Deployment
public void testVersionUpgradeShouldCancelJobs() throws Exception {
  ClockUtil.setCurrentTime(new Date());

  // After process start, there should be timer created
  JobQuery jobQuery = managementService.createJobQuery();
  assertEquals(1, jobQuery.count());

  //we deploy new process version, with some small change
  String process = new String(IoUtil.readInputStream(getClass().getResourceAsStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml"), "")).replaceAll("beforeChange","changed");
  String id = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml",
      new ByteArrayInputStream(process.getBytes())).deploy().getId();

  assertEquals(1, jobQuery.count());

  moveByMinutes(5);

  //we check that correct version was started
  String pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").singleResult().getProcessInstanceId();
  assertEquals("changed", runtimeService.getActiveActivityIds(pi).get(0));
  assertEquals(1, jobQuery.count());

  cleanDB();
  repositoryService.deleteDeployment(id, true);
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:26,代码来源:StartTimerEventTest.java

示例11: viewprocessDef

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
/**
     * 查看流程定义
     * @param request
     * @param processDefId 流程定义id
     * @return
     */
    @RequestMapping(value = "/viewprocessDef.do")
    public String viewprocessDef(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.getResourceName());
        
//        // 输出资源内容到相应对象
//        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;
    }
 
开发者ID:ameizi,项目名称:activiti-demo,代码行数:27,代码来源:SimpleFlowWorkController.java

示例12: viewprocessDefImage

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
/**
     * 查看流程定义图
     * @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;
    }
 
开发者ID:ameizi,项目名称:activiti-demo,代码行数:27,代码来源:SimpleFlowWorkController.java

示例13: serialize

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
public static byte[] serialize(Object value, ValueFields valueFields) {
  if (value == null) {
    return null;
  }
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ObjectOutputStream oos = null;
  try {
    oos = createObjectOutputStream(baos);
    oos.writeObject(value);
  } catch (Exception e) {
    throw new ActivitiException("Couldn't serialize value '"+value+"' in variable '"+valueFields.getName()+"'", e);
  } finally {
    IoUtil.closeSilently(oos);
  }
  return baos.toByteArray();
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:17,代码来源:SerializableType.java

示例14: executeSchemaResource

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
public void executeSchemaResource(String operation, String component, String resourceName, boolean isOptional) {
  InputStream inputStream = null;
  try {
    inputStream = ReflectUtil.getResourceAsStream(resourceName);
    if (inputStream == null) {
      if (isOptional) {
        log.debug("no schema resource {} for {}", resourceName, operation);
      } else {
        throw new ActivitiException("resource '" + resourceName + "' is not available");
      }
    } else {
      executeSchemaResource(operation, component, resourceName, inputStream);
    }

  } finally {
    IoUtil.closeSilently(inputStream);
  }
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:19,代码来源:DbSqlSession.java

示例15: execute

import org.activiti.engine.impl.util.IoUtil; //导入依赖的package包/类
public Attachment execute(CommandContext commandContext) {

    verifyParameters(commandContext);
    
    AttachmentEntity attachment = new AttachmentEntity();
    attachment.setName(attachmentName);
    attachment.setDescription(attachmentDescription);
    attachment.setType(attachmentType);
    attachment.setTaskId(taskId);
    attachment.setProcessInstanceId(processInstanceId);
    attachment.setUrl(url);
    
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
    dbSqlSession.insert(attachment);
    
    if (content != null) {
      byte[] bytes = IoUtil.readInputStream(content, attachmentName);
      ByteArrayEntity byteArray = ByteArrayEntity.createAndInsert(bytes);
      attachment.setContentId(byteArray.getId());
    }

    commandContext.getHistoryManager()
      .createAttachmentComment(taskId, processInstanceId, attachmentName, true);
    
    return attachment;
  }
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:27,代码来源:CreateAttachmentCmd.java


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