Examples of CamelBindingData


Examples of org.switchyard.component.camel.common.composer.CamelBindingData

        }
    }

    private void handleInOut(final Exchange switchyardExchange) throws HandlerException {
        final org.apache.camel.Exchange camelExchange = _producerTemplate.request(_uri, createProcessor(switchyardExchange));
        CamelBindingData bindingData = new CamelBindingData(camelExchange.getOut());
        Exception camelException = camelExchange.getException();

        if (!camelExchange.isFailed()) {
            sendResponseToSwitchyard(switchyardExchange, bindingData);

        } else {
            QName faultName = switchyardExchange.getContract().getProviderOperation().getFaultType();
            Class<?> declaredFault = faultName != null && QNameUtil.isJavaMessageType(faultName) ? QNameUtil.toJavaMessageType(faultName) : null;

            Object camelFault = camelException;
            if (camelFault == null) {
                if (camelExchange.hasOut() && bindingData.getMessage().isFault()) {
                    // Use Out body as a fault content if camelExchange.getException() returns null
                    camelFault = bindingData.getMessage().getBody();
                }
            }
           
            if (camelFault != null && declaredFault != null && declaredFault.isAssignableFrom(camelFault.getClass())) {
                Message msg = null;
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

    /**
     * {@inheritDoc}
     */
    @Override
    public void process(org.apache.camel.Exchange camelExchange) throws Exception {
        _messageComposer.decompose(_exchange, new CamelBindingData(camelExchange.getIn()));
    }
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

                         .addTypeConverter(String.class, BigEndianHeapChannelBuffer.class, new MyConverter());
            MockEndpoint mockEndpoint = _camelContext.getEndpoint("switchyard://dummyService", MockEndpoint.class);
            producer.sendBody("direct://xpath", new BigEndianHeapChannelBuffer(payload.getBytes()));
            Exchange exchange = mockEndpoint.getExchanges().get(0);
            CamelOperationSelector selector = new CamelOperationSelector(operationSelectorModel);
            QName operation = selector.selectOperation(new CamelBindingData(exchange.getIn()));
            Assert.assertNotNull(operation);
            Assert.assertEquals("greet", operation.getLocalPart());
        } finally {
            handler.stop();
        }
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

        return message;
    }

    @Override
    public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
        CamelBindingData decompose = super.decompose(exchange, target);
        decompose.getMessage().setBody(DECOMPOSE_PREFIX + decompose.getMessage().getBody(String.class));
        return decompose;
    }
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

    private Message compose(Exchange exchange) throws Exception {
        Message camelMsg;
        if (_messageComposer != null) {
            camelMsg = getCamelMessage();
            _messageComposer.decompose(exchange, new CamelBindingData(camelMsg));
        } else {
            camelMsg = ExchangeMapper.mapSwitchYardToCamel(exchange, _camelExchange);
            if (isInOnly()) {
                _camelExchange.setIn(camelMsg);
            } else {
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

   
    private Message composeForGateway(MessageComposer<CamelBindingData> composer,
            org.apache.camel.Exchange camelExchange, Exchange switchyardExchange) throws Exception {
       
        BindingDataCreator<?> bindingCreator = getBindingDataCreator(camelExchange);
        CamelBindingData bindingData = bindingCreator.createBindingData(camelExchange.getIn());
        if (bindingData instanceof SecurityBindingData) {
            // returned binding is contains some security bindings, let's move them to security context
            ServiceDomain serviceDomain = ((SwitchYardCamelContext)camelExchange.getContext()).getServiceDomain();
            SecurityContextManager securityContextManager = new SecurityContextManager(serviceDomain);
            securityContextManager.addCredentials(switchyardExchange, ((SecurityBindingData)bindingData).extractCredentials());
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

        String operationName = null;
       
        OperationSelector<CamelBindingData> selector = exchange.getIn().getHeader(CamelConstants.OPERATION_SELECTOR_HEADER, OperationSelector.class);
        if (selector != null) {
            try {
                operationName = selector.selectOperation(new CamelBindingData(exchange.getIn())).getLocalPart();
            } catch (Exception e) {
                SwitchYardCamelComponentLogger.ROOT_LOGGER.cannotLookupOperation(e);
            }
        }
        return operationName;
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

public class FlightCustomerInfoMessageComposer extends CamelMessageComposer {
    private static final Logger LOG = LoggerFactory.getLogger(FlightCustomerInfoMessageComposer.class);

    @Override
    public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
        CamelBindingData response = super.decompose(exchange, target);

        // Get BOOK_FLIGHT Request JAXB Bean object.
        BookFlightRequest bookFlightRequest = exchange.getMessage().getContent(BookFlightRequest.class);

        // Create SAP Request object from target endpoint.
        SAPEndpoint endpoint = target.getMessage().getExchange().getContext().getEndpoint("sap:destination:nplDest:BAPI_FLCUST_GETLIST", SAPEndpoint.class);
        Structure request = endpoint.getRequest();

        // Add Customer Name to request if set
        if (bookFlightRequest.getCustomerName() != null && bookFlightRequest.getCustomerName().length() > 0) {
            request.put("CUSTOMER_NAME", bookFlightRequest.getCustomerName());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added CUSTOMER_NAME = '{}' to request", bookFlightRequest.getCustomerName());
            }
        } else {
            throw new Exception("No Customer Name");
        }

        // Put request object into body of exchange message.
        response.getMessage().setBody(request);
        return response;
    }
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

    private static final Logger LOG = LoggerFactory.getLogger(CreateFlightTripMessageComposer.class);
    private static final String FLIGHT_TRIP_REQUEST_INFO = "flightTripRequestInfo";

    @Override
    public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
        CamelBindingData response = super.decompose(exchange, target);

        // Get flight connection info, flight customer info and passenger info bean objects
        FlightTripRequestInfo flightTripRequestInfo = exchange.getMessage().getContent(FlightTripRequestInfo.class);
        FlightConnectionInfo flightConnectionInfo = flightTripRequestInfo.getFlightConnectionInfo();
        FlightCustomerInfo flightCustomerInfo = flightTripRequestInfo.getFlightCustomerInfo();
        PassengerInfo passengerInfo = flightTripRequestInfo.getPassengerInfo();
        exchange.getContext().setProperty(FLIGHT_TRIP_REQUEST_INFO, flightTripRequestInfo, Scope.EXCHANGE);

        // Create SAP Request object from target endpoint.
        SAPEndpoint endpoint = response.getMessage().getExchange().getContext().getEndpoint("sap:destination:nplDest:BAPI_FLTRIP_CREATE", SAPEndpoint.class);
        Structure request = endpoint.getRequest();

        //
        // Add Flight Trip Data to request object.
        //

        Structure flightTripData = request.get("FLIGHT_TRIP_DATA", Structure.class);

        // Add Travel Agency Number to request if set
        String travelAgencyNumber = flightConnectionInfo.getTravelAgencyNumber();
        if (travelAgencyNumber != null && travelAgencyNumber.length() != 0) {
            flightTripData.put("AGENCYNUM", travelAgencyNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added AGENCYNUM = '{}' to FLIGHT_TRIP_DATA", travelAgencyNumber);
            }

        }

        // Add Customer ID to request if set
        String flightCustomerNumber = flightCustomerInfo.getCustomerNumber();
        if (flightCustomerNumber != null && flightCustomerNumber.length() != 0) {
            flightTripData.put("CUSTOMERID", flightCustomerNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added CUSTOMERID = '{}' to FLIGHT_TRIP_DATA", flightCustomerNumber);
            }

        }

        // Add Flight Connection Number to request if set
        String flightConnectionNumber = flightConnectionInfo.getFlightConnectionNumber();
        if (flightConnectionNumber != null && flightConnectionNumber.length() != 0) {
            flightTripData.put("FLCONN1", flightConnectionNumber);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added FLCONN1 = '{}' to FLIGHT_TRIP_DATA", flightConnectionNumber);
            }

        }

        // Add Departure Date to request if set
        Date flightConnectionDepartureData = flightConnectionInfo.getDepartureDate();
        if (flightConnectionDepartureData != null) {
            flightTripData.put("FLDATE1", flightConnectionDepartureData);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added FLDATE1 = '{}' to FLIGHT_TRIP_DATA", flightConnectionDepartureData);
            }

        }

        // Add Flight Connection Class to  request.
        // C : Business Class
        // Y : Economy Class
        // F : First Class
        String flightConnectionClass = "Y";
        if (flightConnectionClass != null && flightConnectionClass.length() != 0) {
            flightTripData.put("CLASS", flightConnectionClass);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added CLASS = '{}' to FLIGHT_TRIP_DATA", flightConnectionClass);
            }

        }


        //
        // Add Passenger List Data to request object.
        //
        @SuppressWarnings("unchecked")
        Table<Structure> passengerList = request.get("PASSENGER_LIST", Table.class);
        Structure passengerListEntry = passengerList.add();

        // Add Passenger Form of Address to request if set
        String passengerFormOfAddress = passengerInfo.getFormOfAddress();
        if (passengerFormOfAddress != null && passengerFormOfAddress.length() != 0) {
            passengerListEntry.put("PASSFORM", passengerFormOfAddress);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added PASSFORM = '{}' to PASSENGER_LIST", passengerFormOfAddress);
            }

        }

        // Add Passenger Name to request if set
        String passengerName = passengerInfo.getName();
        if (passengerName != null && passengerName.length() != 0) {
            passengerListEntry.put("PASSNAME", passengerName);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added PASSNAME = '{}' to PASSENGER_LIST", passengerName);
            }

        }

        // Add Passenger Data of Birth to request if set
        Date passengerDateOfBirth = passengerInfo.getDateOfBirth();
        if (passengerDateOfBirth != null) {
            passengerListEntry.put("PASSBIRTH", passengerDateOfBirth);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added PASSBIRTH = '{}' to PASSENGER_LIST", passengerDateOfBirth);
            }

        }

        // Put request object into body of exchange message.
        response.getMessage().setBody(request);
        return response;
    }
