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):
- -u = the authorization
- --data - our POST data, URL-encoded
- _charset_=utf8 - what is the encoding
- :status=browser - one of the "hidden" Sling Post variables. Aways returns 200, and gives any error in the reply.
- ./jcr:title=RemovedTagMovies1 - Added this just for fun so we get a faster feedback.
- :ignore - Ignore some of the errors
- ./cq:tags@TypeHint=String[] - Tells the POST servlet how to handle the request. VERY IMPORTANT! Without it, it treats it like a String and removes everything.
- ./cq:tags@Patch=true - I will modify on the values of this value. This allows us to use + and -
- ./cq:tags=--geometrixx-media:entertainment/movies - The tag to remove.
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