Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 80696 invoked from network); 7 Jan 2009 08:37:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Jan 2009 08:37:25 -0000 Received: (qmail 62561 invoked by uid 500); 7 Jan 2009 08:37:25 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 62534 invoked by uid 500); 7 Jan 2009 08:37:25 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 62525 invoked by uid 99); 7 Jan 2009 08:37:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 00:37:25 -0800 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; Wed, 07 Jan 2009 08:37:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D0FD9238895D; Wed, 7 Jan 2009 00:37:01 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r732273 - /incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java Date: Wed, 07 Jan 2009 08:37:01 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090107083701.D0FD9238895D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmeschbe Date: Wed Jan 7 00:37:01 2009 New Revision: 732273 URL: http://svn.apache.org/viewvc?rev=732273&view=rev Log: SLING-784 Fix @Delete operation: only access the item when needed and get the correct item. In addition the test for whether the parent item of an item is a node can be omitted, since the parent of any item is always a node. Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java 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=732273&r1=732272&r2=732273&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 Wed Jan 7 00:37:01 2009 @@ -376,26 +376,28 @@ * removing properties. */ private void processDeletes(Session session, - Map reqProperties, List changes) - throws RepositoryException { + Map reqProperties, + List changes) throws RepositoryException { for (RequestProperty property : reqProperties.values()) { - if (property.isDelete()) { - String propPath = property.getPath(); - if (session.itemExists(propPath)) { - Item item = session.getItem(property.getParentPath()); + + if (property.isDelete() && session.itemExists(property.getPath())) { + + if (property.getName().equals("jcr:mixinTypes")) { - if (property.getName().equals("jcr:mixinTypes") && item.isNode()) { - // clear all mixins - Node parent = (Node) item; - for (NodeType mixin : parent.getMixinNodeTypes()) { - parent.removeMixin(mixin.getName()); - } - } else { - item.remove(); + // clear all mixins + Node parent = (Node) session.getItem(property.getParentPath()); + for (NodeType mixin : parent.getMixinNodeTypes()) { + parent.removeMixin(mixin.getName()); } - changes.add(Modification.onDeleted(propPath)); + + } else { + + session.getItem(property.getPath()).remove(); + } + + changes.add(Modification.onDeleted(property.getPath())); } }