Search in sources :

Example 46 with State

use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.

the class BusinessAgreementWithCoordinatorCompletionStub method saveState.

public boolean saveState(final OutputObjectState oos) {
    try {
        oos.packString(participant.getId());
        // n.b. just use toString() for the endpoint -- it uses the writeTo() method which calls a suitable marshaller
        final StringWriter sw = new StringWriter();
        final XMLStreamWriter writer = SoapUtils.getXMLStreamWriter(sw);
        StreamHelper.writeStartElement(writer, QNAME_BACCWS_PARTICIPANT);
        String eprefText = participant.getParticipant().toString();
        writer.writeCData(eprefText);
        StreamHelper.writeEndElement(writer, null, null);
        writer.close();
        oos.packString(sw.toString());
        final State state = participant.getStatus();
        final QName stateName = state.getValue();
        final String ns = stateName.getNamespaceURI();
        final String localPart = stateName.getLocalPart();
        final String prefix = stateName.getPrefix();
        oos.packString(ns != null ? ns : "");
        oos.packString(localPart != null ? localPart : "");
        oos.packString(prefix != null ? prefix : "");
        return true;
    } catch (final Throwable th) {
        WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithCoordinatorCompletionStub_2(th);
        return false;
    }
}
Also used : StringWriter(java.io.StringWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) State(com.arjuna.webservices11.wsba.State) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) QName(javax.xml.namespace.QName)

Example 47 with State

use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.

the class RegistrarImple method register.

/**
 * Registers the interest of participant in a particular protocol.
 *
 * @param participantProtocolService
 *            the address of the participant protocol service
 * @param protocolIdentifier
 *            the protocol identifier
 *
 * @return the PortReference of the coordinator protocol service
 *
 * @throws com.arjuna.wsc.AlreadyRegisteredException
 *             if the participant is already registered for this
 *             coordination protocol under this activity identifier
 * @throws com.arjuna.wsc.InvalidProtocolException
 *             if the coordination protocol is not supported
 * @throws com.arjuna.wsc.InvalidStateException
 *             if the state of the coordinator no longer allows registration
 *             for this coordination protocol
 * @throws com.arjuna.wsc.NoActivityException
 *             if the activity does not exist.
 */