View Full Code Here

Examples of org.switchyard.component.camel.common.composer.CamelBindingData

public class GetFlightConnectionListMessageComposer extends CamelMessageComposer {
    private static final Logger LOG = LoggerFactory.getLogger(GetFlightConnectionListMessageComposer.class);
   
    @Override
    public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
        CamelBindingData response = super.decompose(exchange, target);
       
        // Get BOOK_FLIGHT Request JAXB Bean object.
        BookFlightRequest bookFlightRequest = exchange.getMessage().getContent(BookFlightRequest.class);

        // Create SAP Request object from target endpoint.
        SAPEndpoint endpoint = response.getMessage().getExchange().getContext().getEndpoint("sap:destination:nplDest:BAPI_FLCONN_GETLIST", SAPEndpoint.class);
        Structure request = endpoint.getRequest();

        // Add Travel Agency Number to request if set
        if (bookFlightRequest.getTravelAgencyNumber() != null && bookFlightRequest.getTravelAgencyNumber().length() > 0) {
            request.put("TRAVELAGENCY", bookFlightRequest.getTravelAgencyNumber());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added TRAVELAGENCY = '{}' to request", bookFlightRequest.getTravelAgencyNumber());
            }
        } else {
            throw new Exception("No Travel Agency Number");
        }

        // Add Flight Date to request if set
        if (bookFlightRequest.getFlightDate() != null) {
            @SuppressWarnings("unchecked")
            Table<Structure> table = request.get("DATE_RANGE", Table.class);
            Structure date_range = table.add();
            date_range.put("SIGN", "I");
            date_range.put("OPTION", "EQ");
            Date date = bookFlightRequest.getFlightDate();
            date_range.put("LOW", date);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added DATE_RANGE = '{}' to request", RfcUtil.marshal(table));
            }
        } else {
            throw new Exception("No Flight Date");
        }

        // Add Start Destination if set
        if (bookFlightRequest.getStartAirportCode() != null && bookFlightRequest.getStartAirportCode().length() > 0) {
            Structure destination_from = request.get("DESTINATION_FROM", Structure.class);
            destination_from.put("AIRPORTID", bookFlightRequest.getStartAirportCode());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added DESTINATION_FROM = '{}' to request", RfcUtil.marshal(destination_from));
            }
        } else {
            throw new Exception("No Start Destination");
        }

        // Add End Destination if set
        if (bookFlightRequest.getEndAirportCode() != null && bookFlightRequest.getEndAirportCode().length() > 0) {
            Structure destination_to = request.get("DESTINATION_TO", Structure.class);
            destination_to.put("AIRPORTID", bookFlightRequest.getEndAirportCode());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Added DESTINATION_TO = '{}' to request", RfcUtil.marshal(destination_to));
            }
        } else {
            throw new Exception("No End Destination");
        }

        // Put request object into body of exchange message.
        response.getMessage().setBody(request);
        return response;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.