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
This commit is contained in:
Costantino Perciante 2016-01-29 11:39:02 +00:00
parent f52cd6a6a6
commit 2f72dd6949
2 changed files with 15 additions and 5 deletions

View File

@ -4,6 +4,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<dependent-module archiveName="fileupload-progress-bar-1.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/fileupload-progress-bar/fileupload-progress-bar">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="share-updates"/>
</wb-module>

View File

@ -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<Attachment> 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("<span style=\"color:gray; font-size:12px;\">shared a set of files.</span>").toString();
}
} else {
textToPost = escapedFeedText;
}