Search in sources :

Example 51 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.

the class TerminationCoordinatorProcessorImpl 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 = getParticipant(instanceIdentifier);
    try {
        if (participant != null) {
            W3CEndpointReference endpoint = participant.getEndpoint();
            final String messageId = MessageId.getMessageId();
            try {
                participant.complete();
            } catch (final FaultedException fe) {
                final MAP responseMAP = AddressingHelper.createNotificationContext(messageId);
                TerminationParticipantClient.getClient().sendFaulted(endpoint, responseMAP, instanceIdentifier);
            } catch (final UnknownTransactionException ute) {
                final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_12());
                TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
                return;
            } catch (final SystemException se) {
                final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
                final String message = WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_13();
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME, message);
                TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
                return;
            } catch (final Throwable th) {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev("Unexpected exception thrown from complete:", th);
                }
                final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
                final SoapFault soapFault = new SoapFault11(th);
                TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
                return;
            }
            final MAP responseMAP = AddressingHelper.createNotificationContext(messageId);
            TerminationParticipantClient.getClient().sendCompleted(endpoint, responseMAP, instanceIdentifier);
        } else {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Complete called on unknown participant: {0}", new Object[] { instanceIdentifier });
            }
            final MAP faultMAP = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
            final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_16());
            TerminationParticipantClient.getClient().sendSoapFault(soapFault, faultMAP, 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) BusinessActivityTerminator(com.arjuna.wst11.BusinessActivityTerminator) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SoapFault11(com.arjuna.webservices11.SoapFault11) FaultedException(com.arjuna.wst.FaultedException) MAP(org.jboss.ws.api.addressing.MAP)

Example 52 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference 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 53 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.

the class BusinessAgreementWithCoordinatorCompletionStub method restoreState.

public boolean restoreState(final InputObjectState ios) {
    try {
        final String id = ios.unpackString();
        final String eprValue = ios.unpackString();
        final XMLStreamReader reader = SoapUtils.getXMLStreamReader(new StringReader(eprValue));
        StreamHelper.checkNextStartTag(reader, QNAME_BACCWS_PARTICIPANT);
        String eprefText = reader.getElementText();
        StreamSource source = new StreamSource(new StringReader(eprefText));
        final W3CEndpointReference endpointReference = new W3CEndpointReference(source);
        String ns = ios.unpackString();
        final String localPart = ios.unpackString();
        String prefix = ios.unpackString();
        if ("".equals(ns)) {
            ns = null;
        }
        if ("".equals(prefix)) {
            prefix = null;
        }
        QName statename = new QName(ns, localPart, prefix);
        State state = State.toState11(statename);
        // if we already have an engine from a previous recovery scan or because
        // we had a heuristic outcome then reuse it with luck it will have been committed
        // or aborted between the last scan and this one
        // note that whatever happens it will not have been removed from the table
        // because it is marked as recovered
        participant = (CoordinatorCompletionCoordinatorEngine) CoordinatorCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
        if (participant == null) {
            participant = new CoordinatorCompletionCoordinatorEngine(id, endpointReference, state, true);
        }
        return true;
    } catch (final Throwable th) {
        WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithCoordinatorCompletionStub_3(th);
        return false;
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) CoordinatorCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) QName(javax.xml.namespace.QName) State(com.arjuna.webservices11.wsba.State) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader)

Example 54 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.

the class RegistrationServiceExceptionTest method sendRegistration.

private W3CEndpointReference sendRegistration(String messageId, String protocolIdentifier) throws CannotRegisterException, InvalidStateException, InvalidProtocolException, SoapFault {
    final CoordinationContextType coordinationContext = new CoordinationContextType();
    CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
    coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE);
    coordinationContext.setIdentifier(identifierInstance);
    identifierInstance.setValue("identifier");
    coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue()));
    W3CEndpointReference participantEndpoint = TestUtil11.getProtocolParticipantEndpoint("participant");
    return RegistrationCoordinator.register(coordinationContext, messageId, participantEndpoint, protocolIdentifier);
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)

Example 55 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.

the class RegistrationTest method executeRequest.

private void executeRequest(final String messageId, final InstanceIdentifier instanceIdentifier) throws Exception {
    final String protocolIdentifier = "http://foo.example.org/bar";
    final W3CEndpointReference participantProtocolEndpoint = TestUtil11.getProtocolParticipantEndpoint("participant");
    String identifier = (instanceIdentifier != null ? instanceIdentifier.getInstanceIdentifier() : null);
    W3CEndpointReference registerEndpoint = TestUtil11.getRegistrationEndpoint(identifier);
    RegisterType registerType = new RegisterType();
    registerType.setProtocolIdentifier(protocolIdentifier);
    registerType.setParticipantProtocolService(participantProtocolEndpoint);
    RegistrationPortType port = WSCOORClient.getRegistrationPort(registerEndpoint, CoordinationConstants.WSCOOR_ACTION_REGISTER, messageId);
    port.registerOperation(registerType);
    final RegisterDetails details = testRegistrationCoordinatorProcessor.getRegisterDetails(messageId, 10000);
    final RegisterType requestRegister = details.getRegister();
    final MAP requestMap = details.getMAP();
    final ArjunaContext requestArjunaContext = details.getArjunaContext();
    assertEquals(requestMap.getTo(), TestUtil11.registrationCoordinatorService);
    assertEquals(requestMap.getMessageID(), messageId);
    if (instanceIdentifier == null) {
        assertNull(requestArjunaContext);
    } else {
        assertEquals(instanceIdentifier.getInstanceIdentifier(), requestArjunaContext.getInstanceIdentifier().getInstanceIdentifier());
    }
    assertEquals(protocolIdentifier, requestRegister.getProtocolIdentifier());
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) RegisterDetails(com.arjuna.wsc.tests.arq.TestRegistrationCoordinatorProcessor.RegisterDetails) RegisterType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP) RegistrationPortType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegistrationPortType)

Aggregations

W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)154 Test (org.junit.Test)80 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)56 MAP (org.jboss.ws.api.addressing.MAP)53 SystemException (com.arjuna.wst.SystemException)16 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)16 QName (javax.xml.namespace.QName)16 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)16 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)15 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)14 WrongStateException (com.arjuna.wst.WrongStateException)12 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)11 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)9 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)9 TxContextImple (com.arjuna.mwlabs.wst11.ba.context.TxContextImple)8 State (com.arjuna.webservices11.wsba.State)8 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)8 CoordinatorCompletionCoordinatorDetails (com.arjuna.wst.tests.arq.TestCoordinatorCompletionCoordinatorProcessor.CoordinatorCompletionCoordinatorDetails)8 ParticipantCompletionParticipantDetails (com.arjuna.wst.tests.arq.TestParticipantCompletionParticipantProcessor.ParticipantCompletionParticipantDetails)8 URL (java.net.URL)8