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#HOvercomingbrowserlimitations > > 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/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

