Fixed ClientFeed exchange problem between this portlet and the news-feed one on posting.

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122313 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-01-19 13:35:51 +00:00
parent b0e22ec9ff
commit 1ff6ca4b94
4 changed files with 44 additions and 9 deletions

View File

@ -4,10 +4,7 @@
<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="gcube-widgets-1.9.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="pickitem-widget-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
<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"/>

View File

@ -6,6 +6,7 @@ import java.util.List;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapter;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException;
import org.gcube.portal.databook.shared.ClientFeed;
import org.gcube.portal.databook.shared.ClientFeed.ClientFeedJsonizer;
import org.gcube.portal.databook.shared.FeedType;
@ -246,6 +247,33 @@ public class ShareUpdateForm extends Composite {
GWT.log("Drag and drop not supported.");
}
// ClientFeed notification = new ClientFeed();
// //Subscribe to message and associate subsequent receptions with custom subscriber data
// try {
// pageBusAdapter.PageBusSubscribe("org.gcube.portal.databook.shared", null, null, notification, (Jsonizer)GWT.create(ClientFeedJsonizer.class));
// }
// catch (PageBusAdapterException e1) {
// GWT.log(e1.toString());
// }
//
// pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener() {
// public void onPageBusSubscriptionCallback(PageBusEvent event) {
// // translate JavaScript message contents and subscriber data to their Java equivalents
// try {
//
// GWT.log("Receiving...");
// ClientFeed feed = (ClientFeed)event.getMessage((Jsonizer)GWT.create(ClientFeedJsonizer.class));
// GWT.log("Received client feed " + feed);
//
// } catch (PageBusAdapterException e) {
// e.printStackTrace();
// }
// }
// public String getName() {
// return null;
// }
// });
}
});
}
@ -367,7 +395,7 @@ public class ShareUpdateForm extends Composite {
if(numberOfAttachmentsUploaded() > 0){
postContent = PostContent.TEXT_AND_ATTACHMENTS;
if(toShare.equals(""))
if(toShare.equals("") || toShare.equals(SHARE_UPDATE_TEXT) || toShare.equals(ERROR_UPDATE_TEXT))
toShare = NO_TEXT_FILE_SHARE;
}
@ -458,7 +486,9 @@ public class ShareUpdateForm extends Composite {
else {
// publish a message with the refresh notification
try {
pageBusAdapter.PageBusPublish("org.gcube.portal.databook.shared", feed, (Jsonizer)GWT.create(ClientFeedJsonizer.class));
} catch (PageBusAdapterException ex) {
GWT.log(ex.getMessage());
}
@ -493,7 +523,7 @@ public class ShareUpdateForm extends Composite {
shareupdateService.sharePostWithAttachments(toShareText, FeedType.TWEET, getPrivacyLevel(), vreId, uploadedFiles, mentionedUsers, notifyGroup, saveInWorkspaceCheckbox.getValue(), new AsyncCallback<ClientFeed>() {
@Override
public void onSuccess(ClientFeed result) {
public void onSuccess(ClientFeed feed) {
submitButton.setEnabled(true);
shareTextArea.setEnabled(true);
@ -503,12 +533,13 @@ public class ShareUpdateForm extends Composite {
preview.clear();
listOfAttachedFiles.clear();
if (result == null)
if (feed == null)
Window.alert("Ops! we encountered some problems delivering your message, please try again in a short while.");
else {
// publish a message with the refresh notification
try {
pageBusAdapter.PageBusPublish("org.gcube.portal.databook.shared", result, (Jsonizer)GWT.create(ClientFeedJsonizer.class));
pageBusAdapter.PageBusPublish("org.gcube.portal.databook.shared", feed, (Jsonizer)GWT.create(ClientFeedJsonizer.class));
GWT.log("SENT");
} catch (PageBusAdapterException ex) {
GWT.log(ex.getMessage());
}

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;
}
/**

View File

@ -29,6 +29,13 @@
});
</script>
<script type="text/javascript" src="js/pagebus.js"></script>
<script type="text/javascript">
if(window.parent.PageBus) {
window.PageBus = window.parent.PageBus;
}
</script>
</head>
<body>