[
https://issues.apache.org/jira/browse/SLING-1983?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alexander Klimetschek updated SLING-1983:
-----------------------------------------
Attachment: SLING-1983.patch
This patch will add @Patch support as described.
Notably, the code is very restrictive and won't change anything on the property
if the operations are wrong (i.e. no +/- ops given in the values). Also, an
existing array is kept, and not forced into a set. For example, if there are
two elements "foo" in the array, and they are not touched by the patch
operations, they will stay in it. The order is also kept, newly added elements
are appended. Otherwise the set semantics are ensured: adding something will
not add it twice, and removing something will remove all occurrences in the
array.
I took the chance to clear up the SlingPropertyValueHandler, remove duplicated
code (there was a lot for the multi-value case and the date/reference handling)
and tried to simplify the rather complex logic. Patching is now basically just
a "filter" for the values before they are written to the multi-value property
as usual.
Included is a new integration test (PostServletPatchTest.java) for this. I also
updated the SlingDateValuesTest to test multi-value date properties, which have
specific handling and thus are quite important to test (because of the above
code cleanup). However, there is no specific test case for date or reference
properties in the context of @Patch yet. Basically if there is a 1:1 mapping
from string to value via getString to string, the patch will work, otherwise
it's impossible anyway, as there is no equals() defined for jcr Value.
To run the integration tests with the new post servlet bundle, one has to
change launchpad/builder/src/main/bundles/list.xml to use 2.1.1-SNAPSHOT of
org.apache.sling.servlets.post. (Or install the latest bundle in the running
sling instance using -PautoInstallBundle).
> Post servlet: Patching multi-value properties
> ---------------------------------------------
>
> Key: SLING-1983
> URL: https://issues.apache.org/jira/browse/SLING-1983
> Project: Sling
> Issue Type: New Feature
> Components: Servlets
> Reporter: Alexander Klimetschek
> Attachments: SLING-1983.patch
>
>
> As described on the sling list
> http://sling.markmail.org/thread/xxaaqowtx7jgfo3p, allow patching of
> multi-value properties:
> New "@Patch" suffix:
> my:property@TypeHint=String[]
> my:property@Patch=true
> my:property=+value1
> my:property=-value1
> When "@Patch" is present, each of the property values from the request are
> expected to start with either "+" or "-", followed by the actual value. These
> two would represent the operations you want to have executed on the set.
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira