本文整理汇总了Java中org.activiti.engine.impl.util.IoUtil.readInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java IoUtil.readInputStream方法的具体用法?Java IoUtil.readInputStream怎么用?Java IoUtil.readInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.impl.util.IoUtil
的用法示例。
在下文中一共展示了IoUtil.readInputStream方法的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: 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;
}
示例3: 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;
}
示例4: 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);
}
示例5: 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;
}
示例6: testTimerShouldNotBeRemovedWhenUndeployingOldVersion
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public void testTimerShouldNotBeRemovedWhenUndeployingOldVersion() throws Exception {
// Deploy test process
String processXml = new String(IoUtil.readInputStream(getClass().getResourceAsStream("StartTimerEventTest.testTimerShouldNotBeRemovedWhenUndeployingOldVersion.bpmn20.xml"), ""));
String firstDeploymentId = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml",
new ByteArrayInputStream(processXml.getBytes()))
.deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE)
.deploy()
.getId();
// After process start, there should be timer created
TimerJobQuery jobQuery = managementService.createTimerJobQuery();
assertEquals(1, jobQuery.count());
// we deploy new process version, with some small change
String processChanged = processXml.replaceAll("beforeChange", "changed");
String secondDeploymentId = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml",
new ByteArrayInputStream(processChanged.getBytes()))
.deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE)
.deploy()
.getId();
assertEquals(1, jobQuery.count());
// Remove the first deployment
repositoryService.deleteDeployment(firstDeploymentId, true);
// The removal of an old version should not affect timer deletion
// ACT-1533: this was a bug, and the timer was deleted!
assertEquals(1, jobQuery.count());
// Cleanup
cleanDB();
repositoryService.deleteDeployment(secondDeploymentId, true);
}
示例7: addInputStream
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
@Override
public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {
if (inputStream == null) {
throw new ActivitiIllegalArgumentException("inputStream for resource '" + resourceName + "' is null");
}
byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);
ResourceEntity resource = new ResourceEntity();
resource.setName(resourceName);
resource.setBytes(bytes);
deployment.addResource(resource);
return this;
}
示例8: createUser
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
protected void createUser(String userId, String firstName, String lastName, String password,
String email, String imageResource, List<String> groups, List<String> userInfo) {
if (identityService.createUserQuery().userId(userId).count() == 0) {
// Following data can already be set by demo setup script
User user = identityService.newUser(userId);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setPassword(password);
user.setEmail(email);
identityService.saveUser(user);
if (groups != null) {
for (String group : groups) {
identityService.createMembership(userId, group);
}
}
}
// Following data is not set by demo setup script
// image
if (imageResource != null) {
byte[] pictureBytes = IoUtil.readInputStream(this.getClass().getClassLoader().getResourceAsStream(imageResource), null);
Picture picture = new Picture(pictureBytes, "image/jpeg");
identityService.setUserPicture(userId, picture);
}
// user info
if (userInfo != null) {
for(int i=0; i<userInfo.size(); i+=2) {
identityService.setUserInfo(userId, userInfo.get(i), userInfo.get(i+1));
}
}
}
示例9: processContentPart
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
protected void processContentPart(int indent, Part part) throws Exception {
if (part.getContent() instanceof MimeMultipart) {
log(indent, "--- multipart "+getMimeType(part)+" ----------------------------------");
MimeMultipart mimeMultipart = (MimeMultipart) part.getContent();
for (int i=0; i<mimeMultipart.getCount(); i++) {
BodyPart bodyPart = mimeMultipart.getBodyPart(i);
processContentPart(indent+1, bodyPart);
}
} else {
log(indent, "--- part "+getMimeType(part)+" ----------------------------------");
if (part.isMimeType("text/plain")) {
String contentText = (String) part.getContent();
log(indent, "adding plain text: "+contentText);
messageText.append(contentText);
} else if (part.isMimeType("text/html")){
String rawHtml = (String) part.getContent();
log(indent, "raw html: "+rawHtml);
String cleanedUpHtml = htmlExtractBodyContent(rawHtml);
log(indent, "adding cleaned up html: "+cleanedUpHtml);
containsHtml = true;
messageHtml.append(cleanedUpHtml);
} else {
String fileName = part.getFileName();
log(indent, "unknown content part | "+part.getContentType()+" | "+part.getDisposition()+" | "+Arrays.toString(part.getHeader("Content-ID"))+" | "+fileName+" | "+part.getContent().getClass().getName());
if (part.getSize()!=-1 && part.getSize()<ATTACHMENT_SIZE_LIMIT && (part.getContent() instanceof InputStream)) {
String attachmentName = null;
String attachmentType = null;
String[] contentIdArray = part.getHeader("Content-ID");
if (contentIdArray!=null && contentIdArray.length>0) {
attachmentName = contentIdArray[0].trim();
if (attachmentName.startsWith("<") && attachmentName.endsWith(">")) {
attachmentName = attachmentName.substring(1, attachmentName.length()-2).trim();
}
attachmentType = getImageMimeType(attachmentName);
} else if (Part.INLINE.equalsIgnoreCase(part.getDisposition())) {
attachmentName = fileName;
attachmentType = getImageMimeType(attachmentName);
messageText.append("<img id=\"cid:"+fileName+"\" src=\"cid:"+fileName+"\" />");
messageHtml.append("<img id=\"cid:"+fileName+"\" src=\"cid:"+fileName+"\" />");
}
if (attachmentName==null) {
attachmentName = fileName;
attachmentType = "email-attachment";
}
AttachmentEntity attachment = new AttachmentEntity();
attachment.setName(attachmentName);
attachment.setType(attachmentType);
attachments.add(attachment);
byte[] bytes = IoUtil.readInputStream((InputStream)part.getContent(), "mail attachment "+attachmentName);
attachment.setContent(new ByteArrayEntity(bytes));
}
}
}
}
示例10: addInputStream
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {
if (inputStream==null) {
throw new ActivitiException("inputStream for resource '"+resourceName+"' is null");
}
byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);
ResourceEntity resource = new ResourceEntity();
resource.setName(resourceName);
resource.setBytes(bytes);
deployment.addResource(resource);
return this;
}
示例11: execute
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public Attachment execute(CommandContext 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 = new ByteArrayEntity(bytes);
dbSqlSession.insert(byteArray);
attachment.setContentId(byteArray.getId());
}
CommentManager commentManager = commandContext.getCommentManager();
if (commentManager.isHistoryEnabled()) {
String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
comment.setUserId(userId);
comment.setType(CommentEntity.TYPE_EVENT);
comment.setTime(ClockUtil.getCurrentTime());
comment.setTaskId(taskId);
comment.setProcessInstanceId(processInstanceId);
comment.setAction(Event.ACTION_ADD_ATTACHMENT);
comment.setMessage(attachmentName);
commentManager.insert(comment);
}
return attachment;
}
示例12: createUser
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
protected void createUser(String userId, String firstName, String lastName, String password,
String email, String imageResource, List<String> groups, List<String> userInfo) {
if (identityService.createUserQuery().userId(userId).count() == 0) {
// Following data can already be set by demo setup script
User user = identityService.newUser(userId);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setPassword(password);
user.setEmail(email);
identityService.saveUser(user);
if (groups != null) {
for (String group : groups) {
identityService.createMembership(userId, group);
}
}
}
// Following data is not set by demo setup script
// image
if (imageResource != null) {
byte[] pictureBytes = IoUtil.readInputStream(this.getClass().getClassLoader().getResourceAsStream(imageResource), null);
Picture picture = new Picture(pictureBytes, "image/jpeg");
identityService.setUserPicture(userId, picture);
}
// user info
if (userInfo != null) {
for (int i = 0; i < userInfo.size(); i += 2) {
identityService.setUserInfo(userId, userInfo.get(i), userInfo.get(i + 1));
}
}
}
示例13: addInputStream
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {
if (inputStream==null) {
throw new ActivitiIllegalArgumentException("inputStream for resource '"+resourceName+"' is null");
}
byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);
ResourceEntity resource = new ResourceEntity();
resource.setName(resourceName);
resource.setBytes(bytes);
deployment.addResource(resource);
return this;
}
示例14: testTimerShouldNotBeRemovedWhenUndeployingOldVersion
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public void testTimerShouldNotBeRemovedWhenUndeployingOldVersion() throws Exception {
// Deploy test process
String process = new String(IoUtil.readInputStream(getClass().getResourceAsStream("StartTimerEventTest.testTimerShouldNotBeRemovedWhenUndeployingOldVersion.bpmn20.xml"), ""));
String firstDeploymentId = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml",
new ByteArrayInputStream(process.getBytes())).deploy().getId();
// 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 processChanged = process.replaceAll("beforeChange","changed");
String secondDeploymentId = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml",
new ByteArrayInputStream(processChanged.getBytes())).deploy().getId();
assertEquals(1, jobQuery.count());
// Remove the first deployment
repositoryService.deleteDeployment(firstDeploymentId, true);
// The removal of an old version should not affect timer deletion
// ACT-1533: this was a bug, and the timer was deleted!
assertEquals(1, jobQuery.count());
// Cleanup
cleanDB();
repositoryService.deleteDeployment(secondDeploymentId, true);
}
示例15: readInputStreamToString
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
private String readInputStreamToString(InputStream inputStream) {
byte[] bytes = IoUtil.readInputStream(inputStream, "input stream");
return new String(bytes);
}