this.resumeTransaction(transaction);
try {
// now "prepare"
final Xid xid = this.xidTransactionID.getXid();
// Courtesy: com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple
final SubordinateTransaction subordinateTransaction = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
int result = subordinateTransaction.doPrepare();
switch (result) {
case TwoPhaseOutcome.PREPARE_READONLY:
// TODO: Would it be fine to not remove the xid? (Need to understand how the subsequent
// flow works)
SubordinationManager.getTransactionImporter().removeImportedTransaction(xid);
return XAResource.XA_RDONLY;
case TwoPhaseOutcome.PREPARE_OK:
return XAResource.XA_OK;
case TwoPhaseOutcome.PREPARE_NOTOK:
// the JCA API spec limits what we can do in terms of reporting
// problems.
// try to use the exception code and cause to provide info
// whilst
// remaining API compliant. JBTM-427.
Exception initCause = null;
int xaExceptionCode = XAException.XA_RBROLLBACK;
try {
subordinateTransaction.doRollback();
} catch (HeuristicCommitException e) {
initCause = e;
xaExceptionCode = XAException.XAER_RMERR;
} catch (HeuristicMixedException e) {
initCause = e;