You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2008/07/31 17:16:23 UTC

svn commit: r681394 - in /incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post: ./ impl/helper/ impl/operations/

Author: cziegeler
Date: Thu Jul 31 08:16:22 2008
New Revision: 681394

URL: http://svn.apache.org/viewvc?rev=681394&view=rev
Log:
SLING-594 : Readd modification object to keep track of all modifications.

Added:
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java   (with props)
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java   (with props)
Modified:
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java
    incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java Thu Jul 31 08:16:22 2008
@@ -16,8 +16,10 @@
  */
 package org.apache.sling.servlets.post;
 
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Iterator;
+import java.util.List;
 import java.util.NoSuchElementException;
 
 import javax.jcr.Item;
@@ -44,14 +46,14 @@
     /**
      * default log
      */
-    private final Logger log = LoggerFactory.getLogger(getClass());
+    protected final Logger log = LoggerFactory.getLogger(getClass());
 
     /**
      * Prepares and finalizes the actual operation. Preparation encompasses
      * getting the absolute path of the item to operate on by calling the
      * {@link #getItemPath(SlingHttpServletRequest)} method and setting the
      * location and parent location on the response. After the operation has
-     * been done in the {@link #doRun(SlingHttpServletRequest, HtmlResponse)}
+     * been done in the {@link #doRun(SlingHttpServletRequest, HtmlResponse, List)}
      * method the session is saved if there are unsaved modifications. In case
      * of errorrs, the unsaved changes in the session are rolled back.
      *
@@ -59,7 +61,8 @@
      * @param response The <code>HtmlResponse</code> to record execution
      *            progress.
      */
-    public final void run(SlingHttpServletRequest request, HtmlResponse response) {
+    public void run(SlingHttpServletRequest request,
+            HtmlResponse response) {
 
         // calculate the paths
         String path = getItemPath(request);
@@ -74,10 +77,22 @@
 
         Session session = request.getResourceResolver().adaptTo(Session.class);
 
+        final List<Modification> changes = new ArrayList<Modification>();
+
         try {
 
-            doRun(request, response);
+            doRun(request, response, changes);
 
+            // set changes on html response
+            for(Modification change : changes) {
+                switch ( change.getType() ) {
+                    case MODIFY : response.onModified(change.getSource()); break;
+                    case DELETE : response.onDeleted(change.getSource()); break;
+                    case MOVE :   response.onMoved(change.getSource(), change.getDestination()); break;
+                    case COPY :   response.onCopied(change.getSource(), change.getDestination()); break;
+                    case CREATE : response.onCreated(change.getSource()); break;
+                }
+            }
             if (session.hasPendingChanges()) {
                 session.save();
             }
@@ -111,7 +126,8 @@
     }
 
     protected abstract void doRun(SlingHttpServletRequest request,
-            HtmlResponse response) throws RepositoryException;
+            HtmlResponse response,
+            List<Modification> changes) throws RepositoryException;
 
     /**
      * Returns an iterator on <code>Resource</code> instances addressed in the

Added: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java?rev=681394&view=auto
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java (added)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java Thu Jul 31 08:16:22 2008
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.servlets.post;
+
+public class Modification {
+
+    private final ModificationType type;
+
+    private final String source;
+    private final String destination;
+
+    public Modification(final ModificationType type, final String source, final String destination) {
+        this.type = type;
+        this.source = source;
+        this.destination = destination;
+    }
+
+    public ModificationType getType() {
+        return type;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public String getDestination() {
+        return destination;
+    }
+
+    /**
+     * Records a 'modified' change
+     *
+     * @param path path of the item that was modified
+     */
+    public static Modification onModified(String path) {
+        return onChange(ModificationType.MODIFY, path);
+    }
+
+    /**
+     * Records a 'created' change
+     *
+     * @param path path of the item that was created
+     */
+    public static Modification onCreated(String path) {
+        return onChange(ModificationType.CREATE, path);
+    }
+
+    /**
+     * Records a 'deleted' change
+     *
+     * @param path path of the item that was deleted
+     */
+    public static Modification onDeleted(String path) {
+        return onChange(ModificationType.DELETE, path);
+    }
+
+    /**
+     * Records a 'moved' change. <p/> Note: the moved change only records the
+     * basic move command. the implied changes on the moved properties and sub
+     * nodes are not recorded.
+     *
+     * @param srcPath source path of the node that was moved
+     * @param dstPath destination path of the node that was moved.
+     */
+    public static Modification onMoved(String srcPath, String dstPath) {
+        return onChange(ModificationType.MOVE, srcPath, dstPath);
+    }
+
+    /**
+     * Records a 'copied' change. <p/> Note: the copy change only records the
+     * basic copy command. the implied changes on the copied properties and sub
+     * nodes are not recorded.
+     *
+     * @param srcPath source path of the node that was copied
+     * @param dstPath destination path of the node that was copied.
+     */
+    public static Modification onCopied(String srcPath, String dstPath) {
+        return onChange(ModificationType.COPY, srcPath, dstPath);
+    }
+
+    protected static Modification onChange(ModificationType type, String source) {
+        return onChange(type, source, null);
+    }
+
+    protected static Modification onChange(ModificationType type,
+            final String source, final String dest) {
+        return new Modification(type, source, dest);
+    }
+}

