[xwiki-devs] Copy page through Restful API
Hi, In XWiki, we could copy a page from one space to another space. Is there any thoughts about making a copy of page through RestApi. While copying a page, all of the objects within that page should be copied over too. The only way I can see it can be done now is by getting all objects of that page, iterate through them and create them one by one. Is there a better solution to this? Thanks in advance Regards, Manish -- View this message in context: http://xwiki.475771.n2.nabble.com/Copy-page-through-Restful-API-tp6575262p65... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi Manish, = Short answer = There is no REST API to help you do it faster, you have to do it on your own, by getting the page and all its metadata and saving it in a new location with a new name. = Long answer / proposal = Maybe I`m wrong, but, as operations, REST only supports the basic HTTP protocol operations: PUT, GET, POST and DELETE. Translated to application operations, you have Create, Retrieve, Update and Delete (CRUD). These are basic operations that can be composed to create more "complex" ones like copy (retrieve+create), rename(retrieve+create+delete), etc. While this is powerful enough to create any operation you would like, it's also a bit limiting for an application's scope because these "new" operations have to be implemented each time by the client, instead of having them available from the application trough an API. One simple example of problem generated by this fact is that the client will perform 3 operations for a rename (retrieve page + create page in new location + delete old page location) and this will trigger 3 application events in the application's (xwiki's) notification system instead of just 1. Modules listening for page copy or page rename events will not be notified because they were listening to 1 specific event, but 3 general events were used instead. The other obvious concern is the performance of 2/3 operations (each sending and receiving data over the network) versus just 1 (possibly optimised). A "not-so-hackish" solution could be used on the application side to provide an extension to the basic HTTP operations by using parameters such as... ".../spaces/Main/pages/Test?action=copy&destination=Tests.Test", just like we do to overcome browser limitations for the HTTP method [1]. Actually, we could just extend the possible values for the "method" parameter used in [1] by adding "copy" and "rename". ------------------ References: [1] http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HOvercomin... On Tue, Jul 12, 2011 at 5:23 PM, xManish <[email protected]> wrote:
Hi, In XWiki, we could copy a page from one space to another space. Is there any thoughts about making a copy of page through RestApi. While copying a page, all of the objects within that page should be copied over too.
The only way I can see it can be done now is by getting all objects of that page, iterate through them and create them one by one.
Is there a better solution to this?
Thanks in advance
Regards, Manish
-- View this message in context: http://xwiki.475771.n2.nabble.com/Copy-page-through-Restful-API-tp6575262p65... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Eduard (and other RESTful API interested users), I am writing to this thread as I never heard back from anyone within the community on a recent posting I made on 2011/7/6 title working with REST API for integrating Sakai and XWiki. There I outlined the performance issues we were experiencing in our integration of Sakai with XWiki. I included some thoughts on a possible extension to the REST API that might help address some of the performance issues. I was looking for some feedback on it. The thought was to : given a permission setting and a list of users we would get back a list of pages or given a permission setting and a list of pages we would get back a list of users. It is my understanding that the RESTful API as implemented is not as mature as the RPC API, and that the REST API was becoming the preferred API. I would appreciate, as I know others in the Sakai community as well, to see if we can overcome some of the performance concerns related to XWiki's RESTful API. If the extension to the REST API as proposed makes sense or an alternative approach is there how is it best to move this forward? Thanks, - Adam Adam Hocek Information Technology Marist College tel: 845-575-3948 From: Eduard Moraru <[email protected]> To: XWiki Developers <[email protected]> Date: 07/13/2011 04:55 AM Subject: Re: [xwiki-devs] Copy page through Restful API Sent by: [email protected] Hi Manish, = Short answer = There is no REST API to help you do it faster, you have to do it on your own, by getting the page and all its metadata and saving it in a new location with a new name. = Long answer / proposal = Maybe I`m wrong, but, as operations, REST only supports the basic HTTP protocol operations: PUT, GET, POST and DELETE. Translated to application operations, you have Create, Retrieve, Update and Delete (CRUD). These are basic operations that can be composed to create more "complex" ones like copy (retrieve+create), rename(retrieve+create+delete), etc. While this is powerful enough to create any operation you would like, it's also a bit limiting for an application's scope because these "new" operations have to be implemented each time by the client, instead of having them available from the application trough an API. One simple example of problem generated by this fact is that the client will perform 3 operations for a rename (retrieve page + create page in new location + delete old page location) and this will trigger 3 application events in the application's (xwiki's) notification system instead of just 1. Modules listening for page copy or page rename events will not be notified because they were listening to 1 specific event, but 3 general events were used instead. The other obvious concern is the performance of 2/3 operations (each sending and receiving data over the network) versus just 1 (possibly optimised). A "not-so-hackish" solution could be used on the application side to provide an extension to the basic HTTP operations by using parameters such as... ".../spaces/Main/pages/Test?action=copy&destination=Tests.Test", just like we do to overcome browser limitations for the HTTP method [1]. Actually, we could just extend the possible values for the "method" parameter used in [1] by adding "copy" and "rename". ------------------ References: [1] http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HOvercomin... On Tue, Jul 12, 2011 at 5:23 PM, xManish <[email protected]> wrote:
Hi, In XWiki, we could copy a page from one space to another space. Is there any thoughts about making a copy of page through RestApi. While copying a page, all of the objects within that page should be copied over too.
The only way I can see it can be done now is by getting all objects of that page, iterate through them and create them one by one.
Is there a better solution to this?
Thanks in advance
Regards, Manish
-- View this message in context:
http://xwiki.475771.n2.nabble.com/Copy-page-through-Restful-API-tp6575262p65...
Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On 07/13/2011 04:55 AM, Eduard Moraru wrote:
Hi Manish,
= Short answer =
There is no REST API to help you do it faster, you have to do it on your own, by getting the page and all its metadata and saving it in a new location with a new name.
= Long answer / proposal =
Maybe I`m wrong, but, as operations, REST only supports the basic HTTP protocol operations: PUT, GET, POST and DELETE. Translated to application operations, you have Create, Retrieve, Update and Delete (CRUD). These are basic operations that can be composed to create more "complex" ones like copy (retrieve+create), rename(retrieve+create+delete), etc. While this is powerful enough to create any operation you would like, it's also a bit limiting for an application's scope because these "new" operations have to be implemented each time by the client, instead of having them available from the application trough an API.
One simple example of problem generated by this fact is that the client will perform 3 operations for a rename (retrieve page + create page in new location + delete old page location) and this will trigger 3 application events in the application's (xwiki's) notification system instead of just 1. Modules listening for page copy or page rename events will not be notified because they were listening to 1 specific event, but 3 general events were used instead. The other obvious concern is the performance of 2/3 operations (each sending and receiving data over the network) versus just 1 (possibly optimised).
A "not-so-hackish" solution could be used on the application side to provide an extension to the basic HTTP operations by using parameters such as... ".../spaces/Main/pages/Test?action=copy&destination=Tests.Test", just like we do to overcome browser limitations for the HTTP method [1]. Actually, we could just extend the possible values for the "method" parameter used in [1] by adding "copy" and "rename".
1/ I'm not a big fan of this solution, since it makes the method (the verb, the action to perform) kind of meaningless. On the other hand, it does allow to overcome another browser limitation, since normally only GET and POST is supported by browsers when using the location bar. One remark, the methods should respect the case of the standard HTTP/WebDAV methods, so capitalized COPY and MOVE. 2/ WebDAV extends the HTTP list of methods with COPY and MOVE. So, a possible solution would be to actually use these as the HTTP/WebDAV methods, but this solution has limitations, meaning that it's not supported by most HTTP clients. 3/ Another option would be to implement copy and move not as methods, but as data sources: PUT /in/this/location ?copyFrom=some/other/location PUT /in/this/location ?moveFrom=some/other/location This option has the advantage that it doesn't break the semantics of the methods, and it works in all cases. Personally, I prefer, in order, 3/, 1/, and then 2/
------------------ References: [1] http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HOvercomin...
On Tue, Jul 12, 2011 at 5:23 PM, xManish<[email protected]> wrote:
Hi, In XWiki, we could copy a page from one space to another space. Is there any thoughts about making a copy of page through RestApi. While copying a page, all of the objects within that page should be copied over too.
The only way I can see it can be done now is by getting all objects of that page, iterate through them and create them one by one.
Is there a better solution to this?
Thanks in advance
Regards, Manish
-- Sergiu Dumitriu http://purl.org/net/sergiu/
participants (4)
-
Adam Hocek -
Eduard Moraru -
Sergiu Dumitriu -
xManish