[dna-commits] DNA SVN: r796 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/property/basic and 1 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Apr 1 11:17:06 EDT 2009


Author: rhauch
Date: 2009-04-01 11:17:06 -0400 (Wed, 01 Apr 2009)
New Revision: 796

Modified:
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/GraphNamespaceRegistry.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java
Log:
DNA-337 Namespace Registries Create Two Nodes at /jcr:system/dna:namespaces

Applied the patch, which corrects this behavior by not storing the trivial mapping in the system view and adding code to explicitly create the dna:namespaces node if it is not already there.

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java	2009-03-24 22:33:26 UTC (rev 795)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java	2009-04-01 15:17:06 UTC (rev 796)
@@ -40,6 +40,7 @@
     public static final Name MERGE_PLAN = new BasicName(Namespace.URI, "mergePlan");
     public static final Name CLASSNAME = new BasicName(Namespace.URI, "classname");
     public static final Name CLASSPATH = new BasicName(Namespace.URI, "classpath");
+    public static final Name NAMESPACES = new BasicName(Namespace.URI, "namespaces");
     public static final Name PROJECTION_RULES = new BasicName(Namespace.URI, "projectionRules");
     public static final Name TIME_TO_EXPIRE = new BasicName(Namespace.URI, "timeToExpire");
     public static final Name NAMESPACE_URI = new BasicName(Namespace.URI, "uri");

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/GraphNamespaceRegistry.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/GraphNamespaceRegistry.java	2009-03-24 22:33:26 UTC (rev 795)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/GraphNamespaceRegistry.java	2009-04-01 15:17:06 UTC (rev 796)
@@ -32,6 +32,7 @@
 import org.jboss.dna.common.util.CheckArg;
 import org.jboss.dna.graph.DnaLexicon;
 import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.JcrLexicon;
 import org.jboss.dna.graph.Location;
 import org.jboss.dna.graph.Node;
 import org.jboss.dna.graph.Subgraph;
@@ -78,6 +79,7 @@
             }
         }
         this.namespaceProperties = Collections.unmodifiableList(properties);
+        createNamespaceParentIfNeeded();
         initializeCacheFromStore(cache);
 
         // Load in the namespaces from the execution context used by the store ...
@@ -86,6 +88,16 @@
         }
     }
 
+    private void createNamespaceParentIfNeeded() {
+        try {
+            this.store.getNodeAt(this.parentOfNamespaceNodes);
+        } catch (PathNotFoundException pnfe) {
+            // The node did not already exist - create it!
+            this.store.create(parentOfNamespaceNodes);
+            this.store.set(JcrLexicon.PRIMARY_TYPE).on(parentOfNamespaceNodes).to(DnaLexicon.NAMESPACES);
+        }
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -221,6 +233,9 @@
                     cache.register(prefix, uri);
                 }
             }
+
+            // Empty prefix to namespace mapping is built-in
+            cache.register("", "");
         } catch (PathNotFoundException e) {
             // Nothing to read
         }
@@ -297,6 +312,11 @@
         prefix = prefix.trim();
         uri = uri.trim();
 
+        // Empty prefix to namespace mapping is built in
+        if (prefix.length() == 0) {
+            return null;
+        }
+
         // Read the store ...
         String previousUri = null;
         ValueFactory<String> stringFactory = store.getContext().getValueFactories().getStringFactory();

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java	2009-03-24 22:33:26 UTC (rev 795)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java	2009-04-01 15:17:06 UTC (rev 796)
@@ -31,12 +31,9 @@
  */
 public class DnaLexicon extends org.jboss.dna.graph.DnaLexicon {
 
-    public static final Name NAMESPACES = new BasicName(Namespace.URI, "namespaces");
     public static final Name NAMESPACE = new BasicName(Namespace.URI, "namespace");
     public static final Name NODE_DEFINITON = new BasicName(Namespace.URI, "nodeDefinition");
     public static final Name ROOT = new BasicName(Namespace.URI, "root");
     public static final Name SYSTEM = new BasicName(Namespace.URI, "system");
     public static final Name URI = new BasicName(Namespace.URI, "uri");
-
-
 }




More information about the dna-commits mailing list