Propchange: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java?rev=681394&view=auto
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java (added)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java Thu Jul 31 08:16:22 2008
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.servlets.post;
+
+public enum ModificationType {
+
+    MODIFY,
+    DELETE,
+    MOVE,
+    COPY,
+    CREATE
+}

Propchange: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java Thu Jul 31 08:16:22 2008
@@ -59,7 +59,7 @@
     /**
      * Executes the operation provided by this service implementation. This
      * method is called by the Sling default POST servlet.
-     * 
+     *
      * @param request The <code>SlingHttpServletRequest</code> object
      *            providing the request input for the operation.
      * @param response The <code>HtmlResponse</code> into which the operation
@@ -73,5 +73,4 @@
      *             occurrs running the operation.
      */
     void run(SlingHttpServletRequest request, HtmlResponse response);
-
 }

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java Thu Jul 31 08:16:22 2008
@@ -18,6 +18,7 @@
 
 import java.io.IOException;
 import java.util.Calendar;
+import java.util.List;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -27,7 +28,7 @@
 
 import org.apache.jackrabbit.util.Text;
 import org.apache.sling.api.request.RequestParameter;
-import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.Modification;
 
 /**
  * Handles file uploads.
@@ -105,7 +106,7 @@
      * @param prop the assembled property info
      * @throws RepositoryException if an error occurs
      */
-    public void setFile(Node parent, RequestProperty prop, HtmlResponse response)
+    public void setFile(Node parent, RequestProperty prop, List<Modification> changes)
             throws RepositoryException {
         RequestParameter value = prop.getValues()[0];
         assert !value.isFormField();
@@ -162,14 +163,14 @@
         if (createNtFile) {
             // create nt:file
             parent = parent.addNode(name, typeHint);
-            response.onCreated(parent.getPath());
+            changes.add(Modification.onCreated(parent.getPath()));
             name = JCR_CONTENT;
             typeHint = NT_RESOURCE;
         }
 
         // create resource node
         Node res = parent.addNode(name, typeHint);
-        response.onCreated(res.getPath());
+        changes.add(Modification.onCreated(res.getPath()));
 
         // get content type
         String contentType = value.getContentType();
@@ -188,16 +189,16 @@
         }
 
         // set properties
-        response.onModified(
+        changes.add(Modification.onModified(
             res.setProperty(JCR_LASTMODIFIED, Calendar.getInstance()).getPath()
-        );
-        response.onModified(
+        ));
+        changes.add(Modification.onModified(
             res.setProperty(JCR_MIMETYPE, contentType).getPath()
-        );
+        ));
         try {
-            response.onModified(
+            changes.add(Modification.onModified(
                 res.setProperty(JCR_DATA, value.getInputStream()).getPath()
-            );
+            ));
         } catch (IOException e) {
             throw new RepositoryException("Error while retrieving inputstream from parameter value.", e);
         }

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java Thu Jul 31 08:16:22 2008
@@ -19,6 +19,7 @@
 
 import java.util.Calendar;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.jcr.Node;
