I have made a pair of patches.
http://jira.xwiki.org/jira/secure/ManageAttachments.jspa?id=14472
The first adds the functionality to the core and the second changes
renameStep1.vm and rename.vm to use the added functionality.
renameStep1.vm asks the user which document parent values to change just
like it does with backlinks.
newly added methods:
xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
public void rename(String newDocumentName, List<String>
backlinkDocumentNames, List<String> childDocumentNames, XWikiContext
context)
changes parent of all documents given in childDocumentNames list.
xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java
public void rename(String newDocumentName, List<String>
backlinkDocumentNames, List<String> childDocumentNames)
changes parent of all documents given in childDocumentNames list. If any
of the names in childDocumentNames list are not actually children AND
the user doesn't have edit permissions to them, it ends without doing
anything.
changed methods:
xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
public void rename(String newDocumentName, List<String>
backlinkDocumentNames, XWikiContext context)
does not change parent fields in child documents
xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
public void rename(String newDocumentName, XWikiContext context)
finds all backlinks and children (by calling getChildren()), changes
parent names.
xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java
public void rename(String newDocumentName, List<String>
backlinkDocumentNames)
does not change parent fields in child documents
xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java
public void rename(String newDocumentName)
finds all backlinks and children, changes parent names.
xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java
adds testing of parent changes, increases stringency of link change testing.
tests [[newwikiname:newspace.newpage]]
[[someName>>newwikiname:newspace.newpage]]
[[newwikiname:newpage]] [[newpage]] and [[newspace.newpage]]
If there are any issues, let me know and I'll see what I can do.
Caleb James DeLisle
Vincent Massol wrote:
On Aug 13, 2009, at 7:39 PM, Ludovic Dubost wrote:
YES ! We should update as much as possible and
clearly we should
update
the parent.
This has caused me issues many times when working on some projects..
The fix should not actually be that difficult.. Is not in one query
(this would not be compatible with future storage systems).
But with "where doc.parent='...'" and then for (doc in search) {
doc.setParent() doc.save() }
That is not a too difficult fix for the renaming.
I'm not sure if we already have a jira for that.
we do:
http://jira.xwiki.org/jira/browse/XWIKI-1082
-Vincent
Ludovic
Caleb James DeLisle a écrit :
> Hello all,
> I noticed that when a document is renamed, it's "child" documents
> don't have their parent values updated. It looks like just a few
> lines
> of code, maybe an hql
> ALTER XWikiDocument doc WHERE doc.parent = '"+oldName+"' SET
> doc.parent
> = '"+newName+"'
>
> Is this too messy?
> I think a loop with doc.doc.setParent(newName) and doc.save() would
> be
> too resource intensive with databases which fsync every transaction.
>
> Should we bother to even ask the user the way it asks to update
> links?
>
> Should we update #includeForm, #includeInContext, and #includeTopic
> as well?
>
> What are your thoughts?
>
> ~Caleb James DeLisle
> I'm new here, let me know if I posted in the wrong section
>
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs