jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Guggisberg <stefan.guggisb...@gmail.com>
Subject Re: MicroKernel add/set property
Date Wed, 17 Oct 2012 14:49:35 GMT
On Wed, Oct 17, 2012 at 3:30 PM, Mete Atamel <matamel@adobe.com> wrote:
> Ok, I opened OAK-381 for adding property twice. However, one thing is
> still not quite clear to me. It looks like set-property is really
> create-or-modify-property whereas add-property is only create-property,


> right? In that case, how do we really generate appropriate PROPERTY_ADDED
> and PROPERTY_CHANGED events? What happens when set-property is being used
> as create-property? For clear separation between PROPERTY_ADDED and
> PROPERTY_CHANGED, I feel like add-property should be prerequisite to
> set-property and set-property should really be modify-property only (i.e.
> If a property does not exist, set-property should throw an exception). If
> you think this is not necessary because appropriate PROPERTY_ADDED and
> PROPERTY_CHANGED events can be derived from set-property as it is today,
> then I'm not sure why add-property is necessary.

the '+' syntax was introduced for representing added properties in the

without the '+' syntax there would no way to reflect property creation
to generate PROPERTY_ADDED events from the journal).

OTOH restricting '^' to set-property semantics (rather than create-or-set)
would IMO seriously impact the usability. mk clients would need to check
first the existence of a property while they usually don't care but just want
to set it to a specific value.

i agree that the ambiguity of '^' vs '+' is confusing. personally i'd prefer
to get rid of the '+' syntax for property creation altogether. as a
consequence we'd loose the ability to generate PROPERTY_ADDED events
from the mk journal. i don't know whether that's a problem for the
current oak-core implementation.



> -Mete
> On 10/17/12 2:58 PM, "Stefan Guggisberg" <stefan.guggisberg@gmail.com>
> wrote:
>>On Tue, Oct 16, 2012 at 4:39 PM, Mete Atamel <matamel@adobe.com> wrote:
>>> Hi,
>>> I have 2 questions on MicroKernel add/set property that MicroKernel
>>> JavaDoc does not seem to answer.
>>> 1- What's the difference between adding a property vs. setting a
>>> Are the two following commits basically the same?
>>> mk.commit("/", "+\"a/key1\" : \"value1\"", null, null);
>>> mk.commit("/", "^\"a/key1\" : \"value1\"", null, null);
>>initially we used to only support the 'set property' (create-or-modify)
>>i.e.  ^"/some/property" : "some value"
>>however, in JCR there are 2 distinct event types:
>>in the mk journal/diff we therefore need to make the same distinction,
>>i.e. added properties are reported with the '+' syntax, whereas the '^'
>>syntax is used to represent property modifications.
>>> Or are there scenarios where adding a property acts differently than
>>> setting a property?
>>> 2- Is adding a property twice supposed to work or is it supposed to
>>> a MicroKernelException? For example, this seems to work with
>>> MicroKernelImpl but is it supposed to?
>>>         mk.commit("/", "+\"a/key1\" : \"value1\"", null, null);
>>>         mk.commit("/", "+\"a/key1\" : \"value1\"", null, null);
>>you're right, that seems to be a bug. could you please file a jira issue?
>>> What about setting a property twice?
>>that shouldn't be an issue. you can set a property more than once in a
>>single commit. only the last modification should be persisted.
>>> Thanks,
>>> Mete

View raw message