Hi Kaushal, 

I'd go for a ternary operator 
${['/etc/cloudservices/memsource-translation/memsource-connector','/etc/cloudservices/memsource-translation/memsource-rnd'].indexOf(tmp)
 > 0 ?  
'/conf/ni/settings/cloudconfigs/translation':'/conf/ni/settings/cloudconfigs' 
}${...some other logic for the suffix without /etc prefix...}

On 10/07/2020 20:12, "Kaushal Mall" <km...@adobe.com.INVALID> wrote:

    Hi Nicolas,

    Thank you very much for helping me through this.

    I have one final question, assume my pipe configuration is like [0], 
currently in my _writeTempProperty_ pipe, all I am doing is copying the 
property from the cloudServiceConfigPipe, as is.

    What is needed is to do some manipulation on the value instead of just 
copying. The requirement is below


      *   If the value bound by the cloudServiceConfigPipe is 
/etc/cloudservices/memsource-translation/memsource-connector or 
/etc/cloudservices/memsource-translation/memsource-rnd
         *   Replace “/etc/cloudservices” with 
“/conf/ni/settings/cloudconfigs/translation”
      *   If the value is anything else
         *   Replace “/etc/cloudservices” with “/conf/ni/settings/cloudconfigs”

    A simple replace in the writeTempProperty pipe would have been easy with 
+[${cloudServiceConfig.replace(“/etc/cloudservices”, 
“/conf/ni/settings/cloudconfigs”)}], but, I am not sure if a conditional 
statement like this is possible.

    Thanks again!

    [0]
    cloudServiceConfigsUpdatePipe:
    {

      *
    jcr:primaryType: "sling:Folder",
      *
    jcr:createdBy: "admin",
      *
    status: "finished",
      *
    jcr:created: "Tue Jul 07 2020 14:35:00 GMT-0700",
      *
    statusModified: "Fri Jul 10 2020 11:00:52 GMT-0700",
      *
    sling:resourceType: "slingPipes/container",
      *
    conf:
    {
         *
    jcr:primaryType: "sling:OrderedFolder",
         *
    jcr:createdBy: "admin",
         *
    jcr:created: "Tue Jul 07 2020 14:35:00 GMT-0700",
         *
    findNodes:
    {
            *
    jcr:primaryType: "sling:Folder",
            *
    jcr:createdBy: "admin",
            *
    jcr:created: "Tue Jul 07 2020 14:35:00 GMT-0700",
            *
    expr: "/jcr:root/content/ni/master/home/validation//element(*, 
nt:base)[(@cq:cloudserviceconfigs)]",
            *
    sling:resourceType: "slingPipes/xpath"
    },
         *
    cloudServiceConfig:
    {
            *
    jcr:primaryType: "nt:unstructured",
            *
    path: "cq:cloudserviceconfigs",
            *
    sling:resourceType: "slingPipes/multiProperty"
    },
         *
    writeTempProperty:
    {
            *
    jcr:primaryType: "nt:unstructured",
            *
    path: "${path.findNodes}",
            *
    sling:resourceType: "slingPipes/write",
            *
    conf:
    {
               *
    jcr:primaryType: "nt:unstructured",
               *
    cloudServiceConfigTmp: "+[${cloudServiceConfig}]"
    }
    }
    }

    }


    Kaushal Mall | Sr. Principal Consultant | 480-512-2260
    Have you been impressed by an AEM Consulting resource?  Please take a 
minute to let us know!
    Our new AEM 
Appreciate<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fforms.office.com%2FPages%2FResponsePage.aspx%3Fid%3DWht7-jR7h0OUrtLBeN7O4Wt4SlUkSKNJhPA9dqz9FkBUQVZNNDJONzhHTFREMTExQktPUFAwNDVFVC4u&amp;data=02%7C01%7Cnpeltier%40adobe.com%7Ce675ff5108a84c4c004808d824fcd8c0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637300015692606105&amp;sdata=Vb9cpXmJNssIUZO6lTl60rirO4MwWa9c2WfKq9eh6zU%3D&amp;reserved=0>
 program makes it quick and easy to provide your feedback and help us to 
