From 2f72dd694921666170451a10b83a0f5d10631a85 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 29 Jan 2016 11:39:02 +0000 Subject: [PATCH] Handled properly the case in which there is more than one attachment but no feed's text. Fixed the download url in the case in which there is one file but no text. git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122642 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 3 +++ .../server/ShareUpdateServiceImpl.java | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index adde6d9..3804aaa 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,6 +4,9 @@ + + uses + 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 cfdbebe..c9f72b8 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; } /** @@ -315,8 +315,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar // 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. - + // In this way we can handle backward-compatibility. List attachments = null; String firstAttachmentName = "", @@ -363,10 +362,18 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar // evaluate the date (this will be the date of the post) Date feedDate = new Date(); - //this means the user has shared a file without text in it. String textToPost = ""; + //this means the user has shared a file without text in it. + + _log.debug("Url vale " + firstAttachmentDownloadUrl); if (escapedFeedText.trim().compareTo(ShareUpdateForm.NO_TEXT_FILE_SHARE) == 0) { - textToPost = TextTransfromUtils.convertFileNameAnchorHTML(textToPost); + if(uploadedFiles.size() <= 1){ + textToPost = TextTransfromUtils.convertFileNameAnchorHTML(firstAttachmentDownloadUrl); + } + else{ + StringBuilder sb = new StringBuilder(); + textToPost = sb.append("shared a set of files.").toString(); + } } else { textToPost = escapedFeedText; }