use of javax.jcr.Session in project jackrabbit-oak by apache.
the class RemoveMembersTest 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();
String groupPath = groupPaths.get(random.nextInt(GROUP_CNT));
Group g = (Group) userManager.getAuthorizableByPath(groupPath);
removeMembers(userManager, g, s);
} catch (RepositoryException e) {
if (s.hasPendingChanges()) {
s.refresh(false);
}
} finally {
if (s != null) {
s.logout();
}
}
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class RemoveMembersTest 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();
}
// remove test-users if they have been created
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 javax.jcr.Session in project jackrabbit by apache.
the class JackrabbitAccessControlManagerTest method testHasPrivilegeThrowsAccessDenied.
public void testHasPrivilegeThrowsAccessDenied() throws RepositoryException {
Session readOnly = getHelper().getReadOnlySession();
JackrabbitAccessControlManager jacMgr = (JackrabbitAccessControlManager) readOnly.getAccessControlManager();
try {
jacMgr.hasPrivileges(testRoot, principals, new Privilege[] { jacMgr.privilegeFromName(Privilege.JCR_READ) });
fail("ReadOnly session isn't allowed to determine the privileges of other principals.");
} catch (AccessDeniedException e) {
// success
} finally {
readOnly.logout();
}
}
use of javax.jcr.Session in project jackrabbit by apache.
the class JackrabbitAccessControlManagerTest method testGetPrivilegesThrowsAccessDenied.
public void testGetPrivilegesThrowsAccessDenied() throws RepositoryException {
Session readOnly = getHelper().getReadOnlySession();
JackrabbitAccessControlManager jacMgr = (JackrabbitAccessControlManager) readOnly.getAccessControlManager();
try {
jacMgr.getPrivileges(testRoot, principals);
fail("ReadOnly session isn't allowed to determine the privileges of other principals.");
} catch (AccessDeniedException e) {
// success
} finally {
readOnly.logout();
}
}
use of javax.jcr.Session in project jackrabbit by apache.
the class ItemStateHierarchyManagerDeadlockTest method retrieveNodesUnderInvRootNode.
public void retrieveNodesUnderInvRootNode() {
System.out.println("Start retrieveNodesUnderInvRootNode ");
Session session = null;
try {
session = login();
// start from the bottom of the tree and move up
Node inventoryRoot = getInvRootNode(session);
NodeIterator nodes = inventoryRoot.getNodes();
while (nodes.hasNext()) {
Node node = nodes.nextNode();
// System.out.println(" Node: " + node.getName());
PropertyIterator properties = node.getProperties();
while (properties.hasNext()) {
Property prop = properties.nextProperty();
// System.out.println(" Prop: " + prop.getName() + " - " + prop.getString());
}
}
session.save();
System.out.println("End retrieveNodesUnderInvRootNode");
} catch (Exception e) {
System.err.println("Exception in retrieveNodesUnderInvRootNode:" + e.getMessage());
} finally {
if (session != null)
session.logout();
}
}
Aggregations