[dna-commits] DNA SVN: r1518 - in trunk/dna-graph/src/main/java/org/jboss/dna/graph/request: processor and 1 other directory.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Mon Jan 4 10:26:51 EST 2010


Author: bcarothers
Date: 2010-01-04 10:26:50 -0500 (Mon, 04 Jan 2010)
New Revision: 1518

Modified:
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
Log:
DNA-549 Creating A New Property And Changing An Existing Property Should Have Different ChangeRequest Types

Applied patch that adds a boolean method (isNewProperty()) that indicates whether a property was created as a result of processing this request. It's a parallel to the same method in SetPropertyRequest.

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java	2010-01-02 16:45:32 UTC (rev 1517)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java	2010-01-04 15:26:50 UTC (rev 1518)
@@ -39,6 +39,7 @@
     private Location actualLocation;
     private List<Object> actualAddedValues;
     private List<Object> actualRemovedValues;
+    private boolean actualCreation;
 
     public UpdateValuesRequest( String workspaceName,
                                 Location on,
@@ -148,6 +149,18 @@
     }
 
     /**
+     * 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 = created;
+    }
+
+    /**
      * Get the actual location of the node that was updated.
      * 
      * @return the actual location, or null if the actual location was not set
@@ -176,6 +189,15 @@
     }
 
     /**
+     * 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}
      * <p>
      * This method does not clone the results.
@@ -188,6 +210,7 @@
         UpdateValuesRequest request = new UpdateValuesRequest(workspaceName, actualLocation != null ? actualLocation : on,
                                                               propertyName, addedValues, removedValues);
         request.setActualLocation(actualLocation, actualAddedValues, actualRemovedValues);
+        request.setNewProperty(actualCreation);
         return request;
     }
 }

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	2010-01-02 16:45:32 UTC (rev 1517)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java	2010-01-04 15:26:50 UTC (rev 1518)
@@ -822,6 +822,7 @@
         // Update the current values
         SetPropertyRequest setProperty = new SetPropertyRequest(on, workspaceName, newProperty);
         process(setProperty);
+        request.setNewProperty(setProperty.isNewProperty());
 
         if (setProperty.hasError()) {
             request.setError(setProperty.getError());



More information about the dna-commits mailing list