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

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Sep 17 16:13:39 EDT 2008


Author: jverhaeg at redhat.com
Date: 2008-09-17 16:13:39 -0400 (Wed, 17 Sep 2008)
New Revision: 529

Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
Log:
Modified populateNode method to not filter out UUID properties from the properties within a JCR node.

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java	2008-09-17 20:11:01 UTC (rev 528)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java	2008-09-17 20:13:39 UTC (rev 529)
@@ -528,22 +528,35 @@
         Set<Property> properties = new HashSet<Property>();
         UUID uuid = null;
         Name jcrUuidName = executionContext.getValueFactories().getNameFactory().create("jcr:uuid");
+        Name jcrMixinTypesName = executionContext.getValueFactories().getNameFactory().create("jcr:mixinTypes");
         UuidFactory uuidFactory = executionContext.getValueFactories().getUuidFactory();
+        org.jboss.dna.spi.graph.Property dnaUuidProp = null;
+        boolean referenceable = false;
         for (org.jboss.dna.spi.graph.Property dnaProp : getNodeCommand.getProperties()) {
             Name name = dnaProp.getName();
-            if (uuid == null && DnaLexicon.UUID.equals(name)) uuid = uuidFactory.create(dnaProp.getValues()).next();
-            else if (dnaProp.isMultiple()) properties.add(new JcrMultiValueProperty(node, executionContext, name, dnaProp));
+            if (dnaProp.isMultiple()) properties.add(new JcrMultiValueProperty(node, executionContext, name, dnaProp));
             else {
-                if (jcrUuidName.equals(name)) {
-                    uuid = uuidFactory.create(dnaProp.getValues()).next();
-                    nodesByJcrUuid.put(uuid.toString(), new WeakReference<Node>(node));
-                } else properties.add(new JcrProperty(node, executionContext, name, dnaProp.getValues().next()));
+                if (uuid == null && DnaLexicon.UUID.equals(name)) uuid = uuidFactory.create(dnaProp.getValues()).next();
+                else if (jcrUuidName.equals(name)) dnaUuidProp = dnaProp;
+                else if (jcrMixinTypesName.equals(name)) {
+                    org.jboss.dna.spi.graph.ValueFactory<String> stringFactory = executionContext.getValueFactories().getStringFactory();
+                    for (String mixin : stringFactory.create(dnaProp)) {
+                        if ("mix:referenceable".equals(mixin)) referenceable = true;
+                    }
+                }
+                properties.add(new JcrProperty(node, executionContext, name, dnaProp.getValues().next()));
             }
 
         }
         node.setProperties(properties);
         // Set node's UUID, creating one if necessary
-        if (uuid == null) uuid = UUID.randomUUID();
+        if (uuid == null) {
+            if (dnaUuidProp == null || !referenceable) uuid = UUID.randomUUID();
+            else {
+                uuid = uuidFactory.create(dnaUuidProp.getValues()).next();
+                nodesByJcrUuid.put(uuid.toString(), new WeakReference<Node>(node));
+            }
+        }
         node.setInternalUuid(uuid);
         // Setup node to be retrieved by DNA UUID
         nodesByUuid.put(new UUID(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits()), new WeakReference<Node>(node));




More information about the dna-commits mailing list