use of javax.jcr.Workspace in project jackrabbit-oak by apache.
the class PrivilegeManagementTest method testRegisterPrivilege.
@Test
public void testRegisterPrivilege() throws Exception {
try {
Workspace testWsp = testSession.getWorkspace();
((JackrabbitWorkspace) testWsp).getPrivilegeManager().registerPrivilege(getNewPrivilegeName(testWsp), false, new String[0]);
fail("Privilege registration should be denied.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.Workspace in project jackrabbit-oak by apache.
the class NodeTypeManagementTest method testCopy.
@Test
public void testCopy() throws Exception {
Workspace wsp = testSession.getWorkspace();
String parentPath = childNode.getParent().getPath();
String srcPath = childNode.getPath();
String destPath = parentPath + "/destination";
try {
wsp.copy(srcPath, destPath);
fail("Missing write privilege.");
} catch (AccessDeniedException e) {
// success
}
// with simple write privilege copying a node is not allowed.
modify(parentPath, Privilege.JCR_WRITE, true);
try {
wsp.copy(srcPath, destPath);
fail("Missing privilege jcr:nodeTypeManagement.");
} catch (AccessDeniedException e) {
// success
}
// adding jcr:nodeTypeManagement privilege will grant permission to copy.
modify(parentPath, REP_WRITE, true);
wsp.copy(srcPath, destPath);
}
use of javax.jcr.Workspace in project jackrabbit-oak by apache.
the class NamespaceManagementTest method testUnregisterNamespace.
@Test
public void testUnregisterNamespace() throws Exception {
Workspace wsp = superuser.getWorkspace();
String pfx = getNewNamespacePrefix(wsp);
wsp.getNamespaceRegistry().registerNamespace(pfx, getNewNamespaceURI(wsp));
try {
Workspace testWsp = testSession.getWorkspace();
testWsp.getNamespaceRegistry().unregisterNamespace(pfx);
fail("Namespace unregistration should be denied.");
} catch (AccessDeniedException e) {
// success
} finally {
// clean up (not supported by jackrabbit-core)
try {
superuser.getWorkspace().getNamespaceRegistry().unregisterNamespace(pfx);
} catch (Exception e) {
// ns unregistration is not supported by jackrabbit-core.
}
}
}
use of javax.jcr.Workspace in project jackrabbit-oak by apache.
the class PrivilegeRegistrationTest method testRegisterCustomPrivilegesVisibleInContent.
/**
* @since oak
*/
@Test
public void testRegisterCustomPrivilegesVisibleInContent() throws RepositoryException {
Workspace workspace = session.getWorkspace();
workspace.getNamespaceRegistry().registerNamespace("test", "http://www.apache.org/jackrabbit/test");
Map<String, String[]> newCustomPrivs = new HashMap<String, String[]>();
newCustomPrivs.put("new", new String[0]);
newCustomPrivs.put("test:new", new String[0]);
for (String name : newCustomPrivs.keySet()) {
boolean isAbstract = true;
String[] aggrNames = newCustomPrivs.get(name);
Privilege registered = privilegeManager.registerPrivilege(name, isAbstract, aggrNames);
Node privilegeRoot = session.getNode(PrivilegeConstants.PRIVILEGES_PATH);
assertTrue(privilegeRoot.hasNode(name));
Node privNode = privilegeRoot.getNode(name);
assertTrue(privNode.getProperty(PrivilegeConstants.REP_IS_ABSTRACT).getBoolean());
assertFalse(privNode.hasProperty(PrivilegeConstants.REP_AGGREGATES));
}
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class ShareableNodeTest method testRemoveAncestorOfSharedNode.
/**
* Verify that a shared node is removed when the ancestor is removed.
* See also JCR-2257.
*/
public void testRemoveAncestorOfSharedNode() throws Exception {
Node a1 = testRootNode.addNode("a1");
Node a2 = a1.addNode("a2");
Node b1 = a1.addNode("b1");
ensureMixinType(b1, mixShareable);
testRootNode.save();
//now we have a shareable node N with path a1/b1
Workspace workspace = testRootNode.getSession().getWorkspace();
String path = a2.getPath() + "/b2";
workspace.clone(workspace.getName(), b1.getPath(), path, false);
testRootNode.save();
//now we have another shareable node N' in the same shared set as N with path a1/a2/b2
a2.remove();
testRootNode.save();
// assert b2 is removed from index
QueryManager qm = superuser.getWorkspace().getQueryManager();
String stmt = testPath + "//b2";
NodeIterator it = qm.createQuery(stmt, Query.XPATH).execute().getNodes();
assertFalse(it.hasNext());
}
Aggregations