You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Andreas Schaefer <sc...@me.com.INVALID> on 2021/02/01 20:05:54 UTC

Sling Repository Initializer is failing on Setting a Property with Curly Brackets in them

Hi

If I try to create a property with a curly brackets in it then the parsing fails:

    set properties on /var/dxml/folderprofiles
        set globalDefaultConfigs{String} to \"{\"type\":\"one\"}\"
    end

I tried to escape the curly brackets with \{ and \} but to no avail.

Is there a way to use unicode or ascii codes or any other way to fix it?

Should this be considered a bug as curly brackets in a string properly is a valid value? If so I will create a ticket for it.

- Andy

Re: Sling Repository Initializer is failing on Setting a Property with Curly Brackets in them

Posted by Andreas Schaefer <sc...@me.com.INVALID>.
Hi Betrand

I was using a org.apache.sling.jcr.repoinit.RepositoryInitializer-test.config file which contains the content as:
scripts=[\
"
“\
]

This makes the repo-init a string in itself. Looking at the generated FM from the repo-init config file I saw that it does escape the quotes with a triple slash \\\”.

I will add a comment to the repository initialization HTML page about it.

- Andy

> On Feb 2, 2021, at 6:21 AM, Bertrand Delacretaz <bd...@apache.org> wrote:
> 
> Hi,
> 
> On Mon, Feb 1, 2021 at 10:59 PM Andreas Schaefer
> <sc...@me.com.invalid> wrote:
>> 
>> I got around this issue by extracting the setting of the properties into a
>> reference file (repoinit.txt) and there is works as there the quotes can be
>> escaped with a \. ...
> 
> This makes me think that your issue was caused by provisioning or
> feature model parsing, are you using one of those? If yes please
> create a SLING- ticket if you can reproduce.
> 
> I have added a test that confirms that the repoinit parser supports
> curly brackets correctly,
> https://github.com/apache/sling-org-apache-sling-repoinit-parser/commit/5592fe34e3f9b288a31b0b2679bd6caafa77c578
> 
> -Bertrand


Re: Sling Repository Initializer is failing on Setting a Property with Curly Brackets in them

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Mon, Feb 1, 2021 at 10:59 PM Andreas Schaefer
<sc...@me.com.invalid> wrote:
>
> I got around this issue by extracting the setting of the properties into a
> reference file (repoinit.txt) and there is works as there the quotes can be
> escaped with a \. ...

This makes me think that your issue was caused by provisioning or
feature model parsing, are you using one of those? If yes please
create a SLING- ticket if you can reproduce.

I have added a test that confirms that the repoinit parser supports
curly brackets correctly,
https://github.com/apache/sling-org-apache-sling-repoinit-parser/commit/5592fe34e3f9b288a31b0b2679bd6caafa77c578

-Bertrand

Re: Sling Repository Initializer is failing on Setting a Property with Curly Brackets in them

Posted by Andreas Schaefer <sc...@me.com.INVALID>.
I have a need to create multi-value properties that either contain no value or just a single value.
In JSon the looks like this:

{
	“noValueMulti”: [],
	“singleMultiValue”:[“single”]
}

Because the Repository Initializer is using a comma separated list as indicator when to create a multi-value I cannot do either of these.
I would suggest that you allow something like this:

	set properties on /pathC
		set noMultiValue{String[]} to
		set singleMultiValue{String[]} to “single”
	end

Cheers - Andy


> On Feb 1, 2021, at 3:57 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
> 
> I ran into another issue:
> 
> How can I define a multi-value string with No or just ONE entry?
> 
> When I try:
> 
> - set test to “one”,		// It is a String[] multi-value but with two values where the 2nd is empty
> - set test to ,			// The parsing fails
> 
> In addition using a keyword like ‘end’ fails to parse:
> 
> - set end to “TEST”		// Fails to parse
> - set end{String} to “TEST”	// Fails to parse
> - set ‘end’ to “TEST”		// Fails to parse
> - set “end” to “TEST”		// Fails to parse
> 
> Cheers - Andy
> 
>> On Feb 1, 2021, at 1:58 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
>> 
>> I got around this issue by extracting the setting of the properties into a reference file (repoinit.txt) and there is works as there the quotes can be escaped with a \.
>> 
>> - Andy
>> 
>>> On Feb 1, 2021, at 12:52 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
>>> 
>>> Hi
>>> 
>>> As it turns out the problem is NOT the curly brackets but rather the internal double quotes.
>>> 
>>> - Andy
>>> 
>>>> On Feb 1, 2021, at 12:05 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
>>>> 
>>>> Hi
>>>> 
>>>> If I try to create a property with a curly brackets in it then the parsing fails:
>>>> 
>>>> set properties on /var/dxml/folderprofiles
>>>>     set globalDefaultConfigs{String} to \"{\"type\":\"one\"}\"
>>>> end
>>>> 
>>>> I tried to escape the curly brackets with \{ and \} but to no avail.
>>>> 
>>>> Is there a way to use unicode or ascii codes or any other way to fix it?
>>>> 
>>>> Should this be considered a bug as curly brackets in a string properly is a valid value? If so I will create a ticket for it.
>>>> 
>>>> - Andy
>>> 
>> 
> 


