Search in sources :

Example 1 with RegisterType

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType in project narayana by jbosstm.

the class RegistrationCoordinatorProcessorImpl method register.

/**
 * Register the participant in the protocol.
 * @param register The register request.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public RegisterResponseType register(final RegisterType register, final MAP map, final ArjunaContext arjunaContext, final boolean isSecure) {
    final com.arjuna.wsc11.RegistrarMapper registrarMapper = RegistrarMapper.getFactory();
    try {
        final String protocolIdentifier = register.getProtocolIdentifier();
        final Registrar registrar = registrarMapper.getRegistrar(protocolIdentifier);
        if (registrar != null) {
            try {
                final W3CEndpointReference participantProtocolService = register.getParticipantProtocolService();
                final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
                final W3CEndpointReference coordinationProtocolService = registrar.register(participantProtocolService, protocolIdentifier, instanceIdentifier, isSecure);
                final RegisterResponseType response = new RegisterResponseType();
                response.setCoordinatorProtocolService(coordinationProtocolService);
                return response;
            } catch (final AlreadyRegisteredException alreadyRegisteredException) {
                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(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_1());
                throw new SOAPFaultException(soapFault);
            } catch (final InvalidProtocolException invalidProtocolException) {
                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_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_2());
                throw new SOAPFaultException(soapFault);
            } catch (final InvalidStateException InvalidStateException) {
                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(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_3());
                throw new SOAPFaultException(soapFault);
            } catch (final NoActivityException noActivityException) {
                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(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_4());
                throw new SOAPFaultException(soapFault);
            } catch (final Throwable th) {
                if (WSCLogger.logger.isTraceEnabled()) {
                    WSCLogger.logger.tracev("Unexpected exception thrown from create:", th);
                }
                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(th.getMessage());
                throw new SOAPFaultException(soapFault);
            }
        } else {
            if (WSCLogger.logger.isTraceEnabled()) {
                WSCLogger.logger.tracev("Register called for unknown protocol identifier: {0}", new Object[] { protocolIdentifier });
            }
            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_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_2());
            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) RegisterResponseType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType) Registrar(com.arjuna.wsc11.Registrar) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) SOAPException(javax.xml.soap.SOAPException) RegistrarMapper(com.arjuna.wsc11.RegistrarMapper) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SOAPFault(javax.xml.soap.SOAPFault)

Example 2 with RegisterType

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType in project narayana by jbosstm.

the class EnduranceTest method doRegisterRequest.

public void doRegisterRequest(final String messageId) throws Exception {
    final String protocolIdentifier = TestUtil.PROTOCOL_IDENTIFIER;
    final W3CEndpointReference participantProtocolService = TestUtil11.getProtocolParticipantEndpoint("participant");
    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 coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
    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);
    assertNotNull(requestArjunaContext);
    assertEquals(requestArjunaContext.getInstanceIdentifier().getInstanceIdentifier(), identifierInstance.getValue());
    assertEquals(protocolIdentifier, requestRegister.getProtocolIdentifier());
    assertNotNull(protocolIdentifier, requestRegister.getParticipantProtocolService());
    assertNotNull(coordinator);
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) RegisterDetails(com.arjuna.wsc.tests.arq.TestRegistrationCoordinatorProcessor.RegisterDetails) CreateCoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) RegisterType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP)

Example 3 with RegisterType

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType in project narayana by jbosstm.

the class EnduranceTest method doRegisterError.

public void doRegisterError(final String messageId, int count) throws Exception {
    final String protocolIdentifier;
    final W3CEndpointReference participantProtocolService = TestUtil11.getProtocolParticipantEndpoint("participant");
    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 coordinator = null;
    switch(count) {
        case 0:
            protocolIdentifier = TestUtil.INVALID_PROTOCOL_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (InvalidProtocolException ipe) {
            }
            if (coordinator != null) {
                fail("expected invalid protocol exception");
            }
            break;
        case 1:
            protocolIdentifier = TestUtil.INVALID_STATE_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (InvalidStateException ise) {
            }
            if (coordinator != null) {
                fail("expected invalid state exception");
            }
            break;
        case 3:
            protocolIdentifier = TestUtil.NO_ACTIVITY_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (CannotRegisterException cre) {
            }
            if (coordinator != null) {
                fail("expected cannot register exception");
            }
            break;
        default:
            protocolIdentifier = TestUtil.ALREADY_REGISTERED_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (CannotRegisterException cre) {
            }
            if (coordinator != null) {
                fail("expected cannot register exception");
            }
            break;
    }
    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);
    assertNotNull(requestArjunaContext);
    assertEquals(requestArjunaContext.getInstanceIdentifier().getInstanceIdentifier(), identifierInstance.getValue());
    ;
    assertEquals(protocolIdentifier, requestRegister.getProtocolIdentifier());
    assertNotNull(protocolIdentifier, requestRegister.getParticipantProtocolService());
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) RegisterDetails(com.arjuna.wsc.tests.arq.TestRegistrationCoordinatorProcessor.RegisterDetails) InvalidStateException(com.arjuna.wsc.InvalidStateException) CreateCoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) RegisterType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP) CannotRegisterException(com.arjuna.wsc.CannotRegisterException)

Example 4 with RegisterType

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType in project narayana by jbosstm.

the class RegistrationCoordinator method registerOperation.

private static RegisterResponseType registerOperation(String messageID, final RegistrationPortType port, final RegisterType registerType) throws CannotRegisterException, InvalidProtocolException, InvalidStateException, SoapFault {
    final WSCEnvironmentBean wscEnvironmentBean = XTSPropertyManager.getWSCEnvironmentBean();
    if (!WSCEnvironmentBean.NO_ASYNC_REQUEST.equals(wscEnvironmentBean.getUseAsynchronousRequest())) {
        // using asynchronous request, we have to wait for the response
        AsynchronousRegistrationMapper.getInstance().addClientMessage(messageID);
    }
    RegisterResponseType response;
    if (System.getSecurityManager() == null) {
        response = port.registerOperation(registerType);
    } else {
        response = AccessController.doPrivileged(new PrivilegedAction<RegisterResponseType>() {

            @Override
            public RegisterResponseType run() {
                return port.registerOperation(registerType);
            }
        });
    }
    if (!WSCEnvironmentBean.NO_ASYNC_REQUEST.equals(wscEnvironmentBean.getUseAsynchronousRequest())) {
        // wait until the response arrives
        FaultOrResponse res = AsynchronousRegistrationMapper.getInstance().waitForResponse(messageID, wscEnvironmentBean.getAsyncRequestWait());
        if (res.isFault()) {
            String detail = res.getFault().getFaultstring();
            if (res.getFault().getDetail() != null && res.getFault().getDetail().getAny() != null && !res.getFault().getDetail().getAny().isEmpty()) {
                detail = res.getFault().getDetail().getAny().get(0).toString();
            }
            throwException(res.getFault().getFaultcode(), detail, null, res.getFault());
        } else if (res.isEmpty()) {
            throw new InvalidStateException("No response assigned to messageID " + messageID);
        }
        response = res.getResponse();
    }
    return response;
}
Also used : RegisterResponseType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType) PrivilegedAction(java.security.PrivilegedAction) WSCEnvironmentBean(org.jboss.jbossts.xts.environment.WSCEnvironmentBean)

Example 5 with RegisterType

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType 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)5 RegisterResponseType (org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType)4 RegisterType (org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType)4 ArjunaContext (com.arjuna.webservices11.wsarj.ArjunaContext)3 RegisterDetails (com.arjuna.wsc.tests.arq.TestRegistrationCoordinatorProcessor.RegisterDetails)3 SOAPFault (javax.xml.soap.SOAPFault)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)3 MAP (org.jboss.ws.api.addressing.MAP)3 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)2 SOAPFactory (javax.xml.soap.SOAPFactory)2 ProtocolException (javax.xml.ws.ProtocolException)2 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)2 CreateCoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType)2 RegistrationPortType (org.oasis_open.docs.ws_tx.wscoor._2006._06.RegistrationPortType)2 CannotRegisterException (com.arjuna.wsc.CannotRegisterException)1 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)1 InvalidStateException (com.arjuna.wsc.InvalidStateException)1 Registrar (com.arjuna.wsc11.Registrar)1 RegistrarMapper (com.arjuna.wsc11.RegistrarMapper)1 PrivilegedAction (java.security.PrivilegedAction)1