From 53eb63ead61f3e27772f0a5b3cd5b0c3b7b23e98 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Tue, 6 Feb 2018 17:33:00 +0000 Subject: [PATCH] avoid checks for vre different than the current one if there is no need (i.e. view per vre is enabled) git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@162996 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 6 ------ .../server/GcubeCkanDataCatalogServiceImpl.java | 4 ++-- .../gcubeckan/gcubeckandatacatalog/server/UserUtil.java | 9 +++++++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index dd7b8bb..5fe3680 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,12 +4,6 @@ - - uses - - - uses - diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java index 3f322b1..a5e1b4d 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java @@ -101,7 +101,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem logger.debug("returning ckanConnectorUri: "+ckAP); return ckAP; }catch(Exception e ){ - String message = "Sorry an error occurred during contacting gCube Ckan Data Catalogue"; + String message = "Sorry an error occurred while contacting gCube Ckan Data Catalogue"; logger.error(message, e); throw new Exception(message); } @@ -169,7 +169,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem Map roleForVre = UserUtil.getVreRoleForUser( SessionUtil.getCurrentUser(getThreadLocalRequest()).getEmail(), scopePerCurrentUrl, - getCatalogue(scopePerCurrentUrl)); + getCatalogue(scopePerCurrentUrl), isViewPerVREEnabled() != null); ckan.addListOfVREs(roleForVre); return ckan; 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 80d48d4..c5555ea 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 @@ -47,9 +47,10 @@ public class UserUtil { * Gets the list vre for user and the role the user has in them. * retrieve the groups to whom a given user belongs (given the user EMail) * @param userEMail the user e mail + * @param pathVre * @return the list vre for user */ - public static Map getVreRoleForUser(String userEMail, String context, DataCatalogue instance){ + public static Map getVreRoleForUser(String userEMail, String context, DataCatalogue instance, boolean isViewPerVREEnabled){ GroupManager groupManager = new LiferayGroupManager(); UserManager userManager = new LiferayUserManager(); @@ -99,7 +100,11 @@ public class UserUtil { instance.assignRolesOtherOrganization(user.getUsername(), vre.getGroupName().toLowerCase(), RolesCkanGroupOrOrg.convertFromCapacity(localRole)); - }else + + if(isViewPerVREEnabled) + break; + + }else if(!isViewPerVREEnabled) mapRoleByGroupExtrasVre.put(vre.getGroupName().toLowerCase(), RolesCkanGroupOrOrg.convertToCkanCapacity(getLiferayHighestRoleInOrg(roleManager.listRolesByUserAndGroup(user.getUserId(), vre.getGroupId())))); }