/*
(non-Javadoc)

@see com.ibm.ws.objectManager.InternalTransaction#backout(boolean, com.ibm.ws.objectManager.Transaction)
326235
public synchronized void backout(boolean reUse,
                                     Transaction transaction)
                    throws ObjectManagerException
    {
        throw new InvalidStateException(this, InternalTransaction.stateTerminated, InternalTransaction.stateNames[InternalTransaction.stateTerminated]);
    }
89039
@Override
   public void setRollbackOnly() throws IllegalStateException, SystemException {
      if (trace) {
         log.tracef("Transaction.setRollbackOnly() invoked in transaction with Xid=%s", xid);
      }
      if (isDone()) {
         throw new IllegalStateException("Transaction is done. Cannot change status");
      }
      markRollbackOnly(new RollbackException("Transaction marked as rollback only."));
   }
1235606
public void rollbackSetRollbackOnly(List objects)
    {
        log.info("rollbackSetRollbackOnly method was called");
        storeObjects(objects);
        /*
        setRollbackOnly does only rollback the transaction, the client will not be
        notified by an RemoteException (tested on JBoss)
        */
        getSessionContext().setRollbackOnly();
        /*
        seems that some appServer expect that all used resources will be closed before
        the JTA-TXManager does call Synchronization#beforeCompletion(), so we have
        to cleanup used resources. This could be done by call abort on odmg-api
        */
        getImplementation().currentTransaction().abort();
    }
724544
@Override
    public void rollback() throws DataCorruptedException, IOException, IllegalStateException{
        try {
            tranManager.rollback(t1);
        } catch (Exception e) {
            throw new DataCorruptedException("Error trying to rollback a Transaction.", e);
        }
    }
133532
public function rollbackTransaction()
    {
        if (!self::$transaction) {
            throw new TransactionException("There is no Active Transaction");
        }

        self::$transaction = false;
        foreach (self::$connectionList as $dbDriver) {
            $dbDriver->rollbackTransaction();
        }
    }
891585
@Override
    public void onRollback()
    {
        onBatchRollBack();

        nodes.clear();
        nodes = null;
        nodes = new ArrayList<Node>();
        isActive = false;
    }
56383
@Override
    public void rollbackStatements() {
        if (log.isDebugEnabled()) {
            log.debug(String.format("Received transaction rollback: '%s':%n",
                    endpointConfiguration.getServerConfiguration().getDatabaseName()));
        }

        if(!endpointConfiguration.isAutoTransactionHandling()){
            handleMessageAndCheckResponse(JdbcMessage.rollbackTransaction());
        }
    }
543332
void localTransactionRolledBack(final SibRaConnection connection) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "localTransactionRolledBack", connection);
        }

        final ConnectionEvent event = new ConnectionEvent(this,
                ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);
        event.setConnectionHandle(connection);

        for (Iterator iterator = _eventListeners.iterator(); iterator.hasNext();) {

            final ConnectionEventListener listener = (ConnectionEventListener) iterator
                    .next();
            listener.localTransactionRolledback(event);

        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "localTransactionRolledBack");
        }

    }
113140
@Override
    public void eventPostRollbackRemove(Transaction transaction) throws SevereMessageStoreException
    {
        super.eventPostRollbackRemove(transaction);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "eventPostRollbackRemove",
                        new Object[] { transaction });

        if (failedInitInRestore)
        {
            //we can only register the listeners if we are fully initialized
            if (stream instanceof DurableSubscriptionItemStream)
            {
                stream.registerListeners(this);
            }
            failedInitInRestore = false;
        }

        /**
         * Message was rolled back. Call the handleUndeliverableMessage routine on the
         * consumer. This may or may not redirect the message depending on the cicumstances
         * of the delivery
         */

        // TODO : wrap in an if statement ?

        // consumerPoint.handleUndeliverableMessage(this, null);                                 

        try
        {
            if (POST_ROLLBACK_REMOVE_4 != null)
            {
                POST_ROLLBACK_REMOVE_4.messageEventOccurred(MessageEvents.POST_ROLLBACK_REMOVE, this, transaction);
            }
            if (POST_ROLLBACK_REMOVE_3 != null)
            {
                POST_ROLLBACK_REMOVE_3.messageEventOccurred(MessageEvents.POST_ROLLBACK_REMOVE, this, transaction);
            }
            if (POST_ROLLBACK_REMOVE_2 != null)
            {
                POST_ROLLBACK_REMOVE_2.messageEventOccurred(MessageEvents.POST_ROLLBACK_REMOVE, this, transaction);
            }
            if (POST_ROLLBACK_REMOVE_1 != null)
            {
                POST_ROLLBACK_REMOVE_1.messageEventOccurred(MessageEvents.POST_ROLLBACK_REMOVE, this, transaction);
            }
        } catch (SIException e)
        {
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.store.items.MessageItemReference.eventPostRollbackRemove",
                                        "1:553:1.147",
                                        this);

            SibTr.exception(tc, e);

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "eventPostRollbackRemove", e);

            throw new SIErrorException(e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "eventPostRollbackRemove");
    }
