use of javax.jcr.PathNotFoundException in project jackrabbit by apache.
the class SessionImpl method getImportContentHandler.
/**
* {@inheritDoc}
*/
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
// check sanity of this session
sanityCheck();
NodeImpl parent;
try {
Path p = getQPath(parentAbsPath).getNormalizedPath();
if (!p.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + parentAbsPath);
}
parent = getItemManager().getNode(p);
} catch (NameException e) {
String msg = parentAbsPath + ": invalid path";
log.debug(msg);
throw new RepositoryException(msg, e);
} catch (AccessDeniedException ade) {
throw new PathNotFoundException(parentAbsPath);
}
// verify that parent node is checked-out, not locked and not protected
// by either node type constraints nor by some retention or hold.
int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
context.getItemValidator().checkModify(parent, options, Permission.NONE);
SessionImporter importer = new SessionImporter(parent, this, uuidBehavior, context.getWorkspace().getConfig().getImportConfig());
return new ImportHandler(importer, this);
}
use of javax.jcr.PathNotFoundException in project jackrabbit by apache.
the class SessionTest method testMovePathNotFoundExceptionSrcInvalid.
/**
* Calls {@link javax.jcr.Session#move(String src, String dest)} with
* invalid source path.
* <p>
* Should throw a {@link javax.jcr.PathNotFoundException}.
*/
public void testMovePathNotFoundExceptionSrcInvalid() throws RepositoryException {
// get default workspace test root node using superuser session
Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
// create a node that will serve as new parent
Node destParentNode = defaultRootNode.addNode(nodeName3, testNodeType);
// save the new nodes
superuser.save();
// move the node
try {
superuser.move(defaultRootNode.getPath() + "/" + nodeName1, destParentNode.getPath() + "/" + nodeName2);
fail("Invalid source path during Session.move() must throw PathNotFoundException");
} catch (PathNotFoundException e) {
// ok. works as expected
}
}
use of javax.jcr.PathNotFoundException in project jackrabbit by apache.
the class HoldTest method testPropertyPath.
public void testPropertyPath() throws RepositoryException, NotExecutableException {
String propPath = null;
for (PropertyIterator it = testRootNode.getProperties(); it.hasNext(); ) {
String path = it.nextProperty().getPath();
if (!superuser.nodeExists(path)) {
propPath = path;
break;
}
}
if (propPath == null) {
throw new NotExecutableException();
}
try {
retentionMgr.getHolds(propPath);
fail("Accessing holds from non-existing node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// success
}
try {
retentionMgr.addHold(propPath, getHoldName(), true);
fail("Adding a hold for a non-existing node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// success
}
try {
Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
retentionMgr.removeHold(propPath, h);
fail("Removing a hold at a non-existing node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// success
}
}
use of javax.jcr.PathNotFoundException in project jackrabbit by apache.
the class UpdateTest method testUpdateAddsMissingSubtree.
public void testUpdateAddsMissingSubtree() throws RepositoryException, NotExecutableException {
String srcWorkspace = getAnotherWorkspace();
// get the root node in the second workspace
Session session2 = getHelper().getSuperuserSession(srcWorkspace);
try {
// make sure the source-session has the corresponding node.
Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
// create test node in second workspace
Node aNode2 = testRootW2.addNode(nodeName1, testNodeType);
aNode2.addNode(nodeName2, testNodeType);
aNode2.setProperty(propertyName2, "test");
Property p2 = testRootW2.setProperty(propertyName1, "test");
testRootW2.save();
// call the update method on test node in default workspace
testRootNode.update(srcWorkspace);
// ok check if the child has been added
boolean allPresent = testRootNode.hasNode(nodeName1) && testRootNode.hasNode(nodeName1 + "/" + nodeName2) && testRootNode.hasProperty(nodeName1 + "/" + propertyName2) && testRootNode.hasProperty(propertyName1);
assertTrue("Node updated with Node.update() should have received childrens", allPresent);
} catch (PathNotFoundException e) {
throw new NotExecutableException();
} catch (ItemNotFoundException e) {
throw new NotExecutableException();
} finally {
session2.logout();
}
}
use of javax.jcr.PathNotFoundException in project jackrabbit by apache.
the class UpdateTest method testUpdateRemovesExtraProperty.
public void testUpdateRemovesExtraProperty() throws RepositoryException, NotExecutableException {
// create test node in default workspace
testRootNode.setProperty(propertyName2, "test");
testRootNode.save();
String srcWorkspace = getAnotherWorkspace();
// get the root node in the second workspace
Session session2 = getHelper().getSuperuserSession(srcWorkspace);
try {
// make sure the source-session has the corresponding node.
Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
if (testRootW2.hasProperty(propertyName2)) {
throw new NotExecutableException();
}
// call the update method on test node in default workspace
testRootNode.update(srcWorkspace);
// ok first check if node has no longer properties
assertFalse("Node updated with Node.update() should have property removed", testRootNode.hasProperty(propertyName2));
} catch (PathNotFoundException e) {
throw new NotExecutableException();
} catch (ItemNotFoundException e) {
throw new NotExecutableException();
} finally {
session2.logout();
}
}
Aggregations