Index: deploy/jbossas/modeshape-jbossas-service/src/kit/modeshape-config.xml
===================================================================
--- deploy/jbossas/modeshape-jbossas-service/src/kit/modeshape-config.xml (revision 2538)
+++ deploy/jbossas/modeshape-jbossas-service/src/kit/modeshape-config.xml (working copy)
@@ -56,6 +56,8 @@
/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdl.cnd
/org/modeshape/sequencer/ddl/dialect/postgres/PostgresDdl.cnd
+
+
Index: deploy/jbossas/modeshape-jbossas-service/src/kit/modeshape-initial-content.xml
new file mode 100644
===================================================================
--- /dev/null (revision 2538)
+++ deploy/jbossas/modeshape-jbossas-service/src/kit/modeshape-initial-content.xml (working copy)
@@ -0,0 +1,28 @@
+
+
+
+
Index: modeshape-graph/src/main/java/org/modeshape/graph/GraphMerger.java
===================================================================
--- modeshape-graph/src/main/java/org/modeshape/graph/GraphMerger.java (revision 2538)
+++ modeshape-graph/src/main/java/org/modeshape/graph/GraphMerger.java (working copy)
@@ -24,10 +24,13 @@
package org.modeshape.graph;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
import net.jcip.annotations.NotThreadSafe;
-import org.modeshape.common.collection.Collections;
import org.modeshape.common.util.CheckArg;
import org.modeshape.graph.Graph.Batch;
import org.modeshape.graph.property.Name;
@@ -42,8 +45,21 @@ import org.modeshape.graph.property.ValueComparators;
@NotThreadSafe
class GraphMerger {
+ private static final PropertyMerger SKIP_MERGER = new SkipMerger();
+ private static final PropertyMerger UNION_MERGER = new UnionPropertyMerger();
+ private static final PropertyMerger DEFAULT_MERGER = new DefaultPropertyMerger();
+
+ private static final Map MERGERS;
+ static {
+ Map mergers = new HashMap();
+ mergers.put(JcrLexicon.NAME, SKIP_MERGER);
+ mergers.put(JcrLexicon.UUID, SKIP_MERGER);
+ mergers.put(ModeShapeLexicon.UUID, SKIP_MERGER);
+ mergers.put(JcrLexicon.MIXIN_TYPES, UNION_MERGER);
+ MERGERS = Collections.unmodifiableMap(mergers);
+ }
+
private final Graph initialContent;
- private final Set ignoredProperties = Collections.unmodifiableSet(JcrLexicon.UUID, ModeShapeLexicon.UUID);
protected GraphMerger( Graph initialContent ) {
CheckArg.isNotNull(initialContent, "initialContent");
@@ -89,29 +105,14 @@ class GraphMerger {
Collection desiredProperties = desiredNode.getProperties();
if (desiredProperties.isEmpty()) return;
for (Property desiredProperty : desiredProperties) {
- Property actual = actualNode.getProperty(desiredProperty.getName());
- boolean performSet = false;
+ Name propertyName = desiredProperty.getName();
+ Property actual = actualNode.getProperty(propertyName);
if (actual == null) {
- performSet = true;
- } else {
- if (ignoredProperties.contains(actual.getName())) continue;
- // the actual property already exists ...
- Iterator> actualValues = actual.getValues();
- Iterator> desiredValues = desiredProperty.getValues();
- while (actualValues.hasNext() && desiredValues.hasNext()) {
- Object actualValue = actualValues.next();
- Object desiredValue = desiredValues.next();
- if (ValueComparators.OBJECT_COMPARATOR.compare(actualValue, desiredValue) != 0) {
- performSet = true;
- break;
- }
- }
- if (!performSet && (actualValues.hasNext() || desiredValues.hasNext())) {
- performSet = true;
- }
- }
- if (performSet) {
batch.set(desiredProperty).on(actualLocation);
+ } else {
+ PropertyMerger merger = MERGERS.get(propertyName);
+ if (merger == null) merger = DEFAULT_MERGER;
+ merger.mergeProperty(batch, actualLocation.getPath(), actual, desiredProperty);
}
}
}
@@ -161,4 +162,98 @@ class GraphMerger {
}
}
+ protected static interface PropertyMerger {
+ public void mergeProperty( Batch batch,
+ Path path,
+ Property actual,
+ Property desired );
+ }
+
+ protected static class SkipMerger implements PropertyMerger {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.modeshape.graph.GraphMerger.PropertyMerger#mergeProperty(org.modeshape.graph.Graph.Batch,
+ * org.modeshape.graph.property.Path, org.modeshape.graph.property.Property, org.modeshape.graph.property.Property)
+ */
+ public void mergeProperty( Batch batch,
+ Path path,
+ Property actual,
+ Property desired ) {
+ // do nothing ...
+ }
+ }
+
+ protected static class UnionPropertyMerger implements PropertyMerger {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.modeshape.graph.GraphMerger.PropertyMerger#mergeProperty(org.modeshape.graph.Graph.Batch,
+ * org.modeshape.graph.property.Path, org.modeshape.graph.property.Property, org.modeshape.graph.property.Property)
+ */
+ public void mergeProperty( Batch batch,
+ Path path,
+ Property actual,
+ Property desired ) {
+ // the actual property already exists ...
+ if (desired.size() == 0) {
+ // nothing in the desired property ...
+ return;
+ }
+
+ Set