Author: bcarothers
Date: 2009-11-26 20:36:53 -0500 (Thu, 26 Nov 2009)
New Revision: 1361
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/DefaultMapNode.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapNode.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepository.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapWorkspace.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryWorkspaceTest.java
Log:
DNA-546 JCR Workspace and Session Imports Can Fail on JPA Connector
Applied patch that makes some preparatory tweaks to the MapRepository code. MapNode is
renamed to DefaultMapNode and now implements a new interface named MapNode. Additionally,
some bulk mutators are added.
The first part is a change that had been kicked around during the original development of
the MapRepository code and, IIRC, was bypassed as one of those "if we need it later,
we'll do it" changes. I'm doing it now to enable the creation of a JpaNode
for the new JPA connector model. Instead of implementing the MapNode interface by managing
state internally (like DefaultMapNode does), the JpaNode will be an adapter over a JPA
entity.
The bulk mutators are added to help limit the number of times that the properties for a
node need to be reserialized.
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java 2009-11-26
20:40:53 UTC (rev 1360)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java 2009-11-27
01:36:53 UTC (rev 1361)
@@ -115,7 +115,7 @@
*/
protected MapNode createMapNode( UUID uuid ) {
assert uuid != null;
- return new MapNode(uuid);
+ return new DefaultMapNode(uuid);
}
/**
@@ -233,26 +233,30 @@
}
/**
- * Removes the given node and its children, correcting the SNS and child indices for
its parent.
+ * Removes the given node and its children, correcting the SNS and child indices for
its parent. This method will return false
+ * if the given node does not exist in this workspace.
*
- * @param context the current execution context
- * @param node the node to be removed
+ * @param context the current execution context; may not be null
+ * @param node the node to be removed; may not be null
+ * @return whether a node was removed as a result of this operation
*/
- public void removeNode( ExecutionContext context,
- MapNode node ) {
+ public boolean removeNode( ExecutionContext context,
+ MapNode node ) {
assert context != null;
assert node != null;
+
if (getRoot().equals(node)) {
removeAllNodesFromMap();
// Recreate the root node ...
addNodeToMap(createMapNode(repository.getRootNodeUuid()));
- return;
+ return true;
}
MapNode parent = node.getParent();
assert parent != null;
- parent.getChildren().remove(node);
+ if (!parent.removeChild(node)) return false;
correctSameNameSiblingIndexes(context, parent, node.getName().getName());
removeUuidReference(node);
+ return true;
}
/**
@@ -274,10 +278,12 @@
*
* @param context the environment; may not be null
* @param pathToNewNode the path to the new node; may not be null
+ * @param properties the properties for the new node
* @return the new node (or root if the path specified the root)
*/
public MapNode createNode( ExecutionContext context,
- String pathToNewNode ) {
+ String pathToNewNode,
+ Iterable<Property> properties ) {
assert context != null;
assert pathToNewNode != null;
Path path = context.getValueFactories().getPathFactory().create(pathToNewNode);
@@ -285,7 +291,7 @@
Path parentPath = path.getParent();
MapNode parentNode = getNode(parentPath);
Name name = path.getLastSegment().getName();
- return createNode(context, parentNode, name, null);
+ return createNode(context, parentNode, name, null, properties);
}
/**
@@ -295,25 +301,27 @@
* @param parentNode the parent node; may not be null
* @param name the name; may not be null
* @param uuid the UUID of the node, or null if the UUID is to be generated
+ * @param properties the properties for the new node
* @return the new node
*/
public MapNode createNode( ExecutionContext context,
MapNode parentNode,
Name name,
- UUID uuid ) {
+ UUID uuid,
+ Iterable<Property> properties ) {
assert context != null;
assert name != null;
if (parentNode == null) parentNode = getRoot();
if (uuid == null) uuid = UUID.randomUUID();
MapNode node = createMapNode(uuid);
- addNodeToMap(node);
- node.setParent(parentNode);
// Find the last node with this same name ...
int nextIndex = 1;
- if (parentNode.existingNames.contains(name)) {
- ListIterator<MapNode> iter =
parentNode.getChildren().listIterator(parentNode.getChildren().size());
+ Set<Name> uniqueNames = parentNode.getUniqueChildNames();
+ if (uniqueNames.contains(name)) {
+ List<MapNode> children = parentNode.getChildren();
+ ListIterator<MapNode> iter = children.listIterator(children.size());
while (iter.hasPrevious()) {
MapNode prev = iter.previous();
if (prev.getName().getName().equals(name)) {
@@ -322,10 +330,15 @@
}
}
}
+
Path.Segment newName =
context.getValueFactories().getPathFactory().createSegment(name, nextIndex);
node.setName(newName);
- parentNode.getChildren().add(node);
- parentNode.existingNames.add(name);
+ node.setProperties(properties);
+ node.setParent(parentNode);
+
+ parentNode.addChild(node);
+ parentNode.getUniqueChildNames().add(name);
+ addNodeToMap(node);
return node;
}
@@ -366,7 +379,7 @@
}
if (oldParent != null) {
- boolean removed = oldParent.getChildren().remove(node);
+ boolean removed = oldParent.removeChild(node);
assert removed == true;
node.setParent(null);
correctSameNameSiblingIndexes(context, oldParent, oldName);
@@ -379,10 +392,10 @@
}
if (beforeNode == null) {
- newParent.getChildren().add(node);
+ newParent.addChild(node);
} else {
int index = newParent.getChildren().indexOf(beforeNode);
- newParent.getChildren().add(index, node);
+ newParent.addChild(index, node);
}
correctSameNameSiblingIndexes(context, newParent, newName);
@@ -464,15 +477,14 @@
// Get or create the new node ...
Name childName = desiredName != null ? desiredName :
original.getName().getName();
UUID uuidForCopy = reuseUuids ? original.getUuid() : UUID.randomUUID();
- MapNode copy = newWorkspace.createNode(context, newParent, childName,
uuidForCopy);
+
+ MapNode copy = newWorkspace.createNode(context, newParent, childName,
uuidForCopy, original.getProperties().values());
+
if (!reuseUuids) {
assert oldToNewUuids != null;
oldToNewUuids.put(original.getUuid(), copy.getUuid());
}
- // Copy the properties ...
- copy.getProperties().clear();
- copy.getProperties().putAll(original.getProperties());
if (recursive) {
// Loop over each child and call this method ...
for (MapNode child : original.getChildren()) {
@@ -553,11 +565,11 @@
// a node that has the UUID of the original node (as this will be handled
later) ...
for (UUID uuid : uuidsInFromBranch) {
if (null != (existing = newWorkspace.getNode(uuid))) {
- newWorkspace.removeNode(context, existing);
if (removedExistingNodes != null) {
Path path = pathFor(pathFactory, existing);
removedExistingNodes.add(Location.create(path, uuid));
}
+ newWorkspace.removeNode(context, existing);
}
}
} else {
@@ -583,14 +595,12 @@
assert newRoot != null;
newRoot.getProperties().clear();
- for (MapNode child : newRoot.getChildren()) {
- newWorkspace.removeNode(context, child);
- }
+ newRoot.setProperties(original.getProperties().values());
- for (Property property : original.getProperties().values()) {
- newRoot.setProperty(property);
- }
+ newRoot.clearChildren();
+ assert newRoot.getChildren().isEmpty();
+
for (MapNode child : original.getChildren()) {
copyNode(context, child, newWorkspace, newRoot, null, true, (Map<UUID,
UUID>)null);
}
@@ -600,11 +610,11 @@
// Now deal with an existing node that has the same UUID as the original node
...
existing = newWorkspace.getNode(original.getUuid());
if (existing != null) {
- newWorkspace.removeNode(context, existing);
if (removedExistingNodes != null) {
Path path = pathFor(pathFactory, existing);
removedExistingNodes.add(Location.create(path, original.getUuid()));
}
+ newWorkspace.removeNode(context, existing);
}
return copyNode(context, original, newWorkspace, newParent, desiredName, true,
(Map<UUID, UUID>)null);
}
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/DefaultMapNode.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/DefaultMapNode.java
(rev 0)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/DefaultMapNode.java 2009-11-27
01:36:53 UTC (rev 1361)
@@ -0,0 +1,237 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.graph.connector.map;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NameFactory;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.graph.property.PropertyFactory;
+
+public class DefaultMapNode implements MapNode {
+
+ private final UUID uuid;
+ private MapNode parent;
+ private Path.Segment name;
+ private final Map<Name, Property> properties = new HashMap<Name,
Property>();
+ private final LinkedList<MapNode> children = new LinkedList<MapNode>();
+ final Set<Name> existingNames = new HashSet<Name>();
+
+ public DefaultMapNode( UUID uuid ) {
+ assert uuid != null;
+ this.uuid = uuid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.dna.graph.connector.map.MapNode#getUuid()
+ */
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.dna.graph.connector.map.MapNode#getName()
+ */
+ public Path.Segment getName() {
+ return name;
+ }
+
+ /**
+ * @param name Sets name to the specified value.
+ */
+ public void setName( Path.Segment name ) {
+ this.name = name;
+ }
+
+ public Set<Name> getUniqueChildNames() {
+ return existingNames;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.dna.graph.connector.map.MapNode#getParent()
+ */
+ public MapNode getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent Sets parent to the specified value.
+ */
+ public void setParent( MapNode parent ) {
+ this.parent = parent;
+ }
+
+ /**
+ * @return children
+ */
+ public LinkedList<MapNode> getChildren() {
+ return children;
+ }
+
+ /**
+ * @return properties
+ */
+ public Map<Name, Property> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public void addChild( int index,
+ MapNode child ) {
+ children.add(index, child);
+ }
+
+ @Override
+ public void addChild( MapNode child ) {
+ children.add(child);
+
+ }
+
+ @Override
+ public void clearChildren() {
+ children.clear();
+ }
+
+ @Override
+ public boolean removeChild( MapNode child ) {
+ return children.remove(child);
+ }
+
+ @Override
+ public MapNode removeProperty( Name propertyName ) {
+ properties.remove(propertyName);
+ return this;
+ }
+
+ @Override
+ public MapNode setProperties( Iterable<Property> properties ) {
+ for (Property property : properties) {
+ this.properties.put(property.getName(), property);
+ }
+ return this;
+ }
+
+ /**
+ * Sets the property with the given name, overwriting any previous property for the
given name
+ *
+ * @param property the property to set
+ * @return this map node
+ */
+ public MapNode setProperty( Property property ) {
+ if (property != null) {
+ this.properties.put(property.getName(), property);
+ }
+ return this;
+ }
+
+ /**
+ * Sets the property with the given name, overwriting any previous property for the
given name
+ *
+ * @param context the current execution context, used to get a {@link NameFactory
name factory} and {@link PropertyFactory
+ * property factory}.
+ * @param name the name of the property
+ * @param values the values for the property
+ * @return this map node
+ */
+ public MapNode setProperty( ExecutionContext context,
+ String name,
+ Object... values ) {
+ PropertyFactory propertyFactory = context.getPropertyFactory();
+ Name propertyName = context.getValueFactories().getNameFactory().create(name);
+ return setProperty(propertyFactory.create(propertyName, values));
+ }
+
+ /**
+ * Returns the named property
+ *
+ * @param context the current execution context, used to get a {@link NameFactory
name factory}
+ * @param name the name of the property to return
+ * @return the property for the given name
+ */
+ public Property getProperty( ExecutionContext context,
+ String name ) {
+ Name propertyName = context.getValueFactories().getNameFactory().create(name);
+ return getProperty(propertyName);
+ }
+
+ /**
+ * Returns the named property
+ *
+ * @param name the name of the property to return
+ * @return the property for the given name
+ */
+ public Property getProperty( Name name ) {
+ return this.properties.get(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return uuid.hashCode();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj == this) return true;
+ if (obj instanceof MapNode) {
+ MapNode that = (MapNode)obj;
+ if (!this.getUuid().equals(that.getUuid())) return false;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ if (this.name == null) {
+ sb.append("");
+ } else {
+ sb.append(this.name);
+ }
+ sb.append(" (").append(uuid).append(")");
+ return sb.toString();
+ }
+}
Property changes on:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/DefaultMapNode.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapNode.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapNode.java 2009-11-26
20:40:53 UTC (rev 1360)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapNode.java 2009-11-27
01:36:53 UTC (rev 1361)
@@ -23,9 +23,7 @@
*/
package org.jboss.dna.graph.connector.map;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -36,88 +34,105 @@
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
-/**
- * A node within a {@link MapRepository}.
- */
-public class MapNode {
+public interface MapNode {
- private final UUID uuid;
- private MapNode parent;
- private Path.Segment name;
- private final Map<Name, Property> properties = new HashMap<Name,
Property>();
- private final LinkedList<MapNode> children = new LinkedList<MapNode>();
- final Set<Name> existingNames = new HashSet<Name>();
-
- public MapNode( UUID uuid ) {
- assert uuid != null;
- this.uuid = uuid;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.dna.graph.connector.map.MapNode#getUuid()
+ /**
+ * Returns the UUID for this node
+ *
+ * @return the UUID for this node
*/
- public UUID getUuid() {
- return uuid;
- }
+ public UUID getUuid();
- /* (non-Javadoc)
- * @see org.jboss.dna.graph.connector.map.MapNode#getName()
+ /**
+ * Returns the name of this node along with its SNS index within its parent's
children
+ *
+ * @return the name of this node along with its SNS index within its parent's
children
*/
- public Path.Segment getName() {
- return name;
- }
+ public Path.Segment getName();
/**
* @param name Sets name to the specified value.
*/
- public void setName( Path.Segment name ) {
- this.name = name;
- }
+ public void setName( Path.Segment name );
- public Set<Name> getUniqueChildNames() {
- return existingNames;
- }
+ /**
+ * Returns the set of child names for this node
+ *
+ * @return the set of child names for this node
+ */
+ public Set<Name> getUniqueChildNames();
- /* (non-Javadoc)
- * @see org.jboss.dna.graph.connector.map.MapNode#getParent()
+ /**
+ * Returns the parent of this node or null if the node is the root node for its
workspace.
+ *
+ * @return the parent of this node; may be null if the node is the root node for its
workspace
*/
- public MapNode getParent() {
- return parent;
- }
+ public MapNode getParent();
/**
* @param parent Sets parent to the specified value.
*/
- public void setParent( MapNode parent ) {
- this.parent = parent;
- }
+ public void setParent( MapNode parent );
/**
* @return children
*/
- public LinkedList<MapNode> getChildren() {
- return children;
- }
+ public List<MapNode> getChildren();
/**
- * @return properties
+ * Removes all of the children for this node in a single operation.
*/
- protected Map<Name, Property> getProperties() {
- return properties;
- }
+ public void clearChildren();
/**
+ * Adds the given child to the end of the list of children for this node
+ *
+ * @param child the child to add to this node
+ */
+ public void addChild( MapNode child );
+
+ /**
+ * Inserts the specified child at the specified position in the list of children.
Shifts the child currently at that position
+ * (if any) and any subsequent children to the right (adds one to their indices).
+ *
+ * @param index index at which the specified child is to be inserted
+ * @param child the child to be inserted
+ */
+ public void addChild( int index,
+ MapNode child );
+
+ /**
+ * Removes the given child from the list of children
+ *
+ * @param child the child to be removed
+ * @return true if the child was one of this node's children (and was removed);
false otherwise
+ */
+ public boolean removeChild( MapNode child );
+
+ /**
+ * Returns a map of property names to the property for the given name
+ *
+ * @return a map of property names to the property for the given name
+ */
+ public Map<Name, Property> getProperties();
+
+ /**
+ * Sets the given properties in a single operation, overwriting any previous
properties for the same name This bulk mutator
+ * should be used when multiple properties are being set in order to allow underlying
implementations to optimize their access
+ * to their respective persistent storage mechanism.
+ *
+ * @param properties the properties to set
+ * @return this map node
+ */
+ public MapNode setProperties( Iterable<Property> properties );
+
+ /**
* Sets the property with the given name, overwriting any previous property for the
given name
*
* @param property the property to set
* @return this map node
*/
- public MapNode setProperty( Property property ) {
- if (property != null) {
- this.properties.put(property.getName(), property);
- }
- return this;
- }
+ public MapNode setProperty( Property property );
/**
* Sets the property with the given name, overwriting any previous property for the
given name
@@ -130,13 +145,17 @@
*/
public MapNode setProperty( ExecutionContext context,
String name,
- Object... values ) {
- PropertyFactory propertyFactory = context.getPropertyFactory();
- Name propertyName = context.getValueFactories().getNameFactory().create(name);
- return setProperty(propertyFactory.create(propertyName, values));
- }
+ Object... values );
/**
+ * Removes the property with the given name
+ *
+ * @param propertyName the name of the property to remove
+ * @return this map node
+ */
+ public MapNode removeProperty( Name propertyName );
+
+ /**
* Returns the named property
*
* @param context the current execution context, used to get a {@link NameFactory
name factory}
@@ -144,10 +163,7 @@
* @return the property for the given name
*/
public Property getProperty( ExecutionContext context,
- String name ) {
- Name propertyName = context.getValueFactories().getNameFactory().create(name);
- return getProperty(propertyName);
- }
+ String name );
/**
* Returns the named property
@@ -155,51 +171,6 @@
* @param name the name of the property to return
* @return the property for the given name
*/
- public Property getProperty( Name name ) {
- return this.properties.get(name);
- }
+ public Property getProperty( Name name );
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return uuid.hashCode();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals( Object obj ) {
- if (obj == this) return true;
- if (obj instanceof MapNode) {
- MapNode that = (MapNode)obj;
- if (!this.getUuid().equals(that.getUuid())) return false;
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- if (this.name == null) {
- sb.append("");
- } else {
- sb.append(this.name);
- }
- sb.append(" (").append(uuid).append(")");
- return sb.toString();
- }
-
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepository.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepository.java 2009-11-26
20:40:53 UTC (rev 1360)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRepository.java 2009-11-27
01:36:53 UTC (rev 1361)
@@ -96,6 +96,10 @@
}
+ protected String getDefaultWorkspaceName() {
+ return defaultWorkspaceName;
+ }
+
/**
* Returns the UUID used by the root nodes in each workspace.
* <p>
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java 2009-11-26
20:40:53 UTC (rev 1360)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java 2009-11-27
01:36:53 UTC (rev 1361)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.graph.connector.map;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
@@ -224,16 +225,21 @@
GraphI18n.inMemoryNodeDoesNotExist.text(parent)));
return;
}
+
UUID uuid = null;
+ // Make a list of the properties that we will store: all props except dna:uuid
and jcr:uuid
+ List<Property> propsToStore = new
ArrayList<Property>(request.properties().size());
for (Property property : request.properties()) {
if (property.getName().equals(DnaLexicon.UUID) ||
property.getName().equals(JcrLexicon.UUID)) {
uuid =
getExecutionContext().getValueFactories().getUuidFactory().create(property.getValues().next());
- break;
+ } else {
+ propsToStore.add(property);
}
}
+
switch (request.conflictBehavior()) {
case APPEND:
- node = workspace.createNode(getExecutionContext(), parentNode,
request.named(), uuid);
+ node = workspace.createNode(getExecutionContext(), parentNode,
request.named(), uuid, propsToStore);
break;
case DO_NOT_REPLACE:
for (MapNode child : parentNode.getChildren()) {
@@ -243,7 +249,7 @@
}
}
if (node == null) {
- node = workspace.createNode(getExecutionContext(), parentNode,
request.named(), uuid);
+ node = workspace.createNode(getExecutionContext(), parentNode,
request.named(), uuid, propsToStore);
}
break;
case REPLACE:
@@ -252,29 +258,19 @@
if (node != null) {
workspace.removeNode(getExecutionContext(), node);
}
- node = workspace.createNode(getExecutionContext(), parentNode,
request.named(), uuid);
+ node = workspace.createNode(getExecutionContext(), parentNode,
request.named(), uuid, propsToStore);
break;
case UPDATE:
// See if the node already exists (this doesn't record an error on
the request) ...
node = getTargetNode(workspace, null,
Location.create(pathFactory.create(parent, request.named()), uuid));
if (node == null) {
- node = workspace.createNode(getExecutionContext(), parentNode,
request.named(), uuid);
+ node = workspace.createNode(getExecutionContext(), parentNode,
request.named(), uuid, propsToStore);
} // otherwise, we found it and we're setting any properties below
break;
}
assert node != null;
Path path =
getExecutionContext().getValueFactories().getPathFactory().create(parent,
node.getName());
- // Now add the properties to the supplied node ...
- for (Property property : request.properties()) {
- Name propName = property.getName();
- if (property.size() == 0) {
- node.getProperties().remove(propName);
- continue;
- }
- if (!propName.equals(DnaLexicon.UUID)) {
- node.getProperties().put(propName, property);
- }
- }
+
Location actualLocation = getActualLocation(Location.create(path), node);
request.setActualLocationOfNode(actualLocation);
recordChange(request);
@@ -323,7 +319,7 @@
// Build the path from the before node to the root.
LinkedList<Path.Segment> segments = new
LinkedList<Path.Segment>();
MapNode current = beforeNode.getParent();
- while (current != workspace.getRoot()) {
+ while (!current.equals(workspace.getRoot())) {
segments.addFirst(current.getName());
current = current.getParent();
}
@@ -338,7 +334,7 @@
return;
}
workspace.moveNode(getExecutionContext(), node, request.desiredName(), workspace,
newParent, beforeNode);
- assert node.getParent() == newParent;
+ assert node.getParent().equals(newParent);
Path newPath =
getExecutionContext().getValueFactories().getPathFactory().create(newParentPath,
node.getName());
Location oldLocation = getActualLocation(request.from(), node);
Location newLocation = Location.create(newPath, node.getUuid());
@@ -360,15 +356,16 @@
for (Map.Entry<Name, Property> propertyEntry :
request.properties().entrySet()) {
Property property = propertyEntry.getValue();
if (property == null) {
- node.getProperties().remove(propertyEntry.getKey());
+ node.removeProperty(propertyEntry.getKey());
continue;
}
Name propName = property.getName();
if (!propName.equals(DnaLexicon.UUID)) {
- if (node.getProperties().put(propName, property) == null) {
+ if (node.getProperties().get(propName) == null) {
// It is a new property ...
request.setNewProperty(propName);
}
+ node.setProperty(property);
}
}
Location actualLocation = getActualLocation(request.on(), node);
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapWorkspace.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapWorkspace.java 2009-11-26
20:40:53 UTC (rev 1360)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapWorkspace.java 2009-11-27
01:36:53 UTC (rev 1361)
@@ -32,6 +32,7 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.request.LockBranchRequest.LockScope;
/**
@@ -81,12 +82,13 @@
MapNode getNode( Path path );
/**
- * Removes the given node. This method will return silently if the given node does
not exist in this workspace.
+ * Removes the given node. This method will return false if the given node does not
exist in this workspace.
*
* @param context the current execution context; may not be null
* @param node the node to be removed; may not be null
+ * @return whether a node was removed as a result of this operation
*/
- void removeNode( ExecutionContext context,
+ boolean removeNode( ExecutionContext context,
MapNode node );
/**
@@ -94,10 +96,12 @@
*
* @param context the environment; may not be null
* @param pathToNewNode the path to the new node; may not be null
+ * @param properties the properties for the new node
* @return the new node (or root if the path specified the root)
*/
MapNode createNode( ExecutionContext context,
- String pathToNewNode );
+ String pathToNewNode,
+ Iterable<Property> properties );
/**
* Create a new node with the supplied name, as a child of the supplied parent.
@@ -106,12 +110,14 @@
* @param parentNode the parent node; may not be null
* @param name the name; may not be null
* @param uuid the UUID of the node, or null if the UUID is to be generated
+ * @param properties the properties for the new node
* @return the new node
*/
MapNode createNode( ExecutionContext context,
MapNode parentNode,
Name name,
- UUID uuid );
+ UUID uuid,
+ Iterable<Property> properties );
/**
* Move the supplied node to the new parent. This method automatically removes the
node from its existing parent, and also
Modified:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryTest.java
===================================================================
---
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryTest.java 2009-11-26
20:40:53 UTC (rev 1360)
+++
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryTest.java 2009-11-27
01:36:53 UTC (rev 1361)
@@ -29,6 +29,8 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItems;
+import java.util.Collection;
+import java.util.Collections;
import java.util.UUID;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.connector.map.MapNode;
@@ -131,12 +133,13 @@
// Populate the workspace with a few nodes ...
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ final Collection<Property> NO_PROPS = Collections.emptySet();
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
ValueFactory<String> stringFactory =
context.getValueFactories().getStringFactory();
Name propertyName = nameFactory.create("something");
@@ -202,12 +205,13 @@
// Populate the workspace with a few nodes ...
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ final Collection<Property> NO_PROPS = Collections.emptySet();
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
ValueFactory<String> stringFactory =
context.getValueFactories().getStringFactory();
Name propertyName = nameFactory.create("something");
Modified:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryWorkspaceTest.java
===================================================================
---
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryWorkspaceTest.java 2009-11-26
20:40:53 UTC (rev 1360)
+++
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryWorkspaceTest.java 2009-11-27
01:36:53 UTC (rev 1361)
@@ -30,6 +30,8 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItems;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -63,6 +65,7 @@
private PathFactory pathFactory;
private NameFactory nameFactory;
private PropertyFactory propertyFactory;
+ private final Collection<Property> NO_PROPS = Collections.emptySet();
@Before
public void beforeEach() throws Exception {
@@ -103,21 +106,21 @@
@Test
public void shouldCreateNodesByPath() {
Name name_a = nameFactory.create("a");
- MapNode node_a = workspace.createNode(context, workspace.getRoot(), name_a,
null);
+ MapNode node_a = workspace.createNode(context, workspace.getRoot(), name_a, null,
NO_PROPS);
assertThat(node_a, is(notNullValue()));
assertThat(node_a.getParent(), is(workspace.getRoot()));
assertThat(node_a.getName().getName(), is(name_a));
assertThat(node_a.getName().hasIndex(), is(false));
Name name_b = nameFactory.create("b");
- MapNode node_b = workspace.createNode(context, node_a, name_b, null);
+ MapNode node_b = workspace.createNode(context, node_a, name_b, null, NO_PROPS);
assertThat(node_b, is(notNullValue()));
assertThat(node_b.getParent(), is(node_a));
assertThat(node_b.getName().getName(), is(name_b));
assertThat(node_b.getName().hasIndex(), is(false));
Name name_c = nameFactory.create("c");
- MapNode node_c = workspace.createNode(context, node_b, name_c, null);
+ MapNode node_c = workspace.createNode(context, node_b, name_c, null, NO_PROPS);
assertThat(node_c, is(notNullValue()));
assertThat(node_c.getParent(), is(node_b));
assertThat(node_c.getName().getName(), is(name_c));
@@ -132,9 +135,9 @@
@Test
public void shouldNotFindNodesThatDoNotExist() {
- MapNode node_a = workspace.createNode(context, workspace.getRoot(),
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- /*Node node_c =*/workspace.createNode(context, node_b,
nameFactory.create("c"), null);
+ MapNode node_a = workspace.createNode(context, workspace.getRoot(),
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ /*Node node_c =*/workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
assertThat(workspace.size(), is(4));
assertThat(workspace.getNode(pathFactory.create("/a")), is(node_a));
@@ -150,14 +153,14 @@
@Test
public void shouldCorrectlyManageIndexesOfSiblingsWithSameNames() {
Name name_a1 = nameFactory.create("a");
- MapNode node_a1 = workspace.createNode(context, workspace.getRoot(), name_a1,
null);
+ MapNode node_a1 = workspace.createNode(context, workspace.getRoot(), name_a1,
null, NO_PROPS);
assertThat(node_a1, is(notNullValue()));
assertThat(node_a1.getParent(), is(workspace.getRoot()));
assertThat(node_a1.getName().getName(), is(name_a1));
assertThat(node_a1.getName().hasIndex(), is(false));
Name name_a2 = nameFactory.create("a");
- MapNode node_a2 = workspace.createNode(context, workspace.getRoot(), name_a2,
null);
+ MapNode node_a2 = workspace.createNode(context, workspace.getRoot(), name_a2,
null, NO_PROPS);
assertThat(node_a2, is(notNullValue()));
assertThat(node_a2.getParent(), is(workspace.getRoot()));
assertThat(node_a2.getName().getName(), is(name_a2));
@@ -169,7 +172,7 @@
// Add another node without the same name ..
Name name_b = nameFactory.create("b");
- MapNode node_b = workspace.createNode(context, workspace.getRoot(), name_b,
null);
+ MapNode node_b = workspace.createNode(context, workspace.getRoot(), name_b, null,
NO_PROPS);
assertThat(node_b, is(notNullValue()));
assertThat(node_b.getParent(), is(workspace.getRoot()));
assertThat(node_b.getName().getName(), is(name_b));
@@ -177,7 +180,7 @@
// Add a third node with the same name ..
Name name_a3 = nameFactory.create("a");
- MapNode node_a3 = workspace.createNode(context, workspace.getRoot(), name_a3,
null);
+ MapNode node_a3 = workspace.createNode(context, workspace.getRoot(), name_a3,
null, NO_PROPS);
assertThat(node_a3, is(notNullValue()));
assertThat(node_a3.getParent(), is(workspace.getRoot()));
assertThat(node_a3.getName().getName(), is(name_a3));
@@ -213,12 +216,12 @@
@Test
public void shouldMoveNodesWithinSameWorkspace() {
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
assertThat(workspace.size(), is(7));
assertThat(workspace.getNode(pathFactory.create("/")),
is(sameInstance(workspace.getRoot())));
@@ -253,12 +256,12 @@
@Test
public void shouldMoveNodeBeforeAnother() {
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
Name propName = nameFactory.create("prop");
node_b.setProperty(propertyFactory.create(propName, "node_b"));
node_b2.setProperty(propertyFactory.create(propName, "node_b2"));
@@ -305,12 +308,12 @@
public void shouldMoveNodesFromOneWorkspaceToAnother() {
// Populate the workspace with some content ..
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
assertThat(workspace.size(), is(7));
assertThat(workspace.getNode(pathFactory.create("/")),
is(sameInstance(workspace.getRoot())));
@@ -326,12 +329,12 @@
assertThat(new_workspace, is(notNullValue()));
MapNode new_root = new_workspace.getRoot();
- MapNode new_node_a = new_workspace.createNode(context, new_root,
nameFactory.create("a"), null);
- MapNode new_node_b = new_workspace.createNode(context, new_node_a,
nameFactory.create("b"), null);
- MapNode new_node_c = new_workspace.createNode(context, new_node_b,
nameFactory.create("c"), null);
- MapNode new_node_d = new_workspace.createNode(context, new_root,
nameFactory.create("d"), null);
- MapNode new_node_e = new_workspace.createNode(context, new_node_d,
nameFactory.create("e"), null);
- MapNode new_node_b2 = new_workspace.createNode(context, new_node_d,
nameFactory.create("b"), null);
+ MapNode new_node_a = new_workspace.createNode(context, new_root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode new_node_b = new_workspace.createNode(context, new_node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode new_node_c = new_workspace.createNode(context, new_node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode new_node_d = new_workspace.createNode(context, new_root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode new_node_e = new_workspace.createNode(context, new_node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode new_node_b2 = new_workspace.createNode(context, new_node_d,
nameFactory.create("b"), null, NO_PROPS);
assertThat(new_workspace.size(), is(7));
assertThat(new_workspace.getNode(pathFactory.create("/")),
is(sameInstance(new_root)));
@@ -365,12 +368,12 @@
@Test
public void shouldCopyNodesWithinSameWorkspace() {
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
ValueFactory<String> stringFactory = valueFactories.getStringFactory();
Name propertyName = nameFactory.create("something");
@@ -409,12 +412,12 @@
public void shouldCopyNodesFromOneWorkspaceToAnotherAndKeepSameUuids() {
// Populate the workspace with some content ..
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
ValueFactory<String> stringFactory = valueFactories.getStringFactory();
Name propertyName = nameFactory.create("something");
@@ -437,12 +440,12 @@
assertThat(new_workspace, is(notNullValue()));
MapNode new_root = new_workspace.getRoot();
- MapNode new_node_a = new_workspace.createNode(context, new_root,
nameFactory.create("a"), null);
- MapNode new_node_b = new_workspace.createNode(context, new_node_a,
nameFactory.create("b"), null);
- MapNode new_node_c = new_workspace.createNode(context, new_node_b,
nameFactory.create("c"), null);
- MapNode new_node_d = new_workspace.createNode(context, new_root,
nameFactory.create("d"), null);
- MapNode new_node_e = new_workspace.createNode(context, new_node_d,
nameFactory.create("e"), null);
- MapNode new_node_b2 = new_workspace.createNode(context, new_node_d,
nameFactory.create("b"), null);
+ MapNode new_node_a = new_workspace.createNode(context, new_root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode new_node_b = new_workspace.createNode(context, new_node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode new_node_c = new_workspace.createNode(context, new_node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode new_node_d = new_workspace.createNode(context, new_root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode new_node_e = new_workspace.createNode(context, new_node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode new_node_b2 = new_workspace.createNode(context, new_node_d,
nameFactory.create("b"), null, NO_PROPS);
assertThat(new_workspace.size(), is(7));
assertThat(new_workspace.getNode(pathFactory.create("/")),
is(sameInstance(new_root)));
@@ -492,12 +495,12 @@
public void shouldCopyNodesFromOneWorkspaceToAnotherAndGenerateNewUuids() {
// Populate the workspace with some content ..
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
ValueFactory<String> stringFactory = valueFactories.getStringFactory();
Name propertyName = nameFactory.create("something");
@@ -520,12 +523,12 @@
assertThat(new_workspace, is(notNullValue()));
MapNode new_root = new_workspace.getRoot();
- MapNode new_node_a = new_workspace.createNode(context, new_root,
nameFactory.create("a"), null);
- MapNode new_node_b = new_workspace.createNode(context, new_node_a,
nameFactory.create("b"), null);
- MapNode new_node_c = new_workspace.createNode(context, new_node_b,
nameFactory.create("c"), null);
- MapNode new_node_d = new_workspace.createNode(context, new_root,
nameFactory.create("d"), null);
- MapNode new_node_e = new_workspace.createNode(context, new_node_d,
nameFactory.create("e"), null);
- MapNode new_node_b2 = new_workspace.createNode(context, new_node_d,
nameFactory.create("b"), null);
+ MapNode new_node_a = new_workspace.createNode(context, new_root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode new_node_b = new_workspace.createNode(context, new_node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode new_node_c = new_workspace.createNode(context, new_node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode new_node_d = new_workspace.createNode(context, new_root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode new_node_e = new_workspace.createNode(context, new_node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode new_node_b2 = new_workspace.createNode(context, new_node_d,
nameFactory.create("b"), null, NO_PROPS);
assertThat(new_workspace.size(), is(7));
assertThat(new_workspace.getNode(pathFactory.create("/")),
is(sameInstance(new_root)));
@@ -578,12 +581,12 @@
@Test
public void shouldCopyNodesWhenDesiredNameIsSpecified() {
MapNode root = workspace.getRoot();
- MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null);
- MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null);
- MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null);
- MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null);
- MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null);
- MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null);
+ MapNode node_a = workspace.createNode(context, root,
nameFactory.create("a"), null, NO_PROPS);
+ MapNode node_b = workspace.createNode(context, node_a,
nameFactory.create("b"), null, NO_PROPS);
+ MapNode node_c = workspace.createNode(context, node_b,
nameFactory.create("c"), null, NO_PROPS);
+ MapNode node_d = workspace.createNode(context, root,
nameFactory.create("d"), null, NO_PROPS);
+ MapNode node_e = workspace.createNode(context, node_d,
nameFactory.create("e"), null, NO_PROPS);
+ MapNode node_b2 = workspace.createNode(context, node_d,
nameFactory.create("b"), null, NO_PROPS);
ValueFactory<String> stringFactory = valueFactories.getStringFactory();
Name propertyName = nameFactory.create("something");
@@ -620,12 +623,14 @@
@Test
public void shouldCreateRepositoryStructure() {
- workspace.createNode(context, "/a")
+ workspace.createNode(context, "/a", NO_PROPS)
.setProperty(context, "name", "value")
- .setProperty(context, "desc", "Some description");
- workspace.createNode(context, "/a/b").setProperty(context,
"name", "value2").setProperty(context,
+.setProperty(context,
+
"desc",
+
"Some description");
+ workspace.createNode(context, "/a/b", NO_PROPS).setProperty(context,
"name", "value2").setProperty(context,
"desc",
-
"Some description 2");
+
"Some description 2");
assertThat(workspace.getNode(context, "/a").getProperty(context,
"name").getValuesAsArray(), is(new Object[] {"value"}));
assertThat(workspace.getNode(context, "/a").getProperty(context,
"desc").getValuesAsArray(),
is(new Object[] {"Some description"}));