Updated to new PortalContext

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@141690 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-01-20 18:18:08 +00:00
parent a56c2b4a62
commit 4e708d1686
7 changed files with 73 additions and 97 deletions

View File

@ -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());
}

View File

@ -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());

View File

@ -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

View File

@ -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";

View File

@ -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) {

View File

@ -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);

View File

@ -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 + "]";
}
}