Hi Jun,
You are right. The code [1] also confirms this. There seems to be, at the
moment, no API for adding a tag instead of replacing all of them.
This is not very nice, or even safe, because you risk overriding someone
else's changes since between the time you get all tags and post back the
(older and) modified version to add/delete a tag, someone else might have
already added/deleted a tag.
Please feel free to fix the documentation [2] and, why not, also make a nice
contribution to the REST module by adding the missing
"/wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/tags/{tagName}")
resource with 3 methods (PUT for add, DELETE for remove and GET just to
display a single tag) in the PageTagResource class in the same package. You
can just copy the code from [1], rename things accordingly and replace the
method bodies with the logic to add/remove a tag. The resulting resource
should look rather more like [3], but for tags instead of pages. All of this
must be done in a fork of xwiki-platform and, at the end, a pull request
must be issued to apply the changes into XWiki. Oh, and don't forget to
create a jira issue to which you link the pull request.
Also, as a general note, please feel free to benefit from XWiki's open
development model and, whenever encountering missing REST API (for example),
(specially if it's a minor thing) feel free to patch it up yourself. You can
learn more about XWiki's data model, it's components and the REST API
itself. Also, you can either wait forever for a missing feature to be added,
or just go for it and add it yourself, ending up with the result you want
instead of a half-baked one that is relying on other people that are busy
with other things :)
Of course, all of the above are just recommendations. Don't feel obligated
or anything :)
Thanks,
Eduard
----------------
References:
[1]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwi…
[2]
http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HTagresou…
[3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwi…
On Sun, Jul 17, 2011 at 8:15 PM, Jun Han <jun.han37(a)gmail.com> wrote:
Dear all,
I am trying to add a tag/tags to a page.
However, it seems to me that there is an inconsistency between XWiki
REST API document and its implementation.
http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HTagresou…
The document indicates that PUT method can take <tag> element and will
add a tag.
However, the implementation only takes <tags> element (via
xml/application) and PUT method replaces all the existing tags with the
new tags included in the <tags> element.
Is there a REST call that only adds a tag to the page without replacing
all the existing ones?
Best regards
Jun Han
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs