Fixed bug on current user

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@141374 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-12-22 14:03:33 +00:00
parent 308fb4cc73
commit 285221c644
2 changed files with 13 additions and 11 deletions

View File

@ -12,6 +12,7 @@ import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
import org.gcube.portlets.widgets.workspaceuploader.shared.UploadProgress; import org.gcube.portlets.widgets.workspaceuploader.shared.UploadProgress;
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem; import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS; import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -108,8 +109,8 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
Workspace workspace; Workspace workspace;
try { try {
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest()); String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
String currUserId = ""+PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()); GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUserId); workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUser.getUserId()+"");
if(workspace!=null) if(workspace!=null)
return workspace.getRoot().getId(); return workspace.getRoot().getId();
} catch (Exception e) { } catch (Exception e) {
@ -130,7 +131,8 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
logger.trace("get itemExistsInWorkpace by parentId: "+parentId); logger.trace("get itemExistsInWorkpace by parentId: "+parentId);
try { try {
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest()); String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
String currUserId = ""+PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()); GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
String currUserId = currUser!=null?currUser.getUserId()+"":null;
Workspace workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUserId); Workspace workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUserId);
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT

View File

@ -36,7 +36,7 @@ public class NotificationsWorkspaceUploaderProducer {
protected NotificationsManager notificationsMng; protected NotificationsManager notificationsMng;
protected String userId; protected String username;
/** /**
* Instantiates a new notifications workspace uploader producer. * Instantiates a new notifications workspace uploader producer.
@ -50,7 +50,7 @@ public class NotificationsWorkspaceUploaderProducer {
this.notificationsMng = getNotificationManager(scopeGroupId, httpSession, request); this.notificationsMng = getNotificationManager(scopeGroupId, httpSession, request);
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
GCubeUser currUser = pContext.getCurrentUser(request); GCubeUser currUser = pContext.getCurrentUser(request);
this.userId = currUser.getUsername(); this.username = currUser.getUsername();
} }
/** /**
@ -91,15 +91,15 @@ public class NotificationsWorkspaceUploaderProducer {
GCubeUser currUser = pContext.getCurrentUser(request); GCubeUser currUser = pContext.getCurrentUser(request);
if (notifMng == null) { if (notifMng == null) {
try{ try{
String scope = pContext.getCurrentScope(scopeGroupId); String scope = pContext.getCurrentScope(scopeGroupId);
logger.trace("Create new NotificationsManager for user: "+currUser.getUsername() + " Scope="+scope); logger.trace("Create new NotificationsManager for user: "+currUser.getUsername() + " Scope="+scope);
logger.trace("New ApplicationNotificationsManager with portlet class name: "+WsUtil.NOTIFICATION_PORTLET_CLASS_ID); logger.trace("New ApplicationNotificationsManager with portlet class name: "+WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
logger.info("Request URI: "+request.getRequestURI()); logger.info("Request URI: "+request.getRequestURI());
SocialNetworkingSite site = new SocialNetworkingSite(request); SocialNetworkingSite site = new SocialNetworkingSite(request);
SocialNetworkingUser curser = new SocialNetworkingUser(currUser.getUsername(), currUser.getEmail(), currUser.getFullname(), currUser.getUserAvatarURL()); SocialNetworkingUser curser = new SocialNetworkingUser(currUser.getUsername(), currUser.getEmail(), currUser.getFullname(), currUser.getUserAvatarURL());
notifMng = new ApplicationNotificationsManager(site, scope, curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID); notifMng = new ApplicationNotificationsManager(site, scope, curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
httpSession.setAttribute(WsUtil.NOTIFICATION_MANAGER_UPLOADER, notifMng); httpSession.setAttribute(WsUtil.NOTIFICATION_MANAGER_UPLOADER, notifMng);
}catch (Exception e) { }catch (Exception e) {
@ -134,7 +134,7 @@ public class NotificationsWorkspaceUploaderProducer {
this.notificationsMng = notificationMng; this.notificationsMng = notificationMng;
} }
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
@ -158,7 +158,7 @@ public class NotificationsWorkspaceUploaderProducer {
try{ try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){ if(infoContactModel.getLogin().compareTo(username)!=0){
logger.info("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); logger.info("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder); boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
@ -199,7 +199,7 @@ public class NotificationsWorkspaceUploaderProducer {
try{ try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){ if(infoContactModel.getLogin().compareTo(username)!=0){
logger.info("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); logger.info("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder); boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);