Search in sources :

Example 1 with RegisterResponseType

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType 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 RegisterResponseType

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType 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 3 with RegisterResponseType

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

the class RegistrationCoordinator method register.

/**
 * Register the participant in the protocol.
 * @param coordinationContext The current coordination context
 * @param messageID The messageID to use.
 * @param participantProtocolService The participant protocol service.
 * @param protocolIdentifier The protocol identifier.
 * @return The endpoint reference of the coordinator protocol service.
 * @throws com.arjuna.wsc.InvalidProtocolException If the protocol is unsupported.
 * @throws com.arjuna.wsc.InvalidStateException If the state is invalid
 * @throws com.arjuna.webservices.SoapFault for errors during processing.
 */
public static W3CEndpointReference register(final CoordinationContextType coordinationContext, final String messageID, final W3CEndpointReference participantProtocolService, final String protocolIdentifier) throws CannotRegisterException, InvalidProtocolException, InvalidStateException, SoapFault {
    final W3CEndpointReference endpointReference = coordinationContext.getRegistrationService();
    try {
        final RegisterType registerType = new RegisterType();
        registerType.setProtocolIdentifier(protocolIdentifier);
        registerType.setParticipantProtocolService(participantProtocolService);
        final RegistrationPortType port = WSCOORClient.getRegistrationPort(endpointReference, CoordinationConstants.WSCOOR_ACTION_REGISTER, messageID);
        final RegisterResponseType response = registerOperation(messageID, port, registerType);
        return response.getCoordinatorProtocolService();
    } catch (SOAPFaultException sfe) {
        final SOAPFault soapFault = sfe.getFault();
        final Detail detail = soapFault.getDetail();
        String message = (detail != null ? detail.getTextContent() : soapFault.getFaultString());
        throwException(soapFault.getFaultCodeAsQName(), message, sfe, null);
        // impossible reach here
        return null;
    }
}
Also used : RegisterResponseType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFault(javax.xml.soap.SOAPFault) RegisterType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType) RegistrationPortType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegistrationPortType) Detail(javax.xml.soap.Detail)

Example 4 with RegisterResponseType

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

the class AsynchronousRegistrationMapperTest method testMapper.

private void testMapper(String message, long millis, Object result) {
    mapper.addClientMessage(message);
    ClientThread client = new ClientThread(message);
    Thread clientThread = new Thread(client);
    Thread serverThread = new Thread(new ServerThread(message, millis, result));
    clientThread.start();
    if (millis >= 0) {
        serverThread.start();
    }
    try {
        clientThread.join(WAIT_TIME * 2);
    } catch (InterruptedException e) {
    }
    Assert.assertFalse(clientThread.isAlive());
    FaultOrResponse r = client.getResult();
    Assert.assertNotNull(r);
    Assert.assertEquals(0, mapper.size());
    if (millis >= 0 && millis < WAIT_TIME) {
        if (result instanceof RegisterResponseType) {
            Assert.assertTrue(r.isResponse());
            Assert.assertEquals(result, r.getResponse());
        } else {
            Assert.assertTrue(r.isFault());
            Assert.assertEquals(result, r.getFault());
        }
    } else {
        Assert.assertTrue(r.isEmpty());
    }
}
Also used : RegisterResponseType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType) FaultOrResponse(com.arjuna.wsc11.FaultOrResponse)

Example 5 with RegisterResponseType

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType 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)

Aggregations

RegisterResponseType (org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType)5 SOAPFault (javax.xml.soap.SOAPFault)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)3 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)2 SOAPFactory (javax.xml.soap.SOAPFactory)2 ProtocolException (javax.xml.ws.ProtocolException)2 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)2 FaultOrResponse (com.arjuna.wsc11.FaultOrResponse)1 Registrar (com.arjuna.wsc11.Registrar)1 RegistrarMapper (com.arjuna.wsc11.RegistrarMapper)1 PrivilegedAction (java.security.PrivilegedAction)1 Detail (javax.xml.soap.Detail)1 SOAPException (javax.xml.soap.SOAPException)1 WSCEnvironmentBean (org.jboss.jbossts.xts.environment.WSCEnvironmentBean)1 RegisterType (org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType)1 RegistrationPortType (org.oasis_open.docs.ws_tx.wscoor._2006._06.RegistrationPortType)1