[dna-commits] DNA SVN: r865 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
dna-commits at lists.jboss.org
dna-commits at lists.jboss.org
Wed Apr 29 10:31:50 EDT 2009
Author: rhauch
Date: 2009-04-29 10:31:49 -0400 (Wed, 29 Apr 2009)
New Revision: 865
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
Log:
DNA-376 Add request to change the order of a child node (or nodes) relative to the other children
Added a partial implementation of the AbstractJcrNode.orderBefore(...) method, though this partial implementation is never reached because the method still throws an UnsupportedOperationException. This partial implementation should be completed when the Graph API has support for reordering children.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2009-04-29 14:23:58 UTC (rev 864)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2009-04-29 14:31:49 UTC (rev 865)
@@ -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;
@@ -1437,8 +1438,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<Object> createPatternsFor( String namePattern ) throws RepositoryException {
More information about the dna-commits
mailing list