You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:56:48 UTC

[sling-org-apache-sling-pipes] 04/31: SLING-5433 - WritePipe should remove a property when value is evaluated as null

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.pipes-0.0.10
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git

commit 3a3623439efc1e5bfd0137ed4bd77c3f66179845
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Jan 15 15:05:49 2016 +0000

    SLING-5433 - WritePipe should remove a property when value is evaluated as null
    
    Submitted-By: Nicolas Peltier
    
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/sling-pipes@1724831 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/pipes/WritePipe.java     | 2 +-
 src/test/java/org/apache/sling/pipes/WritePipeTest.java | 1 +
 src/test/resources/fruits.json                          | 1 +
 src/test/resources/write.json                           | 1 +
 4 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/pipes/WritePipe.java b/src/main/java/org/apache/sling/pipes/WritePipe.java
index 5a4481b..16f0f8f 100644
--- a/src/main/java/org/apache/sling/pipes/WritePipe.java
+++ b/src/main/java/org/apache/sling/pipes/WritePipe.java
@@ -112,7 +112,7 @@ public class WritePipe extends BasePipe {
                     if (value == null) {
                         //null value are not handled by modifiable value maps,
                         //removing the property if it exists
-                        Resource propertyResource = resource.getChild(key);
+                        Resource propertyResource = target.getChild(key);
                         if (propertyResource != null) {
                             logger.info("removing {}", propertyResource.getPath());
                             if (!isDryRun()){
diff --git a/src/test/java/org/apache/sling/pipes/WritePipeTest.java b/src/test/java/org/apache/sling/pipes/WritePipeTest.java
index e6e6bf6..315cf37 100644
--- a/src/test/java/org/apache/sling/pipes/WritePipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/WritePipeTest.java
@@ -53,6 +53,7 @@ public class WritePipeTest extends AbstractPipeTest {
         ValueMap properties =  context.resourceResolver().getResource("/content/fruits/apple").adaptTo(ValueMap.class);
         assertTrue("There should be hasSeed set to true", properties.get("hasSeed", false));
         assertArrayEquals("Colors should be correctly set", new String[]{"green", "red"}, properties.get("colors", String[].class));
+        assertFalse("worm property should be gone (${null} conf)", properties.get("worm", false));
     }
 
     /**
diff --git a/src/test/resources/fruits.json b/src/test/resources/fruits.json
index 046e092..9506a2d 100644
--- a/src/test/resources/fruits.json
+++ b/src/test/resources/fruits.json
@@ -3,6 +3,7 @@
   "index":["apple","banana"],
   "apple":{
     "jcr:primaryType":"nt:unstructured",
+    "worm":"true",
     "isnota":{
       "jcr:primaryType":"nt:unstructured",
       "pea":{
diff --git a/src/test/resources/write.json b/src/test/resources/write.json
index f0ecb48..3d3dda7 100644
--- a/src/test/resources/write.json
+++ b/src/test/resources/write.json
@@ -7,6 +7,7 @@
     "conf": {
       "jcr:primaryType":"nt:unstructured",
       "hasSeed":true,
+      "worm":"${null}",
       "colors":["green","red"]
     }
   },

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.