Sling POST servlet and empty arrays?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Sling POST servlet and empty arrays?

John Logan
Hi, I'm trying to create node with an empty String[] property via the Sling POST servlet.


Patching, and adding/removing the patched property seems to work:


        curl \
                ${CACERT} \
                -s \
                -f \
                -o /dev/null \
                -w "%{http_code}\n" \
                -b ${cookies} \
                -X POST \
                -F jcr:primaryType=sling:Folder \
                -F jcr:mixinTypes=mix:versionable \
                -F 'foo@TypeHint=String[]' \
                -F 'foo@Patch=true' \
                -F 'foo=+dummy' \
                -F 'foo=-dummy' \
                /path/to/resource

Is there a more succinct and accepted way?


Thanks!  John
Reply | Threaded
Open this post in threaded view
|

Re: Sling POST servlet and empty arrays?

Bertrand Delacretaz
Hi,

On Thu, Mar 1, 2018 at 5:07 AM, John Logan <[hidden email]> wrote:
> Hi, I'm trying to create node with an empty String[] property via the Sling POST servlet...
...
> Is there a more succinct and accepted way?...

I don't think so, in general the convention is that empty property
values cause the properties to be removed.

If you rely on that behavior (which I suppose is undocumented and just
happened) it might be wise to contribute an automated test that
clarifies this behavior and prevents it from going away in the future.

-Bertrand
Reply | Threaded
Open this post in threaded view
|

Re: Sling POST servlet and empty arrays?

John Logan
Thanks, Bertrand, for the clarification.  I'm glad you mentioned that this behavior may not be strictly defined.


I don't think I ever turned in my contributor paperwork for Apache and/or Sling but when I can find a little extra time I'll tackle that and add a test.


John



________________________________
From: Bertrand Delacretaz <[hidden email]>
Sent: Monday, March 5, 2018 5:37:22 AM
To: users
Subject: Re: Sling POST servlet and empty arrays?

Hi,

On Thu, Mar 1, 2018 at 5:07 AM, John Logan <[hidden email]> wrote:
> Hi, I'm trying to create node with an empty String[] property via the Sling POST servlet...
...
> Is there a more succinct and accepted way?...

I don't think so, in general the convention is that empty property
values cause the properties to be removed.

If you rely on that behavior (which I suppose is undocumented and just
happened) it might be wise to contribute an automated test that
clarifies this behavior and prevents it from going away in the future.

-Bertrand
Reply | Threaded
Open this post in threaded view
|

Re: Sling POST servlet and empty arrays?

Robert Munteanu-2
Hi John,

On Mon, 2018-03-05 at 17:51 +0000, John Logan wrote:
> Thanks, Bertrand, for the clarification.  I'm glad you mentioned that
> this behavior may not be strictly defined.
>
>
> I don't think I ever turned in my contributor paperwork for Apache
> and/or Sling but when I can find a little extra time I'll tackle that
> and add a test.

That would be great! Note that you don't have to sign a CLA for
submitting individual patches, although it does not hurt to have one on
file.

Robert

>
>
> John
>
>
>
> ________________________________
> From: Bertrand Delacretaz <[hidden email]>
> Sent: Monday, March 5, 2018 5:37:22 AM
> To: users
> Subject: Re: Sling POST servlet and empty arrays?
>
> Hi,
>
> On Thu, Mar 1, 2018 at 5:07 AM, John Logan <[hidden email]>
> wrote:
> > Hi, I'm trying to create node with an empty String[] property via
> > the Sling POST servlet...
>
> ...
> > Is there a more succinct and accepted way?...
>
> I don't think so, in general the convention is that empty property
> values cause the properties to be removed.
>
> If you rely on that behavior (which I suppose is undocumented and
> just
> happened) it might be wise to contribute an automated test that
> clarifies this behavior and prevents it from going away in the
> future.
>
> -Bertrand

Reply | Threaded
Open this post in threaded view
|

Re: Sling POST servlet and empty arrays?

John Logan
Hi Robert,


I created a patch and made it available via:


https://issues.apache.org/jira/browse/SLING-7553


Cheers... John

________________________________
From: Robert Munteanu <[hidden email]>
Sent: Tuesday, March 6, 2018 12:22:18 AM
To: [hidden email]
Subject: Re: Sling POST servlet and empty arrays?

Hi John,

On Mon, 2018-03-05 at 17:51 +0000, John Logan wrote:
> Thanks, Bertrand, for the clarification.  I'm glad you mentioned that
> this behavior may not be strictly defined.
>
>
> I don't think I ever turned in my contributor paperwork for Apache
> and/or Sling but when I can find a little extra time I'll tackle that
> and add a test.

That would be great! Note that you don't have to sign a CLA for
submitting individual patches, although it does not hurt to have one on
file.

Robert

>
>
> John
>
>
>
> ________________________________
> From: Bertrand Delacretaz <[hidden email]>
> Sent: Monday, March 5, 2018 5:37:22 AM
> To: users
> Subject: Re: Sling POST servlet and empty arrays?
>
> Hi,
>
> On Thu, Mar 1, 2018 at 5:07 AM, John Logan <[hidden email]>
> wrote:
> > Hi, I'm trying to create node with an empty String[] property via
> > the Sling POST servlet...
>
> ...
> > Is there a more succinct and accepted way?...
>
> I don't think so, in general the convention is that empty property
> values cause the properties to be removed.
>
> If you rely on that behavior (which I suppose is undocumented and
> just
> happened) it might be wise to contribute an automated test that
> clarifies this behavior and prevents it from going away in the
> future.
>
> -Bertrand

Reply | Threaded
Open this post in threaded view
|

Re: Sling POST servlet and empty arrays?

Robert Munteanu-2
On Thu, 2018-03-22 at 17:30 +0000, John Logan wrote:
> Hi Robert,
>
>
> I created a patch and made it available via:
>
>
> https://issues.apache.org/jira/browse/SLING-7553

Thanks, let's take it from there.

Robert