use of javax.jcr.ItemNotFoundException in project jackrabbit by apache.
the class NodeTest method testGetCorrespondingNodePathItemNotFoundException.
/**
* Calls {@link javax.jcr.Node#getCorrespondingNodePath(String)} on a node
* that has no corresponding node in second workspace
*/
public void testGetCorrespondingNodePathItemNotFoundException() throws RepositoryException, NotExecutableException {
// make sure the repository supports multiple workspaces
super.ensureMultipleWorkspacesSupported();
// get default workspace test root node using superuser session
Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
// create testNode in default workspace
Node defaultTestNode = defaultRootNode.addNode(nodeName1, testNodeType);
// save changes
superuser.save();
try {
// call the update method on test node in default workspace
defaultTestNode.getCorrespondingNodePath(workspaceName);
fail("Calling Node.getCorrespondingNodePath() on node that has no correspondend node should throw ItemNotFoundException");
} catch (ItemNotFoundException e) {
// ok, works as expected
}
}
use of javax.jcr.ItemNotFoundException in project jackrabbit by apache.
the class NodeReadMethodsTest method testGetPrimaryItemItemNotFoundException.
/**
* Test if getPrimaryItem does throw an ItemNotFoundException if the primary
* node type does not define a primary item. Therefor a node without a
* primary item is located recursively in the entire repository. A
* NotExecutableException is thrown when no such node is found.
*/
public void testGetPrimaryItemItemNotFoundException() throws NotExecutableException, RepositoryException {
Node node = locateNodeWithoutPrimaryItem(testRootNode);
if (node == null) {
throw new NotExecutableException("Workspace does not contain a node without primary item defined");
}
try {
node.getPrimaryItem();
fail("getPrimaryItem() must throw a ItemNotFoundException " + "if the primary node type does not define one");
} catch (ItemNotFoundException e) {
// success
}
}
use of javax.jcr.ItemNotFoundException in project jackrabbit by apache.
the class SessionImpl method getNodeById.
/**
* Retrieve the <code>Node</code> with the given id.
*
* @param id
* @return node with the given <code>NodeId</code>.
* @throws ItemNotFoundException if no such node exists or if this
* <code>Session</code> does not have permission to access the node.
* @throws RepositoryException
*/
private Node getNodeById(NodeId id) throws ItemNotFoundException, RepositoryException {
// check sanity of this session
checkIsAlive();
try {
NodeEntry nodeEntry = getHierarchyManager().getNodeEntry(id);
Item item = getItemManager().getItem(nodeEntry);
if (item.isNode()) {
return (Node) item;
} else {
log.error("NodeId '" + id + " does not point to a Node");
throw new ItemNotFoundException(LogUtil.saveGetIdString(id, getPathResolver()));
}
} catch (AccessDeniedException e) {
throw new ItemNotFoundException(LogUtil.saveGetIdString(id, getPathResolver()));
}
}
use of javax.jcr.ItemNotFoundException in project jackrabbit by apache.
the class NodeImpl method orderBefore.
/**
* @see Node#orderBefore(String, String)
*/
public synchronized void orderBefore(String srcChildRelPath, String destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException {
checkIsWritable();
if (!getPrimaryNodeType().hasOrderableChildNodes()) {
throw new UnsupportedRepositoryOperationException("Child node ordering not supported on node " + safeGetJCRPath());
}
// check arguments
if (srcChildRelPath.equals(destChildRelPath)) {
// there's nothing to do
return;
}
// check existence
if (!hasNode(srcChildRelPath)) {
throw new ItemNotFoundException("Node " + safeGetJCRPath() + " has no child node with name " + srcChildRelPath);
}
if (destChildRelPath != null && !hasNode(destChildRelPath)) {
throw new ItemNotFoundException("Node " + safeGetJCRPath() + " has no child node with name " + destChildRelPath);
}
Path srcPath = getReorderPath(srcChildRelPath);
Path beforePath = null;
if (destChildRelPath != null) {
beforePath = getReorderPath(destChildRelPath);
}
Operation op = ReorderNodes.create(getNodeState(), srcPath, beforePath);
session.getSessionItemStateManager().execute(op);
}
use of javax.jcr.ItemNotFoundException in project jackrabbit by apache.
the class NodeImpl method getProperty.
/**
* @see Node#getProperty(String)
*/
public Property getProperty(String relPath) throws PathNotFoundException, RepositoryException {
checkStatus();
PropertyEntry entry = resolveRelativePropertyPath(relPath);
if (entry == null) {
throw new PathNotFoundException(relPath);
}
try {
return (Property) getItemManager().getItem(entry);
} catch (AccessDeniedException e) {
throw new PathNotFoundException(relPath);
} catch (ItemNotFoundException e) {
throw new PathNotFoundException(relPath);
}
}
Aggregations