From 1cae9150af9fee8122ca41d72bf5410a9fcc9983 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Mon, 18 Jan 2016 09:26:36 +0000 Subject: [PATCH] Bug fix and update to handle the new ClientFeed class git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122276 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/view/ShareUpdateForm.java | 13 ++++---- .../server/ShareUpdateServiceImpl.java | 30 +++++++++++-------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java index b7f38e1..dd5ad3c 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java @@ -367,7 +367,9 @@ public class ShareUpdateForm extends Composite { if(numberOfAttachmentsUploaded() > 0){ postContent = PostContent.TEXT_AND_ATTACHMENTS; - toShare = NO_TEXT_FILE_SHARE; + + if(toShare.equals("")) + toShare = NO_TEXT_FILE_SHARE; } } @@ -487,15 +489,12 @@ public class ShareUpdateForm extends Composite { file.getFormat())); } - + // share the post shareupdateService.sharePostWithAttachments(toShareText, FeedType.TWEET, getPrivacyLevel(), vreId, uploadedFiles, mentionedUsers, notifyGroup, saveInWorkspaceCheckbox.getValue(), new AsyncCallback() { @Override public void onSuccess(ClientFeed result) { - - GWT.log("OK"); - submitButton.setEnabled(true); shareTextArea.setEnabled(true); @@ -523,7 +522,7 @@ public class ShareUpdateForm extends Composite { @Override public void onFailure(Throwable caught) { - + GWT.log(caught.toString()); submitButton.setEnabled(true); @@ -957,7 +956,7 @@ public class ShareUpdateForm extends Composite { }); }-*/; - + /** * Check if DND could be enabled (i.e, it's supported by the browser) 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 827b4ce..89128b0 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 @@ -149,8 +149,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar public ClientFeed sharePostWithLinkPreview(String postText, FeedType feedType, PrivacyLevel pLevel, String vreId, LinkPreview preview, String urlThumbnail, ArrayList mentionedUserFullNames, boolean notifyGroup) { - - _log.debug("Writing a new post with text " + postText); + + _log.debug("Writing a new post with text " + postText); // escape text String escapedFeedText = TextTransfromUtils.escapeHtmlAndTransformUrl(postText); @@ -243,7 +243,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //everything went fine ClientFeed cf = new ClientFeed(toShare.getKey(), toShare.getType().toString(), username, feedDate, toShare.getUri(), TextTransfromUtils.replaceAmpersand(toShare.getDescription()), fullName, email, thumbnailAvatarURL, toShare.getLinkTitle(), toShare.getLinkDescription(), - toShare.getUriThumbnail(), toShare.getLinkHost()); + toShare.getUriThumbnail(), toShare.getLinkHost(), null); //send the notification about this posts to everyone in the group if notifyGroup is true @@ -277,6 +277,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar PrivacyLevel pLevel, String vreId, ArrayList uploadedFiles, ArrayList mentionedUserFullNames, boolean notifyGroup, boolean saveCopyWokspace) { + _log.debug("Incoming text is " + feedText); + // escape text String escapedFeedText = TextTransfromUtils.escapeHtmlAndTransformUrl(feedText); @@ -321,7 +323,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar firstAttachmentDescription = "", firstAttachmentFormat = "", firstAttachmentDownloadUrl = "", - firstAttachmenturlThumbnail = ""; + firstAttachmenturlThumbnail = "null"; if(uploadedFiles.size() > 0){ @@ -332,7 +334,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar firstAttachmentDescription = firstAttachment.getDescription(); firstAttachmentFormat = firstAttachment.getFormat(); firstAttachmentDownloadUrl = firstAttachment.getDownloadUrl(); - firstAttachmenturlThumbnail = firstAttachment.getThumbnailUrl(); + firstAttachmenturlThumbnail = firstAttachment.getThumbnailUrl() != null ? firstAttachment.getThumbnailUrl() : "null"; if(uploadedFiles.size() > 1){ @@ -430,10 +432,12 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar } if (!result) return null; + _log.debug("Saved feed text is " + toShare.getDescription()); + //everything went fine ClientFeed cf = new ClientFeed(toShare.getKey(), toShare.getType().toString(), username, feedDate, toShare.getUri(), TextTransfromUtils.replaceAmpersand(toShare.getDescription()), fullName, email, thumbnailAvatarURL, toShare.getLinkTitle(), toShare.getLinkDescription(), - toShare.getUriThumbnail(), toShare.getLinkHost()); + toShare.getUriThumbnail(), toShare.getLinkHost(), attachments); //send the notification about this posts to everyone in the group if notifyGroup is true @@ -537,14 +541,14 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar String httpURL = ""; String smpURI = ""; - //if (isWithinPortal()) { - //get the url to show, before actually uploading it - smpURI = "http://ciccio.com";//storageClient.getUrl(true).RFile(remoteFilePath); + if (isWithinPortal()) { + //get the url to show, before actually uploading it + smpURI = storageClient.getUrl(true).RFile(remoteFilePath); //"http://ciccio.com"; - //The storage uploader Thread starts here asyncronously - //Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath)); - //thread.start(); - //} + //The storage uploader Thread starts here asyncronously + Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath)); + thread.start(); + } try { String mimeType = FilePreviewer.getMimeType(new File(fileabsolutePathOnServer), fileName);