/** * Obtain the {@link Node JCR Node} object for the node with the supplied key. * * @param cachedNode the cached node; may not be null * @param expectedType the expected implementation type for the node, or null if it is not known * @return the JCR node; never null * @see #node(CachedNode, Type, NodeKey) */ AbstractJcrNode node( CachedNode cachedNode, AbstractJcrNode.Type expectedType ) { return node(cachedNode, expectedType, null); }
/** * Obtain the {@link Node JCR Node} object for the node with the supplied key. * * @param cachedNode the cached node; may not be null * @param expectedType the expected implementation type for the node, or null if it is not known * @return the JCR node; never null * @see #node(CachedNode, Type, NodeKey) */ AbstractJcrNode node( CachedNode cachedNode, AbstractJcrNode.Type expectedType ) { return node(cachedNode, expectedType, null); }
/** * Obtain the {@link Node JCR Node} object for the node with the supplied key. * * @param nodeKey the node's key * @param expectedType the expected implementation type for the node, or null if it is not known * @return the JCR node; never null * @throws ItemNotFoundException if there is no node with the supplied key */ AbstractJcrNode node( NodeKey nodeKey, AbstractJcrNode.Type expectedType ) throws ItemNotFoundException { return node(nodeKey, expectedType, null); }
@Override public boolean hasNext() { while (nextNode == null && keyIter.hasNext()) { NodeKey key = keyIter.next(); try { nextNode = session.node(key, expectedType); } catch (ItemNotFoundException e) { // Might have been removed from the session, so just skip this ... } } return nextNode != null; }
@Override public Lock lock( String absPath, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerInfo ) throws LockException, PathNotFoundException, AccessDeniedException, InvalidItemStateException, RepositoryException { AbstractJcrNode node = session.node(session.absolutePathFor(absPath)); return lock(node, isDeep, isSessionScoped, timeoutHint, ownerInfo); }
@Override public void unlock( String absPath ) throws PathNotFoundException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException { AbstractJcrNode node = session.node(session.absolutePathFor(absPath)); unlock(node); }
@Override public boolean holdsLock( String absPath ) throws PathNotFoundException, RepositoryException { AbstractJcrNode node = session.node(session.absolutePathFor(absPath)); return lockManager.findLockFor(node.key()) != null; }
@Override public boolean nodeExists( String absPath ) throws RepositoryException { // This is an optimized version of 'getNode(absPath)' ... checkLive(); CheckArg.isNotEmpty(absPath, "absPath"); Path absolutePath = absolutePathFor(absPath); try { return node(absolutePath) != null; } catch (PathNotFoundException e) { return false; } }
private final JcrVersionNode getFirstNodeForProperty( Name propertyName ) throws RepositoryException { assert JcrLexicon.SUCCESSORS.equals(propertyName) || JcrLexicon.PREDECESSORS.equals(propertyName); Property references = getProperty(propertyName); if (references == null) return null; Value[] values = references.getValues(); if (values.length == 0) return null; NodeKey key = ((NodeKeyReference) ((JcrValue)values[0]).value()).getNodeKey(); AbstractJcrNode node = session().node(key, null); return (JcrVersionNode)node; }
@Override public boolean nodeExists( String absPath ) throws RepositoryException { // This is an optimized version of 'getNode(absPath)' ... checkLive(); CheckArg.isNotEmpty(absPath, "absPath"); Path absolutePath = absolutePathFor(absPath); try { return node(absolutePath) != null; } catch (PathNotFoundException e) { return false; } }
@Override public boolean holdsLock( String absPath ) throws PathNotFoundException, RepositoryException { AbstractJcrNode node = session.node(session.absolutePathFor(absPath)); return lockManager.findLockFor(node.key()) != null; }
final AbstractJcrNode node( CachedNode node, Path path ) throws PathNotFoundException, AccessDeniedException, RepositoryException { CachedNode child = cachedNode(cache, node, path, ModeShapePermissions.READ); AbstractJcrNode result = node(child, (Type)null, null); if (result.isShareable()) { // Find the shared node with the desired path ... AbstractJcrNode atOrBelow = result.sharedSet().getSharedNodeAtOrBelow(path); if (atOrBelow != null) result = atOrBelow; } return result; }
protected boolean isReadonlyPath( Path path, JcrSession session ) throws RepositoryException { AbstractJcrNode node = session.node(path); Connector connector = getConnectorForSourceKey(node.key().getSourceKey()); return connector != null && connector.isReadonly(); }
@Override public AbstractJcrNode getParent() throws ItemNotFoundException, RepositoryException { checkSession(); NodeKey parentKey = node().getParentKey(sessionCache()); return session().node(parentKey, null); }
final AbstractJcrNode node( Path absolutePath ) throws PathNotFoundException, AccessDeniedException, RepositoryException { assert absolutePath.isAbsolute(); if (absolutePath.isRoot()) return getRootNode(); if (absolutePath.isIdentifier()) { // Look up the node by identifier ... String identifierString = stringFactory().create(absolutePath).replaceAll("\\[", "").replaceAll("\\]", ""); return getNodeByIdentifier(identifierString); } CachedNode node = getRootNode().node(); return node(node, absolutePath); }
final AbstractJcrNode node( Path absolutePath ) throws PathNotFoundException, AccessDeniedException, RepositoryException { assert absolutePath.isAbsolute(); if (absolutePath.isRoot()) return getRootNode(); if (absolutePath.isIdentifier()) { // Look up the node by identifier ... String identifierString = stringFactory().create(absolutePath).replaceAll("\\[", "").replaceAll("\\]", ""); return getNodeByIdentifier(identifierString); } CachedNode node = getRootNode().node(); return node(node, absolutePath); }
@Override public Lock getLock( String absPath ) throws PathNotFoundException, LockException, AccessDeniedException, RepositoryException { ModeShapeLock lock = getLowestLockAlongPath(session.node(session.absolutePathFor(absPath)), false); if (lock != null) return lock.lockFor(session); throw new LockException(JcrI18n.notLocked.text(absPath)); }
protected AbstractJcrNode getNodeIfExists( Name childName ) throws RepositoryException { // It's just a name, so look for a child ... ChildReference ref = node().getChildReferences(sessionCache()).getChild(childName); return ref != null ? session().node(ref.getKey(), null, key()) : null; }
AbstractJcrNode getNode( Name childName ) throws PathNotFoundException, RepositoryException { // It's just a name, so look for a child ... ChildReference ref = node().getChildReferences(sessionCache()).getChild(childName); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(childName), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), null, key()); }
@Test public void shouldUseJcrCardinalityPerPropertyDefinition() throws Exception { initializeData(); // Verify that the node does exist in the source ... Path pathToNode = session.context().getValueFactories().getPathFactory().create("/a/b"); Node carsNode = session.node(pathToNode); String mixinTypesName = JcrLexicon.MIXIN_TYPES.getString(session.context().getNamespaceRegistry()); Property mixinTypes = carsNode.getProperty(mixinTypesName); // Check that the JCR property is a MultiProperty - this call will throw an exception if the property is not. mixinTypes.getValues(); }