use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class AuthorizableFolderEditorTest method createSourceContent.
@Override
protected void createSourceContent(final Session session) throws Exception {
UserManager userMgr = ((JackrabbitSession) session).getUserManager();
userMgr.autoSave(false);
Group group = userMgr.createGroup(TEST_GROUP);
User user = userMgr.createUser(TEST_USER, "secret");
group.addMember(user);
session.save();
// simulate the error, set node types to incorrect values
Node home = session.getNode("/home");
home.setPrimaryType(JcrConstants.NT_UNSTRUCTURED);
home.getNode("users").setPrimaryType(JcrConstants.NT_UNSTRUCTURED);
home.getNode("groups").setPrimaryType(JcrConstants.NT_UNSTRUCTURED);
home.addNode("control", JcrConstants.NT_UNSTRUCTURED);
session.save();
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class MemberBaseTest method runTest.
@Override
public void runTest() throws Exception {
Session s = null;
try {
// use system session login to avoid measuring the login-performance here
s = systemLogin();
UserManager uMgr = ((JackrabbitSession) s).getUserManager();
for (int i = 0; i <= 1000; i++) {
testMembership((Group) uMgr.getAuthorizableByPath(groupPaths.get(random.nextInt(numberOfGroups))), (User) uMgr.getAuthorizableByPath(memberPaths.get(random.nextInt(numberOfMembers))));
}
} catch (RepositoryException e) {
System.out.println(e.getMessage());
} finally {
if (s != null) {
s.logout();
}
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class MemberBaseTest method beforeSuite.
@Override
public void beforeSuite() throws Exception {
super.beforeSuite();
Session s = loginAdministrative();
try {
List<String> memberIds = new ArrayList<String>(numberOfMembers);
UserManager userManager = ((JackrabbitSession) s).getUserManager();
for (int i = 0; i <= numberOfMembers; i++) {
User u = userManager.createUser(USER + i, null, new PrincipalImpl(USER + i), REL_TEST_PATH);
memberPaths.add(u.getPath());
memberIds.add(USER + i);
}
String[] idArray = memberIds.toArray(new String[memberIds.size()]);
for (int i = 0, j = 1; i <= numberOfGroups; i++, j++) {
Group g = userManager.createGroup(new PrincipalImpl(GROUP + i), REL_TEST_PATH);
groupPaths.add(g.getPath());
if (nested) {
g.addMembers(ObjectArrays.concat(idArray, GROUP + j));
} else {
g.addMembers(idArray);
}
}
} finally {
s.save();
s.logout();
}
System.out.println("setup done");
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class IsMemberTest method afterSuite.
@Override
public void afterSuite() throws Exception {
Session s = loginAdministrative();
try {
Authorizable authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(GROUP + "0");
if (authorizable != null) {
Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
n.remove();
}
authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(USER + "0");
if (authorizable != null) {
Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
n.remove();
}
s.save();
} finally {
s.logout();
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class IsMemberTest method runTest.
@Override
public void runTest() throws Exception {
Session s = null;
try {
// use system session login to avoid measuring the login-performance here
s = systemLogin();
UserManager userManager = ((JackrabbitSession) s).getUserManager();
for (int i = 0; i <= 1000; i++) {
Group g = getRandomGroup(userManager);
boolean isMember = isMember(g, getRandomUser(userManager));
//System.out.println(USER + i + " is " + (isMember? "" : "not ")+ "member of " +groupId);
}
} catch (RepositoryException e) {
System.out.println(e.getMessage());
} finally {
if (s != null) {
s.logout();
}
}
}
Aggregations