private void syncNewFiles(List<SubAwardAttachments> attachments) { assert attachments != null : "the attachments was null"; for (SubAwardAttachments attachment : attachments) { if (SubAwardAttachmentFormBean.doesNewFileExist(attachment)) { final AttachmentFile newFile = AttachmentFile.createFromFormFile(attachment.getNewFile()); // setting the sequence number to the old file sequence number if (attachment.getFile() != null) { newFile.setSequenceNumber(attachment.getFile().getSequenceNumber()); } attachment.setFile(newFile); } } }
/** * Checks if a new file exists on an attachment * * @param attachment the attachment * @return true if new false if not */ private static boolean doesNewFileExist(SubAwardAttachments attachment) { return attachment.getNewFile() != null && StringUtils.isNotBlank(attachment.getNewFile().getFileName()); }