Package org.activiti.engine.task

Examples of org.activiti.engine.task.Attachment


  public void deleteAttachment(@PathVariable("taskId") String taskId,
      @PathVariable("attachmentId") String attachmentId, HttpServletResponse response) {
   
    Task task = getTaskFromRequest(taskId);
   
    Attachment attachment = taskService.getAttachment(attachmentId);
    if (attachment == null || !task.getId().equals(attachment.getTaskId())) {
      throw new ActivitiObjectNotFoundException("Task '" + task.getId() +"' doesn't have an attachment with id '" + attachmentId + "'.", Comment.class);
    }
   
    taskService.deleteAttachment(attachmentId);
    response.setStatus(HttpStatus.NO_CONTENT.value());
View Full Code Here


      String taskId = task.getId();
      identityService.setAuthenticatedUserId("johndoe");
     
      // Fetch attachment and update its name
      taskService.createAttachment("web page", taskId, null, "weatherforcast", "temperatures and more", "http://weather.com");
      Attachment attachment = taskService.getTaskAttachments(taskId).get(0);
      attachment.setName("UpdatedName");
      taskService.saveAttachment(attachment);
     
      // Refetch and verify
      attachment = taskService.getTaskAttachments(taskId).get(0);
      assertEquals("UpdatedName", attachment.getName());
     
      // Finally, clean up
      taskService.deleteTask(taskId);
     
      assertEquals(0, taskService.getTaskComments(taskId).size());
View Full Code Here

     
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
     
      String processInstanceId = processInstance.getId();
      taskService.createAttachment("web page", null, processInstanceId, "weatherforcast", "temperatures and more", "http://weather.com");
      Attachment attachment = taskService.getProcessInstanceAttachments(processInstanceId).get(0);
      assertEquals("weatherforcast", attachment.getName());
      assertEquals("temperatures and more", attachment.getDescription());
      assertEquals("web page", attachment.getType());
      assertEquals(processInstanceId, attachment.getProcessInstanceId());
      assertNull(attachment.getTaskId());
      assertEquals("http://weather.com", attachment.getUrl());
      assertNull(taskService.getAttachmentContent(attachment.getId()));
     
      // Finally, clean up
      taskService.deleteAttachment(attachment.getId());
     
      // TODO: Bad API design. Need to fix attachment/comment properly
      ((TaskServiceImpl) taskService).deleteComments(null, processInstanceId);
    }
  }
View Full Code Here

  @RequestMapping(value="/runtime/tasks/{taskId}/attachments/{attachmentId}/content", method = RequestMethod.GET, produces="application/json")
  public @ResponseBody byte[] getAttachmentContent(@PathVariable("taskId") String taskId,
      @PathVariable("attachmentId") String attachmentId, HttpServletResponse response) {
   
    HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
    Attachment attachment = taskService.getAttachment(attachmentId);
   
    if (attachment == null || !task.getId().equals(attachment.getTaskId())) {
      throw new ActivitiObjectNotFoundException("Task '" + task.getId() +"' doesn't have an attachment with id '" + attachmentId + "'.", Attachment.class);
    }
   
    InputStream attachmentStream = taskService.getAttachmentContent(attachmentId);
    if (attachmentStream == null) {
      throw new ActivitiObjectNotFoundException("Attachment with id '" + attachmentId +
          "' doesn't have content associated with it.", Attachment.class);
    }
   
    MediaType mediaType = null;
    if (attachment.getType() != null) {
      try {
        mediaType = MediaType.valueOf(attachment.getType());
        response.setContentType(attachment.getType());
      } catch (Exception e) {
        // ignore if unknown media type
      }
    }
   
View Full Code Here

  }

  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

      taskService.saveTask(task);
      String taskId = task.getId();
      identityService.setAuthenticatedUserId("johndoe");
      // Fetch the task again and update
      taskService.createAttachment("web page", taskId, "someprocessinstanceid", "weatherforcast", "temperatures and more", "http://weather.com");
      Attachment attachment = taskService.getTaskAttachments(taskId).get(0);
      assertEquals("weatherforcast", attachment.getName());
      assertEquals("temperatures and more", attachment.getDescription());
      assertEquals("web page", attachment.getType());
      assertEquals(taskId, attachment.getTaskId());
      assertEquals("someprocessinstanceid", attachment.getProcessInstanceId());
      assertEquals("http://weather.com", attachment.getUrl());
      assertNull(taskService.getAttachmentContent(attachment.getId()));
     
      // Finally, clean up
      taskService.deleteTask(taskId);
     
      assertEquals(0, taskService.getTaskComments(taskId).size());
View Full Code Here

      String url = null;
      if(taskJSON.path("url") != null && taskJSON.path("url").getTextValue() != null) {
        url = taskJSON.path("url").getTextValue();
      }
     
      Attachment attachment = ActivitiUtil.getTaskService().createAttachment(
          "url", taskId, null, name, description, url);
     
      return new AttachmentResponse(attachment);
     
    } catch(Exception e) {
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.