There have been a number of questions about renaming documents in XWiki,
and the usual answer has been that you can't.
There is, however, a method,
com.xpn.xwiki.doc.XWikiDocument.rename(String, XWikiContext) that
purports to do exactly this, and from the source, it looks like it does
the correct stuff, cloning itself, updating any objects it contains to
refer to the new document name, etc.
The only problem with this method is that, in my case, I haven't been
able to make it work. In one case, it returned, as advertised, a
Document with the new name to my page, but the document remained intact
under its original name and not under the new one. Since that time,
after which I restarted the server, it only returns null. Due to
problems with CGLIB-generated class files, I can't set a breakpoint to
find out why (anyone know the magic to make CGLIB create line-number
entries?).
A few details: the actual problem I'm trying to solve is scripting the
change of existing login IDs to integrate with an enterprise-wide
authentication service, which requires a company-standard naming scheme.
My change to the security scheme was limited to subclassing
XWikiAuthServiceImpl and overriding only the default constructor (to
instantiate the auth service client library) and the checkPassword
method. Since XWiki's default implementation of a user ID is the user's
profile, named XWiki.<username>, that will entail changing a document
name and all wiki references to it. My first plan was a transitional
scheme that involved using XWiki.copyDocument() to create the new
document, leaving the original document in place for the default
XWikiAuthServiceImpl to use, replacing its content with a notice of the
change and removing the user's edit right, then removing it and changing
all wiki references to it the first time they log in under the new
scheme. Alternatively, using XWiki.createUser to create the new user
was a possibility, but it looks messier from the standpoint of migrating
the original user's profile page.
So, a couple of questions, for discussion and/or authoritative answer:
- Does XWikiDocument.rename() actually work as advertised? I am aware
of the need for the "programming" right on the original document to use
the necessary methods (on the space or the wiki doesn't do it), and have
made sure that I have them by checking with checkProgrammingRights.
- What's the best way to change an existing user's login ID without
disruption beyond having to use the new name?
- XWiki provides reasonable ways to find all of the kinds of document
references that I can think of, including object string
fields(especially group membership and rights objects) and wiki links;
are there any others I will need to consider?
- Does the XWikiAdmin identity (or the XWikiAdminGroup, for that
matter) have any implementation outside the database? I notice that
XWikiAdmin's profile document is not named XWikiAdmin, so something is
not the same about it. The reason I need to know is that it won't work
under the new authentication service's naming rules, and I want to
eliminate it for other reasons too (mostly that it's a shared ID) and
replace all of its rights entries with a group entry for
XWikiAdminGroup. Primarily, I need to know whether there's any reason
this strategy won't work, because re-implementing it would constitute an
access backdoor.
Brian M. Thomas - Senior Technical Architect
AT&T Services, Inc.
One SBC Center, Room 24D3
St. Louis, MO 63101
314 235 3141