Search in sources :

Example 1 with TransactionException

use of org.apache.jackrabbit.data.core.TransactionException in project jackrabbit by apache.

the class XAEnvironment method prepare.

/**
     * Prepare update. Locks global lock manager and feeds all lock/
     * unlock operations.
     */
public void prepare() throws TransactionException {
    status = STATUS_PREPARING;
    if (!operations.isEmpty()) {
        lockMgr.beginUpdate();
        try {
            while (opIndex < operations.size()) {
                try {
                    XALockInfo info = operations.get(opIndex);
                    info.update();
                } catch (RepositoryException e) {
                    throw new TransactionException("Unable to update.", e);
                }
                opIndex++;
            }
        } finally {
            if (opIndex < operations.size()) {
                while (opIndex > 0) {
                    try {
                        XALockInfo info = operations.get(opIndex - 1);
                        info.undo();
                    } catch (RepositoryException e) {
                        log.error("Unable to undo lock operation.", e);
                    }
                    opIndex--;
                }
                lockMgr.cancelUpdate();
            }
        }
    }
    status = STATUS_PREPARED;
}
Also used : TransactionException(org.apache.jackrabbit.data.core.TransactionException) RepositoryException(javax.jcr.RepositoryException)

Aggregations

RepositoryException (javax.jcr.RepositoryException)1 TransactionException (org.apache.jackrabbit.data.core.TransactionException)1