Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-4297

add XWiki.saveDocuments for saving multiple documents in a single db transaction.

    XMLWordPrintable

Details

    • Idea
    • Resolution: Unresolved
    • Major
    • None
    • 2.0 M4
    • Model
    • None
    • Medium

    Description

      I suggest we add a method
      com.xpn.xwiki.XWiki.saveDocuments(List<XWikiDocument>, XWikiContext) throws XWikiException
      This method would save a list of documents in a single database transaction.

      As I imagine it, setComment() and setMinorEdit() would be called on each document before sending them to saveDocuments.

      Since (as far as I can tell) it's impossible to save documents in multiple databases with a single transaction, I think it ought to throw an exception if the user tries. It is draconian but in my opinion the user should be able to rely on it using a single transaction.

      I haven't looked in to it very carefully, but it looks like a matter of calling:

      store.beginTransaction(context);
      try{
          for(XWikiDocument doc : docs){
              orig = doc.getOrigionalDocument();
              store.saveXwikiDoc(doc,context,false);   //bTransaction = false
              (notification stuff)
          }
          store.endTransaction(context, true);
      }finally{
          store.endTransaction(context, false);
      }
      

      See http://markmail.org/message/7qtx7fnxxgxkpwcl for the started discussion

      Attachments

        Activity

          People

            Unassigned Unassigned
            calebjamesdelisle CalebJamesDeLisle
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: