use of javax.jcr.PathNotFoundException in project jackrabbit-oak by apache.
the class LockOperation method performVoid.
@Override
public void performVoid() throws RepositoryException {
session.refresh(true);
NodeDelegate node = session.getNode(path);
if (node != null) {
performVoid(node);
} else {
throw new PathNotFoundException("Node " + path + " not found");
}
}
use of javax.jcr.PathNotFoundException in project jackrabbit-oak by apache.
the class LockOperation method perform.
@Nonnull
@Override
public T perform() throws RepositoryException {
session.refresh(true);
NodeDelegate node = session.getNode(path);
if (node != null) {
return perform(node);
} else {
throw new PathNotFoundException("Node " + path + " not found");
}
}
use of javax.jcr.PathNotFoundException in project jackrabbit-oak by apache.
the class RandomizedReadTest method check.
public void check() throws Exception {
boolean mustThrow;
try {
for (String path : tree.values()) {
mustThrow = false;
Session s1 = readSessions.get(0);
try {
Node n = s1.getNode(path);
if (!path.equals(n.getPath())) {
Assert.fail("did not resolved the same node");
}
} catch (PathNotFoundException pnf) {
mustThrow = true;
}
for (int i = 1; i < readSessions.size(); i++) {
try {
Node n = readSessions.get(i).getNode(path);
if (mustThrow) {
Assert.fail("did not throw for path " + path);
}
if (!path.equals(n.getPath())) {
Assert.fail("did not resolved the same node");
}
} catch (PathNotFoundException pnf) {
if (!mustThrow) {
Assert.fail("did throw for path " + path);
}
}
}
}
} catch (Exception e) {
throw new Exception(e);
}
}
use of javax.jcr.PathNotFoundException in project jackrabbit-oak by apache.
the class AccessControlManagementTest method testReadAccessControlWithoutPrivilege.
@Test
public void testReadAccessControlWithoutPrivilege() throws Exception {
// re-grant READ in order to have an ACL-node
Privilege[] privileges = privilegesFromName(Privilege.JCR_READ);
JackrabbitAccessControlList tmpl = allow(path, privileges);
String policyPath = tmpl.getPath() + "/rep:policy";
// make sure the 'rep:policy' node has been created.
assertTrue(superuser.itemExists(policyPath));
/*
Testuser must still have READ-only access only and must not be
allowed to view the acl-node nor any item in the subtree that
has been created.
*/
assertFalse(testAcMgr.hasPrivileges(path, privilegesFromName(Privilege.JCR_READ_ACCESS_CONTROL)));
assertFalse(testSession.itemExists(policyPath));
assertFalse(testSession.nodeExists(policyPath));
try {
testSession.getNode(policyPath);
fail("Accessing the rep:policy node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// ok.
}
try {
testAcMgr.getPolicies(tmpl.getPath());
fail("test user must not have READ_AC privilege.");
} catch (AccessDeniedException e) {
// success
}
try {
testAcMgr.getEffectivePolicies(tmpl.getPath());
fail("test user must not have READ_AC privilege.");
} catch (AccessDeniedException e) {
// success
}
for (NodeIterator aceNodes = superuser.getNode(policyPath).getNodes(); aceNodes.hasNext(); ) {
Node aceNode = aceNodes.nextNode();
String aceNodePath = aceNode.getPath();
assertFalse(testSession.nodeExists(aceNodePath));
for (PropertyIterator it = aceNode.getProperties(); it.hasNext(); ) {
assertFalse(testSession.propertyExists(it.nextProperty().getPath()));
}
}
}
use of javax.jcr.PathNotFoundException in project jackrabbit-oak by apache.
the class PropertyImpl method getNode.
@Override
@Nonnull
public Node getNode() throws RepositoryException {
return perform(new PropertyOperation<Node>(dlg, "getNode") {
@Nonnull
@Override
public Node perform() throws RepositoryException {
// TODO: avoid nested calls
Value value = getValue();
switch(value.getType()) {
case PropertyType.REFERENCE:
case PropertyType.WEAKREFERENCE:
return getSession().getNodeByIdentifier(value.getString());
case PropertyType.PATH:
case PropertyType.NAME:
String path = value.getString();
if (path.startsWith("[") && path.endsWith("]")) {
// identifier path
String identifier = path.substring(1, path.length() - 1);
return getSession().getNodeByIdentifier(identifier);
} else {
try {
return (path.charAt(0) == '/') ? getSession().getNode(path) : getParent().getNode(path);
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(path);
}
}
case PropertyType.STRING:
try {
Value refValue = ValueHelper.convert(value, PropertyType.REFERENCE, getValueFactory());
return getSession().getNodeByIdentifier(refValue.getString());
} catch (ItemNotFoundException e) {
throw e;
} catch (RepositoryException e) {
// try if STRING value can be interpreted as PATH value
Value pathValue = ValueHelper.convert(value, PropertyType.PATH, getValueFactory());
path = pathValue.getString();
try {
return (path.charAt(0) == '/') ? getSession().getNode(path) : getParent().getNode(path);
} catch (PathNotFoundException e1) {
throw new ItemNotFoundException(pathValue.getString());
}
}
default:
throw new ValueFormatException("Property value cannot be converted to a PATH, REFERENCE or WEAKREFERENCE");
}
}
});
}
Aggregations