From 611d3ab580d24931f5eeab9afbaf6598a02156de Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 9 Feb 2018 14:04:55 +0000 Subject: [PATCH] association with other organizations has been entirely moved in a separated thread git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@163120 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 2 +- .../gcubeckandatacatalog/server/UserUtil.java | 15 ++++++--------- .../thread/AddUserToOrganizationThread.java | 12 +++++++++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 5e9f405..7dc2878 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -10,7 +10,7 @@ uses - + uses diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/UserUtil.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/UserUtil.java index b43d2c9..b614388 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/UserUtil.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/UserUtil.java @@ -62,15 +62,11 @@ public class UserUtil { // filter according the current context: if it is a VO/VRE, we send all the VRES under the VO. If it is the root vo, we send all user's vres. long groupIdContext = groupManager.getGroupIdFromInfrastructureScope(context); GCubeGroup currentVRE = groupManager.getGroup(groupIdContext); - String localRole = RolesCkanGroupOrOrg.convertToCkanCapacity(getLiferayHighestRoleInOrg(roleManager.listRolesByUserAndGroup(user.getUserId(), currentVRE.getGroupId()))); - mapRoleByGroupSingleVre.put(currentVRE.getGroupName().toLowerCase(), - localRole); + String localRoleInThisVre = RolesCkanGroupOrOrg.convertToCkanCapacity(getLiferayHighestRoleInOrg(roleManager.listRolesByUserAndGroup(user.getUserId(), currentVRE.getGroupId()))); - // check if extra roles must be assigned - logger.debug("Checking if there is the need to extend role " + localRole + " for user " + user.getUsername() + " in other vres"); - instance.assignRolesOtherOrganization(user.getUsername(), - currentVRE.getGroupName().toLowerCase(), - RolesCkanGroupOrOrg.convertFromCapacity(localRole)); + // ckan-connector will do it + mapRoleByGroupSingleVre.put(currentVRE.getGroupName().toLowerCase(), + localRoleInThisVre); // perform further checks if(!isViewPerVREEnabled){ @@ -82,7 +78,8 @@ public class UserUtil { isViewPerVREEnabled, groupIdContext, roleManager, - groupManager). + groupManager, + localRoleInThisVre). start(); } logger.debug("Returning Map to the ckan connector : " + mapRoleByGroupSingleVre); diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/thread/AddUserToOrganizationThread.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/thread/AddUserToOrganizationThread.java index 9c33c06..006c689 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/thread/AddUserToOrganizationThread.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/thread/AddUserToOrganizationThread.java @@ -32,6 +32,7 @@ public class AddUserToOrganizationThread extends Thread { private long groupIdContext; private GroupManager groupManager; private RoleManager roleManager; + private String localRoleInThisVre; /** * @param instance @@ -41,11 +42,12 @@ public class AddUserToOrganizationThread extends Thread { * @param groupIdContext * @param groupManager * @param roleManager + * @param localRoleInThisVre */ public AddUserToOrganizationThread(DataCatalogue instance, GCubeUser user, List listOfGroups, boolean isViewPerVREEnabled, - long groupIdContext, RoleManager roleManager, GroupManager groupManager) { + long groupIdContext, RoleManager roleManager, GroupManager groupManager, String localRoleInThisVre) { super(); this.instance = instance; this.user = user; @@ -54,12 +56,20 @@ public class AddUserToOrganizationThread extends Thread { this.groupIdContext = groupIdContext; this.roleManager = roleManager; this.groupManager = groupManager; + this.localRoleInThisVre = localRoleInThisVre; } @Override public void run() { try{ + GCubeGroup currentVRE = groupManager.getGroup(groupIdContext); + + // check if extra roles must be assigned + logger.debug("Checking if there is the need to extend role " + localRoleInThisVre + " for user " + user.getUsername() + " in other vres"); + instance.assignRolesOtherOrganization(user.getUsername(), + currentVRE.getGroupName().toLowerCase(), + RolesCkanGroupOrOrg.convertFromCapacity(localRoleInThisVre)); Map orgAndCapacity = new HashMap(); String username = user.getUsername();