private List<ChangeItemBean> convertTemporaryAttachments(final ApplicationUser user, final Issue issue, final List<Long> selectedAttachments, final TemporaryAttachmentsMonitor temporaryAttachmentsMonitor, final String attachScreenshotFileName) throws AttachmentException { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // NOTE: this method has been copied from attachment manager and changed to accept fileName specified in Screenshot Attachment Dialog ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// notNull("issue", issue); notNull("attachScreenshotFileName", attachScreenshotFileName); 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 = attachmentManager.createAttachment(tempAttachment.getFile(), attachScreenshotFileName, tempAttachment.getContentType(), user, issue, Collections.<String, Object>emptyMap(), UtilDateTime.nowTimestamp()); if (cib != null) { ret.add(cib); } } //finally clear any other remaining temp attachments for give form token temporaryAttachmentsMonitor.clearEntriesForFormToken(formToken); return ret; } }
private Either<AttachmentError, ChangeItemBean> transformTemporaryAttachment(final Long selectedAttachment, final TemporaryAttachmentsMonitor temporaryAttachmentsMonitor, @Nullable final ApplicationUser user, final Issue issue) { final TemporaryAttachment tempAttachment = temporaryAttachmentsMonitor.getById(selectedAttachment); if (tempAttachment == null) { final String errorMessage = getI18n(user).getText("attachfile.error.temp.file.not.exists"); return attachmentError( "Temporary attachment missing: " + selectedAttachment, errorMessage, "#" + selectedAttachment, VALIDATION_FAILED ); } else { return tryCreateAttachment(new CreateAttachmentParamsBean.Builder( tempAttachment.getFile(), tempAttachment.getFilename(), tempAttachment.getContentType(), user, issue).build()); } }