Ejemplo n.º 1
0
 /** Add attachment(s) for an issue */
 public void addAttachment() {
   if (this.attachmentNotAddList != null) {
     for (Attachment att : this.attachmentNotAddList) {
       att.setContainerId(this.issue.getIssueId());
       att.setTemp(false);
       if (this.projectId != null) {
         this.attachmentService.moveAttachmentFile(att, this.projectId);
       }
     }
     this.attachmentNotAddList = new ArrayList<Attachment>();
   }
 }
 private void saveAttachmentsToDatabase(UserStory us) {
   try {
     for (Attachment attachment : this.notAddedAttachmentList) {
       attachment.setContainerId(us.getUserStoryId());
       attachment.setTemp(false);
       this.attachmentService.moveAttachmentFile(attachment, us.getProject().getProjectId());
       this.attachmentService.save(attachment);
     }
   } catch (Exception e) {
     LOGGER.error("saveAttachmentsToDatabase " + e);
   }
 }
Ejemplo n.º 3
0
  /** Upload attachment file for issue */
  public void uploadFile() {
    String filename = JSFUtils.getRequestParameter("filename");
    String diskFileName =
        this.attachmentService.fileNameProcess(FilenameUtils.removeExtension(filename));
    diskFileName = this.attachmentService.replaceFile(filename, diskFileName);
    attachment = new Attachment();
    attachment.setFilename(filename);
    attachment.setDiskFilename(diskFileName);
    attachment.setContainerId(issue.getIssueId());
    attachment.setContainerType(Attachment.ISSUE_ATTACHMENT);
    // add files of Issue in user story for easy to handle.
    if (issue.getUserStory() != null) {
      attachment.setContainerId(issue.getUserStory().getUserStoryId());
      attachment.setContainerType(Attachment.USERSTORY_ATTACHMENT);
    }

    attachment.setTemp(false);
    attachment.setCreatedOn(new Date());
    attachment.setAuthor(utils.getLoggedInMember());
    attachmentService.save(attachment);
    Attachment newAttachment = attachmentService.findAttachmentById(attachment.getAttachmentId());

    if (attachmentNotAddList == null) {
      attachmentNotAddList = new ArrayList<Attachment>();
    }

    if (newAttachment.getContainerId() != null) {
      attachment.setTemp(false);
      attachmentService.moveAttachmentFile(attachment, projectId);
    } else {
      attachment.setTemp(true);
      attachmentNotAddList.add(newAttachment);
    }

    attachmentListByIssue = attachmentService.findAttachmentByIssue(issue);
    if (issue.getUserStory() != null) {
      attachmentListByIssue.addAll(
          attachmentService.findAttachmentByUserStory(issue.getUserStory()));
    }
  }