diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/resource/ResourceTDCreator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/resource/ResourceTDCreator.java index 32ae6fc..531025d 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/resource/ResourceTDCreator.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/resource/ResourceTDCreator.java @@ -4,7 +4,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; -import org.gcube.application.framework.core.session.ASLSession; import org.gcube.data.analysis.tabulardata.commons.webservice.types.resources.ResourceDescriptor; import org.gcube.data.analysis.tabulardata.model.resources.InternalURI; import org.gcube.data.analysis.tabulardata.model.resources.Resource; @@ -13,6 +12,7 @@ import org.gcube.data.analysis.tabulardata.model.resources.StringResource; import org.gcube.data.analysis.tabulardata.model.resources.TableResource; import org.gcube.data.analysis.tabulardata.model.resources.Thumbnail; import org.gcube.portlets.user.td.gwtservice.server.uriresolver.UriResolverTDClient; +import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTD; @@ -39,10 +39,10 @@ public class ResourceTDCreator { protected static SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm"); - private ASLSession aslSession; + private ServiceCredentials serviceCredentials; - public ResourceTDCreator(ASLSession aslSession) { - this.aslSession = aslSession; + public ResourceTDCreator(ServiceCredentials serviceCredentials) { + this.serviceCredentials = serviceCredentials; } /** @@ -121,7 +121,7 @@ public class ResourceTDCreator { thumbnail.getUri().toString(), ApplicationType.SMP_ID, "resourcethumbnail.jpg", thumbnail.getMimeType()); String link = uriResolverTDClient.resolve(uriResolverSession, - aslSession); + serviceCredentials); thumbnailTD = new ThumbnailTD(link, thumbnail.getMimeType()); } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/social/TDMNotifications.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/social/TDMNotifications.java index 4a79948..729bc0c 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/social/TDMNotifications.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/social/TDMNotifications.java @@ -4,13 +4,13 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.gcube.application.framework.core.session.ASLSession; import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.common.homelibrary.util.WorkspaceUtil; import org.gcube.portal.databook.shared.NotificationType; +import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials; import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareRule; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTabResource; @@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory; public class TDMNotifications extends Thread { private static Logger logger = LoggerFactory .getLogger(TDMNotifications.class); - private ASLSession aslSession; + private ServiceCredentials serviceCredentials; private NotificationType notificationType; private ShareTabResource shareTabularResource; private ShareRule shareRule; @@ -41,55 +41,56 @@ public class TDMNotifications extends Thread { /** * Share Tabular Resource * - * @param aslSession + * @param serviceCredentials * @param shareTabularResource */ - public TDMNotifications(HttpServletRequest request, ASLSession aslSession, + public TDMNotifications(HttpServletRequest request, ServiceCredentials serviceCredentials, ShareTabResource shareTabularResource) { - this.aslSession = aslSession; + this.serviceCredentials = serviceCredentials; this.shareTabularResource = shareTabularResource; this.notificationType = NotificationType.TDM_TAB_RESOURCE_SHARE; site = new SocialNetworkingSite(request); - user = new SocialNetworkingUser(aslSession.getUsername(), - aslSession.getUserEmailAddress(), aslSession.getUserFullName(), - aslSession.getUserAvatarId()); - scope = aslSession.getScope(); + user = new SocialNetworkingUser(serviceCredentials.getUserName(), + serviceCredentials.getEmail(), serviceCredentials.getFullName(), + serviceCredentials.getUserAvatarURL()); + scope = serviceCredentials.getScope(); } /** * - * @param aslSession + * @param serviceCredentials * @param shareRule */ - public TDMNotifications(HttpServletRequest request, ASLSession aslSession, + public TDMNotifications(HttpServletRequest request, ServiceCredentials serviceCredentials, ShareRule shareRule) { - this.aslSession = aslSession; + this.serviceCredentials = serviceCredentials; this.shareRule = shareRule; this.notificationType = NotificationType.TDM_RULE_SHARE; site = new SocialNetworkingSite(request); - user = new SocialNetworkingUser(aslSession.getUsername(), - aslSession.getUserEmailAddress(), aslSession.getUserFullName(), - aslSession.getUserAvatarId()); - scope = aslSession.getScope(); + user = new SocialNetworkingUser(serviceCredentials.getUserName(), + serviceCredentials.getEmail(), serviceCredentials.getFullName(), + serviceCredentials.getUserAvatarURL()); + scope = serviceCredentials.getScope(); } /** * - * @param aslSession + * @param serviceCredentials * @param shareTemplate */ - public TDMNotifications(HttpServletRequest request, ASLSession aslSession, + public TDMNotifications(HttpServletRequest request, + ServiceCredentials serviceCredentials, ShareTemplate shareTemplate) { - this.aslSession = aslSession; + this.serviceCredentials = serviceCredentials; this.shareTemplate = shareTemplate; this.notificationType = NotificationType.TDM_TEMPLATE_SHARE; site = new SocialNetworkingSite(request); - user = new SocialNetworkingUser(aslSession.getUsername(), - aslSession.getUserEmailAddress(), aslSession.getUserFullName(), - aslSession.getUserAvatarId()); - scope = aslSession.getScope(); + user = new SocialNetworkingUser(serviceCredentials.getUserName(), + serviceCredentials.getEmail(), serviceCredentials.getFullName(), + serviceCredentials.getUserAvatarURL()); + scope = serviceCredentials.getScope(); } @@ -134,7 +135,7 @@ public class TDMNotifications extends Thread { logger.error("Error in the notification(Type: " + notificationType + " - " - + aslSession.getUsername() + + serviceCredentials.getUserName() + " share tabular resource id=" + shareTabularResource.getTabResource() .getTrId().getId() + " with " @@ -164,7 +165,7 @@ public class TDMNotifications extends Thread { logger.error("Error in the notification(Type: " + notificationType + " - " - + aslSession.getUsername() + + serviceCredentials.getUserName() + " share tabular resource id=" + shareTabularResource.getTabResource().getTrId() .getId() + " with " + contact.getLogin() @@ -196,7 +197,7 @@ public class TDMNotifications extends Thread { logger.error("Error in the notification(Type: " + notificationType + " - " - + aslSession.getUsername() + + serviceCredentials.getUserName() + " share rule id=" + shareRule.getRuleDescriptionData() .getId() + " with " + member @@ -222,7 +223,7 @@ public class TDMNotifications extends Thread { } catch (Exception e) { logger.error("Error in the notification(Type: " + notificationType + " - " - + aslSession.getUsername() + " share rule id=" + + serviceCredentials.getUserName() + " share rule id=" + shareRule.getRuleDescriptionData().getId() + " with " + contact.getLogin() + "): " + e.getLocalizedMessage()); @@ -253,7 +254,7 @@ public class TDMNotifications extends Thread { } catch (Exception e) { logger.error("Error in the notification(Type: " + notificationType + " - " - + aslSession.getUsername() + + serviceCredentials.getUserName() + " share template id=" + shareTemplate.getTemplateData().getId() + " with " + member + "): " @@ -279,7 +280,7 @@ public class TDMNotifications extends Thread { } catch (Exception e) { logger.error("Error in the notification(Type: " + notificationType + " - " - + aslSession.getUsername() + " share template id=" + + serviceCredentials.getUserName() + " share template id=" + shareTemplate.getTemplateData().getId() + " with " + contact.getLogin() + "): " + e.getLocalizedMessage()); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/uriresolver/UriResolverTDClient.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/uriresolver/UriResolverTDClient.java index 81a1d33..0dc3d60 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/uriresolver/UriResolverTDClient.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/uriresolver/UriResolverTDClient.java @@ -3,7 +3,7 @@ package org.gcube.portlets.user.td.gwtservice.server.uriresolver; import java.util.HashMap; import java.util.Map; -import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession; import org.gcube.portlets.user.uriresolvermanager.UriResolverManager; @@ -27,7 +27,7 @@ public class UriResolverTDClient { } public String resolve(UriResolverSession uriResolverSession, - ASLSession aslSession) throws TDGWTServiceException { + ServiceCredentials serviceCredentials) throws TDGWTServiceException { try { String link = ""; @@ -42,7 +42,7 @@ public class UriResolverTDClient { resolver = new UriResolverManager(uriResolverSession .getApplicationType().toString()); params.put("gis-UUID", uriResolverSession.getUuid()); - params.put("scope", aslSession.getScope()); + params.put("scope", serviceCredentials.getScope()); logger.debug("Uri Resolver params: " + params); link = resolver.getLink(params, true); // true, link is shorted // otherwise none diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java index 3984fe5..db12f98 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java @@ -10,12 +10,18 @@ package org.gcube.portlets.user.td.gwtservice.shared; * */ public class Constants { - public static final boolean DEBUG_MODE = false; - public static final boolean TEST_ENABLE = false; + public static final boolean DEBUG_MODE = true; + public static final boolean TEST_ENABLE = true; + public static final String DEFAULT_USER = "giancarlo.panichi"; - public final static String DEFAULT_SCOPE = "/gcube/devNext"; - public final static String DEFAULT_TOKEN = "16e65d4f-11e0-4e4a-84b9-351688fccc12-98187548"; + public static final String DEFAULT_SCOPE = "/gcube/devNext/NextNext"; + public static final String DEFAULT_TOKEN = "ae1208f0-210d-47c9-9b24-d3f2dfcce05f-98187548"; + + + //public static final String DEFAULT_SCOPE = "/gcube/devNext"; + //public static final String DEFAULT_TOKEN = "16e65d4f-11e0-4e4a-84b9-351688fccc12-98187548"; + public static final String DEFAULT_ROLE = "OrganizationMember"; public final static String FILE_XML_MIMETYPE = "application/xml"; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java index 6fe4fdd..cb497d4 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java @@ -6,9 +6,6 @@ import java.util.List; import javax.servlet.http.HttpSession; -import org.gcube.application.framework.core.session.ASLSession; -import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider; -import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken; import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus; import org.gcube.data.analysis.tabulardata.model.metadata.common.TableDescriptorMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.table.DatasetViewTableMetadata; @@ -30,9 +27,9 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.JobClassifierMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.WorkerStateMap; +import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; -import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession; import org.gcube.portlets.user.td.gwtservice.shared.task.JobS; import org.gcube.portlets.user.td.gwtservice.shared.task.JobSClassifier; @@ -64,7 +61,7 @@ public class BackgroundOperationMonitorCreator { protected HttpSession session; protected TaskWrapper taskWrapper; protected OperationMonitorSession operationMonitorSession; - protected ASLSession aslSession; + protected ServiceCredentials serviceCredentials; /** * @@ -73,10 +70,10 @@ public class BackgroundOperationMonitorCreator { * @param operationMonitorSession */ public BackgroundOperationMonitorCreator(HttpSession session, - ASLSession aslSession, TaskWrapper taskWrapper, + ServiceCredentials serviceCredentials, TaskWrapper taskWrapper, OperationMonitorSession operationMonitorSession) { this.session = session; - this.aslSession = aslSession; + this.serviceCredentials = serviceCredentials; this.taskWrapper = taskWrapper; this.operationMonitorSession = operationMonitorSession; logger.debug("BackgroundOperationMonitorCreator: " + taskWrapper + " " @@ -330,10 +327,6 @@ public class BackgroundOperationMonitorCreator { protected TRId retrieveTabularResourceBasicData(TRId trId) throws TDGWTServiceException { try { - ASLSession aslSession = SessionUtil.getAslSession(session); - - AuthorizationProvider.instance.set(new AuthorizationToken( - aslSession.getUsername(), aslSession.getScope())); TabularDataService service = TabularDataServiceFactory.getService(); TabularResourceId tabularResourceId = new TabularResourceId( new Long(trId.getId())); @@ -376,8 +369,7 @@ public class BackgroundOperationMonitorCreator { logger.debug("Retrieved TRId basic info:" + newTRId.toString()); return newTRId; - } catch (TDGWTSessionExpiredException e) { - throw e; + } catch (SecurityException e) { e.printStackTrace(); throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS); @@ -401,7 +393,7 @@ public class BackgroundOperationMonitorCreator { throws TDGWTServiceException { CSVExportSession exportSession = SessionUtil .getCSVExportSession(session); - String user = aslSession.getUsername(); + String user = serviceCredentials.getUserName(); logger.debug("Save Export In Destination"); logger.debug("Destination: " + exportSession.getDestination().getId()); @@ -449,7 +441,7 @@ public class BackgroundOperationMonitorCreator { throws TDGWTServiceException { JSONExportSession exportSession = SessionUtil .getJSONExportSession(session); - String user = aslSession.getUsername(); + String user = serviceCredentials.getUserName(); logger.debug("Save Export In Destination"); logger.debug("Destination: " + exportSession.getDestination().getId()); @@ -488,8 +480,6 @@ public class BackgroundOperationMonitorCreator { private String retrieveTabularResourceIdFromTable(TableId tableId) throws TDGWTServiceException { try { - AuthorizationProvider.instance.set(new AuthorizationToken( - aslSession.getUsername(), aslSession.getScope())); TabularDataService service = TabularDataServiceFactory.getService(); Table table = service.getTable(tableId); @@ -513,8 +503,6 @@ public class BackgroundOperationMonitorCreator { private void retrieveNameOfTabularResourceOnWhicWasLaunchedTheTask( OperationMonitor operationMonitor) throws TDGWTServiceException { try { - AuthorizationProvider.instance.set(new AuthorizationToken( - aslSession.getUsername(), aslSession.getScope())); TabularDataService service = TabularDataServiceFactory.getService(); if (operationMonitor == null || operationMonitor.getTask() == null) { diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java index fc18541..c60605c 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java @@ -6,9 +6,6 @@ import java.util.List; import javax.servlet.http.HttpSession; -import org.gcube.application.framework.core.session.ASLSession; -import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider; -import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken; import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus; import org.gcube.data.analysis.tabulardata.model.metadata.common.TableDescriptorMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.table.DatasetViewTableMetadata; @@ -29,6 +26,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.JobClassifierMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.WorkerStateMap; +import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; @@ -64,7 +62,7 @@ public class OperationMonitorCreator { private HttpSession session; private TaskWrapper taskWrapper; private OperationMonitorSession operationMonitorSession; - private ASLSession aslSession; + private ServiceCredentials serviceCredentials; /** * @@ -72,11 +70,11 @@ public class OperationMonitorCreator { * @param startTRId * @param operationMonitorSession */ - public OperationMonitorCreator(HttpSession session, ASLSession aslSession, + public OperationMonitorCreator(HttpSession session, ServiceCredentials serviceCredentials, TaskWrapper taskWrapper, OperationMonitorSession operationMonitorSession) { - this.session = session; - this.aslSession = aslSession; + this.session=session; + this.serviceCredentials = serviceCredentials; this.taskWrapper = taskWrapper; this.operationMonitorSession = operationMonitorSession; @@ -374,10 +372,7 @@ public class OperationMonitorCreator { protected TRId retrieveTabularResourceBasicData(TRId trId) throws TDGWTServiceException { try { - ASLSession aslSession = SessionUtil.getAslSession(session); - - AuthorizationProvider.instance.set(new AuthorizationToken( - aslSession.getUsername(), aslSession.getScope())); + TabularDataService service = TabularDataServiceFactory.getService(); TabularResourceId tabularResourceId = new TabularResourceId( new Long(trId.getId())); @@ -456,7 +451,7 @@ public class OperationMonitorCreator { throws TDGWTServiceException { CSVExportSession exportSession = SessionUtil .getCSVExportSession(session); - String user = aslSession.getUsername(); + String user = serviceCredentials.getUserName(); logger.debug("Save Export In Destination"); logger.debug("Destination: " + exportSession.getDestination().getId()); @@ -504,7 +499,7 @@ public class OperationMonitorCreator { throws TDGWTServiceException { JSONExportSession exportSession = SessionUtil .getJSONExportSession(session); - String user = aslSession.getUsername(); + String user = serviceCredentials.getUserName(); logger.debug("Save Export In Destination"); logger.debug("Destination: " + exportSession.getDestination().getId()); @@ -543,8 +538,6 @@ public class OperationMonitorCreator { private String retrieveTabularResourceIdFromTable(TableId tableId) throws TDGWTServiceException { try { - AuthorizationProvider.instance.set(new AuthorizationToken( - aslSession.getUsername(), aslSession.getScope())); TabularDataService service = TabularDataServiceFactory.getService(); Table table = service.getTable(tableId); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/user/UserInfo.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/user/UserInfo.java index b7a345d..cf24fb9 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/user/UserInfo.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/user/UserInfo.java @@ -9,14 +9,13 @@ import java.io.Serializable; * */ public class UserInfo implements Serializable { - - private static final long serialVersionUID = -2826549639677017234L; - + + private static final long serialVersionUID = 7894334667499287578L; + private String username; - private long groupId; + private String groupId; private String groupName; private String scope; - private String scopeName; private String userEmailAddress; private String userFullName; @@ -34,15 +33,13 @@ public class UserInfo implements Serializable { * @param userEmailAddress * @param userFullName */ - public UserInfo(String username, long groupId, String groupName, - String scope, String scopeName, String userEmailAddress, - String userFullName) { + public UserInfo(String username, String groupId, String groupName, + String scope, String userEmailAddress, String userFullName) { super(); this.username = username; this.groupId = groupId; this.groupName = groupName; this.scope = scope; - this.scopeName = scopeName; this.userEmailAddress = userEmailAddress; this.userFullName = userFullName; } @@ -55,11 +52,11 @@ public class UserInfo implements Serializable { this.username = username; } - public long getGroupId() { + public String getGroupId() { return groupId; } - public void setGroupId(long groupId) { + public void setGroupId(String groupId) { this.groupId = groupId; } @@ -79,14 +76,6 @@ public class UserInfo implements Serializable { this.scope = scope; } - public String getScopeName() { - return scopeName; - } - - public void setScopeName(String scopeName) { - this.scopeName = scopeName; - } - public String getUserEmailAddress() { return userEmailAddress; } @@ -107,8 +96,7 @@ public class UserInfo implements Serializable { public String toString() { return "UserInfo [username=" + username + ", groupId=" + groupId + ", groupName=" + groupName + ", scope=" + scope - + ", scopeName=" + scopeName + ", userEmailAddress=" - + userEmailAddress + ", userFullName=" + userFullName + "]"; + + ", userEmailAddress=" + userEmailAddress + ", userFullName=" + + userFullName + "]"; } - }