Unfortunately, the fix is not as trivial as I originally planned given
how XWiki works with the url factory.
I assumed the url in the case of a subwiki ressources would be relative
and absolute to the subwiki but it is always normalized after the main
wiki so the wiki reference of the document being linked is lost and
there is no way right now to fix this by just touching this method I
believe, as the context does not have anything useful to figure out
correctly what to do...
The solution seems to not set the wiki.home so the urls reflect the
domain they are coming from however then the following fails:
XWikiServletURLFactory @ 179:
------------------------------------------------------------
public URL getServerURL(String xwikidb, XWikiContext context) throws
MalformedURLException
{
if (xwikidb == null ||
xwikidb.equals(context.getOriginalDatabase())) {
// This is the case if we are getting a URL for a page
which is in
// the same wiki as the page which is now being displayed.
return this.serverURL;
}
if (context.isMainWiki(xwikidb)) {
// Not in the same wiki so we are in a subwiki and we want
a URL which points to the main wiki.
// if xwiki.home is set then lets return that.
final URL homeParam = getXWikiHomeParameter(context);
if (homeParam != null) {
return homeParam;
}
}
URL url = context.getWiki().getServerURL(xwikidb, context);
return url == null ? this.serverURL : url;
}
----------------------------------------------------------------------
Since wiki.home is not set, the method fails to return an url pointing
to the main wiki....
XWikiServletURLFactory @ 505
------------------------------------------------------
public String getURL(URL url, XWikiContext context)
{
String relativeURL = "";
try {
if (url != null) {
String surl = url.toString();
if (!surl.startsWith(serverURL.toString())) {
// External URL: leave it as is.
relativeURL = surl;
} else {
.........
}
------------------------------------------------------------
Variables of interest:
surl =
http://wiki.domain.com:8080/bin/view/XWiki/myUser
serverUrl =
http://wiki.domain.com:8080
Note that main wiki is 'http://wiki.domain.com:8080' and subwiki is
'http://rift.wiki.domain.com:8080'
So basically the test if (!surl.startsWith(serverURL.toString())) is
either not sufficient (need to test we are no in the main wiki) or the
serverURL is wrong in case of a subwiki (shouldnt it point to the sub
wiki ??).
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs