patch for getting infra manager role
This commit is contained in:
parent
027a53e026
commit
978bde8610
|
@ -97,29 +97,36 @@ public class GCubeHookSiteRoleLocalService extends UserGroupRoleLocalServiceWrap
|
|||
String context = gm.getInfrastructureScope(groupId);
|
||||
ScopeProvider.instance.set(context);
|
||||
String vreFolderTitle = Util.getVREGroupFromContext(context);
|
||||
_log.debug("The vreFolderTitle on which the VREFolder role is being {} is {}", enable, vreFolderTitle);
|
||||
_log.info("The vreFolderTitle on which the VREFolder role is being {} is {}", enable, vreFolderTitle);
|
||||
_log.info("Before StorageHubClient shc = new StorageHubClient();");
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
_log.info("Before shc.getVreFolderManager(vreFolderTitle);");
|
||||
VREFolderManager vreFolderManager = shc.getVreFolderManager(vreFolderTitle);
|
||||
|
||||
String previousToken = SecurityTokenProvider.instance.get();
|
||||
//get the super user
|
||||
_log.info("//get the super user");
|
||||
String infraContext = "/"+PortalContext.getConfiguration().getInfrastructureName();
|
||||
long rootgroupId = gm.getGroupIdFromInfrastructureScope(infraContext);
|
||||
RoleManager rm = new LiferayRoleManager();
|
||||
long roleId = rm.getRoleId(HookConstants.AUTORISED_INFRA_ROLE, rootgroupId);
|
||||
List<GCubeUser> users = uMan.listUsersByGroupAndRole(rootgroupId, roleId);
|
||||
if (users.isEmpty()) {
|
||||
_log.error("Cannot add the user as VRE Folder admin: there is no user having role {} on context: {}", HookConstants.AUTORISED_INFRA_ROLE, infraContext);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
GCubeUser theAdmin = users.get(0);
|
||||
String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, theAdmin.getUsername());
|
||||
List<GCubeRole> theAdminRoles = rm.listRolesByUserAndGroup(theAdmin.getUserId(), rootgroupId);
|
||||
// long rootgroupId = gm.getGroupIdFromInfrastructureScope(infraContext);
|
||||
// RoleManager rm = new LiferayRoleManager();
|
||||
// long roleId = rm.getRoleId(HookConstants.AUTORISED_INFRA_ROLE, rootgroupId);
|
||||
// List<GCubeUser> users = uMan.listUsersByGroupAndRole(rootgroupId, roleId);
|
||||
// if (users.isEmpty()) {
|
||||
// _log.error("Cannot add the user as VRE Folder admin: there is no user having role {} on context: {}", HookConstants.AUTORISED_INFRA_ROLE, infraContext);
|
||||
// return false;
|
||||
// }
|
||||
// else {
|
||||
//GCubeUser theAdmin = users.get(0);
|
||||
String adminUsername = "lucio.lelii";
|
||||
_log.info("Got the super user: {}",adminUsername);
|
||||
String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, adminUsername);
|
||||
List<String> rolesString = new ArrayList<String>();
|
||||
for (GCubeRole gCubeRole : theAdminRoles) {
|
||||
rolesString.add(gCubeRole.getRoleName());
|
||||
}
|
||||
// List<GCubeRole> theAdminRoles = rm.listRolesByUserAndGroup(theAdmin.getUserId(), rootgroupId);
|
||||
// for (GCubeRole gCubeRole : theAdminRoles) {
|
||||
// rolesString.add(gCubeRole.getRoleName());
|
||||
// }
|
||||
rolesString.add("Infrastructure-Manager");
|
||||
_log.info("authorizationService().setTokenRoles(theAdminToken, rolesString);",theAdminToken);
|
||||
authorizationService().setTokenRoles(theAdminToken, rolesString);
|
||||
SecurityTokenProvider.instance.set(theAdminToken);
|
||||
|
||||
|
@ -131,7 +138,7 @@ public class GCubeHookSiteRoleLocalService extends UserGroupRoleLocalServiceWrap
|
|||
vreFolderManager.removeAdmin(theUserToPromoteOrDeclass);
|
||||
SecurityTokenProvider.instance.set(previousToken);
|
||||
return true;
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -155,22 +155,26 @@ public class GCubeHookUserLocalService extends UserLocalServiceWrapper {
|
|||
String previousToken = SecurityTokenProvider.instance.get();
|
||||
//get the super user
|
||||
String infraContext = "/"+PortalContext.getConfiguration().getInfrastructureName();
|
||||
long groupId = gm.getGroupIdFromInfrastructureScope(infraContext);
|
||||
RoleManager rm = new LiferayRoleManager();
|
||||
long roleId = rm.getRoleId(HookConstants.AUTORISED_INFRA_ROLE, groupId);
|
||||
List<GCubeUser> users = uMan.listUsersByGroupAndRole(groupId, roleId);
|
||||
if (users.isEmpty()) {
|
||||
_log.error("Cannot add the user to the VRE Folder: there is no user having role " + HookConstants.AUTORISED_INFRA_ROLE + " on context: " + infraContext);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
GCubeUser theAdmin = users.get(0);
|
||||
String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, theAdmin.getUsername());
|
||||
List<GCubeRole> theAdminRoles = rm.listRolesByUserAndGroup(theAdmin.getUserId(), groupId);
|
||||
// long rootgroupId = gm.getGroupIdFromInfrastructureScope(infraContext);
|
||||
// RoleManager rm = new LiferayRoleManager();
|
||||
// long roleId = rm.getRoleId(HookConstants.AUTORISED_INFRA_ROLE, rootgroupId);
|
||||
// List<GCubeUser> users = uMan.listUsersByGroupAndRole(rootgroupId, roleId);
|
||||
// if (users.isEmpty()) {
|
||||
// _log.error("Cannot add the user as VRE Folder admin: there is no user having role {} on context: {}", HookConstants.AUTORISED_INFRA_ROLE, infraContext);
|
||||
// return false;
|
||||
// }
|
||||
// else {
|
||||
//GCubeUser theAdmin = users.get(0);
|
||||
String adminUsername = "lucio.lelii";
|
||||
_log.info("Got the super user: " +adminUsername);
|
||||
String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, adminUsername);
|
||||
List<String> rolesString = new ArrayList<String>();
|
||||
for (GCubeRole gCubeRole : theAdminRoles) {
|
||||
rolesString.add(gCubeRole.getRoleName());
|
||||
}
|
||||
// List<GCubeRole> theAdminRoles = rm.listRolesByUserAndGroup(theAdmin.getUserId(), rootgroupId);
|
||||
// for (GCubeRole gCubeRole : theAdminRoles) {
|
||||
// rolesString.add(gCubeRole.getRoleName());
|
||||
// }
|
||||
rolesString.add("Infrastructure-Manager");
|
||||
_log.info("authorizationService().setTokenRoles(theAdminToken, rolesString);" +theAdminToken);
|
||||
authorizationService().setTokenRoles(theAdminToken, rolesString);
|
||||
SecurityTokenProvider.instance.set(theAdminToken);
|
||||
GroupManagerClient client = AbstractPlugin.groups().build();
|
||||
|
@ -180,7 +184,7 @@ public class GCubeHookUserLocalService extends UserLocalServiceWrapper {
|
|||
client.removeUserFromGroup(username2Add, getVREFolderNameFromContext(context));
|
||||
SecurityTokenProvider.instance.set(previousToken);
|
||||
return true;
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
private static String getVREFolderNameFromContext(String context) {
|
||||
|
|
Loading…
Reference in New Issue