diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploaderServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploaderServiceImpl.java index d559226..2b1aa69 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploaderServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploaderServiceImpl.java @@ -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.WorkspaceUploaderItem; import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS; +import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -108,8 +109,8 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement Workspace workspace; try { String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest()); - String currUserId = ""+PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()); - workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUserId); + GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()); + workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUser.getUserId()+""); if(workspace!=null) return workspace.getRoot().getId(); } catch (Exception e) { @@ -130,7 +131,8 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement logger.trace("get itemExistsInWorkpace by parentId: "+parentId); try { 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); WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploaderProducer.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploaderProducer.java index cd05cf4..ef4fd47 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploaderProducer.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploaderProducer.java @@ -36,7 +36,7 @@ public class NotificationsWorkspaceUploaderProducer { protected NotificationsManager notificationsMng; - protected String userId; + protected String username; /** * Instantiates a new notifications workspace uploader producer. @@ -50,7 +50,7 @@ public class NotificationsWorkspaceUploaderProducer { this.notificationsMng = getNotificationManager(scopeGroupId, httpSession, request); PortalContext pContext = PortalContext.getConfiguration(); 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); if (notifMng == null) { try{ - + String scope = pContext.getCurrentScope(scopeGroupId); 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.info("Request URI: "+request.getRequestURI()); SocialNetworkingSite site = new SocialNetworkingSite(request); SocialNetworkingUser curser = new SocialNetworkingUser(currUser.getUsername(), currUser.getEmail(), currUser.getFullname(), currUser.getUserAvatarURL()); - - + + notifMng = new ApplicationNotificationsManager(site, scope, curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID); httpSession.setAttribute(WsUtil.NOTIFICATION_MANAGER_UPLOADER, notifMng); }catch (Exception e) { @@ -134,7 +134,7 @@ public class NotificationsWorkspaceUploaderProducer { this.notificationsMng = notificationMng; } - + /** * Runs a new thread to notify the contacts passed in input. * @@ -158,7 +158,7 @@ public class NotificationsWorkspaceUploaderProducer { try{ //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()); boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder); @@ -199,7 +199,7 @@ public class NotificationsWorkspaceUploaderProducer { try{ //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()); boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);