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
This commit is contained in:
Costantino Perciante 2018-02-06 17:33:00 +00:00
parent 984767eb5d
commit 53eb63ead6
3 changed files with 9 additions and 10 deletions

View File

@ -4,12 +4,6 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="grsf-manage-widget-1.3.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-manage-widget/grsf-manage-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="grsf-common-library-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-common-library/grsf-common-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="gcube-ckan-datacatalog"/> <property name="context-root" value="gcube-ckan-datacatalog"/>
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module> </wb-module>

View File

@ -101,7 +101,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
logger.debug("returning ckanConnectorUri: "+ckAP); logger.debug("returning ckanConnectorUri: "+ckAP);
return ckAP; return ckAP;
}catch(Exception e ){ }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); logger.error(message, e);
throw new Exception(message); throw new Exception(message);
} }
@ -169,7 +169,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
Map<String, String> roleForVre = UserUtil.getVreRoleForUser( Map<String, String> roleForVre = UserUtil.getVreRoleForUser(
SessionUtil.getCurrentUser(getThreadLocalRequest()).getEmail(), SessionUtil.getCurrentUser(getThreadLocalRequest()).getEmail(),
scopePerCurrentUrl, scopePerCurrentUrl,
getCatalogue(scopePerCurrentUrl)); getCatalogue(scopePerCurrentUrl), isViewPerVREEnabled() != null);
ckan.addListOfVREs(roleForVre); ckan.addListOfVREs(roleForVre);
return ckan; return ckan;

View File

@ -47,9 +47,10 @@ public class UserUtil {
* Gets the list vre for user and the role the user has in them. * 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) * retrieve the groups to whom a given user belongs (given the user EMail)
* @param userEMail the user e mail * @param userEMail the user e mail
* @param pathVre
* @return the list vre for user * @return the list vre for user
*/ */
public static Map<String, String> getVreRoleForUser(String userEMail, String context, DataCatalogue instance){ public static Map<String, String> getVreRoleForUser(String userEMail, String context, DataCatalogue instance, boolean isViewPerVREEnabled){
GroupManager groupManager = new LiferayGroupManager(); GroupManager groupManager = new LiferayGroupManager();
UserManager userManager = new LiferayUserManager(); UserManager userManager = new LiferayUserManager();
@ -99,7 +100,11 @@ public class UserUtil {
instance.assignRolesOtherOrganization(user.getUsername(), instance.assignRolesOtherOrganization(user.getUsername(),
vre.getGroupName().toLowerCase(), vre.getGroupName().toLowerCase(),
RolesCkanGroupOrOrg.convertFromCapacity(localRole)); RolesCkanGroupOrOrg.convertFromCapacity(localRole));
}else
if(isViewPerVREEnabled)
break;
}else if(!isViewPerVREEnabled)
mapRoleByGroupExtrasVre.put(vre.getGroupName().toLowerCase(), mapRoleByGroupExtrasVre.put(vre.getGroupName().toLowerCase(),
RolesCkanGroupOrOrg.convertToCkanCapacity(getLiferayHighestRoleInOrg(roleManager.listRolesByUserAndGroup(user.getUserId(), vre.getGroupId())))); RolesCkanGroupOrOrg.convertToCkanCapacity(getLiferayHighestRoleInOrg(roleManager.listRolesByUserAndGroup(user.getUserId(), vre.getGroupId()))));
} }