@@ -28,7 +29,7 @@
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 
-import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.Modification;
 
 /**
  * Sets a Property on the given Node, in some cases with a specific type and
@@ -55,7 +56,7 @@
     /**
      * the post processor
      */
-    private final HtmlResponse response;
+    private final List<Modification> changes;
 
     private final DateParser dateParser;
 
@@ -67,9 +68,9 @@
     /**
      * Constructs a propert value handler
      */
-    public SlingPropertyValueHandler(DateParser dateParser, HtmlResponse response) {
+    public SlingPropertyValueHandler(DateParser dateParser, List<Modification> changes) {
         this.dateParser = dateParser;
-        this.response = response;
+        this.changes = changes;
     }
 
 
@@ -132,9 +133,9 @@
     private void setCurrentDate(Node parent, String name)
             throws RepositoryException {
         removePropertyIfExists(parent, name);
-        response.onModified(
+        changes.add(Modification.onModified(
             parent.setProperty(name, now).getPath()
-        );
+        ));
     }
 
     /**
@@ -146,9 +147,9 @@
     private void setCurrentUser(Node parent, String name)
             throws RepositoryException {
         removePropertyIfExists(parent, name);
-        response.onModified(
+        changes.add(Modification.onModified(
             parent.setProperty(name, parent.getSession().getUserID()).getPath()
-        );
+        ));
     }
 
     /**
@@ -197,22 +198,22 @@
         String[] values = prop.getStringValues();
         if (values == null) {
             // remove property
-            response.onDeleted(
+            changes.add(Modification.onDeleted(
                 removePropertyIfExists(parent, prop.getName())
-            );
+            ));
         } else if (values.length == 0) {
             // do not create new prop here, but clear existing
             if (parent.hasProperty(prop.getName())) {
-                response.onModified(
+                changes.add(Modification.onModified(
                     parent.setProperty(prop.getName(), "").getPath()
-                );
+                ));
             }
         } else if (values.length == 1) {
             final String removePath = removePropertyIfExists(parent, prop.getName());
             // if the provided value is the empty string, we don't have to do anything.
             if ( values[0].length() == 0 ) {
                 if ( removePath != null ) {
-                    response.onDeleted(removePath);
+                    changes.add(Modification.onDeleted(removePath));
                 }
             } else {
                 // modify property
@@ -223,13 +224,13 @@
                         if ( prop.hasMultiValueTypeHint() ) {
                             final Value[] array = new Value[1];
                             array[0] = parent.getSession().getValueFactory().createValue(c);
-                            response.onModified(
+                            changes.add(Modification.onModified(
                                 parent.setProperty(prop.getName(), array).getPath()
-                            );
+                            ));
                         } else {
-                            response.onModified(
+                            changes.add(Modification.onModified(
                                     parent.setProperty(prop.getName(), c).getPath()
-                                );
+                                ));
                         }
                         return;
                     }
@@ -247,7 +248,7 @@
                         p = parent.setProperty(prop.getName(), values[0], type);
                     }
                 }
-                response.onModified(p.getPath());
+                changes.add(Modification.onModified(p.getPath()));
             }
         } else {
             removePropertyIfExists(parent, prop.getName());
@@ -256,9 +257,9 @@
                 ValueFactory valFac = parent.getSession().getValueFactory();
                 Value[] c = dateParser.parse(values, valFac);
                 if (c != null) {
-                    response.onModified(
+                    changes.add(Modification.onModified(
                         parent.setProperty(prop.getName(), c).getPath()
-                    );
+                    ));
                     return;
                 }
                 // fall back to default behaviour
@@ -269,7 +270,7 @@
             } else {
                 p = parent.setProperty(prop.getName(), values, type);
             }
-            response.onModified(p.getPath());
+            changes.add(Modification.onModified(p.getPath()));
         }
     }
 

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java Thu Jul 31 08:16:22 2008
@@ -17,6 +17,7 @@
 package org.apache.sling.servlets.post.impl.operations;
 
 import java.util.Iterator;
+import java.util.List;
 
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
@@ -29,6 +30,7 @@
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.api.servlets.HtmlResponse;
 import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.Modification;
 import org.apache.sling.servlets.post.SlingPostConstants;
 
 /**
@@ -40,7 +42,9 @@
 
     @Override
     protected final void doRun(SlingHttpServletRequest request,
-            HtmlResponse response) throws RepositoryException {
+            HtmlResponse response,
+            List<Modification> changes)
+    throws RepositoryException {
 
         Resource resource = request.getResource();
         String source = resource.getPath();
@@ -103,7 +107,7 @@
             }
 
             String dstName = trailingSlash ? null : ResourceUtil.getName(dest);
-            execute(response, item, dstParent, dstName);
+            execute(changes, item, dstParent, dstName);
 
         } else {
 
@@ -122,7 +126,7 @@
                 Resource applyTo = resources.next();
                 Item item = applyTo.adaptTo(Item.class);
                 if (item != null) {
-                    execute(response, item, dstParent, null);
+                    execute(changes, item, dstParent, null);
                 }
             }
 
@@ -139,7 +143,7 @@
 
     /**
      * Actually executes the operation.
-     * 
+     *
      * @param response The <code>HtmlResponse</code> used to record success of
      *            the operation.
      * @param source The source item to act upon.
@@ -150,7 +154,7 @@
      * @throws RepositoryException May be thrown if an error occurrs executing
      *             the operation.
      */
-    protected abstract void execute(HtmlResponse response, Item source,
+    protected abstract void execute(List<Modification> changes, Item source,
             String destParent, String destName) throws RepositoryException;
 
 }

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java Thu Jul 31 08:16:22 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.servlets.post.impl.operations;
 
+import java.util.List;
+
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -24,9 +26,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 
-import org.apache.sling.api.servlets.HtmlResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.sling.servlets.post.Modification;
 
 /**
  * The <code>CopyOperation</code> class implements the
@@ -35,24 +35,19 @@
  */
 public class CopyOperation extends AbstractCopyMoveOperation {
 
-    /**
-     * default log
-     */
-    private static final Logger log = LoggerFactory.getLogger(CopyOperation.class);
-
     @Override
     protected String getOperationName() {
         return "copy";
     }
 
     @Override
-    protected void execute(HtmlResponse response, Item source,
+    protected void execute(List<Modification> changes, Item source,
             String destParent, String destName) throws RepositoryException {
 
         copy(source, (Node) source.getSession().getItem(destParent), destName);
 
         String dest = destParent + "/" + destName;
-        response.onCopied(source.getPath(), dest);
+        changes.add(Modification.onCopied(source.getPath(), dest));
         log.debug("copy {} to {}", source, dest);
     }
 

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java Thu Jul 31 08:16:22 2008
@@ -17,6 +17,7 @@
 package org.apache.sling.servlets.post.impl.operations;
 
 import java.util.Iterator;
+import java.util.List;
 
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
@@ -26,6 +27,7 @@
 import org.apache.sling.api.resource.ResourceNotFoundException;
 import org.apache.sling.api.servlets.HtmlResponse;
 import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.Modification;
 
 /**
  * The <code>DeleteOperation</code> class implements the
@@ -35,12 +37,12 @@
 public class DeleteOperation extends AbstractSlingPostOperation {
 
     @Override
-    protected void doRun(SlingHttpServletRequest request, HtmlResponse response)
-            throws RepositoryException {
+    protected void doRun(SlingHttpServletRequest request, HtmlResponse response, List<Modification> changes)
+    throws RepositoryException {
 
         Iterator<Resource> res = getApplyToResources(request);
         if (res == null) {
-            
+
             Resource resource = request.getResource();
             Item item = resource.adaptTo(Item.class);
             if (item == null) {
@@ -49,19 +51,19 @@
             }
 
             item.remove();
-            response.onDeleted(resource.getPath());
-            
+            changes.add(Modification.onDeleted(resource.getPath()));
+
         } else {
-            
+
             while (res.hasNext()) {
                 Resource resource = res.next();
                 Item item = resource.adaptTo(Item.class);
                 if (item != null) {
                     item.remove();
-                    response.onDeleted(resource.getPath());
+                    changes.add(Modification.onDeleted(resource.getPath()));
                 }
             }
-            
+
         }
 
     }

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java Thu Jul 31 08:16:22 2008
@@ -19,6 +19,7 @@
 package org.apache.sling.servlets.post.impl.operations;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.jcr.Item;
@@ -36,14 +37,13 @@
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.api.servlets.HtmlResponse;
 import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.Modification;
 import org.apache.sling.servlets.post.SlingPostConstants;
 import org.apache.sling.servlets.post.impl.helper.DateParser;
 import org.apache.sling.servlets.post.impl.helper.NodeNameGenerator;
 import org.apache.sling.servlets.post.impl.helper.RequestProperty;
 import org.apache.sling.servlets.post.impl.helper.SlingFileUploadHandler;
 import org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * The <code>ModifyOperation</code> class implements the default operation
@@ -52,9 +52,6 @@
  */
 public class ModifyOperation extends AbstractSlingPostOperation {
 
-    /** default log */
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
     /**
      * utility class for generating node names
      */
@@ -75,27 +72,27 @@
     }
 
     @Override
-    protected void doRun(SlingHttpServletRequest request, HtmlResponse response)
+    protected void doRun(SlingHttpServletRequest request, HtmlResponse response, List<Modification> changes)
             throws RepositoryException {
 
         Map<String, RequestProperty> reqProperties = collectContent(request,
-            response);
+                response);
 
         // do not change order unless you have a very good reason.
         Session session = request.getResourceResolver().adaptTo(Session.class);
 
         // ensure root of new content
-        processCreate(session, reqProperties, response);
+        processCreate(session, reqProperties, response, changes);
 
         // write content from existing content (@Move/CopyFrom parameters)
-        processMoves(session, reqProperties, response);
-        processCopies(session, reqProperties, response);
+        processMoves(session, reqProperties, changes);
+        processCopies(session, reqProperties, changes);
 
         // cleanup any old content (@Delete parameters)
-        processDeletes(session, reqProperties, response);
+        processDeletes(session, reqProperties, changes);
 
         // write content from form
-        writeContent(session, reqProperties, response);
+        writeContent(session, reqProperties, changes);
 
         // order content
         String path = response.getPath();
@@ -205,12 +202,12 @@
      * @throws RepositoryException if a repository error occurs
      */
     private void processCreate(Session session,
-            Map<String, RequestProperty> reqProperties, HtmlResponse response)
+            Map<String, RequestProperty> reqProperties, HtmlResponse response, List<Modification> changes)
             throws RepositoryException {
 
         String path = response.getPath();
         if (!session.itemExists(path)) {
-            deepGetOrCreateNode(session, path, reqProperties, response);
+            deepGetOrCreateNode(session, path, reqProperties, changes);
             response.setCreateRequest(true);
         }
 
@@ -221,13 +218,13 @@
      * request properties to the locations indicated by the resource properties.
      */
     private void processMoves(Session session,
-            Map<String, RequestProperty> reqProperties, HtmlResponse response)
+            Map<String, RequestProperty> reqProperties, List<Modification> changes)
             throws RepositoryException {
 
         for (RequestProperty property : reqProperties.values()) {
             if (property.hasRepositoryMoveSource()) {
                 processMovesCopiesInternal(property, true, session,
-                    reqProperties, response);
+                    reqProperties, changes);
             }
         }
     }
@@ -237,13 +234,13 @@
      * request properties to the locations indicated by the resource properties.
      */
     private void processCopies(Session session,
-            Map<String, RequestProperty> reqProperties, HtmlResponse response)
+            Map<String, RequestProperty> reqProperties, List<Modification> changes)
             throws RepositoryException {
 
         for (RequestProperty property : reqProperties.values()) {
             if (property.hasRepositoryCopySource()) {
                 processMovesCopiesInternal(property, false, session,
-                    reqProperties, response);
+                    reqProperties, changes);
             }
         }
     }
