ref 17080: Workspace - list of users I shared folder with varies from a gateway to another

https://support.d4science.org/issues/17080

Fix removed due to problems with shared folder by groups in the old HL

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@181148 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-07-05 13:12:05 +00:00
parent 651e35ec87
commit b34e54635f
3 changed files with 37 additions and 26 deletions

View File

@ -1,4 +1,8 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-9-1"
date="2019-07-05">
<Change>Added support for users in different Gateway [ticket: #17080]</Change>
</Changeset>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-9-0" <Changeset component="portlets-widgets.workspace-sharing-widget.1-9-0"
date="2019-06-05"> date="2019-06-05">
<Change>Updated to StorageHub [ticket: #13226]</Change> <Change>Updated to StorageHub [ticket: #13226]</Change>

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-sharing-widget</artifactId> <artifactId>workspace-sharing-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.9.0-SNAPSHOT</version> <version>1.9.1-SNAPSHOT</version>
<name>gCube Workspace Sharing Widget</name> <name>gCube Workspace Sharing Widget</name>
<description> <description>
gCube Workspace Sharing Widget allows users to share gCube Workspace items gCube Workspace Sharing Widget allows users to share gCube Workspace items

View File

@ -50,6 +50,9 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.ReportAssignment
import org.gcube.portlets.widgets.workspacesharingwidget.shared.SessionExpiredException; import org.gcube.portlets.widgets.workspacesharingwidget.shared.SessionExpiredException;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL; import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup; import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
@ -154,12 +157,12 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
} }
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest()); PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder(); GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(info); List<InfoContactModel> 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()); logger.debug("Get all Gateway Users returning a list having size: " + listContactsModel.size());
return listContactsModel; return listContactsModel;
@ -226,14 +229,18 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
if (map != null && !map.isEmpty()) { if (map != null && !map.isEmpty()) {
List<InfoContactModel> listShared = new ArrayList<>(); List<InfoContactModel> listShared = new ArrayList<>();
List<String> keys = new ArrayList<String>(map.keySet()); List<String> keys = new ArrayList<String>(map.keySet());
List<InfoContactModel> listContactsModel = getAllContacts(); UserManager um = new LiferayUserManager();
GCubeUser curr;
for (String username : keys) { for (String username : keys) {
for (InfoContactModel contact : listContactsModel) { curr = null;
if (contact != null && contact.getLogin() != null try {
&& contact.getLogin().compareTo(username) == 0) { curr = um.getUserByUsername(username);
listShared.add(contact); } catch (Throwable e) {
break; logger.warn("Invalid info for user " + username, e);
} }
if (curr != null && curr.getFullname() != null && !curr.getFullname().isEmpty()) {
InfoContactModel userInfo = new InfoContactModel(username, username, curr.getFullname(), false);
listShared.add(userInfo);
} }
} }
return listShared; return listShared;
@ -705,15 +712,16 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
return addAdminstratorByWorkspace(folderItem.getId(), listContactLogins); return addAdminstratorByWorkspace(folderItem.getId(), listContactLogins);
} else { } else {
String error = "Attention, the set administrators operation can only be done on the root shared folder. " 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."; + "Please, select the root shared folder if you want to set the administrators.";
logger.error(error); logger.error(error);
throw new Exception(error); throw new Exception(error);
} }
} else { } else {
logger.error("The item requested is not a valid shared folder : [itemId=" + itemId + "]"); 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) { } catch (Exception e) {
@ -741,7 +749,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
// logger.info("Retrieving old administator/s are/is:" + // logger.info("Retrieving old administator/s are/is:" +
// oldAdmins.size()); // oldAdmins.size());
logger.info("Setting administators: "+listContactLogins); logger.info("Setting administators: " + listContactLogins);
sharedFolder.setAdmins(listContactLogins); sharedFolder.setAdmins(listContactLogins);
/* /*
@ -1164,7 +1172,6 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
} }
} }
private List<WorkspaceACL> retrieveUserACLsFromFolderContainer(FolderContainer folderContainer) throws Exception { private List<WorkspaceACL> retrieveUserACLsFromFolderContainer(FolderContainer folderContainer) throws Exception {
String currentUser = getMyLogin(); String currentUser = getMyLogin();
logger.debug("Current User: " + currentUser); logger.debug("Current User: " + currentUser);
@ -1190,7 +1197,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
String principal = acl.getPricipal(); String principal = acl.getPricipal();
String rootVO = PortalContext.getConfiguration().getInfrastructureName(); String rootVO = PortalContext.getConfiguration().getInfrastructureName();
if (principal.startsWith(rootVO)) { if (principal.startsWith(rootVO)) {
String tempScope=principal.substring(rootVO.length()); String tempScope = principal.substring(rootVO.length());
int voIndex = tempScope.indexOf("-"); int voIndex = tempScope.indexOf("-");
if (voIndex != -1) { if (voIndex != -1) {
tempScope = tempScope.substring(voIndex + 1); tempScope = tempScope.substring(voIndex + 1);
@ -1198,7 +1205,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
if (vreIndex != -1) { if (vreIndex != -1) {
tempScope = tempScope.substring(vreIndex + 1); tempScope = tempScope.substring(vreIndex + 1);
if (tempScope.compareTo(vreName) == 0) { if (tempScope.compareTo(vreName) == 0) {
logger.debug("User is member of: "+principal); logger.debug("User is member of: " + principal);
currentUserACL = acl; currentUserACL = acl;
break; break;
} }
@ -1209,7 +1216,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
i++; i++;
} }
if (currentUserACL != null) { if (currentUserACL != null) {
logger.debug("Permission found: "+currentUserACL); logger.debug("Permission found: " + currentUserACL);
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder(); GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
wsAcls = builder.getWorkspaceACLForUser(currentUserACL); wsAcls = builder.getWorkspaceACLForUser(currentUserACL);
} else { } else {
@ -1242,7 +1249,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
List<GCubeGroup> listOfGroups = groupManager.listGroupsByUser(userId); List<GCubeGroup> listOfGroups = groupManager.listGroupsByUser(userId);
List<GCubeGroup> vres = new ArrayList<GCubeGroup>(); List<GCubeGroup> vres = new ArrayList<GCubeGroup>();
for (GCubeGroup g : listOfGroups) { for (GCubeGroup g : listOfGroups) {
if (groupManager.isVRE(g.getGroupId())){ if (groupManager.isVRE(g.getGroupId())) {
vres.add(g); vres.add(g);
} }
} }
@ -1308,19 +1315,19 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
FolderContainer folderContainer = openResolverForItem.asFolder(); FolderContainer folderContainer = openResolverForItem.asFolder();
FolderItem folderItem = folderContainer.get(); FolderItem folderItem = folderContainer.get();
if (folderItem != null) { if (folderItem != null) {
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest()); PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
String username = info.getUsername(); String username = info.getUsername();
if (folderItem.isPublicItem()) { if (folderItem.isPublicItem()) {
logger.info("The folder is already public. Access granted to " + username); 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, return new AllowAccess(itemId, true, "The folder is already public. Access granted to " + username,
null); null);
} }
logger.debug("Owner is: " + folderItem.getOwner()); logger.debug("Owner is: " + folderItem.getOwner());
logger.info("The current context user: " + username); logger.info("The current context user: " + username);
if (folderItem.getOwner() != null && folderItem.getOwner().compareToIgnoreCase(username) == 0) { if (folderItem.getOwner() != null && folderItem.getOwner().compareToIgnoreCase(username) == 0) {
logger.info("Access to Folder Link " + folderItem.getName() + " granted, " + username logger.info("Access to Folder Link " + folderItem.getName() + " granted, " + username
+ " is the owner of: " + itemId); + " is the owner of: " + itemId);