/** * When this object is unbount from the HttpSession, it's responsible for cleanup. Any temporary * attachments not converted to real attachments by now should be deleted to save disk space! * * @param httpSessionBindingEvent */ public void valueUnbound(final HttpSessionBindingEvent httpSessionBindingEvent) { // delete any temporary attachments left over. for (TemporaryAttachment temporaryAttachment : temporaryAttachments.values()) { temporaryAttachment.getFile().delete(); } temporaryAttachments.clear(); }
/** * Removes all temporary attachments for the given issue. The issueId may be null to indicate a * newly created issue, that doesn't have an id yet. * * @param issueId The id of the issue to remove entries for. May be null. */ public void clearEntriesForIssue(final Long issueId) { final Collection<TemporaryAttachment> attachmentsForIssueId = getByIssueId(issueId); for (TemporaryAttachment temporaryAttachment : attachmentsForIssueId) { temporaryAttachment.getFile().delete(); temporaryAttachments.remove(temporaryAttachment.getId()); } }
@Override public List<ChangeItemBean> convertTemporaryAttachments( final User user, final Issue issue, final List<Long> selectedAttachments, final TemporaryAttachmentsMonitor temporaryAttachmentsMonitor) throws AttachmentException { notNull("issue", issue); notNull("selectedAttachments", selectedAttachments); notNull("temporaryAttachmentsMonitor", temporaryAttachmentsMonitor); final List<ChangeItemBean> ret = new ArrayList<ChangeItemBean>(); for (final Long selectedAttachment : selectedAttachments) { final TemporaryAttachment tempAttachment = temporaryAttachmentsMonitor.getById(selectedAttachment); final ChangeItemBean cib = createAttachment( tempAttachment.getFile(), tempAttachment.getFilename(), tempAttachment.getContentType(), user, issue, Collections.<String, Object>emptyMap(), UtilDateTime.nowTimestamp()); if (cib != null) { ret.add(cib); } } return ret; }
/** * Adds temporary attachments to the interally maintained list of temporary attachements * * @param temporaryAttachment the attachment to add */ public void add(final TemporaryAttachment temporaryAttachment) { temporaryAttachments.put(temporaryAttachment.getId(), temporaryAttachment); }