diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java index 5ecb9b4..00a2ef7 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java @@ -124,7 +124,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar } public String getDevelopmentUser() { String user = TEST_USER; -// user = "costantino.perciante"; + // user = "costantino.perciante"; return user; } /** @@ -313,7 +313,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar } } - // Managing attachments: the first one (if any) will use the same fields of a link preview. + // Managing attachments: the first one will use the same fields of a link preview. // If more than one attachments are present, they will be saved as Attachment objects. // In this way we can handle retro-compatibility. @@ -327,7 +327,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar if(uploadedFiles.size() > 0){ - // retrieve the first element + // retrieve the first element (and remove it) UploadedFile firstAttachment = uploadedFiles.get(0); firstAttachmentName = firstAttachment.getFileName(); @@ -338,20 +338,22 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar firstAttachment.getThumbnailUrl() != null ? firstAttachment.getThumbnailUrl() : firstAttachmenturlThumbnail; + // check if there are more files if(uploadedFiles.size() > 1){ attachments = new ArrayList<>(); - // check if there are more files - for (UploadedFile file : uploadedFiles) { + for (int i = 1; i < uploadedFiles.size(); i++){ + UploadedFile file = uploadedFiles.get(i); + attachments.add(new Attachment( UUID.randomUUID().toString(), file.getDownloadUrl(), file.getFileName(), file.getDescription(), - file.getThumbnailUrl(), + file.getThumbnailUrl() == null ? "null" : file.getThumbnailUrl(), file.getFormat()) - ); + ); } } @@ -366,7 +368,6 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar textToPost = TextTransfromUtils.convertFileNameAnchorHTML(textToPost); } else { textToPost = escapedFeedText; - //System.out.println("textToPost=" + textToPost); } //get the VRE scope if single channel post