On Mar 24, 2009, at 8:36 AM, asiri (SVN) wrote:
Author: asiri
Date: 2009-03-24 08:36:32 +0100 (Tue, 24 Mar 2009)
New Revision: 17954
Modified:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/
DocumentModelBridge.java
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/
DocumentName.java
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/
XWikiDocument.java
Log:
XWIKI-3427: Introduce DocumentModelBridge.setParent() method
* Changed tha parameter type of setParent() method from
DocumentModelBridge to DocumentName.
Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/
bridge/DocumentModelBridge.java
===================================================================
--- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/
DocumentModelBridge.java 2009-03-23 21:15:24 UTC (rev 17953)
+++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/
DocumentModelBridge.java 2009-03-24 07:36:32 UTC (rev 17954)
@@ -30,11 +30,11 @@
public interface DocumentModelBridge
{
/**
- * Sets the parent document attribute of this document to the
given value.
+ * Sets the parent document name attribute for this document.
*
- * @param parent the {@link DocumentModelBridge} representing
the parent document.
+ * @param parentName name of the parent document.
*/
- void setParent(DocumentModelBridge parent);
+ void setParent(DocumentName parentName);
/**
* Retrieve the full name of the document, in the
<code>Space.Name</code> format, for example
<tt>Main.WebHome</tt>.
Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/
bridge/DocumentName.java
===================================================================
--- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/
DocumentName.java 2009-03-23 21:15:24 UTC (rev 17953)
+++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/
DocumentName.java 2009-03-24 07:36:32 UTC (rev 17954)
@@ -77,4 +77,14 @@
{
return this.page;
}
+
+ /**
+ * Converts this {@link DocumentName} into a string
representation.
+ *
+ * @return a string representing this {@link DocumentName} of
the form wiki:space.page.
+ */
+ public String toString()
+ {
+ return getWiki() + ":" + getSpace() + "." + getPage();
This will fail if the wiki, space or page are null.
Note that the serializer should resolve not specified values when
calling getXXX() using current wiki/space. You can do this by
injecting the Execution component and accessing the XWikiContext. Then
you can call getDoc().getSpace() to get the current space. Use
"WebHome" when the page isn't specified and use getDatabase() when the
wiki isn't specified.
Also you should create a DocumentNameSerializer() interface and a
DefaultDocumentNameSerializer implementation:
String serialize(DocumentName();
Then refactor XWikiDocument to use DocumentNameSerializer in
setFullName()
Thanks
-Vincent
+ }
}
Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
doc/XWikiDocument.java
===================================================================
--- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/
XWikiDocument.java 2009-03-23 21:15:24 UTC (rev 17953)
+++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/
XWikiDocument.java 2009-03-24 07:36:32 UTC (rev 17954)
@@ -71,6 +71,7 @@
import org.suigeneris.jrcs.rcs.Version;
import org.suigeneris.jrcs.util.ToString;
import org.xwiki.bridge.DocumentModelBridge;
+import org.xwiki.bridge.DocumentName;
import org.xwiki.rendering.block.Block;
import org.xwiki.rendering.block.HeaderBlock;
import org.xwiki.rendering.block.LinkBlock;
@@ -570,9 +571,9 @@
/**
* {@inheritDoc}
*/
- public void setParent(DocumentModelBridge parent)
- {
- this.parent = parent.getFullName();
+ public void setParent(DocumentName parentName)
+ {
+ this.parent = parentName.toString();
}
public String getFullName()