[xwiki-devs] [VOTE] Add support for specifying relative document names
Hi Devs, Currently DocumentNames generated by DocumentNameFactory contains the fully qualified document name at all times. And when they are serialized using DocumentNameSerializer, they result in the fully qualified document name string like "wiki:space.name". The problem with this is that new xwiki components using DocumentAccessBridge cannot use relative document names. For an example, "parent" field of a document cannot be set w.r.t the current wiki because the "wiki:" part is always appended by default (by the serializer). So we need a mechanism to specify "what kind of document name" we mean (relative or absolute). We can achive this in many ways: 1. Allow pasing a Serializer into methods which takes in a DocumentName. 2. Allow associating a Serilizer with a DocumentName. 3. Use Execution as a means of passing the preferred Serializer 4. Use a flag inside DocumentName (ABSOLUTE, WIKI_RELATIVE, SPACE_RELATIVE) which will be intepretted by the Serializer appropriately whenever a DocumentName is serialized. None of the above approaches are perfectly clean. But the fourth approach seems to make more sense. I'm +1 for 4. Thanks. - Asiri
On Tue, Jun 2, 2009 at 16:25, Asiri Rathnayake <[email protected]> wrote:
Hi Devs,
Currently DocumentNames generated by DocumentNameFactory contains the fully qualified document name at all times. And when they are serialized using DocumentNameSerializer, they result in the fully qualified document name string like "wiki:space.name".
The problem with this is that new xwiki components using DocumentAccessBridge cannot use relative document names. For an example, "parent" field of a document cannot be set w.r.t the current wiki because the "wiki:" part is always appended by default (by the serializer). So we need a mechanism to specify "what kind of document name" we mean (relative or absolute).
We can achive this in many ways:
1. Allow pasing a Serializer into methods which takes in a DocumentName.
2. Allow associating a Serilizer with a DocumentName.
3. Use Execution as a means of passing the preferred Serializer
4. Use a flag inside DocumentName (ABSOLUTE, WIKI_RELATIVE, SPACE_RELATIVE) which will be intepretted by the Serializer appropriately whenever a DocumentName is serialized.
None of the above approaches are perfectly clean. But the fourth approach seems to make more sense.
I'm +1 for 4.
Not that there is a CompactDocumentNameSerializer (DocumentNameSerializer componenet with hint "compact"). It serialize the given DocumentName depending of the context: if the DocumentName wiki is the name that the current wiki, it's not serialized, same for space. So there is already a way to serialize a relative document name by making setting the context correctly. This serializer is used in XWikiDocument#getUniqueLinkedPages for example.
Thanks.
- Asiri _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Tue, Jun 2, 2009 at 22:11, Thomas Mortagne <[email protected]> wrote:
On Tue, Jun 2, 2009 at 16:25, Asiri Rathnayake <[email protected]> wrote:
Hi Devs,
Currently DocumentNames generated by DocumentNameFactory contains the fully qualified document name at all times. And when they are serialized using DocumentNameSerializer, they result in the fully qualified document name string like "wiki:space.name".
The problem with this is that new xwiki components using DocumentAccessBridge cannot use relative document names. For an example, "parent" field of a document cannot be set w.r.t the current wiki because the "wiki:" part is always appended by default (by the serializer). So we need a mechanism to specify "what kind of document name" we mean (relative or absolute).
We can achive this in many ways:
1. Allow pasing a Serializer into methods which takes in a DocumentName.
2. Allow associating a Serilizer with a DocumentName.
3. Use Execution as a means of passing the preferred Serializer
4. Use a flag inside DocumentName (ABSOLUTE, WIKI_RELATIVE, SPACE_RELATIVE) which will be intepretted by the Serializer appropriately whenever a DocumentName is serialized.
None of the above approaches are perfectly clean. But the fourth approach seems to make more sense.
I'm +1 for 4.
Not that there is a CompactDocumentNameSerializer (DocumentNameSerializer componenet with hint "compact"). It serialize the given DocumentName depending of the context: if the DocumentName wiki is the name that the current wiki, it's not serialized, same for space.
Actually it does not handle space yet as far as i can see in the code but it should.
So there is already a way to serialize a relative document name by making setting the context correctly. This serializer is used in XWikiDocument#getUniqueLinkedPages for example.
Thanks.
- Asiri _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne
Thomas Mortagne wrote:
On Tue, Jun 2, 2009 at 22:11, Thomas Mortagne <[email protected]> wrote:
On Tue, Jun 2, 2009 at 16:25, Asiri Rathnayake <[email protected]> wrote:
Hi Devs,
Currently DocumentNames generated by DocumentNameFactory contains the fully qualified document name at all times. And when they are serialized using DocumentNameSerializer, they result in the fully qualified document name string like "wiki:space.name".
The problem with this is that new xwiki components using DocumentAccessBridge cannot use relative document names. For an example, "parent" field of a document cannot be set w.r.t the current wiki because the "wiki:" part is always appended by default (by the serializer). So we need a mechanism to specify "what kind of document name" we mean (relative or absolute).
We can achive this in many ways:
1. Allow pasing a Serializer into methods which takes in a DocumentName.
2. Allow associating a Serilizer with a DocumentName.
3. Use Execution as a means of passing the preferred Serializer
4. Use a flag inside DocumentName (ABSOLUTE, WIKI_RELATIVE, SPACE_RELATIVE) which will be intepretted by the Serializer appropriately whenever a DocumentName is serialized.
None of the above approaches are perfectly clean. But the fourth approach seems to make more sense.
I'm +1 for 4. Not that there is a CompactDocumentNameSerializer (DocumentNameSerializer componenet with hint "compact"). It serialize the given DocumentName depending of the context: if the DocumentName wiki is the name that the current wiki, it's not serialized, same for space.
Actually it does not handle space yet as far as i can see in the code but it should.
So why aren't we using that one for setting the parent? Actually, why aren't we using _any serializer_ for the parent? public void setParent(DocumentName parentName) { this.parent = parentName.toString(); } DocumentName @Override public String toString() { return getWiki() + ":" + getSpace() + "." + getPage(); } Is there some reason for this or we just forgot about it? Happy hacking all, Anca
So there is already a way to serialize a relative document name by making setting the context correctly. This serializer is used in XWikiDocument#getUniqueLinkedPages for example.
Thanks.
- Asiri _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
Hi,
Actually it does not handle space yet as far as i can see in the code but it should.
So why aren't we using that one for setting the parent?
Actually, why aren't we using _any serializer_ for the parent?
public void setParent(DocumentName parentName) { this.parent = parentName.toString(); }
DocumentName
@Override public String toString() { return getWiki() + ":" + getSpace() + "." + getPage(); }
Is there some reason for this or we just forgot about it?
I think we forgot about it. I will fix the set parent method. I don't think it's correct to use a serializer inside the toString() method because well.... it's the toString() method. Instead we should use a serializer inside the setParent() method. Thanks. - Asiri
On Wed, Jun 3, 2009 at 04:54, Asiri Rathnayake <[email protected]> wrote:
Hi,
Actually it does not handle space yet as far as i can see in the code but it should.
So why aren't we using that one for setting the parent?
Actually, why aren't we using _any serializer_ for the parent?
public void setParent(DocumentName parentName) { this.parent = parentName.toString(); }
DocumentName
@Override public String toString() { return getWiki() + ":" + getSpace() + "." + getPage(); }
Is there some reason for this or we just forgot about it?
I think we forgot about it.
I will fix the set parent method. I don't think it's correct to use a serializer inside the toString() method because well.... it's the toString() method. Instead we should use a serializer inside the setParent() method.
I agree, this toString() is a debug tool it should never be used for something else.
Thanks.
- Asiri _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
participants (3)
-
Anca Paula Luca -
Asiri Rathnayake -
Thomas Mortagne