You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2019/10/07 06:14:32 UTC
[sling-org-apache-sling-servlets-post] branch master updated:
SLING-8768 : Revert SLING-2534 and let empty values remove the property
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-post.git
The following commit(s) were added to refs/heads/master by this push:
new 003f01c SLING-8768 : Revert SLING-2534 and let empty values remove the property
003f01c is described below
commit 003f01c72cfa4f8ea599455c90df0fc541ac8c00
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Oct 7 08:14:22 2019 +0200
SLING-8768 : Revert SLING-2534 and let empty values remove the property
---
.../servlets/post/impl/helper/SlingPropertyValueHandler.java | 11 +++++------
.../post/impl/helper/SlingPropertyValueHandlerTest.java | 5 ++---
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java b/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
index 0ff1365..c5c69fb 100644
--- a/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
+++ b/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
@@ -211,12 +211,9 @@ public class SlingPropertyValueHandler {
// RequestProperty#getStringValues already takes care of the configs ignoreBlanks, defaultValues etc.
// and provides values as null, new String[0] etc. accordingly.
- final int type = getType(parent, prop);
-
- if (values == null
- || (values.length == 1 && values[0].length() == 0 && type != PropertyType.STRING
- && type != PropertyType.UNDEFINED)) {
- // if no value is present, just remove the existing property (if any)
+ if (values == null || (values.length == 1 && values[0].length() == 0)) {
+ // if no value is present or a single empty string is given,
+ // just remove the existing property (if any)
removeProperty(parent, prop);
} else if (values.length == 0) {
@@ -239,7 +236,9 @@ public class SlingPropertyValueHandler {
removeIfSingleValueProperty(parent, prop);
}
+ final int type = getType(parent, prop);
if (jcrSupport.hasSession(parent.resource.getResourceResolver())) {
+
if (type == PropertyType.DATE) {
if (storeAsDate(parent, prop.getName(), values, multiValue)) {
return;
diff --git a/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerTest.java b/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerTest.java
index 3689438..0e819c8 100644
--- a/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerTest.java
+++ b/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerTest.java
@@ -132,10 +132,9 @@ public class SlingPropertyValueHandlerTest {
handler.setProperty(rsrc, prop);
// value map should be empty, one change: delete
- assertEquals(1, valueMap.size());
- assertEquals("", valueMap.get("property"));
+ assertTrue(valueMap.isEmpty());
assertEquals(1, mods.size());
- assertEquals(ModificationType.MODIFY, mods.get(0).getType());
+ assertEquals(ModificationType.DELETE, mods.get(0).getType());
assertEquals("/content/property", mods.get(0).getSource());
}
}