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<String, RequestProperty> reqProperties, List<Modification>
changes)
- throws RepositoryException {
+ Map<String, RequestProperty> reqProperties,
+ List<Modification> 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()));
}
}