recognize our top performers.

    On Jul 9, 2020, at 2:48 AM, Nicolas Peltier 
<npelt...@adobe.com.INVALID<mailto:npelt...@adobe.com.INVALID>> wrote:

    Hi Kaushall,

    Sorry i was referring to the "fluent" language that was proven to be needed 
to communicate over something else than node structures (that was kind of 
ruining the point). I'm preparing another even simpler alternative in [1] that 
will make those conversations better.

    Back to your point, I think you could :
    - search for the node directly using sling query, or modifying your xpath 
query with something like element(*,nt:base)[@cq:cloudserviceconfigs], and then 
just chain with the mv pipe with a "path" property value of 
'cloudserviceconfigs', which will put the current resource to be the property,
    - my bad, but chaining directly the write will write on the resource, that 
is do nothing, so you should add a path property on the pipe too, with value of 
the first one so here "${path.findNodes}"

    Then it should work.
    For the move one, you can chain the same findNode pipe with a move pipe, 
that has as a path input 'tmp' and as an expr 'cq:cloudserviceconfigs'. Don't 
forget to add the property overrideTarget=true

    Nicolas

    [1] 
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fissues.apache.org%2Fjira%2Fbrowse%2FSLING-9556&amp;data=02%7C01%7Cnpeltier%40adobe.com%7Ce675ff5108a84c4c004808d824fcd8c0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637300015692606105&amp;sdata=GAC6TWkfAS6H3t%2B79I%2FnRNvDab2rTxhvgxPaPeDDSjA%3D&amp;reserved=0

    On 09/07/2020 00:14, "Kaushal Mall" 
<km...@adobe.com.INVALID<mailto:km...@adobe.com.INVALID>> wrote:

       Thanks Nicolas. Unfortunately, I am still confused on this the below 
translates to a node structure for my pipe. [0] is what I have right now.


         *   findNodes pipe finds all nodes of cq:Page nodes that have 
jcr:content/cq:cloudserviceconfigs property set
         *   pageContentNode pipe gets the “jcr:content” node for the cq:Page
         *   cloudServiceConfig pipe is looking for the cq:cloudserviceconfigs 
property
         *   writeTempProperty pipe will then write all the values returned by 
cloudServiceConfig to a temp property named “tmp”

       Running this pipe doesn’t actually write the tmp property on my 
jcr:content node. Also, I am not sure what the move pipe config should be after 
the writeTempProperty pipe to move “tmp” to “cq:cloudserviceconfigs” property.

       Thanks in advance.


       [0]

       cloudServiceConfigsUpdatePipe:
       {

         *
       jcr:primaryType: "sling:Folder",
         *
       jcr:createdBy: "admin",
         *
       status: "finished",
         *
       jcr:created: "Tue Jul 07 2020 14:35:00 GMT-0700",
         *
       statusModified: "Wed Jul 08 2020 15:02:02 GMT-0700",
         *
       sling:resourceType: "slingPipes/container",
         *
       conf:
       {
            *
       jcr:primaryType: "sling:OrderedFolder",
            *
       jcr:createdBy: "admin",
            *
       jcr:created: "Tue Jul 07 2020 14:35:00 GMT-0700",
            *
       findNodes:
       {
               *
       jcr:primaryType: "sling:Folder",
               *
       jcr:createdBy: "admin",
               *
       jcr:created: "Tue Jul 07 2020 14:35:00 GMT-0700",
               *
       expr: "/jcr:root/content/ni/master/home/validation//element(*, 
cq:Page)[(jcr:content/@cq:cloudserviceconfigs)]",
               *
       sling:resourceType: "slingPipes/xpath"
       },
            *
       pageContentNode:
       {
               *
       jcr:primaryType: "nt:unstructured",
               *
       expr: "#'jcr:content'",
               *
       sling:resourceType: "slingPipes/children"
       },
            *
       cloudServiceConfig:
       {
               *
       jcr:primaryType: "nt:unstructured",
               *
       path: "cq:cloudserviceconfigs",
               *
       sling:resourceType: "slingPipes/multiProperty"
       },
            *
       writeTempProperty:
       {
               *
       jcr:primaryType: "nt:unstructured",
               *
       sling:resourceType: "slingPipes/write",
               *
       conf:
       {
                  *
       jcr:primaryType: "nt:unstructured",
                  *
       tmp: "+[${cloudServiceConfig}]"
       }
       }
       }

       }

       Kaushal Mall | Sr. Principal Consultant | 480-512-2260
       Have you been impressed by an AEM Consulting resource?  Please take a 
