incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject svn commit: r897932 - in /sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations: AbstractCopyMoveOperation.java CopyOperation.java MoveOperation.java
Date Mon, 11 Jan 2010 16:41:21 GMT
Author: ieb
Date: Mon Jan 11 16:41:20 2010
New Revision: 897932

URL: http://svn.apache.org/viewvc?rev=897932&view=rev
Log:
SLING-1281 Fixed, removed the save operation and replaced with the Node or Item just created
to avoid pulling the item from the session transientStore of items.

Modified:
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java?rev=897932&r1=897931&r2=897932&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
(original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
Mon Jan 11 16:41:20 2010
@@ -96,6 +96,7 @@
         }
 
         Iterator<Resource> resources = getApplyToResources(request);
+        Item destItem = null;
         if (resources == null) {
 
             // ensure we have an item underlying the request's resource
@@ -107,7 +108,7 @@
             }
 
             String dstName = trailingSlash ? null : ResourceUtil.getName(dest);
-            execute(changes, item, dstParent, dstName);
+            destItem = execute(changes, item, dstParent, dstName);
 
         } else {
 
@@ -129,11 +130,12 @@
                     execute(changes, item, dstParent, null);
                 }
             }
+            destItem = session.getItem(dest);
 
         }
 
         // finally apply the ordering parameter
-        orderNode(request, session.getItem(dest), changes);
+        orderNode(request, destItem, changes);
     }
 
     /**
@@ -154,7 +156,7 @@
      * @throws RepositoryException May be thrown if an error occurrs executing
      *             the operation.
      */
-    protected abstract void execute(List<Modification> changes, Item source,
+    protected abstract Item execute(List<Modification> changes, Item source,
             String destParent, String destName) throws RepositoryException;
 
 }

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java?rev=897932&r1=897931&r2=897932&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java
(original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java
Mon Jan 11 16:41:20 2010
@@ -41,14 +41,15 @@
     }
 
     @Override
-    protected void execute(List<Modification> changes, Item source,
+    protected Item execute(List<Modification> changes, Item source,
             String destParent, String destName) throws RepositoryException {
 
-        copy(source, (Node) source.getSession().getItem(destParent), destName);
+        Item destItem = copy(source, (Node) source.getSession().getItem(destParent), destName);
 
         String dest = destParent + "/" + destName;
         changes.add(Modification.onCopied(source.getPath(), dest));
         log.debug("copy {} to {}", source, dest);
+        return destItem;
     }
 
     /**
@@ -66,12 +67,12 @@
      * @see #copy(Node, Node, String)
      * @see #copy(Property, Node, String)
      */
-    static void copy(Item src, Node dstParent, String name)
+    static Item copy(Item src, Node dstParent, String name)
             throws RepositoryException {
         if (src.isNode()) {
-            copy((Node) src, dstParent, name);
+            return copy((Node) src, dstParent, name);
         } else {
-            copy((Property) src, dstParent, name);
+            return copy((Property) src, dstParent, name);
         }
     }
 
@@ -92,7 +93,7 @@
      * @throws RepositoryException May be thrown in case of any problem copying
      *             the content.
      */
-    static void copy(Node src, Node dstParent, String name)
+    static Item copy(Node src, Node dstParent, String name)
             throws RepositoryException {
 
         // ensure destination name
@@ -103,7 +104,6 @@
         // ensure new node creation
         if (dstParent.hasNode(name)) {
             dstParent.getNode(name).remove();
-            dstParent.save();
         }
 
         // create new node
@@ -124,6 +124,7 @@
                 copy(n, dst, null);
             }
         }
+        return dst;
     }
 
     /**
@@ -141,7 +142,7 @@
      * @throws RepositoryException May be thrown in case of any problem copying
      *             the content.
      */
-    static void copy(Property src, Node dstParent, String name)
+    static Item copy(Property src, Node dstParent, String name)
             throws RepositoryException {
         if (!src.getDefinition().isProtected()) {
             if (name == null) {
@@ -154,11 +155,12 @@
             }
 
             if (src.getDefinition().isMultiple()) {
-                dstParent.setProperty(name, src.getValues());
+                return dstParent.setProperty(name, src.getValues());
             } else {
-                dstParent.setProperty(name, src.getValue());
+                return dstParent.setProperty(name, src.getValue());
             }
         }
+        return null;
     }
 
 }

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java?rev=897932&r1=897931&r2=897932&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java
(original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java
Mon Jan 11 16:41:20 2010
@@ -37,7 +37,7 @@
     }
 
     @Override
-    protected void execute(List<Modification> changes, Item source,
+    protected Item execute(List<Modification> changes, Item source,
             String destParent, String destName) throws RepositoryException {
 
         if (destName == null) {
@@ -57,6 +57,7 @@
 
         session.move(sourcePath, destPath);
         changes.add(Modification.onMoved(sourcePath, destPath));
+        return session.getItem(destPath);
     }
 
 }



Mime
View raw message