Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 8834 invoked from network); 11 Jan 2010 16:41:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Jan 2010 16:41:43 -0000 Received: (qmail 39379 invoked by uid 500); 11 Jan 2010 16:41:43 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 39317 invoked by uid 500); 11 Jan 2010 16:41:43 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 39308 invoked by uid 99); 11 Jan 2010 16:41:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2010 16:41:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2010 16:41:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EC1D623889BB; Mon, 11 Jan 2010 16:41:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@sling.apache.org From: ieb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100111164121.EC1D623889BB@eris.apache.org> 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 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 changes, Item source, + protected abstract Item execute(List 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 changes, Item source, + protected Item execute(List 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 changes, Item source, + protected Item execute(List 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); } }