[dna-commits] DNA SVN: r831 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Apr 16 10:11:21 EDT 2009


Author: rhauch
Date: 2009-04-16 10:11:21 -0400 (Thu, 16 Apr 2009)
New Revision: 831

Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrBuiltinNodeTypeSource.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
Log:
DNA-357 Hide dna:nodeDefinition Property from Users

Applied both patches.  The first hides the "dna:nodeDefinition" property from the JCR layer (meaning it might exist in the graph layer, but won't appear as properties of JCR nodes).  The second patch adds to "nt:base" a property definition for a "dna:nodeDefinition" property that is protected and not mandatory (nor autocreated).  The spec is not clear as to whether a JCR implementation can add properties to "nt:base" (the required supertype of all node types), the spec is clear that an implementation can add properties to any of the built-in node types through mixins.  Therefore, the second patch actually adds this new definition to "nt:base" by having "nt:base" extend the new "dna:defined" mixin, which has the new "dna:nodeDefinition" property definition.  

Because the "dna:nodeDefinition" is protected, JCR clients will not be allowed to define another property with this name, nor will they be able to set the property (using a residual definition) to any value.  All this validation is done through the normal process, requiring no code specific to "dna:nodeDefinition".  Nicely done!

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-04-16 13:58:49 UTC (rev 830)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java	2009-04-16 14:11:21 UTC (rev 831)
@@ -31,6 +31,7 @@
  */
 public class DnaLexicon extends org.jboss.dna.graph.DnaLexicon {
 
+    public static final Name DEFINED = new BasicName(Namespace.URI, "defined");
     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 NODE_TYPES = new BasicName(Namespace.URI, "nodeTypes");

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrBuiltinNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrBuiltinNodeTypeSource.java	2009-04-16 13:58:49 UTC (rev 830)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrBuiltinNodeTypeSource.java	2009-04-16 14:11:21 UTC (rev 831)
@@ -57,8 +57,28 @@
         // Value trueValue = new JcrValue(context.getValueFactories(), null, PropertyType.BOOLEAN, Boolean.TRUE);
         Value ntBaseValue = new JcrValue(context.getValueFactories(), null, PropertyType.NAME, JcrNtLexicon.BASE);
 
+        JcrNodeType defined = new JcrNodeType(
+                                                    context,
+                                                    NO_NODE_TYPE_MANAGER,
+                                                    DnaLexicon.DEFINED,
+                                                    NO_SUPERTYPES,
+                                                    DnaLexicon.NODE_DEFINITON,
+                                                    NO_CHILD_NODES,
+                                                    Arrays.asList(new JcrPropertyDefinition[] {new JcrPropertyDefinition(
+                                                                                                                         context,
+                                                                                                                         null,
+                                                                                                                         DnaLexicon.NODE_DEFINITON,
+                                                                                                                         OnParentVersionBehavior.INITIALIZE.getJcrValue(),
+                                                                                                                         false,
+                                                                                                                         false,
+                                                                                                                         true,
+                                                                                                                         NO_DEFAULT_VALUES,
+                                                                                                                         PropertyType.STRING,
+                                                                                                                         NO_CONSTRAINTS,
+                                                                                                                         false),}),
+                                                    IS_A_MIXIN, UNORDERABLE_CHILD_NODES);
         // Stubbing in child node and property definitions for now
-        JcrNodeType base = new JcrNodeType(context, NO_NODE_TYPE_MANAGER, JcrNtLexicon.BASE, NO_SUPERTYPES, NO_PRIMARY_ITEM_NAME,
+        JcrNodeType base = new JcrNodeType(context, NO_NODE_TYPE_MANAGER, JcrNtLexicon.BASE, Arrays.asList(new JcrNodeType[] {defined}), NO_PRIMARY_ITEM_NAME,
                                            NO_CHILD_NODES, Arrays.asList(new JcrPropertyDefinition[] {
                                                new JcrPropertyDefinition(context, null, JcrLexicon.PRIMARY_TYPE,
                                                                          OnParentVersionBehavior.COMPUTE.getJcrValue(), true,
@@ -565,7 +585,7 @@
         // NOT_MIXIN, UNORDERABLE_CHILD_NODES);
 
         // Disabling version-related types until DNA supports versioning, as per section 4.11 of the 1.0.1 specification
-        nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {base, unstructured, childNodeDefinition, file, folder, frozenNode,
+        nodeTypes.addAll(Arrays.asList(new JcrNodeType[] {defined, base, unstructured, childNodeDefinition, file, folder, frozenNode,
             hierarchyNode, linkedFile, nodeType, propertyDefinition, query, resource, nodeType /*, version, versionHistory,
                    versionLabels, versionedChild */}));
 

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java	2009-04-16 13:58:49 UTC (rev 830)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java	2009-04-16 14:11:21 UTC (rev 831)
@@ -401,6 +401,8 @@
         PropertyInfo info = findPropertyInfo(propertyId); // throws PathNotFoundException if node not there
         if (info == null) return null; // no such property on this node
 
+        if (DnaLexicon.NODE_DEFINITON.equals(info.getPropertyName())) return null;
+        
         // Now create the appropriate JCR Property object ...
         return createAndCacheJcrPropertyFor(info);
     }
@@ -411,7 +413,9 @@
         Set<Name> propertyNames = info.getPropertyNames();
         Collection<AbstractJcrProperty> result = new ArrayList<AbstractJcrProperty>(propertyNames.size());
         for (Name propertyName : propertyNames) {
-            result.add(findJcrProperty(new PropertyId(nodeUuid, propertyName)));
+            if (!DnaLexicon.NODE_DEFINITON.equals(propertyName)) {
+                result.add(findJcrProperty(new PropertyId(nodeUuid, propertyName)));
+            }
         }
         return result;
     }




More information about the dna-commits mailing list