[dna-commits] DNA SVN: r818 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
dna-commits at lists.jboss.org
dna-commits at lists.jboss.org
Mon Apr 13 15:27:37 EDT 2009
Author: rhauch
Date: 2009-04-13 15:27:37 -0400 (Mon, 13 Apr 2009)
New Revision: 818
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
Log:
DNA-349 AbstractJcrNode.addNode Does Not Add jcr:uuid Property if Primary Type Extends mix:referenceable
Applied the patch, whic correctly adds the "jcr:uuid" property now.
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-13 19:23:31 UTC (rev 817)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-04-13 19:27:37 UTC (rev 818)
@@ -881,6 +881,27 @@
Property primaryTypeProp = propertyFactory.create(JcrLexicon.PRIMARY_TYPE, primaryTypeName);
Property nodeDefinitionProp = propertyFactory.create(DnaLexicon.NODE_DEFINITON, definition.getId().getString());
+ // Now add the "jcr:uuid" property if and only if referenceable ...
+ if (primaryType.isNodeType(JcrMixLexicon.REFERENCEABLE)) {
+ if (desiredUuid == null) {
+ desiredUuid = UUID.randomUUID();
+ }
+
+ // We know that this property is single-valued
+ JcrValue value = new JcrValue(factories(), SessionCache.this, PropertyType.STRING, desiredUuid.toString());
+ PropertyDefinition propertyDefinition = nodeTypes().findPropertyDefinition(primaryTypeName,
+ Collections.<Name>emptyList(),
+ JcrLexicon.UUID,
+ value,
+ false,
+ false);
+ PropertyId propId = new PropertyId(desiredUuid, JcrLexicon.UUID);
+ JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
+ org.jboss.dna.graph.property.Property uuidProperty = propertyFactory.create(JcrLexicon.UUID, desiredUuid);
+ PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), PropertyType.STRING, uuidProperty, defn.isMultiple());
+ properties.put(JcrLexicon.UUID, propInfo);
+ }
+
// Create the property info for the "jcr:primaryType" child property ...
JcrPropertyDefinition primaryTypeDefn = findBestPropertyDefintion(node.getPrimaryTypeName(),
node.getMixinTypeNames(),
More information about the dna-commits
mailing list