public W3CEndpointReference register(final W3CEndpointReference participantProtocolService, final String protocolIdentifier, final InstanceIdentifier instanceIdentifier, final boolean isSecure) throws AlreadyRegisteredException, InvalidProtocolException, InvalidStateException, NoActivityException {
    Object tx = _hierarchies.get(instanceIdentifier.getInstanceIdentifier());
    if (tx instanceof SubordinateBACoordinator)
        return registerWithSubordinate((SubordinateBACoordinator) tx, participantProtocolService, protocolIdentifier, isSecure);
    ActivityHierarchy hier = (ActivityHierarchy) tx;
    if (hier == null)
        throw new NoActivityException();
    try {
        _coordManager.resume(hier);
    } catch (com.arjuna.mw.wsas.exceptions.InvalidActivityException ex) {
        throw new NoActivityException();
    } catch (SystemException ex) {
        throw new InvalidProtocolException();
    }
    if (BusinessActivityConstants.WSBA_SUB_PROTOCOL_PARTICIPANT_COMPLETION.equals(protocolIdentifier)) {
        // enlist participant that wraps the requester URI.
        final String id = new Uid().stringForm();
        try {
            final ParticipantCompletionCoordinatorEngine engine = new ParticipantCompletionCoordinatorEngine(id, participantProtocolService);
            BusinessAgreementWithParticipantCompletionImple participant = new BusinessAgreementWithParticipantCompletionImple(new BusinessAgreementWithParticipantCompletionStub(engine), id);
            engine.setCoordinator(participant.participantManager());
            _coordManager.enlistParticipant(participant);
            _coordManager.suspend();
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_SERVICE_QNAME, BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_SERVICE_NAME, isSecure), id);
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (BusinessActivityConstants.WSBA_SUB_PROTOCOL_COORDINATOR_COMPLETION.equals(protocolIdentifier)) {
        final String id = new Uid().stringForm();
        try {
            final CoordinatorCompletionCoordinatorEngine engine = new CoordinatorCompletionCoordinatorEngine(id, participantProtocolService);
            BusinessAgreementWithCoordinatorCompletionImple participant = new BusinessAgreementWithCoordinatorCompletionImple(new BusinessAgreementWithCoordinatorCompletionStub(engine), id);
            engine.setCoordinator(participant.participantManager());
            _coordManager.enlistParticipant(participant);
            _coordManager.suspend();
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_SERVICE_QNAME, BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_SERVICE_NAME, isSecure), id);
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION.equals(protocolIdentifier)) {
        /*
                     * update the server side terminator with the participant end point
                     */
        BusinessActivityTerminatorImple terminator;
        terminator = (BusinessActivityTerminatorImple) TerminationCoordinatorProcessor.getProcessor().getParticipant(instanceIdentifier);
        terminator.setEndpoint(participantProtocolService);
        try {
            _coordManager.suspend();
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(ArjunaTX11Constants.TERMINATION_COORDINATOR_SERVICE_QNAME, ArjunaTX11Constants.TERMINATION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(ArjunaTX11Constants.TERMINATION_COORDINATOR_SERVICE_NAME, isSecure), instanceIdentifier.getInstanceIdentifier());
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION_RPC.equals(protocolIdentifier)) {
        try {
            _coordManager.suspend();
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_QNAME, ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_PORT_QNAME, serviceRegistry.getServiceURI(ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_NAME, isSecure), instanceIdentifier.getInstanceIdentifier());
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else {
        wstxLogger.i18NLogger.warn_mwlabs_wst_ba_Registrar11Imple_1(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, protocolIdentifier);
        throw new InvalidProtocolException();
    }
}
Also used : CoordinatorCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine) BusinessAgreementWithCoordinatorCompletionImple(com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithCoordinatorCompletionImple) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) BusinessAgreementWithParticipantCompletionStub(com.arjuna.wst11.stub.BusinessAgreementWithParticipantCompletionStub) ProtocolNotRegisteredException(com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException) DuplicateParticipantException(com.arjuna.mw.wscf.exceptions.DuplicateParticipantException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) Uid(com.arjuna.ats.arjuna.common.Uid) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry) BusinessAgreementWithCoordinatorCompletionStub(com.arjuna.wst11.stub.BusinessAgreementWithCoordinatorCompletionStub) ParticipantCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine) BusinessAgreementWithParticipantCompletionImple(com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithParticipantCompletionImple)

Example 48 with State

use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.

the class BusinessAgreementWithCoordinatorCompletionParticipantTest method testSendFault.

@Test
public void testSendFault() throws Exception {
    final String messageId = "testSendFault";
    final InstanceIdentifier instanceIdentifier = new InstanceIdentifier("4");
    W3CEndpointReference endpoint = TestUtil.getCoordinatorCompletionCoordinatorEndpoint(instanceIdentifier.getInstanceIdentifier());
    final MAP map = AddressingHelper.createRequestContext(TestUtil.coordinatorCompletionCoordinatorServiceURI, messageId);
    final State state = State.STATE_FAILING_COMPENSATING;
    CoordinatorCompletionCoordinatorClient.getClient().sendFail(endpoint, map, new InstanceIdentifier("sender"), state.getValue());
    CoordinatorCompletionCoordinatorDetails details = testCoordinatorCompletionCoordinatorProcessor.getCoordinatorCompletionCoordinatorDetails(messageId, 10000);
    assertNotNull(details.hasFail());
    assertEquals(details.hasFail().getExceptionIdentifier(), state.getValue());
    checkDetails(details, true, true, messageId, instanceIdentifier);
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) State(com.arjuna.webservices11.wsba.State) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) MAP(org.jboss.ws.api.addressing.MAP) CoordinatorCompletionCoordinatorDetails(com.arjuna.wst.tests.arq.TestCoordinatorCompletionCoordinatorProcessor.CoordinatorCompletionCoordinatorDetails) Test(org.junit.Test)

Example 49 with State

use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.

the class TestRegistrationCoordinatorProcessor method register.

