package edu.harvard.iq.dataverse.actionlogging;

import java.util.Date;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * A service bean that persists {@link ActionLogRecord}s to the DB.
 * @author michael
 */
@Stateless
public class ActionLogServiceBean {
    
    @PersistenceContext(unitName = "VDCNet-ejbPU")
    private EntityManager em;
    
    /**
     * Log the record. Set default values.
     * @param rec 
     */
    public void log( ActionLogRecord rec ) {
        if ( rec.getEndTime() == null ) {
            rec.setEndTime( new Date() );
        }
        if ( rec.getActionResult() == null 
                && rec.getActionType() != ActionLogRecord.ActionType.Command ) {
            rec.setActionResult(ActionLogRecord.Result.OK);
        }
        em.persist(rec);
    }
}

@@ -93,16 +93,98 @@
 teless;%0A
+import javax.ejb.TransactionAttribute;%0Aimport javax.ejb.TransactionAttributeType;%0A
 import j
@@ -572,16 +572,81 @@
      */%0A
+    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)%0A
     publ

Add Transaction Requires New to Action Log service