482005
void handleRollback(SubscriptionMessage subMessage, 
                      LocalTransaction transaction)
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "handleRollback", new Object[] { subMessage, transaction });

    try
    {
      if (transaction != null)
      {
        try
        {
          transaction.rollback();
        }
        catch (SIException e)
        {
          // If there are any exceptions, then this is bad, log a FFDC
          FFDCFilter.processException(
            e,
            "com.ibm.ws.sib.processor.proxyhandler.NeighbourProxyListener.handleRollback",
            "1:330:1.73",
            this);
          
          SibTr.exception(tc, e);
        }
      }
    
      Transaction msTran = iProxyHandler.getMessageProcessor().resolveAndEnlistMsgStoreTransaction(transaction);
      
      switch (subMessage.getSubscriptionMessageType().toInt())
      {
        case SubscriptionMessageType.CREATE_INT :
    
          // Remove any created Proxy subscriptions
         iProxyHandler.remoteUnsubscribeEvent(iAddTopicSpaces,
                                              iAddTopics, 
                                              subMessage.getBus(), 
                                              msTran,
                                              false);
    
          break;
    
        case SubscriptionMessageType.DELETE_INT :
    
        // Create any removed Proxy subscriptions
        iProxyHandler.remoteSubscribeEvent(iDeleteTopicSpaces,
                                           iDeleteTopics,                                          
                                           subMessage.getBus(),
                                           msTran, 
                                           false);              
    
          break;
    
        case SubscriptionMessageType.RESET_INT :
    
        // Remove any created Proxy subscriptions
        iProxyHandler.remoteUnsubscribeEvent(iAddTopicSpaces,
                                             iAddTopics,                                            
                                             subMessage.getBus(), 
                                             msTran,
                                             false);
    
        // Create any removed Proxy subscriptions
        iProxyHandler.remoteSubscribeEvent(iDeleteTopicSpaces,
                                           iDeleteTopics,                                            
                                           subMessage.getBus(),
                                           msTran, 
                                           false);
                                                         
          break;
    
        default :
          // Log Message
          break;
      }
    }
    catch (SIException e)
    {
      // FFDC
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.proxyhandler.NeighbourProxyListener.handleRollback",
        "1:392:1.73",
        this);
    }
    
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "handleRollback");
  }
