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
This commit is contained in:
Costantino Perciante 2018-02-09 14:04:55 +00:00
parent a37ce79aca
commit 611d3ab580
3 changed files with 18 additions and 11 deletions

View File

@ -10,7 +10,7 @@
<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>
<dependent-module archiveName="ckan-util-library-2.4.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
<dependent-module archiveName="ckan-metadata-publisher-widget-1.3.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-metadata-publisher-widget/ckan-metadata-publisher-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="gcube-ckan-datacatalog"/>

View File

@ -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);

View File

@ -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<GCubeGroup> 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<String, String> orgAndCapacity = new HashMap<String, String>();
String username = user.getUsername();