Hi,
Context: a 2.7.2 XEM farm
I'm trying to permanently suppress all the deleted docs of one of the
wiki of the farm using a groovy script included in a page located in
the main wiki.
This is the code. It's a draft... A db query retrieve the list of the
deleted docs (I think it would be better to use the API to obtain this
list), then each document is deleted using the RecycleBinStore.
def emptyDocBin(wiki) {
xcontext.setDatabase(wiki)
def workWiki = xcontext.getXWiki()
def query = "SELECT DISTINCT XDD_FULLNAME FROM " + wiki +
".XWIKIRECYCLEBIN"
def docsResult = runQuery(query)
if (docsResult.size() > 0) {
for (doc in docsResult) {
def docName = doc.get("XDD_FULLNAME")
workWiki.getDeletedDocuments(docName, "", xcontext.context).each{
println "Deleting : " + it.fullName + " - " + it.getDate() +
"
- " + it.id
workWiki.getRecycleBinStore().deleteFromRecycleBin(
workWiki.getDocument(it.fullName,xcontext.context),
it.getId(),
xcontext.context,
true);
}
}
}
xcontext.setDatabase(xcontext.getOriginalDatabase())
}
All is working fine, a list of deleted docs is displayed BUT nothing
is deleted and the documents are still present in the recycle bin.
In the xwiki.log, I can read this kind of "things":
2011-10-04 18:51:43,319
[
http://www.lclh.org/bin/view/Admin/ShrinkRecycleBins?w=calife&confirmat…]
[
http://www.lclh.org/bin/view/Admin/ShrinkRecycleBins?w=calife&confirmat…]
WARN store.XWikiHibernateBaseStore - Cleanup of session was needed:
SessionImpl(PersistenceContext[entityKeys=[EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#6],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#11],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#12],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#32],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#33],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#1],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#36],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#37],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#4],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#34],
EntityKey[com.xpn.xwiki.doc.XWikiDeletedDocument#35]],collectionKeys=[]];ActionQueue[insertions=[]
updates=[] deletions=[] collectionCreations=[] collectionRemovals=[]
collectionUpdates=[]])
2011-10-04 18:51:43,321 [
http://www.lclh.org/bin/view/Main/]
[Statistics storing daemon] ERROR xwiki.DocumentStatsStoreItem -
Failed to save visit statictics object [class
com.xpn.xwiki.stats.impl.xwiki.VisitStatsStoreItem XWiki.Admin
DJ64XAIYEJIPIXOADG9VMJ94RHOHD2U2 DJ64XAIYEJIPIXOADG9VMJ94RHOHD2U2]
2011-10-04 18:51:43,321 [
http://www.lclh.org/bin/view/Main/]
[Statistics storing daemon] WARN store.XWikiHibernateBaseStore -
Incompatible session (null) and transaction
(org.hibernate.transaction.JDBCTransaction@d9a754) status
Your help, ideas or other are welcome.
Maxime