Last modified by Thomas Mortagne on 2023/10/13

From version 30.1
edited by Thomas Mortagne
on 2015/06/30
Change comment: There is no comment for this version
To version 31.1
edited by Vincent Massol
on 2015/06/30
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ThomasMortagne
1 +XWiki.VincentMassol
Content
... ... @@ -10,7 +10,7 @@
10 10  
11 11  [[Full list of issues fixed and Dashboard for <version>>>http://jira.xwiki.org/secure/Dashboard.jspa?selectPageId=<fill id here>]].
12 12  
13 -== Nested spaces ==
13 +== Nested Spaces ==
14 14  
15 15  {{todo/}}
16 16  
... ... @@ -22,18 +22,43 @@
22 22  
23 23  = For Developers =
24 24  
25 -== Nested spaces ==
25 +== Nested Spaces ==
26 26  
27 -Since nested spaces were already planned and supported in APIs like DocumentReference there is not too much changes for those who were using recent API but there is still some and here are the main ones.
27 +Since Nested Spaces were already planned and supported in APIs like ##DocumentReference## there are not too many changes for those who were using recent APIs but there is still some and here are the main ones.
28 28  
29 -=== Space reference instead of space name ===
29 +=== Space reference instead of Space name ===
30 30  
31 31  The heart of the implementation is that the field that used to contain the unique document space now contain the possibly nested space reference. In practice it means that:
32 32  
33 -* "##.##" (dot), "##:##" (colon) and "##\##" (baskslash) which are part of a space name will now be escaped (using "##\##" character) in the database document ##space## (##XWD_WEB##) field. For example a space named "##Space:with.special\char##" will be stored as "##Space\:with\.special##".
34 -* same as for the database ##XWikiDocument/Document#getSpace()## now return a serialized reference of the space instead of what used to be the unique space name (basically it return what's in the database). Same logic for ##XWikiDocument#setSpace()##. Those field are deprecated since a long time but still used a lot...
35 -* various API are also affected by this space name to space reference input change:
33 +* "##.##" (dot), "##:##" (colon) and "##\##" (baskslash) characters, which are part of a Space name will now be escaped (using the "##\##" character) in the ##space## (##XWD_WEB##) field from the Document's table in the Database. For example a space named ##Space:with.special\char## will be stored as ##{{{Space\:with\.special\\char}}}##.
34 +* Same as for the database, the ##XWikiDocument/Document#getSpace()## methods now return a serialized reference to the Space instead of what used to be the unique Space name (basically it return what's in the database). Same logic for ##XWikiDocument#setSpace()##. Those field have been deprecated a long time ago but they are still used in lots of places...
35 +* Various APIs are also affected by this Space name to Space reference input change:
36 36  ** ##XWiki#getSpaceDocsName## methods (both in the public and private XWiki API)
37 +** All the default ##XWikiURLFactory## implementation methods accepting a Space as parameter have been modified to accept a serialized Space reference. Extensions/code implementing ##XWikiURLFactory## (or extending classes implementing ##XWikiURLFactory## such as ##XWikiServletURLFactory##) will need to be modified to handle nested spaces passed in the ##space## parameter of the various APIs. Here's how to parse Spaces passed as a String:(((
38 +{{code language="java"}}
39 +private EntityReferenceResolver<String> relativeEntityReferenceResolver =
40 + Utils.getComponent(EntityReferenceResolver.TYPE_STRING, "relative");
41 +...
42 +or
43 +...
44 +@Inject
45 +@Named("relative")
46 +private EntityReferenceResolver<String> relativeEntityReferenceResolver;
47 +...
48 +private List<String> extractSpaceNames(String spaces)
49 +{
50 + List<String> spaceNames = new ArrayList<>();
51 + // Parse the spaces list into Space References
52 + EntityReference spaceReference = this.relativeEntityReferenceResolver.resolve(spaces, EntityType.SPACE);
53 + for (EntityReference reference : spaceReference.getReversedReferenceChain()) {
54 + spaceNames.add(reference.getName());
55 + }
56 + return spaceNames;
57 +}
58 +{{/code}}
59 +)))
60 +** Extensions/code implementing ##ExportURLFactoryActionHandler## will also need to be modified to handle nested Spaces passed in the ##space## parameter.
61 +** Extensions/code implementing ##EntityReferenceSerializer## or ##DocumentReferenceResolver## must now handle Nested Spaces (in the past they were already supposed to handle Nested Spaces but since it was not used they could take shortcuts and it wasn't visible. It's now going to fail, see [[XWIKI-12191>>http://jira.xwiki.org/browse/XWIKI-12191]]).
37 37  
38 38  === Space separator properly taken into account ===
39 39  
... ... @@ -163,7 +163,7 @@
163 163  
164 164  === Nested spaces ===
165 165  
166 -See [[previous Nested spaces section>>||anchor="HNestedspaces-1"]] for details on what changes in the way some API and the database are dealing with the document space.
191 +See [[previous Nested spaces section>>||anchor="HNestedSpaces-1"]] for details on what changes in the way some API and the database are dealing with the Document Space.
167 167  
168 168  === Templates ===
169 169  

Get Connected