684595
private void postInvokeRolledbackException(EJSDeployedSupport s, CSITransactionRolledbackException ex) throws RemoteException {
        //---------------------------------------------------------------
        // Check to see if the application requested that this transaction
        // be rolled back. If so, we can report no exception so suppress
        // the rollback exception here.
        // Only applies if the beginner bean called setRollbackOnly
        // during the business method.                            d186801
        // Or, if the beginner threw an Application Exception     d199884
        // Except, don't supress for ejbTimeout.                LI2281.07
        //---------------------------------------------------------------

        //d140003.19 d186801
        if ((!s.ivBeginnerSetRollbackOnly &&
             (!s.began ||
              s.exType != ExceptionType.CHECKED_EXCEPTION))
            ||
            s.methodInfo.ivInterface == MethodInterface.TIMED_OBJECT) { //90514;;
                                                                                                                                                                           //d140003.19
            final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); // d532639.2
            if (isTraceOn && tc.isEventEnabled())
                Tr.event(tc, "postInvoke: transaction rollback in finally",
                         ex); //93496

            // If an exception occurred during beforeCompletion, then override
            // the cause set by TranStrategy since that one will contain
            // superfluous RuntimeException wrappers.          d109641.1 d616849.2
            if (s.currentTx != null &&
                s.currentTx.ivPostProcessingException != null) {
                // If there was an exception during post processing
                // (commit), then set it as an unchecked exception.
                // This will not override any exception that occurred
                // during the bean method.        PQ90221 d219086 d219086.1
                s.getExceptionMappingStrategy().setUncheckedException(s, s.currentTx.ivPostProcessingException);
                ex.detail = s.getRootCause();
            } else if (ex.detail == null) {
                ex.detail = s.getRootCause();//d140003.19
            }
            //d171654 make sure CSITRBException root cause not overwritten
            else {
                //d174358.1---------->
                Throwable exceptionToUse = s.getRootCause();//d140003.19

                if (exceptionToUse == null) {
                    s.rootEx = s.getExceptionMappingStrategy().findRootCause(ex.detail);
                } else {
                    // we have a checked or unchecked so use that per spec
                    ex.detail = exceptionToUse;
                }
                //<----------d174358.1
            } //<--------d171654

            // Perform standard exception mapping using the exception
            // mapping utilities (just like EJSDeployedSupport). This
            // will wrap the CSI exception in a
            // TransactionRolledBackException, which is the exception
            // required by the EJB spec, then that will be mapped to
            // a CORBA TRANSACTION_ROLLEDBACK exception, as required
            // by the ORB.  The ORB should convert the
            // TRANSACTION_ROLLEDBACK to a TransactionRolledBackException
            // on the client.  Note that the root cause will be lost,
            // but will be embeded as part of the message text.  d109641.1
            Exception crex = s.mapCSITransactionRolledBackException(ex); //d140003.19             // d113344

            // The above result should always be a TRANSACTION_ROLLEDBACK,
            // but this is coded just in case mapException is changed in
            // the future.                                       d109641.1
            if (crex instanceof RemoteException)
                throw (RemoteException) crex;
            else if (crex instanceof RuntimeException)
                throw (RuntimeException) crex;
        }
    }
469966
public void rollbackOdmgAbort(List objects)
    {
        log.info("rollbackOdmgAbort method was called");
        storeObjects(objects);
        getImplementation().currentTransaction().abort();
    }
1341377
@Override
	public void rollback() {
		Optional<LocalTransactionContext> txContext = currentTxContext();
		if (txContext.isPresent()) {
			txContext.get().rollback();
		} else {
			this.unmanagedTransaction.ifPresent(LocalTransactionContext::rollback);
		}
	}
1368237
private void rollback(Transaction txn, Exception cause) throws Exception {
        try {
            txn.rollback();
        } catch (Exception e) {
            logger.debug(e, "Error while rolling back transaction " + txn);
        } finally {
            throw cause;
        }
    }
1367127
private boolean rollbackIfNecessary(
      Transactional transactional, Exception e, EntityTransaction txn) {
    boolean commit = true;

    //check rollback clauses
    for (Class<? extends Exception> rollBackOn : transactional.rollbackOn()) {

      //if one matched, try to perform a rollback
      if (rollBackOn.isInstance(e)) {
        commit = false;

        //check ignore clauses (supercedes rollback clause)
        for (Class<? extends Exception> exceptOn : transactional.ignore()) {
          //An exception to the rollback clause was found, DON'T rollback
          // (i.e. commit and throw anyway)
          if (exceptOn.isInstance(e)) {
            commit = true;
            break;
          }
        }

        //rollback only if nothing matched the ignore check
        if (!commit) {
          txn.rollback();
        }
        //otherwise continue to commit

        break;
      }
    }

    return commit;
  }
72814
static void rollbackIfActive(Transaction transaction) {
    try {
      if (transaction != null && transaction.isActive()) {
        transaction.rollback();
      }
    } catch (DatastoreException exp) {
      throw new EntityManagerException(exp);
    }
  }
1261753
void postBackout(Transaction transaction)
                    throws ObjectManagerException
    {
        throw new InvalidStateException(this, InternalTransaction.stateTerminated, InternalTransaction.stateNames[InternalTransaction.stateTerminated]);
    }