On Wed, Oct 17, 2012 at 3:30 PM, Mete Atamel <mata...@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,
correct > 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 diff/journal. without the '+' syntax there would no way to reflect property creation (required 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. opinions? cheers stefan > > -Mete > > > On 10/17/12 2:58 PM, "Stefan Guggisberg" <stefan.guggisb...@gmail.com> > wrote: > >>On Tue, Oct 16, 2012 at 4:39 PM, Mete Atamel <mata...@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 >>>property? >>> 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) >>syntax, >>i.e. ^"/some/property" : "some value" >> >>however, in JCR there are 2 distinct event types: >>PROPERTY_ADDED and PROPERTY_CHANGED >> >>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 >>>throw >>> 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. >> >>cheers >>stefan >> >>> >>> >>> Thanks, >>> Mete >>> >>> >