Search in sources :

Example 1 with ContextFactory

use of com.arjuna.wsc11.ContextFactory in project narayana by jbosstm.

the class ActivationCoordinatorProcessorImpl method createCoordinationContext.

/**
 * Create the coordination context.
 * @param createCoordinationContext The create coordination context request.
 * @param map The addressing context.
 */
public CreateCoordinationContextResponseType createCoordinationContext(final CreateCoordinationContextType createCoordinationContext, final MAP map, final boolean isSecure) {
    final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getMapper();
    try {
        final String coordinationType = createCoordinationContext.getCoordinationType();
        final ContextFactory contextFactory = contextFactoryMapper.getContextFactory(coordinationType);
        if (contextFactory != null) {
            final CoordinationContext coordinationContext;
            try {
                final Expires expiresElement = createCoordinationContext.getExpires();
                final Long expires = (expiresElement == null ? null : new Long(expiresElement.getValue()));
                coordinationContext = contextFactory.create(coordinationType, expires, createCoordinationContext.getCurrentContext(), isSecure);
                final CreateCoordinationContextResponseType response = new CreateCoordinationContextResponseType();
                response.setCoordinationContext(coordinationContext);
                return response;
            } catch (final InvalidCreateParametersException invalidCreateParametersException) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME);
                soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_ActivationCoordinatorProcessorImpl_1());
                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_CREATE_CONTEXT_QNAME);
                soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_CREATE_CONTEXT_QNAME).addTextNode(th.getMessage());
                throw new SOAPFaultException(soapFault);
            }
        } else {
            if (WSCLogger.logger.isTraceEnabled()) {
                WSCLogger.logger.tracev("CreateCoordinationContext called for unknown coordination type: {0}", new Object[] { coordinationType });
            }
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME);
            soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_ActivationCoordinatorProcessorImpl_1());
            throw new SOAPFaultException(soapFault);
        }
    } catch (SOAPException se) {
        se.printStackTrace(System.err);
        throw new ProtocolException(se);
    }
}
Also used : ProtocolException(javax.xml.ws.ProtocolException) ContextFactoryMapper(com.arjuna.wsc11.ContextFactoryMapper) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) SOAPFactory(javax.xml.soap.SOAPFactory) ContextFactory(com.arjuna.wsc11.ContextFactory) SOAPException(javax.xml.soap.SOAPException) SOAPFault(javax.xml.soap.SOAPFault)

Aggregations

InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)1 ContextFactory (com.arjuna.wsc11.ContextFactory)1 ContextFactoryMapper (com.arjuna.wsc11.ContextFactoryMapper)1 SOAPException (javax.xml.soap.SOAPException)1 SOAPFactory (javax.xml.soap.SOAPFactory)1 SOAPFault (javax.xml.soap.SOAPFault)1 ProtocolException (javax.xml.ws.ProtocolException)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1