From 84fde911c0886fae00d2971c6cdceeeb63bbbd09 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 15 Oct 2014 16:50:46 +0000 Subject: [PATCH] Updated Multi Tab git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-share-widget@100735 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/td/sharewidget/client/TRShare.java | 65 ++++++++++++++----- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/sharewidget/client/TRShare.java b/src/main/java/org/gcube/portlets/user/td/sharewidget/client/TRShare.java index 0c59b1c..a2c9e8e 100644 --- a/src/main/java/org/gcube/portlets/user/td/sharewidget/client/TRShare.java +++ b/src/main/java/org/gcube/portlets/user/td/sharewidget/client/TRShare.java @@ -4,9 +4,11 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.sharewidget.client.util.InfoMessageBox; import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; @@ -40,6 +42,7 @@ public class TRShare { private TRId trId; private EventBus eventBus; + private TabResource tabResource; private ShareInfo shareInfo; public TRShare(TRId trId, EventBus eventBus) { @@ -50,25 +53,54 @@ public class TRShare { } - protected void retrieveInfo() { - TDGWTServiceAsync.INSTANCE.getShareInfo(trId, - new AsyncCallback() { + /* + * protected void retrieveInfo() { + * TDGWTServiceAsync.INSTANCE.getShareInfo(trId, new + * AsyncCallback() { + * + * public void onFailure(Throwable caught) { if (caught instanceof + * TDGWTSessionExpiredException) { eventBus.fireEvent(new + * SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { + * Log.debug("ShareInfo Error: " + caught.getLocalizedMessage()); + * alert("Error retrienving share info", "Error retrieving share info"); } } + * + * public void onSuccess(ShareInfo result) { shareInfo = result; + * shareWindow(); } + * + * }); } + */ + + public void retrieveInfo() { + TDGWTServiceAsync.INSTANCE.getTabResourceInformation(trId, + new AsyncCallback() { + + public void onSuccess(TabResource result) { + Log.info("Retrived TR: " + result.getTrId()); + tabResource = result; + shareWindow(); + + } public void onFailure(Throwable caught) { if (caught instanceof TDGWTSessionExpiredException) { eventBus.fireEvent(new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.debug("ShareInfo Error: " - + caught.getLocalizedMessage()); - alert("Error retrienving share info", - "Error retrieving share info"); - } - } + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + alert("Error Locked", + caught.getLocalizedMessage()); - public void onSuccess(ShareInfo result) { - shareInfo = result; - shareWindow(); + } else { + Log.error("Error retrienving properties: " + + caught.getLocalizedMessage()); + alert("Error", + "Retrieving tabular resource info: " + + caught.getLocalizedMessage()); + + } + + } } }); @@ -79,11 +111,11 @@ public class TRShare { */ protected void shareWindow() { - FileModel file = new FileModel(shareInfo.getTabResource().getTrId() - .getId(), shareInfo.getTabResource().getName(), false); + FileModel file = new FileModel(tabResource.getTrId() + .getId(), tabResource.getName(), false); List listAlreadySharedContact = new ArrayList(); - for (Contacts contacts : shareInfo.getContacts()) { + for (Contacts contacts : tabResource.getContacts()) { CredentialModel cm = new CredentialModel(null, contacts.getLogin(), false); listAlreadySharedContact.add(cm); @@ -120,8 +152,7 @@ public class TRShare { cred.isGroup()); listContacts.add(cont); } - - shareInfo.setContacts(listContacts); + shareInfo=new ShareInfo(tabResource,listContacts); TDGWTServiceAsync.INSTANCE.setShare(shareInfo, new AsyncCallback() {