Package org.activiti.engine.task

Examples of org.activiti.engine.task.Attachment


  }

  protected void saveAttachment() {
    try {
      // Creation and persistence of attachment is done in editor
      Attachment attachment = currentEditor.getAttachment();

      fireEvent(new SubmitEvent(this, SubmitEvent.SUBMITTED, attachment));

      // Finally, close window
      close();
View Full Code Here


   
    if(attachmentId == null) {
      throw new ActivitiException("No attachment id provided");
    }

    Attachment attachment = ActivitiUtil.getTaskService().getAttachment(attachmentId);
    if(attachment == null) {
      throw new ActivitiException("No attachment found for " + attachmentId);
    }
   
    String contentType = attachment.getType();
    MediaType mediatType = MediaType.IMAGE_PNG;
    if(contentType != null) {
      if(contentType.contains(";")) {
        contentType = contentType.substring(0, contentType.indexOf(";"));
      }
View Full Code Here

        }
      }
     
      String fileName = uploadItem.getName();
     
      Attachment attachment = ActivitiUtil.getTaskService().createAttachment(
          uploadItem.getContentType(), taskId, null, fileName, fileName, uploadItem.getInputStream());
     
      return new AttachmentResponse(attachment);
     
    } catch(Exception e) {
View Full Code Here

   
    if (attachmentRequest.getName() == null) {
      throw new ActivitiIllegalArgumentException("Attachment name is required.");
    }

    Attachment createdAttachment = taskService.createAttachment(attachmentRequest.getType(), task.getId(),
        task.getProcessInstanceId(), attachmentRequest.getName(), attachmentRequest.getDescription(), attachmentRequest.getExternalUrl());

    return restResponseFactory.createAttachmentResponse(createdAttachment, serverRootUrl);
  }
View Full Code Here

    if (file == null) {
      throw new ActivitiIllegalArgumentException("Attachment content is required.");
    }
   
    try {
      Attachment createdAttachment = taskService.createAttachment(type, task.getId(), task.getProcessInstanceId(), name,
              description, file.getInputStream());
     
      response.setStatus(HttpStatus.CREATED.value());
      return restResponseFactory.createAttachmentResponse(createdAttachment, serverRootUrl);
     
View Full Code Here

    try {
      Task task = taskService.newTask();
      taskService.saveTask(task);
     
      // Create URL-attachment
      Attachment urlAttachment = taskService.createAttachment("simpleType", task.getId(), null, "Simple attachment",
              "Simple attachment description", "http://activiti.org");
      taskService.saveAttachment(urlAttachment);
     
      // Create Binary-attachment
      Attachment binaryAttachment = taskService.createAttachment("binaryType", task.getId(), null, "Binary attachment",
              "Binary attachment description", new ByteArrayInputStream("This is binary content".getBytes()));
      taskService.saveAttachment(binaryAttachment);
     
      CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT_COLLECTION, task.getId())), HttpStatus.SC_OK);
View Full Code Here

    try {
      Task task = taskService.newTask();
      taskService.saveTask(task);

      // Create URL-attachment
      Attachment urlAttachment = taskService.createAttachment("simpleType", task.getId(), null, "Simple attachment", "Simple attachment description",
              "http://activiti.org");
      taskService.saveAttachment(urlAttachment);

      // Create Binary-attachment
      Attachment binaryAttachment = taskService.createAttachment("binaryType", task.getId(), null, "Binary attachment", "Binary attachment description",
              new ByteArrayInputStream("This is binary content".getBytes()));
      taskService.saveAttachment(binaryAttachment);

      // Get external url attachment
      CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT, task.getId(), urlAttachment.getId())), HttpStatus.SC_OK);
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertEquals(urlAttachment.getId(), responseNode.get("id").textValue());
      assertEquals("simpleType", responseNode.get("type").textValue());
      assertEquals("Simple attachment", responseNode.get("name").textValue());
      assertEquals("Simple attachment description", responseNode.get("description").textValue());
      assertEquals("http://activiti.org", responseNode.get("externalUrl").textValue());
      assertTrue(responseNode.get("url").textValue()
              .endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT, task.getId(), urlAttachment.getId())));
      assertTrue(responseNode.get("taskUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK, task.getId())));

      assertTrue(responseNode.get("contentUrl").isNull());
      assertTrue(responseNode.get("processInstanceUrl").isNull());
     
     
      // Get binary attachment
      response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT, task.getId(), binaryAttachment.getId())), HttpStatus.SC_OK);
      responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertEquals(binaryAttachment.getId(), responseNode.get("id").textValue());
      assertEquals("binaryType", responseNode.get("type").textValue());
      assertEquals("Binary attachment", responseNode.get("name").textValue());
      assertEquals("Binary attachment description", responseNode.get("description").textValue());
      assertTrue(responseNode.get("url").textValue()
              .endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT, task.getId(), binaryAttachment.getId())));
      assertTrue(responseNode.get("contentUrl").textValue()
              .endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT_DATA, task.getId(), binaryAttachment.getId())));
      assertTrue(responseNode.get("taskUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK, task.getId())));

      assertTrue(responseNode.get("externalUrl").isNull());
      assertTrue(responseNode.get("processInstanceUrl").isNull());
     
View Full Code Here

    try {
      Task task = taskService.newTask();
      taskService.saveTask(task);

      // Create URL-attachment
      Attachment urlAttachment = taskService.createAttachment("simpleType", task.getId(), null, "Simple attachment", "Simple attachment description",
              "http://activiti.org");
      taskService.saveAttachment(urlAttachment);

      // Get attachment for unexisting task
      closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT, "unexistingtask", urlAttachment.getId())), HttpStatus.SC_NOT_FOUND));
     
      // Get attachment for task attachment
      closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT, task.getId(), "unexistingattachment")), HttpStatus.SC_NOT_FOUND));
     
View Full Code Here

    try {
      Task task = taskService.newTask();
      taskService.saveTask(task);

      // Create Binary-attachment
      Attachment binaryAttachment = taskService.createAttachment("binaryType", task.getId(), null, "Binary attachment", "Binary attachment description",
              new ByteArrayInputStream("This is binary content".getBytes()));
      taskService.saveAttachment(binaryAttachment);

      // Get external url attachment
      CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT_DATA, task.getId(), binaryAttachment.getId())), HttpStatus.SC_OK);
     
      // Check response body
      String responseBodyString = IOUtils.toString(response.getEntity().getContent());
      assertEquals("This is binary content", responseBodyString);
     
View Full Code Here

    try {
      Task task = taskService.newTask();
      taskService.saveTask(task);

      // Create Binary-attachment
      Attachment binaryAttachment = taskService.createAttachment("application/xml", task.getId(), null, "Binary attachment", "Binary attachment description",
              new ByteArrayInputStream("<p>This is binary content</p>".getBytes()));
      taskService.saveAttachment(binaryAttachment);

      // Get external url attachment
      CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_ATTACHMENT_DATA, task.getId(), binaryAttachment.getId())), HttpStatus.SC_OK);
     
      // Check response headers
      assertEquals("application/xml", response.getEntity().getContentType().getValue());
      closeResponse(response);
   
View Full Code Here

TOP

Related Classes of org.activiti.engine.task.Attachment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.