From 636c42d7aa37a598128610383500cd4a45c966d4 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Wed, 20 Jan 2016 09:36:24 +0000 Subject: [PATCH] Fix for attachments handling git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122336 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../server/ShareUpdateServiceImpl.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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