Search in sources :

Example 16 with UnknownTransactionException

use of com.arjuna.wst.UnknownTransactionException in project narayana by jbosstm.

the class CompletionCoordinatorProcessorImpl method commit.

/**
 * Commit.
 * @param commit The commit notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void commit(final Notification commit, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final CompletionCoordinatorParticipant participant = getParticipant(instanceIdentifier);
    try {
        if (participant != null) {
            final String messageId = MessageId.getMessageId();
            try {
                participant.commit();
            } catch (final TransactionRolledBackException trbe) {
                final MAP responseAddressingContext = AddressingHelper.createResponseContext(map, messageId);
                CompletionInitiatorClient.getClient().sendAborted(participant.getParticipant(), responseAddressingContext, instanceIdentifier);
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev(trbe, "Participant {0} commit failed to be aborted on instance {1}", participant.getParticipant(), instanceIdentifier);
                }
                return;
            } catch (final UnknownTransactionException ute) {
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, messageId);
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_1());
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev(ute, "Participant {0} commit unknown failure on instance {1}: {2}", participant.getParticipant(), instanceIdentifier, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_1(), ute);
                }
                return;
            } catch (final SystemException se) {
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, messageId);
                final String pattern = WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_2();
                final String message = MessageFormat.format(pattern, new Object[] { se });
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME, message);
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev(se, "Participant {0} commit system failure on instance {1}: {2}", participant.getParticipant(), instanceIdentifier, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_1());
                }
                return;
            } catch (final Throwable th) {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev(th, "Unexpected exception thrown from commit for participant {0} on instance {1}", participant.getParticipant(), instanceIdentifier);
                }
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
                final SoapFault soapFault = new SoapFault11(th);
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                return;
            }
            final MAP responseAddressingContext = AddressingHelper.createResponseContext(map, messageId);
            CompletionInitiatorClient.getClient().sendCommitted(participant.getParticipant(), responseAddressingContext, instanceIdentifier);
        } else {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Commit called on unknown participant: {0}", new Object[] { instanceIdentifier });
            }
            final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
            final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_5());
            CompletionInitiatorClient.getClient().sendSoapFault(faultAddressingContext, soapFault, instanceIdentifier);
        }
    } catch (Throwable throwable) {
        throwable.printStackTrace(System.err);
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) SoapFault11(com.arjuna.webservices11.SoapFault11) CompletionCoordinatorParticipant(com.arjuna.wst11.CompletionCoordinatorParticipant) MAP(org.jboss.ws.api.addressing.MAP)

Example 17 with UnknownTransactionException

use of com.arjuna.wst.UnknownTransactionException in project narayana by jbosstm.

the class BusinessActivityTerminatorStub method close.

public void close() throws TransactionRolledBackException, UnknownTransactionException, SystemException {
    final MAP map = AddressingHelper.createNotificationContext(MessageId.getMessageId());
    final RequestCallback callback = new RequestCallback();
    final TerminationParticipantProcessor terminationParticipantProcessor = TerminationParticipantProcessor.getProcessor();
    terminationParticipantProcessor.registerCallback(_id, callback);
    try {
        TerminationCoordinatorClient.getClient().sendClose(_terminationCoordinator, map, new InstanceIdentifier(_id));
        callback.waitUntilTriggered();
    } catch (final Throwable th) {
        throw new SystemException();
    } finally {
        terminationParticipantProcessor.removeCallback(_id);
    }
    if (callback.hasTriggered()) {
        if (callback.receivedClosed()) {
            return;
        }
        final SoapFault soapFault = callback.getSoapFault();
        if (soapFault != null) {
            final QName subcode = soapFault.getSubcode();
            if (ArjunaTXConstants.TRANSACTIONROLLEDBACK_ERROR_CODE_QNAME.equals(subcode)) {
                throw new TransactionRolledBackException();
            } else if (ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME.equals(subcode)) {
                throw new UnknownTransactionException();
            }
        }
    }
    throw new SystemException();
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) QName(javax.xml.namespace.QName) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) MAP(org.jboss.ws.api.addressing.MAP) TerminationParticipantProcessor(com.arjuna.webservices11.wsarjtx.processors.TerminationParticipantProcessor)

Example 18 with UnknownTransactionException

use of com.arjuna.wst.UnknownTransactionException in project narayana by jbosstm.

the class TerminationCoordinatorRPCProcessorImpl method cancel.

/**
 * Cancel.
 * @param cancel The cancel notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void cancel(final NotificationType cancel, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final BusinessActivityTerminator participant = TerminationCoordinatorProcessor.getProcessor().getParticipant(instanceIdentifier);
    try {
        if (participant != null) {
            try {
                participant.cancel();
            } catch (FaultedException fm) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_RECEIVER.getValue(), ArjunaTXConstants.FAULTED_ERROR_CODE_QNAME);
                throw new SOAPFaultException(soapFault);
            } catch (final UnknownTransactionException ute) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_1());
                throw new SOAPFaultException(soapFault);
            } catch (final SystemException se) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_RECEIVER.getValue(), ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_2());
                throw new SOAPFaultException(soapFault);
            } catch (final Throwable th) {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev("Unexpected exception thrown from close:", th);
                }
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_RECEIVER.getValue(), ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_2());
                throw new SOAPFaultException(soapFault);
            }
        } else {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Cancel called on unknown participant: {0}", new Object[] { instanceIdentifier });
            }
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME);
            soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_5());
            throw new SOAPFaultException(soapFault);
        }
    } catch (SOAPException se) {
        se.printStackTrace(System.err);
        throw new ProtocolException(se);
    }
}
Also used : ProtocolException(javax.xml.ws.ProtocolException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) BusinessActivityTerminator(com.arjuna.wst11.BusinessActivityTerminator) SOAPException(javax.xml.soap.SOAPException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) FaultedException(com.arjuna.wst.FaultedException) SOAPFactory(javax.xml.soap.SOAPFactory)

Example 19 with UnknownTransactionException

use of com.arjuna.wst.UnknownTransactionException in project narayana by jbosstm.

the class TerminationCoordinatorRPCProcessorImpl method complete.

/**
 * Complete.
 * @param complete The complete notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void complete(final NotificationType complete, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final BusinessActivityTerminator participant = TerminationCoordinatorProcessor.getProcessor().getParticipant(instanceIdentifier);
    try {
        if (participant != null) {
            W3CEndpointReference endpoint = participant.getEndpoint();
            final String messageId = MessageId.getMessageId();
            try {
                participant.complete();
            } catch (FaultedException fm) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_RECEIVER.getValue(), ArjunaTXConstants.FAULTED_ERROR_CODE_QNAME);
                throw new SOAPFaultException(soapFault);
            } catch (final UnknownTransactionException ute) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_12());
                throw new SOAPFaultException(soapFault);
            } catch (final SystemException se) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_RECEIVER.getValue(), ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_13());
                throw new SOAPFaultException(soapFault);
            } catch (final Throwable th) {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev("Unexpected exception thrown from close:", th);
                }
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_RECEIVER.getValue(), ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_13());
                throw new SOAPFaultException(soapFault);
            }
        } else {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Complete called on unknown participant: {0}", new Object[] { instanceIdentifier });
            }
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME);
            soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_12());
            throw new SOAPFaultException(soapFault);
        }
    } catch (SOAPException se) {
        se.printStackTrace(System.err);
        throw new ProtocolException(se);
    }
}
Also used : ProtocolException(javax.xml.ws.ProtocolException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFactory(javax.xml.soap.SOAPFactory) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) BusinessActivityTerminator(com.arjuna.wst11.BusinessActivityTerminator) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) SOAPException(javax.xml.soap.SOAPException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SOAPFault(javax.xml.soap.SOAPFault) FaultedException(com.arjuna.wst.FaultedException)

Example 20 with UnknownTransactionException

use of com.arjuna.wst.UnknownTransactionException in project narayana by jbosstm.

the class CompletionStub method commit.

public void commit() throws TransactionRolledBackException, UnknownTransactionException, SystemException {
    final MAP map = AddressingHelper.createNotificationContext(MessageId.getMessageId());
    final CompletionStub.RequestCallback callback = new CompletionStub.RequestCallback();
    final CompletionInitiatorProcessor completionInitiator = CompletionInitiatorProcessor.getProcessor();
    completionInitiator.registerCallback(_id, callback);
    try {
        CompletionCoordinatorClient.getClient().sendCommit(_completionCoordinator, map, new InstanceIdentifier(_id));
        callback.waitUntilTriggered();
    } catch (final Throwable th) {
        th.printStackTrace();
        throw new SystemException();
    } finally {
        completionInitiator.removeCallback(_id);
    }
    if (callback.hasTriggered()) {
        if (callback.receivedCommitted()) {
            return;
        } else if (callback.receivedAborted()) {
            throw new TransactionRolledBackException();
        }
        final SoapFault soapFault = callback.getSoapFault();
        if ((soapFault != null) && ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME.equals(soapFault.getSubcode())) {
            throw new UnknownTransactionException();
        }
    }
    throw new SystemException();
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) CompletionInitiatorProcessor(com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) MAP(org.jboss.ws.api.addressing.MAP)

Aggregations

UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)61 SystemException (com.arjuna.wst.SystemException)57 WrongStateException (com.arjuna.wst.WrongStateException)40 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)35 ArrayList (java.util.ArrayList)18 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)16 UserBusinessActivity (com.arjuna.mw.wst11.UserBusinessActivity)14 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)13 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)13 SoapFault (com.arjuna.webservices.SoapFault)11 MAP (org.jboss.ws.api.addressing.MAP)11 TxContextImple (com.arjuna.mwlabs.wst11.ba.context.TxContextImple)8 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)7 FaultedException (com.arjuna.wst.FaultedException)6 BusinessActivityTerminator (com.arjuna.wst11.BusinessActivityTerminator)6 UserTransaction (com.arjuna.mw.wst11.UserTransaction)5 SoapFault11 (com.arjuna.webservices11.SoapFault11)5 InvalidActivityException (com.arjuna.mw.wsas.exceptions.InvalidActivityException)4 Context (com.arjuna.mw.wsc11.context.Context)3 TransactionManager (com.arjuna.mw.wst11.TransactionManager)3