Author: rhauch
Date: 2009-11-25 19:36:08 -0500 (Wed, 25 Nov 2009)
New Revision: 1358
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinMirrorRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.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/request/Request.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/CustomPropertiesFactory.java
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/Serializer.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/util/SerializerTest.java
Log:
DNA-549 Added fields to the UpdatePropertiesRequest and SetPropertyRequest to record which
properties were created vs changed. Since this is a change to the request classes
involving new methods that must be called when processing these requests, all the
connectors were checked and changed if required. All tests pass.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java 2009-11-26 00:33:28
UTC (rev 1357)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java 2009-11-26 00:36:08
UTC (rev 1358)
@@ -85,6 +85,7 @@
public static I18n actualNewLocationMustHaveSameParentAsOldLocation;
public static I18n actualNewLocationMustHaveSameNameAsRequest;
public static I18n requestIsFrozenAndMayNotBeChanged;
+ public static I18n propertyIsNotPartOfRequest;
public static I18n errorImportingContent;
public static I18n unableToFindRepositorySourceWithName;
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinMirrorRequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinMirrorRequestProcessor.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinMirrorRequestProcessor.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -213,7 +213,9 @@
public void process( SetPropertyRequest request ) {
SetPropertyRequest source =
(SetPropertyRequest)federatedRequest.getFirstProjectedRequest().getRequest();
if (checkErrorOrCancel(request, source)) return;
+ // Set the actual location and created flags ...
request.setActualLocationOfNode(source.getActualLocationOfNode());
+ request.setNewProperty(source.isNewProperty());
}
/**
@@ -305,6 +307,7 @@
UpdatePropertiesRequest source =
(UpdatePropertiesRequest)federatedRequest.getFirstProjectedRequest().getRequest();
if (checkErrorOrCancel(request, source)) return;
request.setActualLocationOfNode(source.getActualLocationOfNode());
+ request.setNewProperties(source.getNewPropertyNames());
}
/**
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -863,6 +863,7 @@
if (checkErrorOrCancel(request, source)) return;
Location sourceLocation = source.getActualLocationOfNode();
request.setActualLocationOfNode(projectToFederated(request.on(),
projected.getProjection(), sourceLocation, request));
+ request.setNewProperties(source.getNewPropertyNames());
}
/**
@@ -876,8 +877,10 @@
assert !projected.hasNext();
SetPropertyRequest source = (SetPropertyRequest)projected.getRequest();
if (checkErrorOrCancel(request, source)) return;
+ // Set the actual location and created flags ...
Location sourceLocation = source.getActualLocationOfNode();
request.setActualLocationOfNode(projectToFederated(request.on(),
projected.getProjection(), sourceLocation, request));
+ request.setNewProperty(source.isNewProperty());
}
/**
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
00:33:28 UTC (rev 1357)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/MapRequestProcessor.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -365,7 +365,10 @@
}
Name propName = property.getName();
if (!propName.equals(DnaLexicon.UUID)) {
- node.getProperties().put(propName, property);
+ if (node.getProperties().put(propName, property) == null) {
+ // It is a new property ...
+ request.setNewProperty(propName);
+ }
}
}
Location actualLocation = getActualLocation(request.on(), node);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/Request.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/Request.java 2009-11-26
00:33:28 UTC (rev 1357)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/Request.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -151,13 +151,17 @@
/**
* Freeze this request to prevent any further modification. This method does nothing
if the request is already frozen.
+ *
+ * @return true if this request was frozen, or false if it was already frozen
*/
- public void freeze() {
+ public boolean freeze() {
if (frozen.compareAndSet(false, true)) {
// Was not already frozen, so decrement the latch (atomically)
CountDownLatch latch = this.freezingLatch;
if (latch != null) latch.countDown();
+ return true;
}
+ return false;
}
/**
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -43,6 +43,7 @@
private final String workspaceName;
private final Property property;
private Location actualLocation;
+ private boolean actualCreation;
/**
* Create a request to set the property on the node at the supplied location.
@@ -131,6 +132,27 @@
}
/**
+ * Record that the property did not exist prior to the processing of this request and
was actually created by this request.
+ * This method must be called when processing the request, and the actual location
must have a {@link Location#getPath() path}
+ * .
+ *
+ * @param created true if the property was created by this request, or false if this
request updated an existing property
+ * @throws IllegalStateException if the request is frozen
+ */
+ public void setNewProperty( boolean created ) {
+ this.actualCreation = true;
+ }
+
+ /**
+ * Get whether the {@link #property() property} was created.
+ *
+ * @return true if this request created the property, or false if this request
changed an existing property
+ */
+ public boolean isNewProperty() {
+ return actualCreation;
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.request.ChangeRequest#changes(java.lang.String,
org.jboss.dna.graph.property.Path)
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -24,7 +24,9 @@
package org.jboss.dna.graph.request;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.graph.GraphI18n;
@@ -58,6 +60,7 @@
private final Location on;
private final String workspaceName;
private final Map<Name, Property> properties;
+ private Set<Name> createdPropertyNames;
private Location actualLocation;
/**
@@ -125,6 +128,9 @@
* @throws IllegalArgumentException if the actual location does represent the {@link
Location#isSame(Location) same location}
* as the {@link #on() current location}, or if the actual location does not
have a path.
* @throws IllegalStateException if the request is frozen
+ * @see #setNewProperties(Iterable)
+ * @see #setNewProperties(Name...)
+ * @see #setNewProperty(Name)
*/
public void setActualLocationOfNode( Location actual ) {
checkNotFrozen();
@@ -148,8 +154,124 @@
}
/**
+ * Record that the named property did not exist prior to the processing of this
request and was actually created by this
+ * request. This method (or one of its sibling methods) must be called at least once
when processing the request, and may be
+ * called repeatedly for additional properties.
+ *
+ * @param nameOfCreatedProperty the name of one of the {@link #properties()
properties} that was created by this request
+ * @throws IllegalStateException if the request is frozen
+ * @throws IllegalArgumentException if the name is null or if it is not the name of
one of the {@link #properties()
+ * properties}
+ * @see #setActualLocationOfNode(Location)
+ * @see #setNewProperties(Name...)
+ * @see #setNewProperties(Iterable)
+ */
+ public void setNewProperty( Name nameOfCreatedProperty ) {
+ CheckArg.isNotNull(nameOfCreatedProperty, "nameOfCreatedProperty");
+ checkNotFrozen();
+ if (!properties().containsKey(nameOfCreatedProperty)) {
+ throw new
IllegalStateException(GraphI18n.propertyIsNotPartOfRequest.text(nameOfCreatedProperty,
this));
+ }
+ if (createdPropertyNames == null) createdPropertyNames = new
HashSet<Name>();
+ createdPropertyNames.add(nameOfCreatedProperty);
+ }
+
+ /**
+ * Record that the named properties did not exist prior to the processing of this
request and were actually created by this
+ * request. This method (or one of its sibling methods) must be called at least once
when processing the request, and may be
+ * called repeatedly for additional properties.
+ *
+ * @param nameOfCreatedProperties the names of the {@link #properties() properties}
that were created by this request
+ * @throws IllegalStateException if the request is frozen
+ * @throws IllegalArgumentException if the name is null or if it is not the name of
one of the {@link #properties()
+ * properties}
+ * @see #setActualLocationOfNode(Location)
+ * @see #setNewProperties(Iterable)
+ * @see #setNewProperty(Name)
+ */
+ public void setNewProperties( Name... nameOfCreatedProperties ) {
+ checkNotFrozen();
+ if (createdPropertyNames == null) createdPropertyNames = new
HashSet<Name>();
+ for (Name name : nameOfCreatedProperties) {
+ if (name != null) {
+ if (!properties().containsKey(name)) {
+ throw new
IllegalStateException(GraphI18n.propertyIsNotPartOfRequest.text(name, this));
+ }
+ createdPropertyNames.add(name);
+ }
+ }
+ }
+
+ /**
+ * Record that the named properties did not exist prior to the processing of this
request and were actually created by this
+ * request. This method (or one of its sibling methods) must be called at least once
when processing the request, and may be
+ * called repeatedly for additional properties.
+ *
+ * @param nameOfCreatedProperties the names of the {@link #properties() properties}
that were created by this request
+ * @throws IllegalStateException if the request is frozen
+ * @throws IllegalArgumentException if any of the names are not in the updated {@link
#properties() properties}
+ * @see #setActualLocationOfNode(Location)
+ * @see #setNewProperties(Name...)
+ * @see #setNewProperty(Name)
+ */
+ public void setNewProperties( Iterable<Name> nameOfCreatedProperties ) {
+ checkNotFrozen();
+ if (nameOfCreatedProperties == null) return;
+ if (createdPropertyNames == null) createdPropertyNames = new
HashSet<Name>();
+ for (Name name : nameOfCreatedProperties) {
+ if (name != null) {
+ if (!properties().containsKey(name)) {
+ throw new
IllegalStateException(GraphI18n.propertyIsNotPartOfRequest.text(name, this));
+ }
+ createdPropertyNames.add(name);
+ }
+ }
+ }
+
+ /**
+ * Get the names of the {@link #properties() properties} that were created by this
request.
+ *
+ * @return the names of the properties
+ */
+ public Set<Name> getNewPropertyNames() {
+ return createdPropertyNames;
+ }
+
+ /**
+ * Determine whether the named property was created by this request
+ *
+ * @param name the property name
+ * @return true if the named property was created by the request, or false otherwise
+ */
+ public boolean isNewProperty( Name name ) {
+ return createdPropertyNames != null &&
createdPropertyNames.contains(name);
+ }
+
+ /**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.Request#freeze()
+ */
+ @Override
+ public boolean freeze() {
+ if (super.freeze()) {
+ if (createdPropertyNames != null) {
+ if (createdPropertyNames.isEmpty()) {
+ createdPropertyNames = Collections.emptySet();
+ } else if (createdPropertyNames.size() == 1) {
+ createdPropertyNames =
Collections.singleton(createdPropertyNames.iterator().next());
+ } else {
+ createdPropertyNames =
Collections.unmodifiableSet(createdPropertyNames);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.ChangeRequest#changes(java.lang.String,
org.jboss.dna.graph.property.Path)
*/
@Override
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -746,8 +746,9 @@
if (update.hasError()) {
request.setError(update.getError());
} else {
- // Set the actual location ...
+ // Set the actual location and created flags ...
request.setActualLocationOfNode(update.getActualLocationOfNode());
+ request.setNewProperty(update.isNewProperty(property.getName()));
}
}
Modified: trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
===================================================================
--- trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-11-26
00:33:28 UTC (rev 1357)
+++ trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-11-26
00:36:08 UTC (rev 1358)
@@ -73,6 +73,7 @@
actualNewLocationMustHaveSameParentAsOldLocation = The new location of {0} must be a
sibling of the old location of {1}
actualNewLocationMustHaveSameNameAsRequest = The new location of {0} must have the same
name as in the request ({1})
requestIsFrozenAndMayNotBeChanged = Request is frozen and may not be changed: {0}
+propertyIsNotPartOfRequest = The "{0}" property is not part of the request:
{1}
errorImportingContent = Error importing {0} content from {1}
unableToFindRepositorySourceWithName = Unable to find a repository source named
"{0}"
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-11-26 00:33:28
UTC (rev 1357)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-11-26 00:36:08
UTC (rev 1358)
@@ -1304,6 +1304,7 @@
public void process( UpdatePropertiesRequest request ) {
// Just update the actual location
request.setActualLocationOfNode(actualLocationOf(request.on()));
+ request.setNewProperties();
}
@Override
Modified:
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/CustomPropertiesFactory.java
===================================================================
---
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/CustomPropertiesFactory.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/CustomPropertiesFactory.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -27,6 +27,7 @@
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
+import java.util.Set;
import net.jcip.annotations.Immutable;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.JcrLexicon;
@@ -106,13 +107,14 @@
* @param file the file system object; never null, and both {@link File#exists()} and
{@link File#isDirectory()} will always
* return true
* @param properties the properties that are to be set
+ * @return the names of the properties that were created, or an empty or null set if
no properties were created on the file
* @throws RepositorySourceException if any properties are invalid or cannot be set
on these nodes
*/
- void recordDirectoryProperties( ExecutionContext context,
- String sourceName,
- Location location,
- File file,
- Map<Name, Property> properties ) throws
RepositorySourceException;
+ Set<Name> recordDirectoryProperties( ExecutionContext context,
+ String sourceName,
+ Location location,
+ File file,
+ Map<Name, Property> properties ) throws
RepositorySourceException;
/**
* Record the supplied properties as being set on the designated "nt:file"
node.
@@ -123,13 +125,14 @@
* @param file the file system object; never null, and both {@link File#exists()} and
{@link File#isFile()} will always return
* true
* @param properties the properties that are to be set
+ * @return the names of the properties that were created, or an empty or null set if
no properties were created on the file
* @throws RepositorySourceException if any properties are invalid or cannot be set
on these nodes
*/
- void recordFileProperties( ExecutionContext context,
- String sourceName,
- Location location,
- File file,
- Map<Name, Property> properties ) throws
RepositorySourceException;
+ Set<Name> recordFileProperties( ExecutionContext context,
+ String sourceName,
+ Location location,
+ File file,
+ Map<Name, Property> properties ) throws
RepositorySourceException;
/**
* Record the supplied properties as being set on the designated
"nt:resource" node.
@@ -140,12 +143,13 @@
* @param file the file system object; never null, and both {@link File#exists()} and
{@link File#isFile()} will always return
* true
* @param properties the properties that are to be set
+ * @return the names of the properties that were created, or an empty or null set if
no properties were created on the file
* @throws RepositorySourceException if any properties are invalid or cannot be set
on these nodes
*/
- void recordResourceProperties( ExecutionContext context,
- String sourceName,
- Location location,
- File file,
- Map<Name, Property> properties ) throws
RepositorySourceException;
+ Set<Name> recordResourceProperties( ExecutionContext context,
+ String sourceName,
+ Location location,
+ File file,
+ Map<Name, Property> properties ) throws
RepositorySourceException;
}
Modified:
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java
===================================================================
---
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -573,30 +573,34 @@
}
Location location = request.on();
+ Set<Name> createdProperties = null;
if (target.isFile()) {
if (path.endsWith(JcrLexicon.CONTENT)) {
- customPropertiesFactory.recordResourceProperties(getExecutionContext(),
- getSourceName(),
- location,
- target,
- request.properties());
+ createdProperties =
customPropertiesFactory.recordResourceProperties(getExecutionContext(),
+
getSourceName(),
+
location,
+
target,
+
request.properties());
} else {
- customPropertiesFactory.recordFileProperties(getExecutionContext(),
- getSourceName(),
- location,
- target,
- request.properties());
+ createdProperties =
customPropertiesFactory.recordFileProperties(getExecutionContext(),
+
getSourceName(),
+
location,
+ target,
+
request.properties());
}
} else {
assert target.isDirectory();
- customPropertiesFactory.recordDirectoryProperties(getExecutionContext(),
- getSourceName(),
- location,
- target,
- request.properties());
+ createdProperties =
customPropertiesFactory.recordDirectoryProperties(getExecutionContext(),
+
getSourceName(),
+
location,
+
target,
+
request.properties());
}
request.setActualLocationOfNode(location);
+ if (createdProperties != null) {
+ request.setNewProperties(createdProperties);
+ }
}
/**
Modified:
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java
===================================================================
---
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -699,12 +699,13 @@
* @see
org.jboss.dna.connector.filesystem.CustomPropertiesFactory#recordDirectoryProperties(org.jboss.dna.graph.ExecutionContext,
* java.lang.String, org.jboss.dna.graph.Location, java.io.File,
java.util.Map)
*/
- public void recordDirectoryProperties( ExecutionContext context,
- String sourceName,
- Location location,
- File file,
- Map<Name, Property> properties )
throws RepositorySourceException {
+ public Set<Name> recordDirectoryProperties( ExecutionContext context,
+ String sourceName,
+ Location location,
+ File file,
+ Map<Name, Property> properties
) throws RepositorySourceException {
ensureValidProperties(context, sourceName, properties.values(),
ALLOWABLE_PROPERTIES_FOR_FILE_OR_FOLDER);
+ return null;
}
/**
@@ -713,12 +714,13 @@
* @see
org.jboss.dna.connector.filesystem.CustomPropertiesFactory#recordFileProperties(org.jboss.dna.graph.ExecutionContext,
* java.lang.String, org.jboss.dna.graph.Location, java.io.File,
java.util.Map)
*/
- public void recordFileProperties( ExecutionContext context,
- String sourceName,
- Location location,
- File file,
- Map<Name, Property> properties ) throws
RepositorySourceException {
+ public Set<Name> recordFileProperties( ExecutionContext context,
+ String sourceName,
+ Location location,
+ File file,
+ Map<Name, Property> properties )
throws RepositorySourceException {
ensureValidProperties(context, sourceName, properties.values(),
ALLOWABLE_PROPERTIES_FOR_FILE_OR_FOLDER);
+ return null;
}
/**
@@ -727,12 +729,13 @@
* @see
org.jboss.dna.connector.filesystem.CustomPropertiesFactory#recordResourceProperties(org.jboss.dna.graph.ExecutionContext,
* java.lang.String, org.jboss.dna.graph.Location, java.io.File,
java.util.Map)
*/
- public void recordResourceProperties( ExecutionContext context,
- String sourceName,
- Location location,
- File file,
- Map<Name, Property> properties )
throws RepositorySourceException {
+ public Set<Name> recordResourceProperties( ExecutionContext context,
+ String sourceName,
+ Location location,
+ File file,
+ Map<Name, Property> properties )
throws RepositorySourceException {
ensureValidProperties(context, sourceName, properties.values(),
ALLOWABLE_PROPERTIES_FOR_CONTENT);
+ return null;
}
/**
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -909,6 +909,7 @@
public void process( UpdatePropertiesRequest request ) {
logger.trace(request.toString());
Location actualLocation = null;
+ Set<Name> createdProperties = null;
try {
// Find the workspace ...
WorkspaceEntity workspace = getExistingWorkspace(request.inWorkspace(),
request);
@@ -950,6 +951,7 @@
if (originalData == null) {
largeValues = new LargeValueSerializer(entity);
numProps = props.size();
+ createdProperties = props.keySet(); // all properties were created
serializer.serializeProperties(oos, numProps, props.values(),
largeValues, refs);
if (gos != null) gos.finish();
} else {
@@ -960,9 +962,16 @@
InputStream is = compressed ? new GZIPInputStream(bais) : bais;
ObjectInputStream ois = new ObjectInputStream(is);
SkippedLargeValues removedValues = new
SkippedLargeValues(largeValues);
+ createdProperties = new HashSet<Name>();
try {
Serializer.ReferenceValues refValues = refs != null ? refs :
Serializer.NO_REFERENCES_VALUES;
- numProps = serializer.reserializeProperties(ois, oos, props,
largeValues, removedValues, refValues);
+ numProps = serializer.reserializeProperties(ois,
+ oos,
+ props,
+ largeValues,
+ removedValues,
+ createdProperties,
+ refValues);
if (gos != null) gos.finish();
} finally {
try {
@@ -1025,6 +1034,7 @@
} catch (NoResultException e) {
// there are no properties yet ...
createProperties(workspace, actual.uuid, request.properties().values());
+ createdProperties = request.properties().keySet();
}
} catch (Throwable e) { // Includes PathNotFoundException
@@ -1032,6 +1042,7 @@
return;
}
if (actualLocation != null) request.setActualLocationOfNode(actualLocation);
+ request.setNewProperties(createdProperties);
recordChange(request);
}
@@ -1217,7 +1228,10 @@
oldUuidsToNewUuids.put(original.getId().getChildUuidString(), newUuid);
if (existingLocation != null &&
existingLocation.childEntity.getParentUuidString().equals(actualNewParent.uuid)) {
- if (desiredName == null) desiredName = desiredSegment.getName();
+ if (desiredName == null) {
+ assert desiredSegment != null;
+ desiredName = desiredSegment.getName();
+ }
NamespaceEntity namespace = NamespaceEntity.findByUri(entities,
desiredName.getNamespaceUri());
ChildEntity existingChild = existingLocation.childEntity;
@@ -1238,7 +1252,10 @@
} else {
// Now add the new copy of the original ...
boolean allowSnS = original.getAllowsSameNameChildren();
- if (desiredName == null) desiredName = desiredSegment.getName();
+ if (desiredName == null) {
+ assert desiredSegment != null;
+ desiredName = desiredSegment.getName();
+ }
newLocation = addNewChild(intoWorkspace.getId(), actualNewParent, newUuid,
desiredName, allowSnS);
}
@@ -2126,8 +2143,8 @@
} else {
ActualLocation actualBeforeLocation = getActualLocation(workspace,
beforeLocation);
- ActualLocation actualIntoLocation = getActualLocation(workspace,
-
Location.create(beforeLocation.getPath().getParent()));
+ ActualLocation actualIntoLocation = getActualLocation(workspace,
Location.create(beforeLocation.getPath()
+
.getParent()));
actualNewLocation = moveNodeBefore(workspace, actualLocation,
actualIntoLocation, actualBeforeLocation);
}
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/Serializer.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/Serializer.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/Serializer.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -352,6 +352,7 @@
* @param updatedProperties the properties that are being updated (or removed, if
there are no values); may not be null
* @param largeValues the interface to use for writing large values; may not be null
* @param removedLargeValues the interface to use for recording the large values that
were removed; may not be null
+ * @param createdProperties the set into which should be placed the names of the
properties that were created; may not be null
* @param references the interface to use for recording which {@link Reference}
values were found during serialization, or
* null if the references do not need to be accumulated
* @return the number of properties
@@ -363,18 +364,23 @@
Map<Name, Property> updatedProperties,
LargeValues largeValues,
LargeValues removedLargeValues,
+ Set<Name> createdProperties,
ReferenceValues references ) throws IOException,
ClassNotFoundException {
assert input != null;
assert output != null;
assert updatedProperties != null;
+ assert createdProperties != null;
assert largeValues != null;
assert references != null;
// Assemble a set of property names to skip deserializing
Map<Name, Property> allProperties = new HashMap<Name, Property>();
+ // Start out by assuming that all properties are new ...
+ createdProperties.addAll(updatedProperties.keySet());
+
// Read the number of properties ...
int count = input.readInt();
- // Deserialize all of the proeprties ...
+ // Deserialize all of the properties ...
for (int i = 0; i != count; ++i) {
// Read the property name ...
String nameStr = (String)input.readObject();
@@ -391,15 +397,18 @@
assert property != null;
allProperties.put(name, property);
}
+ // This is an existing property, so remove it from the set of created
properties ...
+ createdProperties.remove(name);
}
// Add all the updated properties ...
for (Map.Entry<Name, Property> entry : updatedProperties.entrySet()) {
Property updated = entry.getValue();
+ Name name = entry.getKey();
if (updated == null) {
- allProperties.remove(entry.getKey());
+ allProperties.remove(name);
} else {
- allProperties.put(updated.getName(), updated);
+ allProperties.put(name, updated);
}
}
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/util/SerializerTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/util/SerializerTest.java 2009-11-26
00:33:28 UTC (rev 1357)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/util/SerializerTest.java 2009-11-26
00:36:08 UTC (rev 1358)
@@ -416,15 +416,20 @@
Name[] removedProperties ) throws IOException,
ClassNotFoundException {
Collection<Name> propertiesThatStay = new HashSet<Name>();
Collection<Name> propertiesThatAreDeleted = new HashSet<Name>();
+ Set<Name> propertiesThatAreNew = new HashSet<Name>();
for (Property prop : originalProperties) {
propertiesThatStay.add(prop.getName());
}
for (Property prop : updatedProperties) {
- propertiesThatStay.add(prop.getName());
+ if (propertiesThatStay.add(prop.getName())) {
+ // The property is new since it wasn't in the original set of names
...
+ propertiesThatAreNew.add(prop.getName());
+ }
}
for (Name removedPropertyName : removedProperties) {
propertiesThatAreDeleted.add(removedPropertyName);
propertiesThatStay.remove(removedPropertyName);
+ assertThat(propertiesThatAreNew.contains(removedPropertyName), is(false));
}
// Serialize the properties one at a time ...
@@ -439,8 +444,15 @@
ObjectInputStream ois = new ObjectInputStream(bais);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
+ Set<Name> createdProperties = new HashSet<Name>();
try {
- serializer.reserializeProperties(ois, oos, updatedProps, largeValues,
removedLargeValues, references);
+ serializer.reserializeProperties(ois,
+ oos,
+ updatedProps,
+ largeValues,
+ removedLargeValues,
+ createdProperties,
+ references);
} finally {
oos.close();
ois.close();
@@ -460,6 +472,7 @@
for (Name deleted : propertiesThatAreDeleted) {
assertThat(namesAfter.contains(deleted), is(false));
}
+ assertThat(createdProperties, is(propertiesThatAreNew));
}
protected class SkippedLargeValues implements Serializer.LargeValues {