// Validate transaction state before we commit
//
if ((this.status == Status.STATUS_ROLLING_BACK)
|| (this.status == Status.STATUS_ROLLEDBACK)) {
throw new JDOUserException(I18NHelper.getMessage(messages,
"transaction.transactionimpl.rolledback", // NOI18N
"commit", // NOI18N
this.statusString(this.status)));
}
if (this.status == Status.STATUS_MARKED_ROLLBACK) {
rollbackOnly = true;
} else if (this.status != Status.STATUS_ACTIVE) {
throw new JDOUserException(I18NHelper.getMessage(messages,
"transaction.transactionimpl.commit_rollback.notactive", // NOI18N
"commit", // NOI18N
this.statusString(this.status)));
}
if (this.startedCommit) {
throw new JDOUserException(I18NHelper.getMessage(messages,
"transaction.transactionimpl.commitbefore.incommit", // NOI18N
"commit")); // NOI18N
}
this.startedCommit = true;
//
// User notifications done outside of lock - check for concurrent
// rollback or setRollbackOnly during notification.
//
if (!rollbackOnly) {
this.notifyBeforeCompletion();
notified = true;
if (this.status == Status.STATUS_ACTIVE) { // All ok
this.setStatus(Status.STATUS_PREPARING);
} else if (this.status == Status.STATUS_MARKED_ROLLBACK) {
rollbackOnly = true;
} else { // Must have been concurrently rolled back
throw new JDOUserException(I18NHelper.getMessage(messages,
"transaction.transactionimpl.commitbefore.rolledback")); // NOI18N
}
}
if (rollbackOnly && txType == NON_MGD) {
this.rollback();
throw new JDOUserException(I18NHelper.getMessage(messages,
notified ?
"transaction.transactionimpl.commitbefore.rollbackonly_insync" : // NOI18N
"transaction.transactionimpl.commitbefore.rollbackonly")); // NOI18N
}
}