On Feb 20, 2007, at 10:02 AM, Vincent Massol wrote:
Hi,
I'd like to clean a bit the XWikiHibernateVersioningStore class but
I'd like to confirm my changes as I don't want to break anything.
There are several methods like this one:
public void updateXWikiDocArchive(XWikiDocument doc, String
text, boolean bTransaction, XWikiContext context) throws
XWikiException {
try {
if (bTransaction) {
checkHibernate(context);
bTransaction = beginTransaction(false, context);
}
Session session = getSession(context);
XWikiDocumentArchive archivedoc =
getXWikiDocumentArchive(doc, context);
archivedoc.updateArchive(doc.getFullName(), text);
saveXWikiDocArchive(archivedoc, bTransaction, context);
if (bTransaction) {
endTransaction(context, true, false);
}
} catch (Exception e) {
Object[] args = { doc.getFullName() };
throw new XWikiException
( XWikiException.MODULE_XWIKI_STORE,
XWikiException.ERROR_XWIKI_STORE_HIBERNATE_SAVING_OBJECT,
"Exception while updating archive {0}", e, args);
} finally {
try {
if (bTransaction)
endTransaction(context, false, false);
} catch (Exception e) {}
}
}
1) Why is checkHibernate done only when the operation is done in a
transaction?
2) Why is getSession called as the session object is not used?
3) I think the endTransaction is called twice...
4) Shouldn't we log something if the endTransaction fails?
Thus I'd like to:
a) move the checkHibernate outside of the if(bTransaction)
b) remove getSession call
c) remove the first endTransaction and leave the one in the finally
clause
Ah just noticed the 2 endTransactions are not called with the same
parameters. Is that something wanted?
Thanks
-Vincent
d) add a warn log if the end transaction fail
ok with everyone?
Thanks
-Vincent
___________________________________________________________________________
Yahoo! Mail r�invente le mail ! D�couvrez le nouveau Yahoo! Mail et son interface
r�volutionnaire.
http://fr.mail.yahoo.com