diff --git a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/server/WorkspaceSharingServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/server/WorkspaceSharingServiceImpl.java index 894a290..3849add 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/server/WorkspaceSharingServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/server/WorkspaceSharingServiceImpl.java @@ -154,12 +154,12 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements } PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest()); - + GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder(); List listContactsModel = builder.buildGXTListContactsModelFromUserModel(info); - //listContactsModel.addAll(builder.getGXTListContactsModelFromVOs(info)); + // listContactsModel.addAll(builder.getGXTListContactsModelFromVOs(info)); logger.debug("Get all Gateway Users returning a list having size: " + listContactsModel.size()); return listContactsModel; @@ -226,14 +226,11 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements if (map != null && !map.isEmpty()) { List listShared = new ArrayList<>(); List keys = new ArrayList(map.keySet()); - List listContactsModel = getAllContacts(); for (String username : keys) { - for (InfoContactModel contact : listContactsModel) { - if (contact != null && contact.getLogin() != null - && contact.getLogin().compareTo(username) == 0) { - listShared.add(contact); - break; - } + if (username != null && !username.isEmpty()) { + InfoContactModel contact = new InfoContactModel(username, username, + UserUtil.getUserFullName(username), false); + listShared.add(contact); } } return listShared; @@ -705,15 +702,16 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements return addAdminstratorByWorkspace(folderItem.getId(), listContactLogins); } else { - String error = "Attention, the set administrators operation can only be done on the root shared folder. " - + "Please, select the root shared folder if you want to set the administrators."; - logger.error(error); - throw new Exception(error); - + String error = "Attention, the set administrators operation can only be done on the root shared folder. " + + "Please, select the root shared folder if you want to set the administrators."; + logger.error(error); + throw new Exception(error); + } } else { logger.error("The item requested is not a valid shared folder : [itemId=" + itemId + "]"); - throw new Exception("The item requested is not a valid shared folder. Impossible set the administrators."); + throw new Exception( + "The item requested is not a valid shared folder. Impossible set the administrators."); } } catch (Exception e) { @@ -741,7 +739,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements // logger.info("Retrieving old administator/s are/is:" + // oldAdmins.size()); - logger.info("Setting administators: "+listContactLogins); + logger.info("Setting administators: " + listContactLogins); sharedFolder.setAdmins(listContactLogins); /* @@ -1164,7 +1162,6 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements } } - private List retrieveUserACLsFromFolderContainer(FolderContainer folderContainer) throws Exception { String currentUser = getMyLogin(); logger.debug("Current User: " + currentUser); @@ -1190,7 +1187,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements String principal = acl.getPricipal(); String rootVO = PortalContext.getConfiguration().getInfrastructureName(); if (principal.startsWith(rootVO)) { - String tempScope=principal.substring(rootVO.length()); + String tempScope = principal.substring(rootVO.length()); int voIndex = tempScope.indexOf("-"); if (voIndex != -1) { tempScope = tempScope.substring(voIndex + 1); @@ -1198,7 +1195,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements if (vreIndex != -1) { tempScope = tempScope.substring(vreIndex + 1); if (tempScope.compareTo(vreName) == 0) { - logger.debug("User is member of: "+principal); + logger.debug("User is member of: " + principal); currentUserACL = acl; break; } @@ -1209,7 +1206,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements i++; } if (currentUserACL != null) { - logger.debug("Permission found: "+currentUserACL); + logger.debug("Permission found: " + currentUserACL); GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder(); wsAcls = builder.getWorkspaceACLForUser(currentUserACL); } else { @@ -1242,7 +1239,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements List listOfGroups = groupManager.listGroupsByUser(userId); List vres = new ArrayList(); for (GCubeGroup g : listOfGroups) { - if (groupManager.isVRE(g.getGroupId())){ + if (groupManager.isVRE(g.getGroupId())) { vres.add(g); } } @@ -1308,19 +1305,19 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements FolderContainer folderContainer = openResolverForItem.asFolder(); FolderItem folderItem = folderContainer.get(); if (folderItem != null) { - + PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest()); String username = info.getUsername(); - + if (folderItem.isPublicItem()) { logger.info("The folder is already public. Access granted to " + username); return new AllowAccess(itemId, true, "The folder is already public. Access granted to " + username, null); } - + logger.debug("Owner is: " + folderItem.getOwner()); logger.info("The current context user: " + username); - + if (folderItem.getOwner() != null && folderItem.getOwner().compareToIgnoreCase(username) == 0) { logger.info("Access to Folder Link " + folderItem.getName() + " granted, " + username + " is the owner of: " + itemId);