minute to let us know!
       Our new AEM 
Appreciate<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fforms.office.com%2FPages%2FResponsePage.aspx%3Fid%3DWht7-jR7h0OUrtLBeN7O4Wt4SlUkSKNJhPA9dqz9FkBUQVZNNDJONzhHTFREMTExQktPUFAwNDVFVC4u&amp;data=02%7C01%7Cnpeltier%40adobe.com%7Ce675ff5108a84c4c004808d824fcd8c0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637300015692606105&amp;sdata=Vb9cpXmJNssIUZO6lTl60rirO4MwWa9c2WfKq9eh6zU%3D&amp;reserved=0>
 program makes it quick and easy to provide your feedback and help us to 
recognize our top performers.

       On Jul 8, 2020, at 1:45 AM, Nicolas Peltier 
<npelt...@adobe.com.INVALID<mailto:npelt...@adobe.com.INVALID><mailto:npelt...@adobe.com.INVALID>>
 wrote:

       Hi Kaushall,

       Multivalue pipe only role is to fork the flow for each value of the MV 
property, adding the value in the bindings.
       I think you should write to a temp property before moving it back
       So something like plumber.newPipe(resourceResolver)
       .echo("/etc/your/configuration/mvProperty")
       .mp().name("mvProp")
       .write("temp", "+[${mvProp}]")
       .run()

       And then
       
.echo("/etc/your/configuration/temp").mv("/etc/your/configuration/mvProperty").with("overwriteTarget",
 true).run()

       Hope this helps,
       Nicolas
       On 07/07/2020 21:19, "Kaushal Mall" 
<km...@adobe.com.INVALID<mailto:km...@adobe.com.INVALID><mailto:km...@adobe.com.INVALID>>
 wrote:

          Hi All,

          I have a use case described below to update a particular multi value 
property and hoping someone can help me with the appropriate Sling Pipe 
configuration.

          There are certain nodes of type cq:PageContent with a property 
cq:cloudservices (string[]) where the value can be similar to 
/etc/cloudservices/mycloudconfig1/cloudconfig, 
/etc/cloudservices/mycloudconfig2/cloudconfig

          The pipe needs to find the nodes where this property is set and 
change the value and replace “/etc/cloudservices” part of the path with 
“/conf/global/settings”

          I am unsure how to write a multi value property using a pipe. I can 
get the appropriate nodes by using the xpath pipe and read the values using a 
multi value pipe (I think), but, not sure how to do string manipulation and 
write the values back.

          Does anyone know how to read and write the values for this use case?

          Thanks in advance.

          Kaushal Mall | Technical Architect | 480-512-2260 | 
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblogs.adobe.com%2Fcontentmanagement&amp;data=02%7C01%7Cnpeltier%40adobe.com%7Ce675ff5108a84c4c004808d824fcd8c0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637300015692606105&amp;sdata=fnGnV%2FypL%2FcRT6oVbnsXhf9iOpVFpsg3TVcLrgvk%2BSU%3D&amp;reserved=0
          Have you been impressed by an AEM Consulting resource?  Please take a 
minute to let us know!
          Our new AEM 
Appreciate<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fforms.office.com%2FPages%2FResponsePage.aspx%3Fid%3DWht7-jR7h0OUrtLBeN7O4Wt4SlUkSKNJhPA9dqz9FkBUQVZNNDJONzhHTFREMTExQktPUFAwNDVFVC4u&amp;data=02%7C01%7Cnpeltier%40adobe.com%7Ce675ff5108a84c4c004808d824fcd8c0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637300015692606105&amp;sdata=Vb9cpXmJNssIUZO6lTl60rirO4MwWa9c2WfKq9eh6zU%3D&amp;reserved=0>
 program makes it quick and easy to provide your feedback and help us to 
recognize our top performers.


Reply via email to