Author: rhauch
Date: 2009-03-11 15:13:08 -0400 (Wed, 11 Mar 2009)
New Revision: 771
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaBuiltinNodeTypeSource.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/test/resources/repositoryForTckTests.xml
Log:
DNA-296 JcrSession Sometimes Eschews Single-Valued Variants of PropertyDefinitions
Applied the patch that corrects the assignment of the PropertyDefinition to each Property
instance.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaBuiltinNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaBuiltinNodeTypeSource.java 2009-03-11
14:44:39 UTC (rev 770)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaBuiltinNodeTypeSource.java 2009-03-11
19:13:08 UTC (rev 771)
@@ -136,49 +136,10 @@
}), NO_PROPERTIES, NOT_MIXIN,
UNORDERABLE_CHILD_NODES);
- /* Name of node type that holds xmltext from document view import (see JCR 1.0
spec section 7.3.2) */
- JcrNodeType xmlText = new JcrNodeType(
- session,
- DnaLexicon.XML_TEXT,
- Arrays.asList(new NodeType[] {base}),
- NO_PRIMARY_ITEM_NAME,
- NO_CHILD_NODES,
- Arrays.asList(new JcrPropertyDefinition[]
{new JcrPropertyDefinition(
-
session,
-
null,
-
JcrLexicon.XMLCHARACTERS,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
true,
-
true,
-
true,
-
NO_DEFAULT_VALUES,
-
PropertyType.STRING,
-
NO_CONSTRAINTS,
-
false)}),
- NOT_MIXIN, UNORDERABLE_CHILD_NODES);
+
+ primaryNodeTypes.addAll(Arrays.asList(new JcrNodeType[] {root, system,
namespaces, namespace, }));
+ mixinNodeTypes.addAll(Arrays.asList(new JcrNodeType[] { }));
- /* Mixin type that indicates the node contains an xmltext node which holds
xmltext from document view import (see JCR 1.0 spec section 7.3.2) */
- JcrNodeType xmlContent = new JcrNodeType(
- session,
- DnaLexicon.XML_CONTENT,
- Arrays.asList(new NodeType[] {base}),
- NO_PRIMARY_ITEM_NAME,
- Arrays.asList(new JcrNodeDefinition[]
{new JcrNodeDefinition(
-
session,
-
null,
-
JcrLexicon.XMLTEXT,
-
OnParentVersionBehavior.VERSION.getJcrValue(),
-
false,
-
true,
-
false,
-
false,
-
DnaLexicon.XML_TEXT,
-
new NodeType[] {xmlText})}),
- NO_PROPERTIES, IS_A_MIXIN,
UNORDERABLE_CHILD_NODES);
-
- primaryNodeTypes.addAll(Arrays.asList(new JcrNodeType[] {root, system,
namespaces, namespace, xmlText,}));
- mixinNodeTypes.addAll(Arrays.asList(new JcrNodeType[] {xmlContent}));
-
}
/**
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-11 14:44:39 UTC
(rev 770)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaLexicon.java 2009-03-11 19:13:08 UTC
(rev 771)
@@ -38,17 +38,5 @@
public static final Name SYSTEM = new BasicName(Namespace.URI, "system");
public static final Name URI = new BasicName(Namespace.URI, "uri");
- /**
- * Mixin type that indicates the node contains an xmltext node which holds xmltext
from document view import (see JCR 1.0
- * specification section 7.3.2). This node has a child node named {@link
JcrLexicon#XMLTEXT} of type
- * {@link DnaLexicon#XML_TEXT}.
- */
- public static final Name XML_CONTENT = new BasicName(Namespace.URI,
"xmlContent");
- /**
- * Name of node type that holds xmltext from document view import (see JCR 1.0
specification section 7.3.2). It is defined in
- * the node type named {@link DnaLexicon#XML_CONTENT}.
- */
- public static final Name XML_TEXT = new BasicName(Namespace.URI,
"xmlText");
-
}
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 2009-03-11 14:44:39 UTC
(rev 770)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-03-11 19:13:08 UTC
(rev 771)
@@ -862,7 +862,12 @@
// Create JCR properties for corresponding DNA properties
// ------------------------------------------------------
// First get the property type for each property, based upon the primary type and
mixins ...
- Map<Name, PropertyDefinition> propertyDefinitionsByPropertyName = new
HashMap<Name, PropertyDefinition>();
+ // The map with single-valued properties...
+ Map<Name, PropertyDefinition> svPropertyDefinitionsByPropertyName = new
HashMap<Name, PropertyDefinition>();
+ // ... and the map with multi-valued properties
+ Map<Name, PropertyDefinition> mvPropertyDefinitionsByPropertyName = new
HashMap<Name, PropertyDefinition>();
+
+
boolean referenceable = false;
NamespaceRegistry registry = namespaces();
@@ -881,8 +886,15 @@
continue;
}
Name name = nameFactory.create(nameString);
- PropertyDefinition prev = propertyDefinitionsByPropertyName.put(name,
propertyDefn);
- if (prev != null) propertyDefinitionsByPropertyName.put(name, prev); // put
the first one back ...
+
+ if (propertyDefn.isMultiple()) {
+ PropertyDefinition prev = mvPropertyDefinitionsByPropertyName.put(name,
propertyDefn);
+ if (prev != null) mvPropertyDefinitionsByPropertyName.put(name, prev); //
put the first one back ...
+ }
+ else {
+ PropertyDefinition prev = svPropertyDefinitionsByPropertyName.put(name,
propertyDefn);
+ if (prev != null) svPropertyDefinitionsByPropertyName.put(name, prev); //
put the first one back ...
+ }
}
// The process the mixin types ...
org.jboss.dna.graph.property.Property mixinTypesProperty =
graphNode.getProperty(JcrLexicon.MIXIN_TYPES);
@@ -899,8 +911,14 @@
continue;
}
Name name = nameFactory.create(nameString);
- PropertyDefinition prev = propertyDefinitionsByPropertyName.put(name,
propertyDefn);
- if (prev != null) propertyDefinitionsByPropertyName.put(name, prev);
// put the first one back ...
+ if (propertyDefn.isMultiple()) {
+ PropertyDefinition prev =
mvPropertyDefinitionsByPropertyName.put(name, propertyDefn);
+ if (prev != null) mvPropertyDefinitionsByPropertyName.put(name,
prev); // put the first one back ...
+ }
+ else {
+ PropertyDefinition prev =
svPropertyDefinitionsByPropertyName.put(name, propertyDefn);
+ if (prev != null) svPropertyDefinitionsByPropertyName.put(name,
prev); // put the first one back ...
+ }
}
}
}
@@ -908,7 +926,8 @@
// Now create the JCR property object wrapper around the "jcr:uuid"
property ...
Map<Name, Property> properties = new HashMap<Name, Property>();
if (referenceable) {
- PropertyDefinition propertyDefinition =
propertyDefinitionsByPropertyName.get(JcrLexicon.UUID);
+ // We know that this property is single-valued
+ PropertyDefinition propertyDefinition =
svPropertyDefinitionsByPropertyName.get(JcrLexicon.UUID);
properties.put(JcrLexicon.UUID, new JcrSingleValueProperty(node,
propertyDefinition, PropertyType.STRING,
uuidProperty));
}
@@ -921,25 +940,35 @@
if (JcrLexicon.UUID.equals(name) || DnaLexicon.UUID.equals(name)) continue;
// Figure out the JCR property type for this property ...
- PropertyDefinition propertyDefinition =
propertyDefinitionsByPropertyName.get(name);
+ PropertyDefinition propertyDefinition;
+
+ if (dnaProp.isMultiple()) {
+ propertyDefinition = mvPropertyDefinitionsByPropertyName.get(name);
+ }
+ else {
+ propertyDefinition = svPropertyDefinitionsByPropertyName.get(name);
+
+ // If the property has only one value, dnaProp.isMultiple() will return
false, but the
+ // property may actually be a multi-valued property that happens to have
one property set.
+ if (propertyDefinition == null) {
+ propertyDefinition = mvPropertyDefinitionsByPropertyName.get(name);
+ }
+ }
// If no property type was found for this property, see if there is a
wildcard property ...
- if (propertyDefinition == null && !anyPropertyDefinitions.isEmpty())
{
- Iterator<PropertyDefinition> iter =
anyPropertyDefinitions.iterator();
- propertyDefinition = iter.next(); // use the first one by default ...
- if (iter.hasNext()) {
- // Look for a better one if not multiple but the property has
multiple values ...
- if (!propertyDefinition.isMultiple() && dnaProp.isMultiple())
{
- while (iter.hasNext()) {
- PropertyDefinition next = iter.next();
- if (next.isMultiple()) {
- propertyDefinition = next;
- break;
- }
- }
+ if (propertyDefinition == null) {
+ for (Iterator<PropertyDefinition> iter =
anyPropertyDefinitions.iterator(); iter.hasNext(); ) {
+ PropertyDefinition nextDef = iter.next();
+
+ // Grab the first residual definition that matches on cardinality
(single-valued vs. multi-valued)
+ if ((nextDef.isMultiple() && dnaProp.isMultiple())
+ || (!nextDef.isMultiple() && !dnaProp.isMultiple())) {
+ propertyDefinition = nextDef;
+ break;
}
}
}
+
// If there still is no property type defined ...
if (propertyDefinition == null) {
Modified: trunk/dna-jcr/src/test/resources/repositoryForTckTests.xml
===================================================================
--- trunk/dna-jcr/src/test/resources/repositoryForTckTests.xml 2009-03-11 14:44:39 UTC
(rev 770)
+++ trunk/dna-jcr/src/test/resources/repositoryForTckTests.xml 2009-03-11 19:13:08 UTC
(rev 771)
@@ -30,7 +30,7 @@
jcr:primaryType="nt:unstructured">
<nt:unstructured jcr:name="node1"
prop1="<foo&foo>" >
<!-- This stanza checks for the jcr:xmltext special case for document export. DO
NOT change this element. -->
- <dna:xmlText jcr:name="jcr:xmltext" jcr:xmlcharacters="This is my
"XML" text!" />
+ <nt:unstructured jcr:name="jcr:xmltext" jcr:xmlcharacters="This is
my "XML" text!" />
</nt:unstructured>
<nt:unstructured jcr:name="node2 has a multi-word name"
prop2="bar" />
<nt:unstructured jcr:name="node3" />