@Override public boolean isNew() { try { CachedNode node = node(); return node instanceof MutableCachedNode && ((MutableCachedNode)node).isNew(); } catch (RepositoryException e) { // continue by returning false, since the node probably doesn't exist anymore return false; } }
/** * Get the names of this node's mixin types. * * @return the mixin type names; never null but possibly empty * @throws ItemNotFoundException if this node no longer exists in the repository * @throws InvalidItemStateException if the node has been removed in this session's transient state */ Set<Name> getMixinTypeNames() throws ItemNotFoundException, InvalidItemStateException { return node().getMixinTypes(sessionCache()); }
/** * Get the name of this node's primary type. * * @return the primary type name * @throws ItemNotFoundException if this node no longer exists in the repository * @throws InvalidItemStateException if the node has been removed in this session's transient state */ Name getPrimaryTypeName() throws ItemNotFoundException, InvalidItemStateException { return node().getPrimaryType(sessionCache()); }
/** * Get the name of this node's primary type. * * @return the primary type name * @throws ItemNotFoundException if this node no longer exists in the repository * @throws InvalidItemStateException if the node has been removed in this session's transient state */ Name getPrimaryTypeName() throws ItemNotFoundException, InvalidItemStateException { return node().getPrimaryType(sessionCache()); }
@Override public void refresh( boolean keepChanges ) throws RepositoryException { CachedNode node = node(); // TCK: this should throw an exception if the node has been removed if (!keepChanges) { session.cache().clear(node); } }
/** * Get the names of this node's mixin types. * * @return the mixin type names; never null but possibly empty * @throws ItemNotFoundException if this node no longer exists in the repository * @throws InvalidItemStateException if the node has been removed in this session's transient state */ Set<Name> getMixinTypeNames() throws ItemNotFoundException, InvalidItemStateException { return node().getMixinTypes(sessionCache()); }
/** * Get the number of shared nodes within this shared set. * * @return the number of shared nodes; always 1 or more * @throws RepositoryException if there's a problem getting the size */ public int getSize() throws RepositoryException { final SessionCache cache = session().cache(); Set<NodeKey> additionalParents = shareableNode.node().getAdditionalParentKeys(cache); return additionalParents.size() + 1; }
@Override public NodeType[] getMixinNodeTypes() throws RepositoryException { checkSession(); JcrNodeTypeManager nodeTypeManager = session().nodeTypeManager(); List<NodeType> mixinNodeTypes = new LinkedList<NodeType>(); for (Name mixinTypeName : node().getMixinTypes(sessionCache())) { NodeType nodeType = nodeTypeManager.getNodeType(mixinTypeName); if (nodeType != null) mixinNodeTypes.add(nodeType); } return mixinNodeTypes.toArray(new NodeType[mixinNodeTypes.size()]); }
/** * Get the total number of children. * * @return the total number of children * @throws RepositoryException */ protected final long childCount() throws RepositoryException { return node().getChildReferences(sessionCache()).size(); }
@Override public PropertyIterator getProperties() throws RepositoryException { checkSession(); Iterator<Property> iter = node().getProperties(sessionCache()); return new JcrPropertyIterator(findJcrProperties(iter)); }
boolean isReferenceable() throws RepositoryException { SessionCache cache = sessionCache(); NodeTypes nodeTypes = session().nodeTypes(); try { CachedNode node = node(); return nodeTypes.isReferenceable(node.getPrimaryType(cache), node.getMixinTypes(cache)); } catch (ItemNotFoundException e) { // The node has been removed, so do nothing } return false; }
@Override public JcrNodeType getPrimaryNodeType() throws RepositoryException { checkSession(); return session().nodeTypeManager().getNodeType(node().getPrimaryType(sessionCache())); }
@Override protected Segment segment() throws RepositoryException { AbstractJcrNode parent = parent(); CachedNode node = parent.node(); SessionCache cache = session.cache(); ChildReference childRef = node.getChildReferences(cache).getChild(sharedSet.key()); return childRef.getSegment(); } }
@Override public JcrNodeType getPrimaryNodeType() throws RepositoryException { checkSession(); return session().nodeTypeManager().getNodeType(node().getPrimaryType(sessionCache())); }
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; }
protected NodeIterator getNodesInternal() throws RepositoryException { ChildReferences childReferences = node().getChildReferences(sessionCache()); if (childReferences.isEmpty()) return JcrEmptyNodeIterator.INSTANCE; return new JcrChildNodeIterator(new ChildNodeResolver(session, key(), false), childReferences); }
@Override Path path() throws ItemNotFoundException, InvalidItemStateException { AbstractJcrNode parent = parent(); CachedNode node = parent.node(); SessionCache cache = session.cache(); ChildReference childRef = node.getChildReferences(cache).getChild(sharedSet.key()); Path parentPath = parent.path(); return session().pathFactory().create(parentPath, childRef.getSegment()); }
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()); }
@Override public NodeIterator getNodes() throws RepositoryException { checkSession(); ChildReferences childReferences = node().getChildReferences(sessionCache()); if (childReferences.isEmpty()) return JcrEmptyNodeIterator.INSTANCE; // if we don't require permission checking, we should use the child references directly since it may have precomputed the size return session.checkPermissionsWhenIteratingChildren() ? new JcrChildNodeIterator(new ChildNodeResolver(session, key()), childReferences.iterator()) : new JcrChildNodeIterator(new ChildNodeResolver(session, key()), childReferences); }
private void assertUniqueChildren( JcrSession session, String nodeAbsPath, Set<String> names ) throws RepositoryException { ChildReferences childReferences = session.getNode(nodeAbsPath).node().getChildReferences(session.cache()); for (String name : names) { assertEquals(1, childReferences.getChildCount(session.nameFactory().create(name))); } }