@Override public String createEndpointUri(final String scheme, final Map<String, String> options) throws URISyntaxException { // set serviceUri on delegate component Olingo4Component delegate = getCamelContext().getComponent(scheme, Olingo4Component.class); Olingo4Configuration configuration = new Olingo4Configuration(); configuration.setServiceUri(this.serviceUri); delegate.setConfiguration(configuration); setAfterProducer( exchange -> { if (!exchange.isFailed()) { ClientEntity clientEntity = exchange.getIn().getBody(ClientEntity.class); if (clientEntity != null) { // convert client entity to JSON final StringWriter writer = new StringWriter(); final Entity entity = odataClient.getBinder().getEntity(clientEntity); final ODataSerializer serializer = odataClient.getSerializer(APPLICATION_JSON); serializer.write(writer, entity); exchange.getIn().setBody(writer.toString()); } } // TODO handle failure on missing resource 404 }); return super.createEndpointUri(scheme, options); }
@ConditionalOnMissingBean(Olingo4Component.class) public Olingo4Component configureOlingo4Component() throws Exception { Olingo4Component component = new Olingo4Component(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null,
@Override public String createEndpointUri(final String scheme, final Map<String, String> options) throws URISyntaxException { // set serviceUri on delegate component Olingo4Component delegate = getCamelContext().getComponent(scheme, Olingo4Component.class); Olingo4Configuration configuration = new Olingo4Configuration(); configuration.setServiceUri(this.serviceUri); delegate.setConfiguration(configuration); setAfterProducer( exchange -> { if (!exchange.isFailed()) { ClientEntity clientEntity = exchange.getIn().getBody(ClientEntity.class); if (clientEntity != null) { // convert client entity to JSON final StringWriter writer = new StringWriter(); final Entity entity = odataClient.getBinder().getEntity(clientEntity); final ODataSerializer serializer = odataClient.getSerializer(APPLICATION_JSON); serializer.write(writer, entity); exchange.getIn().setBody(writer.toString()); } } // TODO handle failure on missing resource 404 }); return super.createEndpointUri(scheme, options); }