2013/7/23 Thomas Mortagne <thomas.mortagne(a)xwiki.com>
On Tue, Jul 23, 2013 at 12:00 PM, Jeremie
BOUSQUET
<jeremie.bousquet(a)gmail.com> wrote:
> 2013/7/23 Thomas Mortagne <thomas.mortagne(a)xwiki.com>
>
>> On Tue, Jul 23, 2013 at 10:36 AM, Jeremie BOUSQUET
>> <jeremie.bousquet(a)gmail.com> wrote:
>> > Hello,
>> >
>> > I'm moving toward Workspace enabled wiki, and trying to retrieve a
global
>> > user Document from a subwiki.
>> > I'm using LDAP, but creating users only on global wiki.
>> >
>> > My problem, is that from various APIs (workspace, wikimanager,
>> xwiki...), I
>> > was not able to find an easy to retrieve the name of the main wiki -
>> which
>> > in my case is not "xwiki".
>>
>> Are you talking about the wiki or the database ? Whatever you put in
>> the xwiki.db property the main wiki remain "xwiki", the store is
doing
>> a mappiig between the wiki name and the actual database name.
>>
>
> Sorry I realize I was unclear ... My webapp name is "xwikitest" (also
in
> "xwiki.webapppath" in xwiki.cfg), my db is "xwiki" with a
prefix
"test_"
> (so main wiki is in "test_xwiki").
> But I suppose that even with that, my main wiki still is named "xwiki"
as
> you said.
The proper way to get the main wiki id is through
XWikiContext#getMainWikiName() (which happen to be "xwiki" usually now
but it could change maybe). Whatever you put in xwiki.db or
xwiki.db.prefix just affect a mapping on storage side (and yes
XWikiContext#set/getDatabase is a very bad naming for what is actually
about wiki id and not database).
Many thanks for explainations ! :)
Just realizing something strange though, is that I have a
xwiki.getDocument('some-not-existing-page-name') that returns null.
I wonder how this is possible. I can't reproduce it from another location
(currently, it's in a groovy class in a page, parsed with
xwiki.parseGroovyFromPage() ). All other attempts return an object as
expected, on which I can call isNew() or whatever.
In which case(s), xwiki.getDocument() could return null without throwing
an Exception ? (particularly in a subwiki/workspace, but I don't if it's
related).
I'm having a look at the source code, but I didn't find anything obvious.
Additionnally, in this wiki instance, I deactivated all versioning
(attachments and docs) and deactivated also recyclebin (for attachments and
docs), I'll try reactivating versioning on docs to see if it makes a
difference.