本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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());
}
示例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();
}
示例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;
}
示例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);
}
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}