Hi,
I have a requirement to remove values from cq:tags property of the asset. The value to be removed will be entered through text field present in a dialog panel.
I am trying to achieve this using SlingPostServlet and specifying the suffix for the property as 'Patch' like below
./jcr:content/metadata/cq:tags@Patch found from the below thread
On click of Ok of the dialog, I am adding minus(-) sign at the start of the value entered in the textfield. But this is not working. Can you please let me know where I am making a mistake.
Thanks in advance
Solved! Go to Solution.
Views
Replies
Total Likes
That is exactly what the Sling Post Servlet can do.
Attached is a small package I've done for test and education purposes (change the ext to zip). It adds a node /content/geometrixx-media/en/propertytest and 8 subpages that all has the tag Music but only half of the pages has the "wrongly set" Movies (named hastag#). The acceptance criteria is to use a POST to remove the Movies tag. I used curl to post my content, but you can use whatever POST-tool you want.
The curl command to remove a tag is:
curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag1/jcr:content
If we break it down it consist of (decoded):
Now, if I try to do the same thing on a "notag#" node like this:
curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag1/jcr:content
the only thing that happens is that we change the title.
The "whole" bunch of curl-commands then is:
curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag1/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag1/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag11/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag11/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag12/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag12/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag13/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag13/jcr:content
/Ove
Views
Replies
Total Likes
What you need to do is sending the following information in the request to the metadata to remove is, here removing the tag year/2011:
./cq:tags -year/2011 ./cq:tags@Patch true ./cq:tags@TypeHint String[]
The magic is in the @TypeHint String[] that tells the SlingPost servlet that it should handle the value as a String array. Without it, it tries to default to just String, since that is what you provide for it.
/Ove
Views
Replies
Total Likes
Our specific use case is bulk-editing of multiple resources, where you want to say " remove valueX to/from the set", regardless of whether the certain property has the value or not. That should be automatically done by the POST servlet.An example would be tags. In this case, having to rewrite the entire array in the POST is not optimal, sometimes you just want to say "add valueX" or "remove valueX".
Specifically for the Bulk Editor functionality, where the requirement is deletion of specific tags from certain DAM Assets, we have tried two approaches -
1. Using the @Patch Suffix , but is not working correctly.
2. Even a generic
Values[] v = prop.getValues(); for each (Value val in v) { v.remove(val); }
is not working. Is there any specific thing we need to handling while considering remove of selected Tags?
Views
Replies
Total Likes
That is exactly what the Sling Post Servlet can do.
Attached is a small package I've done for test and education purposes (change the ext to zip). It adds a node /content/geometrixx-media/en/propertytest and 8 subpages that all has the tag Music but only half of the pages has the "wrongly set" Movies (named hastag#). The acceptance criteria is to use a POST to remove the Movies tag. I used curl to post my content, but you can use whatever POST-tool you want.
The curl command to remove a tag is:
curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag1/jcr:content
If we break it down it consist of (decoded):
Now, if I try to do the same thing on a "notag#" node like this:
curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag1/jcr:content
the only thing that happens is that we change the title.
The "whole" bunch of curl-commands then is:
curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag1/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag1/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag11/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag11/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag12/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag12/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=RemovedTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/hastag13/jcr:content curl -u admin:admin --data "_charset_=utf-8&%3Astatus=browser&.%2Fjcr%3Atitle=StillNoTagMovies1&%3Aignore=&.%2Fcq%3Atags%40TypeHint=String%5B%5D&.%2Fcq%3Atags%40Patch=true&.%2Fcq%3Atags=-geometrixx-media%3Aentertainment%2Fmovies" http://localhost:4502/content/geometrixx-media/en/propertytest/notag13/jcr:content
/Ove
Views
Replies
Total Likes