public RegisterResponseType register(final RegisterType register, final MAP map, final ArjunaContext arjunaContext, boolean isSecure) {
    final String messageId = map.getMessageID();
    synchronized (messageIdMap) {
        messageIdMap.put(messageId, new RegisterDetails(register, map, arjunaContext));
        messageIdMap.notifyAll();
    }
    String protocolIdentifier = register.getProtocolIdentifier();
    if (TestUtil.ALREADY_REGISTERED_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME);
            soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME).addTextNode("already registered");
            throw new SOAPFaultException(soapFault);
        } catch (Throwable th) {
            throw new ProtocolException(th);
        }
    }
    if (TestUtil.INVALID_PROTOCOL_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PROTOCOL_QNAME);
            soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PROTOCOL_QNAME).addTextNode("invalid protocol");
            throw new SOAPFaultException(soapFault);
        } catch (Throwable th) {
            throw new ProtocolException(th);
        }
    }
    if (TestUtil.INVALID_STATE_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME);
            soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME).addTextNode("invalid state");
            throw new SOAPFaultException(soapFault);
        } catch (Throwable th) {
            throw new ProtocolException(th);
        }
    }
    if (TestUtil.NO_ACTIVITY_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME);
            soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME).addTextNode("no activity");
            throw new SOAPFaultException(soapFault);
        } catch (Throwable th) {
            throw new ProtocolException(th);
        }
    }
    // we need to cook up a response here
    RegisterResponseType registerResponseType = new RegisterResponseType();
    if (arjunaContext != null) {
        InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
        registerResponseType.setCoordinatorProtocolService(TestUtil11.getProtocolCoordinatorEndpoint(instanceIdentifier.getInstanceIdentifier()));
    } else {
        registerResponseType.setCoordinatorProtocolService(TestUtil11.getProtocolCoordinatorEndpoint(null));
    }
    return registerResponseType;
}
Also used : ProtocolException(javax.xml.ws.ProtocolException) RegisterResponseType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFactory(javax.xml.soap.SOAPFactory)

Example 50 with State

use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.

the class BusinessAgreementWithCoordinatorCompletionCoordinatorTest method testSendStatus.

@Test
public void testSendStatus() throws Exception {
    final String messageId = "testSendStatus";
    final InstanceIdentifier instanceIdentifier = new InstanceIdentifier("6");
    W3CEndpointReference endpoint = TestUtil.getCoordinatorCompletionParticipantEndpoint(instanceIdentifier.getInstanceIdentifier());
    final MAP map = AddressingHelper.createRequestContext(TestUtil.coordinatorCompletionParticipantServiceURI, messageId);
    final State state = State.STATE_ACTIVE;
    CoordinatorCompletionParticipantClient.getClient().sendStatus(endpoint, map, new InstanceIdentifier("sender"), state.getValue());
    final CoordinatorCompletionParticipantDetails details = testCoordinatorCompletionParticipantProcessor.getCoordinatorCompletionParticipantDetails(messageId, 10000);
    assertNotNull(details.hasStatus());
    assertEquals(details.hasStatus().getState(), state.getValue());
    checkDetails(details, true, true, messageId, instanceIdentifier);
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) State(com.arjuna.webservices11.wsba.State) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) CoordinatorCompletionParticipantDetails(com.arjuna.wst.tests.arq.TestCoordinatorCompletionParticipantProcessor.CoordinatorCompletionParticipantDetails) MAP(org.jboss.ws.api.addressing.MAP) Test(org.junit.Test)

Aggregations

State (com.arjuna.webservices11.wsba.State)31 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)12 MAP (org.jboss.ws.api.addressing.MAP)12 State (com.arjuna.webservices11.wsat.State)11 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)10 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)6 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)6 Test (org.junit.Test)6 SoapFault11 (com.arjuna.webservices11.SoapFault11)5 QName (javax.xml.namespace.QName)5 ConfirmCompletedParticipant (com.arjuna.wst11.ConfirmCompletedParticipant)3 StringReader (java.io.StringReader)3 StringWriter (java.io.StringWriter)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)3 StreamSource (javax.xml.transform.stream.StreamSource)3 BAParticipantRecoveryRecord (org.jboss.jbossts.xts11.recovery.participant.ba.BAParticipantRecoveryRecord)3 FaultedException (com.arjuna.wst.FaultedException)2 CoordinatorCompletionCoordinatorDetails (com.arjuna.wst.tests.arq.TestCoordinatorCompletionCoordinatorProcessor.CoordinatorCompletionCoordinatorDetails)2 ParticipantCompletionCoordinatorDetails (com.arjuna.wst.tests.arq.TestParticipantCompletionCoordinatorProcessor.ParticipantCompletionCoordinatorDetails)2