@@ -272,7 +269,7 @@
      */
     private void processMovesCopiesInternal(RequestProperty property,
             boolean isMove, Session session,
-            Map<String, RequestProperty> reqProperties, HtmlResponse response)
+            Map<String, RequestProperty> reqProperties, List<Modification> changes)
             throws RepositoryException {
 
         String propPath = property.getPath();
@@ -285,10 +282,10 @@
             // first, otherwise ensure the parent location
             if (session.itemExists(propPath)) {
                 session.getItem(propPath).remove();
-                response.onDeleted(propPath);
+                changes.add(Modification.onDeleted(propPath));
             } else {
                 deepGetOrCreateNode(session, property.getParentPath(),
-                    reqProperties, response);
+                    reqProperties, changes);
             }
 
             // move through the session and record operation
@@ -326,9 +323,9 @@
 
             // record successful move
             if (isMove) {
-                response.onMoved(source, propPath);
+                changes.add(Modification.onMoved(source, propPath));
             } else {
-                response.onCopied(source, propPath);
+                changes.add(Modification.onCopied(source, propPath));
             }
         }
     }
@@ -347,7 +344,7 @@
      *             removing properties.
      */
     private void processDeletes(Session session,
-            Map<String, RequestProperty> reqProperties, HtmlResponse response)
+            Map<String, RequestProperty> reqProperties, List<Modification> changes)
             throws RepositoryException {
 
         for (RequestProperty property : reqProperties.values()) {
@@ -355,7 +352,7 @@
                 String propPath = property.getPath();
                 if (session.itemExists(propPath)) {
                     session.getItem(propPath).remove();
-                    response.onDeleted(propPath);
+                    changes.add(Modification.onDeleted(propPath));
                 }
             }
         }
