Hi,
There are (only) three solutions to your problem
1/ Either connect the tomcat XWiki cache and your process XWiki Cache
using oscache's clustering possibilities. This is not so easy and can
make tomcat innefficient. This is not very usefull.
2/ Run your code from within Tomcat (launch it from a Groovy script for
example)
3/ Run your code as is and make an HTTP call at the end to flush the
cache (call a wiki page that has "$xwiki.flushCache()" in it)
Ludovic
georg.mayrhauser(a)jku.at a écrit :
Hi!
We have a (maybe very small) problem that keeps us busy for weeks now, and we do not find
the solution.
We want to create XWiki-documents from another web-application and set also the
document-rights depending on the rights the user has in that other web-application.
Creating the document works very fine and also the document-rights are set correctly in
the database. But with the document-rights we unfortunately have (presumably) problems
with the cache.
When a user opens the link to a XWiki-document, the document-rights of that document are
newly set before the document is openend. So when user "1" opens a new
XWiki-document, the user "XWiki.1" (xws_value) is entered in the db-table
"xwikistrings" along with the value "users" in the
"xws_name"-column (xws_id of the document). And that user can then correctly see
the XWiki-document. But when a second user "2" wants to open that same document,
he only gets the message "You are not allowed to view this document or perform this
action" although he is correctly entered in the "xwikistrings"-table:
xws_id = id of document; xws_name = users; xws_value = "XWiki.1,XWiki.2". That
second user can see the document not until a $xwiki.flushcache() is performed (which is
not easy to automatically realize in that process) or the tomcat is restartet. A
com.xpn.xwiki.XWiki.flushCache() in our Java-Code - which would serve us best - does
somehow not have the desired effect.
If we run XWiki without Cache (xwiki.store.cache) our procedure works also correctly.
Hence, it seems like flushing the cache from our java-code does not work for any reason.
Here is our code for setting the document-rights:
private boolean doUpdateRight(String fullname, String user, String group, String level,
boolean allow, boolean global) throws XWikiException {
this.xdoc = xwiki.getDocument(fullname, context);
this.bobj = new BaseObject();
this.bobj.setName(fullname);
if (global)
this.bclass = xwiki.getGlobalRightsClass(context);
else
this.bclass = xwiki.getRightsClass(context);
this.bobj = (BaseObject) xdoc.getObject(bclass.getName());
String oldusers = bobj.getStringValue("users");
if(!(oldusers.contains(user))) {
bobj.setStringValue("users", oldusers+","+user);
XWikiDocument tdoc;
tdoc = xdoc;
XWikiDocument olddoc = (XWikiDocument) tdoc.clone();
tdoc.setObject(bclass.getClassName(), 0, bobj);
xwiki.saveDocument(tdoc, olddoc, context);
xwiki.flushCache();
}
return true;
}
When starting Xwiki we get the warning, that oscache.properties and
oscache-local.properties are not loade although they are existing in the WEB-INF folder
([http-8080-Processor24] WARN com.xpn.xwiki.cache.impl.OSCacheService - Could not load
cache properties oscache.properties: null [http-8080-Processor24] WARN
com.xpn.xwiki.cache.impl.OSCacheService - Could not load cache properties
oscache-local.properties: null). Could that have an influence on the XWiki-cache problem
mentioned above?
We are working with XWiki 1.0
We would be very pleased if anybody could help us out. We do have no further ideas what
else to try :-(
Thanks in advance!
Georg
--
Ludovic Dubost
Blog:
http://www.ludovic.org/blog/
XWiki:
http://www.xwiki.com
Skype: ldubost GTalk: ldubost
AIM: nvludo Yahoo: ludovic