Index: dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java =================================================================== --- dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java (revision 860) +++ dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java (working copy) @@ -69,6 +69,7 @@ import org.jboss.dna.graph.property.Name; import org.jboss.dna.graph.property.NamespaceRegistry; import org.jboss.dna.graph.property.Path; +import org.jboss.dna.graph.property.PathFactory; import org.jboss.dna.graph.property.ValueFactories; import org.jboss.dna.jcr.SessionCache.NodeEditor; import org.jboss.dna.jcr.cache.ChildNode; @@ -241,7 +242,6 @@ /** * {@inheritDoc} * - * @throws UnsupportedOperationException always * @see javax.jcr.Node#getPrimaryNodeType() */ public JcrNodeType getPrimaryNodeType() throws RepositoryException { @@ -256,7 +256,6 @@ /** * {@inheritDoc} * - * @throws UnsupportedOperationException always * @see javax.jcr.Node#getMixinNodeTypes() */ public NodeType[] getMixinNodeTypes() throws RepositoryException { @@ -422,6 +421,8 @@ * @see javax.jcr.Node#getReferences() */ public final PropertyIterator getReferences() throws RepositoryException { + if (true) throw new UnsupportedOperationException(); + // This implementation is just wrong. // Iterate through the properties to see which ones have a REFERENCE type ... Collection properties = cache.findJcrPropertiesFor(nodeUuid); Collection references = new LinkedList(); @@ -564,7 +565,6 @@ /** * {@inheritDoc} * - * @throws UnsupportedOperationException always * @see javax.jcr.Node#getNodes(java.lang.String) */ public NodeIterator getNodes( String namePattern ) throws RepositoryException { @@ -1439,8 +1439,44 @@ * @see javax.jcr.Node#orderBefore(java.lang.String, java.lang.String) */ public final void orderBefore( String srcChildRelPath, - String destChildRelPath ) throws UnsupportedRepositoryOperationException { - throw new UnsupportedRepositoryOperationException(); + String destChildRelPath ) throws UnsupportedRepositoryOperationException, RepositoryException { + if (true) throw new UnsupportedRepositoryOperationException(); + + // This implementation is correct, except for not calling the SessionCache or graph layer to do the re-order + if (!getPrimaryNodeType().hasOrderableChildNodes()) { + throw new UnsupportedRepositoryOperationException(); + } + + PathFactory pathFactory = this.cache.pathFactory(); + + Path srcPath = pathFactory.create(srcChildRelPath); + ChildNode source; + + if (srcPath.isAbsolute() || srcPath.size() != 1) { + throw new ItemNotFoundException(); + } + // getLastSegment should return the only segment, since we verified that size() == 1 + source = nodeInfo().getChildren().getChild(srcPath.getLastSegment()); + if (source == null) { + throw new ItemNotFoundException(); + } + + Path destPath = null; + ChildNode destination = null; + + if (destChildRelPath != null) { + destPath = pathFactory.create(destChildRelPath); + if (destPath.isAbsolute() || destPath.size() != 1) { + throw new ItemNotFoundException(); + } + + // getLastSegment should return the only segment, since we verified that size() == 1 + destination = nodeInfo().getChildren().getChild(destPath.getLastSegment()); + if (destination == null) { + throw new ItemNotFoundException(); + } + } + } protected static List createPatternsFor( String namePattern ) throws RepositoryException {