protected void ignoreResponseHeaders(Message in) { in.removeHeader(Olingo4Constants.PROPERTY_PREFIX + Olingo4Constants.RESPONSE_HTTP_HEADERS); } }
protected void ignoreResponseHeaders(Message in) { in.removeHeader(Olingo4Constants.PROPERTY_PREFIX + Olingo4Constants.RESPONSE_HTTP_HEADERS); } }
protected void readRequestHeaders(GHttpEndpoint endpoint, Exchange exchange, HttpServletRequest request) { // EXPERIMENTAL // TODO: resolve gzip encoding issues exchange.getIn().removeHeader("Accept-Encoding"); exchange.getIn().removeHeader("Content-Encoding"); }
/** * Gets and removes the <code> <code>headerName</code> header form the input * <code>message</code> (the header will not be propagated) */ protected <T> T getAndRemoveHeader(Message message, String headerName, T defaultValue, Class<T> headerType) { T h = message.getHeader(headerName, defaultValue, headerType); message.removeHeader(headerName); return h; } }
@SuppressWarnings("suspicious") public boolean isCompleted(Exchange exchange) throws ReflectiveOperationException { return exchange == null || exchange.getIn() == null || (boolean) exchange.getIn().removeHeader(FINISHED_EXCHANGE); } }
@Override public void process(Exchange exchange) throws Exception { if (path != null) { exchange.getIn().setHeader(Exchange.HTTP_PATH, path); } else { exchange.getIn().removeHeader(Exchange.HTTP_PATH); } if (query != null) { exchange.getIn().setHeader(Exchange.HTTP_QUERY, query); } else { exchange.getIn().removeHeader(Exchange.HTTP_QUERY); } }
private void extractHeader(String headerMame, Message camelMessage, InternetHeaders headers) { String h = camelMessage.getHeader(headerMame, String.class); if (h != null) { headers.addHeader(headerMame, h); camelMessage.removeHeader(headerMame); } }
public static DispatchCallback<Exchange> detachCallback(Exchange exchange) { DispatchCallback<Exchange> callback = getCallback(exchange); if (callback != null) { exchange.getIn().removeHeader(ReactiveStreamsConstants.REACTIVE_STREAMS_CALLBACK); } return callback; }
@Override public void process(Exchange exchange) throws Exception { // cleanup and remove the headers we used exchange.getMessage().removeHeader(Exchange.HTTP_PATH); exchange.getMessage().removeHeader(Exchange.HTTP_QUERY); }
@Override public void process(Exchange exchange) throws Exception { // store any existing file header which we want to keep and propagate final String existing = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class); // create the target file name String target = createFileName(exchange); try { processExchange(exchange, target); } finally { // remove the write file name header as we only want to use it once (by design) exchange.getIn().removeHeader(Exchange.OVERRULE_FILE_NAME); // and restore existing file name exchange.getIn().setHeader(Exchange.FILE_NAME, existing); } }
@Override public void process(Exchange exchange) throws Exception { // NOPMD see // method // processSignedDataHader InputStream signature = exchange.getIn().getHeader(CryptoCmsConstants.CAMEL_CRYPTO_CMS_SIGNED_DATA, InputStream.class); if (signature == null) { LOG.debug("No signed data found in header {}. Assuming signed data contained in message body", CryptoCmsConstants.CAMEL_CRYPTO_CMS_SIGNED_DATA); super.process(exchange); } else { LOG.debug("Signed data header {} found.", CryptoCmsConstants.CAMEL_CRYPTO_CMS_SIGNED_DATA); processSignedDataHeader(exchange, signature); // remove header exchange.getIn().removeHeader(CryptoCmsConstants.CAMEL_CRYPTO_CMS_SIGNED_DATA); } }
@Override public void process(Exchange exchange) throws Exception { WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); if (wonMessage == null){ logger.debug("did not find a WonMessage in header {}, this is unexpected ", WonCamelConstants.MESSAGE_HEADER); return; } //remove the factory from the camel message so it does not slow down the rest of the processing chain Object factory = exchange.getIn().removeHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER); if (factory == null){ logger.debug("did not find an outbound message for message {} in header {}, this is unexpected ", wonMessage.getMessageURI(), WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER); return; } OutboundMessageFactoryProcessor factoryProcessor = (OutboundMessageFactoryProcessor) factory; WonMessage outboundMessage = factoryProcessor.process(wonMessage); if (outboundMessage == null){ logger.debug("factory did not produce an outgoing WonMessage based on WonMessage {}, this is unexpected", wonMessage.getMessageURI()); } exchange.getIn().setHeader(WonCamelConstants.OUTBOUND_MESSAGE_HEADER, outboundMessage); } }
/** * Define how the message should be processed. * * @param exchange the current camel message exchange */ public void process(final Exchange exchange) throws IOException { final Message in = exchange.getIn(); final CamelContext ctx = exchange.getContext(); final StringBuilder key = new StringBuilder("/buckets/"); try { final String prefix = ctx.resolvePropertyPlaceholders("{{riak.bucket}}"); key.append(prefix); } catch (final Exception ex) { throw new RuntimeCamelException("Could not resolve properties", ex); } key.append("/keys/"); key.append(URLEncoder.encode( in.getHeader(FcrepoHeaders.FCREPO_IDENTIFIER, String.class), "UTF-8")); in.removeHeader(Exchange.HTTP_URL); in.setHeader(Exchange.HTTP_PATH, key.toString()); } }
public void process(Exchange exchange) throws Exception { LOG.trace("Cache Name: {}", config.getCacheName()); Map<String, Object> headers = exchange.getIn().getHeaders(); String key = (headers.containsKey(CacheConstants.CACHE_KEY)) ? exchange.getIn().getHeader(CacheConstants.CACHE_KEY, String.class) : getEndpoint().getKey(); String operation = (headers.containsKey(CacheConstants.CACHE_OPERATION)) ? (String)headers .get(CacheConstants.CACHE_OPERATION) : getEndpoint().getOperation(); if (operation == null) { throw new CacheException(CacheConstants.CACHE_OPERATION + " header not specified in message"); } if ((key == null) && (!checkIsEqual(operation, CacheConstants.CACHE_OPERATION_DELETEALL))) { throw new CacheException(CacheConstants.CACHE_KEY + " is not specified in message header or endpoint URL."); } performCacheOperation(exchange, operation, key); //cleanup the cache headers exchange.getIn().removeHeader(CacheConstants.CACHE_KEY); exchange.getIn().removeHeader(CacheConstants.CACHE_OPERATION); }
/** * Evaluates the exchange */ protected void sendToConsumers(Exchange exchange) throws Exception { // ensure route id is correct set due CAMEL-4806 // TODO: Remove this when CAMEL-4806 is in released Fuse Camel version // and override prepareExchange method instead and set from route id detail there String routeId = (String) exchange.getIn().removeHeader("EcaRouteId"); if (exchange.getFromRouteId() == null) { exchange.setFromRouteId(routeId); } getEndpoint().evaluate(exchange); }
@Override public void removeProperty(Property property) { switch (property.getScope()) { case EXCHANGE: _exchange.removeProperty(property.getName()); break; default: _message.removeHeader(property.getName()); break; } }
@Override public void removeProperty(Property property) { switch (property.getScope()) { case EXCHANGE: _exchange.removeProperty(property.getName()); break; default: _message.removeHeader(property.getName()); break; } }
@Override protected Object getRequestBody(Exchange exchange) throws Exception { // creating the url to use takes 2-steps String uri = NettyHttpHelper.createURL(exchange, getEndpoint()); URI u = NettyHttpHelper.createURI(exchange, uri, getEndpoint()); HttpRequest request = getEndpoint().getNettyHttpBinding().toNettyRequest(exchange.getIn(), u.toString(), getConfiguration()); String actualUri = request.getUri(); exchange.getIn().setHeader(Exchange.HTTP_URL, actualUri); // Need to check if we need to close the connection or not if (!HttpHeaders.isKeepAlive(request)) { // just want to make sure we close the channel if the keepAlive is not true exchange.setProperty(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, true); } if (getConfiguration().isBridgeEndpoint()) { // Need to remove the Host key as it should be not used when bridging/proxying exchange.getIn().removeHeader("host"); } return request; }
private boolean processInOnly(Exchange exchange, AsyncCallback callback) throws Exception { // remove the OVERRIDE header so it does not propagate String exchangeName = (String) exchange.getIn().removeHeader(RabbitMQConstants.EXCHANGE_OVERRIDE_NAME); // If it is BridgeEndpoint we should ignore the message header of EXCHANGE_OVERRIDE_NAME if (exchangeName == null || getEndpoint().isBridgeEndpoint()) { exchangeName = getEndpoint().getExchangeName(); } else { log.debug("Overriding header: {} detected sending message to exchange: {}", RabbitMQConstants.EXCHANGE_OVERRIDE_NAME, exchangeName); } String key = exchange.getIn().getHeader(RabbitMQConstants.ROUTING_KEY, String.class); // we just need to make sure RoutingKey option take effect if it is not BridgeEndpoint if (key == null || getEndpoint().isBridgeEndpoint()) { key = getEndpoint().getRoutingKey() == null ? "" : getEndpoint().getRoutingKey(); } if (ObjectHelper.isEmpty(key) && ObjectHelper.isEmpty(exchangeName)) { throw new IllegalArgumentException("ExchangeName and RoutingKey is not provided in the endpoint: " + getEndpoint()); } basicPublish(exchange, exchangeName, key); callback.done(true); return true; }
@Test public void shouldAddWrapperProcessorIfSyndesisJsonSchemaGiven() throws Exception { final WebhookConnectorCustomizer customizer = new WebhookConnectorCustomizer(); customizer.setCamelContext(mock(CamelContext.class)); customizer.setOutputDataShape(new DataShape.Builder().kind(DataShapeKinds.JSON_SCHEMA).specification(SIMPLE_SCHEMA).build()); customizer.customize(component, Collections.emptyMap()); final Processor beforeConsumer = component.getBeforeConsumer(); assertThat(beforeConsumer).isInstanceOf(Pipeline.class); final Pipeline pipeline = (Pipeline) beforeConsumer; final Collection<Processor> processors = pipeline.getProcessors(); assertThat(processors).hasSize(2).anySatisfy(p -> assertThat(p).isInstanceOf(HttpRequestWrapperProcessor.class)); final HttpRequestWrapperProcessor wrapper = (HttpRequestWrapperProcessor) processors.stream().filter(p -> p instanceof HttpRequestWrapperProcessor) .findFirst().get(); assertThat(wrapper.getParameters()).containsOnly("source", "status"); final Processor removeHeader = processors.stream().filter(p -> !(p instanceof HttpRequestWrapperProcessor)).findFirst().get(); final Exchange exchange = mock(Exchange.class); final Message in = mock(Message.class); when(exchange.getIn()).thenReturn(in); removeHeader.process(exchange); verify(in).removeHeader(Exchange.HTTP_URI); }