incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r644721 - /incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPropertyValueHandler.java
Date Fri, 04 Apr 2008 14:18:18 GMT
Author: cziegeler
Date: Fri Apr  4 07:18:16 2008
New Revision: 644721

URL: http://svn.apache.org/viewvc?rev=644721&view=rev
Log:
SLING-355: Handle request with a parameter containing no value as a remove of the property.

Modified:
    incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPropertyValueHandler.java

Modified: incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPropertyValueHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPropertyValueHandler.java?rev=644721&r1=644720&r2=644721&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPropertyValueHandler.java
(original)
+++ incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPropertyValueHandler.java
Fri Apr  4 07:18:16 2008
@@ -205,25 +205,33 @@
                 );
             }
         } else if (values.length == 1) {
-            removePropertyIfExists(parent, prop.getName());
-            if (type == PropertyType.DATE) {
-                // try conversion
-                Calendar c = ctx.getDateParser().parse(values[0]);
-                if (c != null) {
-                    ctx.getHtmlResponse().onModified(
-                        parent.setProperty(prop.getName(), c).getPath()
-                    );
-                    return;
+            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 ) {
+                    ctx.getHtmlResponse().onDeleted(removePath);
                 }
-                // fall back to default behaviour
-            }
-            final Property p;
-            if ( type == PropertyType.UNDEFINED ) {
-                p = parent.setProperty(prop.getName(), values[0]);
             } else {
-                p = parent.setProperty(prop.getName(), values[0], type);
+                // modify property
+                if (type == PropertyType.DATE) {
+                    // try conversion
+                    Calendar c = ctx.getDateParser().parse(values[0]);
+                    if (c != null) {
+                        ctx.getHtmlResponse().onModified(
+                            parent.setProperty(prop.getName(), c).getPath()
+                        );
+                        return;
+                    }
+                    // fall back to default behaviour
+                }
+                final Property p;
+                if ( type == PropertyType.UNDEFINED ) {
+                    p = parent.setProperty(prop.getName(), values[0]);
+                } else {
+                    p = parent.setProperty(prop.getName(), values[0], type);
+                }
+                ctx.getHtmlResponse().onModified(p.getPath());
             }
-            ctx.getHtmlResponse().onModified(p.getPath());
         } else {
             removePropertyIfExists(parent, prop.getName());
             if (type == PropertyType.DATE) {



Mime
View raw message