public static Attachment deleteAttachmentByCode(TextConfiguration textConfiguration, String code) { Attachment attachment = findAttachmentById(textConfiguration, code); if (attachment == null) { return null; } else { textConfiguration.getAttachments().remove(attachment); return attachment; } } }
public static Attachment findAttachmentById( TextConfiguration textConfiguration, String code) { for (Attachment current : textConfiguration.getAttachments()) { if (current.getId().equals(code)) { return current; } } return null; }
public static Attachment deleteAttachmentByCode(TextConfiguration textConfiguration, String code) { Attachment attachment = findAttachmentById(textConfiguration, code); if (attachment == null) { return null; } else { textConfiguration.getAttachments().remove(attachment); return attachment; } } }
public static Attachment findAttachmentById( TextConfiguration textConfiguration, String code) { for (Attachment current : textConfiguration.getAttachments()) { if (current.getId().equals(code)) { return current; } } return null; }
public List<Attachment> getDownloadableAttachments() { List<Attachment> downloadableAttachments = new ArrayList<Attachment>(); for(Attachment attachment : getTextConfiguration().getAttachments()) { if(attachment.isDownloadable()) { downloadableAttachments.add(attachment); } } return downloadableAttachments; } }
public static Attachment createAttachment(TextConfiguration textConfiguration, String id, String fileName, String contentType, long size) { Attachment attachment = new Attachment(id); attachment.setFilename(fileName); attachment.setContentType(contentType); attachment.setSize(size); textConfiguration.getAttachments().add(attachment); return attachment; }
public static Attachment createAttachment(TextConfiguration textConfiguration, String id, String fileName, String contentType, long size) { Attachment attachment = new Attachment(id); attachment.setFilename(fileName); attachment.setContentType(contentType); attachment.setSize(size); textConfiguration.getAttachments().add(attachment); return attachment; }
@Button(list = "manage-attachments", key = "ok", order = 1, type = Button.TYPE_PRIMARY) @RequiresPermissions(level = AccessLevel.VIEW, permissions = { PERMISSION_EDIT }) public Resolution saveAttachments() { if(downloadable == null) { downloadable = new String[0]; } if(textConfiguration == null) { textConfiguration = new TextConfiguration(); } for(Attachment attachment : textConfiguration.getAttachments()) { boolean contained = ArrayUtils.contains(downloadable, attachment.getId()); attachment.setDownloadable(contained); } saveConfiguration(textConfiguration); return cancel(); }