@@ -369,23 +366,23 @@
      * @throws ServletException if an internal error occurs
      */
     private void writeContent(Session session,
-            Map<String, RequestProperty> reqProperties, HtmlResponse response)
+            Map<String, RequestProperty> reqProperties, List<Modification> changes)
             throws RepositoryException {
 
         SlingPropertyValueHandler propHandler = new SlingPropertyValueHandler(
-            dateParser, response);
+            dateParser, changes);
 
         for (RequestProperty prop : reqProperties.values()) {
             if (prop.hasValues()) {
                 Node parent = deepGetOrCreateNode(session,
-                    prop.getParentPath(), reqProperties, response);
+                    prop.getParentPath(), reqProperties, changes);
                 // skip jcr special properties
                 if (prop.getName().equals("jcr:primaryType")
                     || prop.getName().equals("jcr:mixinTypes")) {
                     continue;
                 }
                 if (prop.isFileUpload()) {
-                    uploadHandler.setFile(parent, prop, response);
+                    uploadHandler.setFile(parent, prop, changes);
                 } else {
                     propHandler.setProperty(parent, prop);
                 }
@@ -615,7 +612,7 @@
      *             <code>null</code>
      */
     private Node deepGetOrCreateNode(Session session, String path,
-            Map<String, RequestProperty> reqProperties, HtmlResponse response)
+            Map<String, RequestProperty> reqProperties, List<Modification> changes)
             throws RepositoryException {
         if (log.isDebugEnabled()) {
             log.debug("Deep-creating Node '{}'", path);
@@ -675,7 +672,7 @@
                         node.addMixin(mix);
                     }
                 }
-                response.onCreated(node.getPath());
+                changes.add(Modification.onCreated(node.getPath()));
             }
             from = to + 1;
         }

Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java?rev=681394&r1=681393&r2=681394&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java Thu Jul 31 08:16:22 2008
@@ -16,11 +16,13 @@
  */
 package org.apache.sling.servlets.post.impl.operations;
 
+import java.util.List;
+
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
-import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.Modification;
 
 /**
  * The <code>MoveOperation</code> class implements the
@@ -35,7 +37,7 @@
     }
 
     @Override
-    protected void execute(HtmlResponse response, Item source,
+    protected void execute(List<Modification> changes, Item source,
             String destParent, String destName) throws RepositoryException {
 
         if (destName == null) {
@@ -51,7 +53,7 @@
         }
 
         session.move(sourcePath, destPath);
-        response.onMoved(sourcePath, destPath);
+        changes.add(Modification.onMoved(sourcePath, destPath));
     }
 
 }