Repoinit, multi-value property with a single value (was: Sling Repository Initializer is failing...)

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Tue, Feb 2, 2021 at 12:57 AM Andreas Schaefer
<sc...@me.com.invalid> wrote:
> ...How can I define a multi-value string with No or just ONE entry?
>
> When I try:
>
> - set test to “one”,            // It is a String[] multi-value but with two values where the 2nd is empty
> - set test to ,                 // The parsing fails

If you need this it requires changes in the parser + JCR processing
code to define a way to mark such a statement as targeting a
multi-value property and process it accordingly.

The jcr-repoinit code at [1] does:

  if (values.size() > 1) {
    Value[] pValues = convertToValues(values);
    n.setProperty(pName, pValues, type);
  } else {
    Value pValue = convertToValue(values.get(0));
    n.setProperty(pName, pValue, type);
  }

So it clearly needs more than one value to create a multi-value
property, and there's no way to express that currently in the reponit
language.

If you agree, please create a SLING- ticket with your requirements,
and patches are welcome of course!

-Bertrand

[1] https://github.com/apache/sling-org-apache-sling-jcr-repoinit/blob/5a14f4c3c96381f44310316689fdd4bd048bf436/src/main/java/org/apache/sling/jcr/repoinit/impl/NodePropertiesVisitor.java#L84

Re: Sling Repository Initializer is failing on Setting a Property with Curly Brackets in them

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, Feb 2, 2021 at 12:57 AM Andreas Schaefer
<sc...@me.com.invalid> wrote:
> - set end to “TEST”             // Fails to parse ...

Indeed, I have created
https://issues.apache.org/jira/browse/SLING-10119 for this one.

-Bertrand

Re: Sling Repository Initializer is failing on Setting a Property with Curly Brackets in them

Posted by Andreas Schaefer <sc...@me.com.INVALID>.
I ran into another issue:

How can I define a multi-value string with No or just ONE entry?

When I try:

- set test to “one”,		// It is a String[] multi-value but with two values where the 2nd is empty
- set test to ,			// The parsing fails

In addition using a keyword like ‘end’ fails to parse:

- set end to “TEST”		// Fails to parse
- set end{String} to “TEST”	// Fails to parse
- set ‘end’ to “TEST”		// Fails to parse
- set “end” to “TEST”		// Fails to parse

Cheers - Andy

> On Feb 1, 2021, at 1:58 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
> 
> I got around this issue by extracting the setting of the properties into a reference file (repoinit.txt) and there is works as there the quotes can be escaped with a \.
> 
> - Andy
> 
>> On Feb 1, 2021, at 12:52 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
>> 
>> Hi
>> 
>> As it turns out the problem is NOT the curly brackets but rather the internal double quotes.
>> 
>> - Andy
>> 
>>> On Feb 1, 2021, at 12:05 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
>>> 
>>> Hi
>>> 
>>> If I try to create a property with a curly brackets in it then the parsing fails:
>>> 
>>>  set properties on /var/dxml/folderprofiles
>>>      set globalDefaultConfigs{String} to \"{\"type\":\"one\"}\"
>>>  end
>>> 
>>> I tried to escape the curly brackets with \{ and \} but to no avail.
>>> 
>>> Is there a way to use unicode or ascii codes or any other way to fix it?
>>> 
>>> Should this be considered a bug as curly brackets in a string properly is a valid value? If so I will create a ticket for it.
>>> 
>>> - Andy
>> 
> 


Re: Sling Repository Initializer is failing on Setting a Property with Curly Brackets in them

Posted by Andreas Schaefer <sc...@me.com.INVALID>.
I got around this issue by extracting the setting of the properties into a reference file (repoinit.txt) and there is works as there the quotes can be escaped with a \.

- Andy

> On Feb 1, 2021, at 12:52 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
> 
> Hi
> 
> As it turns out the problem is NOT the curly brackets but rather the internal double quotes.
> 
> - Andy
> 
>> On Feb 1, 2021, at 12:05 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
>> 
>> Hi
>> 
>> If I try to create a property with a curly brackets in it then the parsing fails:
>> 
>>   set properties on /var/dxml/folderprofiles
>>       set globalDefaultConfigs{String} to \"{\"type\":\"one\"}\"
>>   end
>> 
>> I tried to escape the curly brackets with \{ and \} but to no avail.
>> 
>> Is there a way to use unicode or ascii codes or any other way to fix it?
>> 
>> Should this be considered a bug as curly brackets in a string properly is a valid value? If so I will create a ticket for it.
>> 
>> - Andy
> 


Re: Sling Repository Initializer is failing on Setting a Property with Curly Brackets in them

Posted by Andreas Schaefer <sc...@me.com.INVALID>.
Hi

As it turns out the problem is NOT the curly brackets but rather the internal double quotes.

- Andy

> On Feb 1, 2021, at 12:05 PM, Andreas Schaefer <sc...@me.com.INVALID> wrote:
> 
> Hi
> 
> If I try to create a property with a curly brackets in it then the parsing fails:
> 
>    set properties on /var/dxml/folderprofiles
>        set globalDefaultConfigs{String} to \"{\"type\":\"one\"}\"
>    end
> 
> I tried to escape the curly brackets with \{ and \} but to no avail.
> 
> Is there a way to use unicode or ascii codes or any other way to fix it?
> 
> Should this be considered a bug as curly brackets in a string properly is a valid value? If so I will create a ticket for it.
> 
> - Andy