updated remove user from JCR method call to improve performance
This commit is contained in:
parent
d8edcb1b7b
commit
2f49e53a2a
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<artifactId>user-registration-hook</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>user-registration-hook Hook</name>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1</version>
|
||||
<scm>
|
||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/user-registration-hook.git</connection>
|
||||
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/user-registration-hook.git</developerConnection>
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.portal.removeaccount.thread;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portal.usersaccount.Constants;
|
||||
import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class RemovedUserAccountThread implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
_log.info("Trying to remove user " + userNameToDelete + " from JCR first, using storageHub with role: "+Constants.AUTORISED_INFRA_ROLE);
|
||||
_log.info("Trying to remove user " + userNameToDelete + " from JCR first, using storageHub with role: "+GatewayRolesNames.INFRASTRUCTURE_MANAGER.getRoleName());
|
||||
RemoveUserFromJCR rmJCR = new RemoveUserFromJCR(userNameToDelete, theAdminToken, theAdminRolesString);
|
||||
boolean result = rmJCR.remove();
|
||||
_log.info("The user " + userNameToDelete + " has been removed from JCR with success? " + result);
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package org.gcube.portal.usersaccount;
|
||||
|
||||
public class Constants {
|
||||
public static final String AUTORISED_INFRA_ROLE = "Infrastructure-Manager";
|
||||
}
|
|
@ -14,6 +14,8 @@ import org.gcube.vomanagement.usermanagement.UserManager;
|
|||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||
import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -57,16 +59,23 @@ public class MyCreateUserAccountListener extends BaseModelListener<User> {
|
|||
String username2Delete = user.getScreenName();
|
||||
_log.info("Trying to remove user from JCR and not notify infra-managers ...");
|
||||
try {
|
||||
_log.debug("Getting super user with role {}", Constants.AUTORISED_INFRA_ROLE);
|
||||
_log.debug("Getting super user with role {}", GatewayRolesNames.INFRASTRUCTURE_MANAGER.getRoleName());
|
||||
//get the super user
|
||||
String infraContext = "/"+PortalContext.getConfiguration().getInfrastructureName();
|
||||
|
||||
String adminUsername = "lucio.lelii";
|
||||
long rootgroupId = gm.getGroupIdFromInfrastructureScope(infraContext);
|
||||
User theAdmin = LiferayUserManager.getRandomUserWithRole(rootgroupId, GatewayRolesNames.INFRASTRUCTURE_MANAGER);
|
||||
if (theAdmin == null) {
|
||||
System.out.println("Cannot add the user as VRE Folder admin: there is no user having role {} on context: " + GatewayRolesNames.INFRASTRUCTURE_MANAGER.getRoleName());
|
||||
}
|
||||
String adminUsername = theAdmin.getScreenName();
|
||||
_log.info("Got the super user: {}",adminUsername);
|
||||
String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, adminUsername);
|
||||
List<String> rolesString = new ArrayList<String>();
|
||||
rolesString.add("Infrastructure-Manager");
|
||||
_log.info("authorizationService().setTokenRoles done");
|
||||
List<GCubeRole> theAdminRoles = rm.listRolesByUserAndGroup(theAdmin.getUserId(), rootgroupId);
|
||||
for (GCubeRole gCubeRole : theAdminRoles) {
|
||||
rolesString.add(gCubeRole.getRoleName());
|
||||
}
|
||||
rolesString.add(GatewayRolesNames.INFRASTRUCTURE_MANAGER.getRoleName());
|
||||
Thread dropUserWorkspaceThread = new Thread(new RemovedUserAccountThread(username2Delete, theAdminToken, rolesString));
|
||||
dropUserWorkspaceThread.start();
|
||||
|
||||
|
|
Loading…
Reference in New Issue