[xwiki-devs] about how to implement "rename page" function in xeclipse
Dear all, I am not sure how to implement "rename page" in xeclipse via REST API. In the current xmlrpc implementation, page rename changes the page name of and keeps the page history at the same time. However, in REST API, changing the page name means changes the resource URL of the page. This means that a new resource will be created. For example, change from "wikis/xwiki/spaces/myspace/pages/oldPageName" to "wikis/xwiki/spaces/myspace/pages/newName" Here are my questions: 1. Will the old page resource be removed? 2. Will the old page history be kept and stored in the new page? From REST API, I cannot find an http method to add page history Best regards Jun Han
Hi Jun, There has recently been a thread [1] almost on the same topic. The idea is that copy and rename are not currently supported by the REST API. Using only the existing CRUD operations to perform copy and rename is really not an option, mainly because of page history and performance issues. A good solution, from my POV, is the one suggested by Sergiu in [1]. The idea is to PUT to a new location an empty page with the mention that it is a copyFrom or a renameFrom another page. Technically, you just have to: 1. override the putPage method [2] in the PageResource class of the REST module by adding the 2 extra parameters (copyFrom and moveFrom). 2. Then, you check for which of these parameters was given, 3. (if moveFrom) get the document specified by the parameter value and use XWikiDocument.rename(newDocumentReference, context) [3] to rename the document or 3.1. (if copyFrom) get the document reference specified by the parameter value and use XWiki.copyDocument(sourceDocumentReference, targetDocumentReference, context) [4] 4. If none of the 2 parameters was given, fall-back to the default and current behaviour of the putPage method (which is to expect page content). The above 2 xwiki methods take care of history, objects and attachments. Do the above in your forked xwiki-platform repository and then ask for a pull request so that it can be integrated in XWiki. You can directly use it offline in order to implement rename and copy in XEclipse, while it is being reviewed for integration in XWiki. This should be really easy to do and a great chance to contribute :). Thanks, Eduard ----------------- References: [1] http://markmail.org/message/lzlcsrjboa6v654e [2] https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... [3] https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... [4] https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... On Wed, Aug 10, 2011 at 9:37 PM, Jun Han <jun.han37@gmail.com> wrote:
Dear all,
I am not sure how to implement "rename page" in xeclipse via REST API. In the current xmlrpc implementation, page rename changes the page name of and keeps the page history at the same time.
However, in REST API, changing the page name means changes the resource URL of the page. This means that a new resource will be created. For example, change from "wikis/xwiki/spaces/myspace/pages/oldPageName" to "wikis/xwiki/spaces/myspace/pages/newName"
Here are my questions: 1. Will the old page resource be removed? 2. Will the old page history be kept and stored in the new page? From REST API, I cannot find an http method to add page history
Best regards Jun Han _______________________________________________ devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs
participants (2)
-
Eduard Moraru -
Jun Han