users list ordering added
This commit is contained in:
parent
288e8d4254
commit
6b690caf56
|
@ -2,6 +2,7 @@ package org.gcube.data.access.storagehub.services;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -32,6 +33,7 @@ import org.apache.jackrabbit.api.security.user.Query;
|
||||||
import org.apache.jackrabbit.api.security.user.QueryBuilder;
|
import org.apache.jackrabbit.api.security.user.QueryBuilder;
|
||||||
import org.apache.jackrabbit.api.security.user.User;
|
import org.apache.jackrabbit.api.security.user.User;
|
||||||
import org.apache.jackrabbit.core.security.principal.PrincipalImpl;
|
import org.apache.jackrabbit.core.security.principal.PrincipalImpl;
|
||||||
|
import org.apache.poi.hpsf.Array;
|
||||||
import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
||||||
import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse;
|
import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse;
|
||||||
import org.gcube.common.storagehub.model.Excludes;
|
import org.gcube.common.storagehub.model.Excludes;
|
||||||
|
@ -84,10 +86,11 @@ public class UserManager {
|
||||||
InnerMethodName.instance.set("getUsers");
|
InnerMethodName.instance.set("getUsers");
|
||||||
|
|
||||||
JackrabbitSession session = null;
|
JackrabbitSession session = null;
|
||||||
List<String> users= new ArrayList<>();
|
List<String> users = null;
|
||||||
try {
|
try {
|
||||||
session = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
session = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
|
|
||||||
|
|
||||||
Iterator<Authorizable> result = session.getUserManager().findAuthorizables(new Query() {
|
Iterator<Authorizable> result = session.getUserManager().findAuthorizables(new Query() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,11 +99,19 @@ public class UserManager {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Set<String> usersSet= new HashSet<>();
|
||||||
|
String adminUser = context.getInitParameter(Constants.ADMIN_PARAM_NAME);
|
||||||
|
|
||||||
while (result.hasNext()) {
|
while (result.hasNext()) {
|
||||||
Authorizable user = result.next();
|
Authorizable user = result.next();
|
||||||
log.debug("user {} found",user.getPrincipal().getName());
|
log.debug("user {} found",user.getPrincipal().getName());
|
||||||
users.add(user.getPrincipal().getName());
|
if (user.getPrincipal().getName().equals(adminUser)) continue;
|
||||||
|
usersSet.add(user.getPrincipal().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
users = new ArrayList<>(usersSet);
|
||||||
|
Collections.sort(users);
|
||||||
|
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("jcr error getting users", e);
|
log.error("jcr error getting users", e);
|
||||||
GXOutboundErrorResponse.throwException(new BackendGenericError(e));
|
GXOutboundErrorResponse.throwException(new BackendGenericError(e));
|
||||||
|
@ -159,6 +170,7 @@ public class UserManager {
|
||||||
org.apache.jackrabbit.api.security.user.UserManager usrManager = session.getUserManager();
|
org.apache.jackrabbit.api.security.user.UserManager usrManager = session.getUserManager();
|
||||||
|
|
||||||
User createdUser = usrManager.createUser(user, password);
|
User createdUser = usrManager.createUser(user, password);
|
||||||
|
|
||||||
userId = createdUser.getID();
|
userId = createdUser.getID();
|
||||||
|
|
||||||
Node homeNode = session.getNode("/Home");
|
Node homeNode = session.getNode("/Home");
|
||||||
|
|
|
@ -25,7 +25,7 @@ The projects leading to this software have received funding from a series of
|
||||||
Version
|
Version
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
1.2.5-SNAPSHOT (20210311-193254)
|
1.2.5-SNAPSHOT (20210315-104913)
|
||||||
|
|
||||||
Please see the file named "changelog.xml" in this directory for the release notes.
|
Please see the file named "changelog.xml" in this directory for the release notes.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue