protected void exporting( Node node ) throws RepositoryException { if (node instanceof AbstractJcrNode) { AbstractJcrNode jcrNode = (AbstractJcrNode)node; if (jcrNode.isShareable()) { shareableNodes.add(jcrNode.key()); } } }
/** * Get the {@link SharedSet} for the given shareable node. * * @param shareableNode the shareable node * @return the SharedSet; never null */ public SharedSet getSharedSet( AbstractJcrNode shareableNode ) { NodeKey shareableNodeKey = shareableNode.key(); return sharedSets.computeIfAbsent(shareableNodeKey, key -> new SharedSet(shareableNode)); }
/** * Checks if this node is foreign for its current owning session * * @return boolean if this node is considered "foreign" to this session, or false otherwise * @see JcrSession#isForeignKey(org.modeshape.jcr.cache.NodeKey) */ protected final boolean isForeign() { return session().isForeignKey(key()); }
@Override public boolean isSame( Item otherItem ) throws RepositoryException { if (otherItem == this) return true; if (otherItem instanceof AbstractJcrNode) { NodeKey thatKey = ((AbstractJcrNode)otherItem).key(); if (!this.key.equals(thatKey)) return false; // Make sure they are the same repository ... return super.isSameRepository(otherItem); } return false; }
/** * Checks if this node is foreign for its current owning session * * @return boolean if this node is considered "foreign" to this session, or false otherwise * @see JcrSession#isForeignKey(org.modeshape.jcr.cache.NodeKey) */ protected final boolean isForeign() { return session().isForeignKey(key()); }
@Override public boolean isSame( Item otherItem ) throws RepositoryException { if (otherItem == this) return true; if (otherItem instanceof AbstractJcrNode) { NodeKey thatKey = ((AbstractJcrNode)otherItem).key(); if (!this.key.equals(thatKey)) return false; // Make sure they are the same repository ... return super.isSameRepository(otherItem); } return false; }
@Override public boolean holdsLock( String absPath ) throws PathNotFoundException, RepositoryException { AbstractJcrNode node = session.node(session.absolutePathFor(absPath)); return lockManager.findLockFor(node.key()) != null; }
/** * Checks if this node belongs to an external source. * * @return true if the node is not repository-local */ protected final boolean isExternal() { return !key().getSourceKey().equals(session().cache().getRootKey().getSourceKey()); }
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 JcrValue createSimpleReference( Node node ) throws RepositoryException { AbstractJcrNode abstractJcrNode = validateReferenceableNode(node); Reference ref = valueFactories.getSimpleReferenceFactory().create(abstractJcrNode.key(), abstractJcrNode.isForeign()); return new JcrValue(valueFactories, org.modeshape.jcr.api.PropertyType.SIMPLE_REFERENCE, ref); }
@Override public JcrValue createSimpleReference( Node node ) throws RepositoryException { AbstractJcrNode abstractJcrNode = validateReferenceableNode(node); Reference ref = valueFactories.getSimpleReferenceFactory().create(abstractJcrNode.key(), abstractJcrNode.isForeign()); return new JcrValue(valueFactories, org.modeshape.jcr.api.PropertyType.SIMPLE_REFERENCE, ref); }
@Override public JcrValue createValue( Node value ) throws RepositoryException { if (value == null) { return new JcrValue(valueFactories, PropertyType.REFERENCE, null); } AbstractJcrNode node = validateReferenceableNode(value); Reference ref = valueFactories.getReferenceFactory().create(node.key(), node.isForeign()); return new JcrValue(valueFactories, PropertyType.REFERENCE, ref); }
@Override public JcrValue createValue( Node value ) throws RepositoryException { if (value == null) { return new JcrValue(valueFactories, PropertyType.REFERENCE, null); } AbstractJcrNode node = validateReferenceableNode(value); Reference ref = valueFactories.getReferenceFactory().create(node.key(), node.isForeign()); return new JcrValue(valueFactories, PropertyType.REFERENCE, ref); }
@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); }
@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); }
@Override public JcrValue createValue( Node value, boolean weak ) throws RepositoryException { if (value == null) { return new JcrValue(valueFactories, weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE, null); } AbstractJcrNode node = validateReferenceableNode(value); ReferenceFactory factory = weak ? valueFactories.getWeakReferenceFactory() : valueFactories.getReferenceFactory(); int refType = weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE; Reference ref = factory.create(node.key(), node.isForeign()); return new JcrValue(valueFactories, refType, ref); }
@Override public JcrValue createValue( Node value, boolean weak ) throws RepositoryException { if (value == null) { return new JcrValue(valueFactories, weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE, null); } AbstractJcrNode node = validateReferenceableNode(value); ReferenceFactory factory = weak ? valueFactories.getWeakReferenceFactory() : valueFactories.getReferenceFactory(); int refType = weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE; Reference ref = factory.create(node.key(), node.isForeign()); return new JcrValue(valueFactories, refType, ref); }
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); }
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()); }