Refine search
protected URI prepareCamelUri(String schema, String path, Map<String, Object> params) throws URISyntaxException { String url; if (schema == null) { url = path; } else { url = schema + "://" + path; } URI camelUri; try { camelUri = new URI(URISupport.normalizeUri(url)); } catch (UnsupportedEncodingException e) { camelUri = new URI(url); } if (params.isEmpty()) { return camelUri; } else { return URISupport.createURIWithQuery(camelUri, URISupport.createQueryString(params)); } }
/** * Creates a new AS/400 data queue endpoint using the specified connection * pool. */ protected Jt400Endpoint(String endpointUri, Jt400Component component, AS400ConnectionPool connectionPool) throws CamelException { super(endpointUri, component); ObjectHelper.notNull(connectionPool, "connectionPool"); try { configuration = new Jt400Configuration(endpointUri, connectionPool); } catch (URISyntaxException e) { throw new CamelException("Unable to parse URI for " + URISupport.sanitizeUri(endpointUri), e); } }
/** * Constructs a {@link URL} from an <code>uri</code> and an optional * <code>query</code> string. The encoding strategy follow those of the * Camel HTTP component. * * @param uri * must be encoded with * {@link UnsafeUriCharactersEncoder#encode(String)}. * @param query * decoded query string. Replaces the query part of * <code>uri</code> if not <code>null</code>. */ static URL getEndpointUrl(String uri, String query) throws Exception { Map<String, Object> parameters = null; URI uriObj = new URI(uri); if (query == null) { parameters = URISupport.parseParameters(uriObj); } else { parameters = URISupport.parseQuery(query, false, true); } if (uriObj.getScheme().equals(GHTTPS_SCHEME)) { uriObj = new URI(HTTPS_SCHEME + ":" + uriObj.getRawSchemeSpecificPart()); } else { // ghttp or anything else uriObj = new URI(HTTP_SCHEME + ":" + uriObj.getRawSchemeSpecificPart()); } return URISupport.createRemainingURI(uriObj, parameters).toURL(); }
public SyncMockDefinitionBuilder restMock(String endpointUri) { try { if (!URISupport.parseParameters(new URI(endpointUri)).containsKey("matchOnUriPrefix")) { Map<String, Object> params = new HashMap<>(); params.put("matchOnUriPrefix", "true"); endpointUri = URISupport.appendParametersToURI(endpointUri, params); } } catch (URISyntaxException | UnsupportedEncodingException e) { throw new RuntimeException(e); } return syncMock(endpointUri); }
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { URI uriHttpUriAddress = new URI(UnsafeUriCharactersEncoder.encodeHttpURI(remaining)); URI endpointUri = URISupport.createRemainingURI(uriHttpUriAddress, parameters); URI httpUri = URISupport.createRemainingURI( new URI(uriHttpUriAddress.getScheme(), uriHttpUriAddress.getUserInfo(), uriHttpUriAddress.getHost(),
URI u = new URI(UnsafeUriCharactersEncoder.encode(uri)); String[] userInfo = u.getUserInfo() != null ? u.getUserInfo().split(":") : null; String username = userInfo != null ? userInfo[0] : null; String password = userInfo != null && userInfo.length > 1 ? userInfo[1] : null; Map<String, Object> parameters = URISupport.parseParameters(u); String user = (String)parameters.get("username"); String nick = (String)parameters.get("nickname");
private void parseUri(String remaining, HipchatEndpoint endpoint) throws Exception { String uri = URISupport.normalizeUri(remaining); URI hipChatUri = new URI(uri); if (hipChatUri.getHost() != null) { endpoint.getConfiguration().setHost(hipChatUri.getHost()); if (hipChatUri.getPort() != -1) { endpoint.getConfiguration().setPort(hipChatUri.getPort()); } endpoint.getConfiguration().setProtocol(hipChatUri.getScheme()); } }
int indexOfPath = uri.indexOf((new URI(uri)).getPath()); if (indexOfPath > 0) { uriForRequest = uri.substring(indexOfPath); TypeConverter tc = message.getExchange().getContext().getTypeConverter(); String queryString = message.getHeader(Exchange.HTTP_QUERY, String.class); if (queryString != null) { skipRequestHeaders = URISupport.parseQuery(queryString, false, true); final Iterator<?> it = ObjectHelper.createIterator(value, null, true); while (it.hasNext()) { String headerValue = tc.convertTo(String.class, it.next()); URI u = new URI(uri); String hostHeader = u.getHost() + (u.getPort() == 80 ? "" : ":" + u.getPort()); request.headers().set(HttpHeaders.Names.HOST, hostHeader);
HttpClientConfigurer configurer = createHttpClientConfigurer(parameters, authMethods); addressUri = UnsafeUriCharactersEncoder.encodeHttpURI(addressUri); URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), httpClientParameters); HttpEndpoint endpoint = createHttpEndpoint(endpointUri.toString(), this, clientParams, thisHttpConnectionManager, configurer); getCamelContext().addService(urlRewrite); endpoint.setUrlRewrite(urlRewrite); URI httpUri = URISupport.createRemainingURI(new URI(addressUri), parameters);
URI uri = new URI(request.getUri()); headers.put(Exchange.HTTP_URI, uri.getPath()); headers.put(Exchange.HTTP_QUERY, uri.getQuery()); headers.put(Exchange.HTTP_RAW_QUERY, uri.getRawQuery()); Iterator<?> it = ObjectHelper.createIterator(values); while (it.hasNext()) { Object extracted = it.next(); Map<String, Object> uriParameters = URISupport.parseQuery(query, false, true); Iterator<?> it = ObjectHelper.createIterator(values); while (it.hasNext()) { Object extracted = it.next(); if (ObjectHelper.isNotEmpty(body)) { for (String param : body.split("&")) { String[] pair = param.split("=", 2);
Map<String, Object> options = new HashMap<>(); if (IntrospectionSupport.getProperties(bootstrapConfiguration, options, null, false)) { IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), config, options); URI u = new URI(UnsafeUriCharactersEncoder.encodeHttpURI(remaining)); String addressUri = URISupport.createRemainingURI(u, parameters).toString();
URI u; try { u = new URI(UnsafeUriCharactersEncoder.encode(result)); String path = u.getSchemeSpecificPart(); String scheme = u.getScheme(); Map parameters = URISupport.parseParameters(u); parameters.put(EcaEndpoint.PATTERN_NAME, getEvaluation()); parameters.put(EcaEndpoint.WINDOW_NAME, getEventWindow()); sorted.put(key, parameters.get(key)); String query = URISupport.createQueryString(sorted); result = scheme + "://" + path + "?" + query; this.createdUri = result;
public void parseURI(URI uri) throws URISyntaxException { String protocol = uri.getScheme(); if (!protocol.equalsIgnoreCase("hdfs2")) { throw new IllegalArgumentException("Unrecognized protocol: " + protocol + " for uri: " + uri); } hostName = uri.getHost(); if (hostName == null) { hostName = "localhost"; } port = uri.getPort() == -1 ? HdfsConstants.DEFAULT_PORT : uri.getPort(); path = uri.getPath(); Map<String, Object> hdfsSettings = URISupport.parseParameters(uri); overwrite = getBoolean(hdfsSettings, "overwrite", overwrite); append = getBoolean(hdfsSettings, "append", append); wantAppend = append; bufferSize = getInteger(hdfsSettings, "bufferSize", bufferSize); replication = getShort(hdfsSettings, "replication", replication); blockSize = getLong(hdfsSettings, "blockSize", blockSize); compressionType = getCompressionType(hdfsSettings, "compressionType", compressionType); compressionCodec = getCompressionCodec(hdfsSettings, "compressionCodec", compressionCodec); fileType = getFileType(hdfsSettings, "fileType", fileType); fileSystemType = getFileSystemType(hdfsSettings, "fileSystemType", fileSystemType); keyType = getWritableType(hdfsSettings, "keyType", keyType); valueType = getWritableType(hdfsSettings, "valueType", valueType); openedSuffix = getString(hdfsSettings, "openedSuffix", openedSuffix); readSuffix = getString(hdfsSettings, "readSuffix", readSuffix); pattern = getString(hdfsSettings, "pattern", pattern); chunkSize = getInteger(hdfsSettings, "chunkSize", chunkSize); splitStrategies = getSplitStrategies(hdfsSettings); }
/** * Creates the URI to invoke. * * @param exchange the exchange * @param url the url to invoke * @param endpoint the endpoint * @return the URI to invoke */ public static URI createURI(Exchange exchange, String url, NettyHttpEndpoint endpoint) throws URISyntaxException { URI uri = new URI(url); // is a query string provided in the endpoint URI or in a header // (header overrules endpoint, raw query header overrules query header) String queryString = exchange.getIn().getHeader(Exchange.HTTP_RAW_QUERY, String.class); if (queryString == null) { queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class); } if (queryString == null) { // use raw as we encode just below queryString = uri.getRawQuery(); } if (queryString != null) { // need to encode query string queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString); uri = URISupport.createURIWithQuery(uri, queryString); } return uri; }
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { ObjectHelper.notNull(getCamelContext(), "Camel Context"); URI remainingUri = new URI(URISupport.normalizeUri(remaining)); String scheme = remainingUri.getScheme();
public void parseURI() throws Exception { protocol = uri.getScheme(); Map<String, Object> settings = URISupport.parseParameters(uri); setFromPort(Integer.parseInt((String) settings.get("fromPort"))); setToUser(uri.getUserInfo()); setToHost(uri.getHost()); setToPort(uri.getPort()); } else { ObjectHelper.notNull(fromUser, "From User"); ObjectHelper.notNull(fromHost, "From Host"); ObjectHelper.notNull(fromPort, "From Port"); ObjectHelper.notNull(eventHeader, "Event Header"); ObjectHelper.notNull(eventHeaderName, "Event Header Name");
path = path.substring(0, idx); Map<String, Object> params = URISupport.parseParameters(new URI(child)); String consumer = params != null ? (String) params.remove("consumer") : null; if (consumer != null) { Map<String, Object> properties = IntrospectionSupport.extractProperties(params, "consumer."); if (properties != null && properties.size() > 0) { consumer = consumer + "?" + URISupport.createQueryString(properties); for (String k : properties.keySet()) { params.remove(k); child = child + "?" + URISupport.createQueryString(params);
private void findSchedulerUriComponent(String uri, Set<String> components) { // the input may use a scheduler which can be quartz or spring if (uri != null) { try { URI u = new URI(uri); Map<String, Object> parameters = URISupport.parseParameters(u); Object value = parameters.get("scheduler"); if (value == null) { value = parameters.get("consumer.scheduler"); } if (value != null) { // the scheduler can be quartz2 or spring based, so add reference to camel component // from these components os blueprint knows about the requirement String name = value.toString(); if ("quartz2".equals(name)) { components.add("quartz2"); } else if ("spring".equals(name)) { components.add("spring-event"); } } } catch (URISyntaxException e) { // ignore as uri should be already validated at findUriComponent method } } }
/** * Verify if uri generated by model binding is equals to uri produced by test. * * @throws Exception Any exception can be thrown from uri normalization code. */ @Test public void verifyModelUri() throws Exception { String componentURI = createTestModel().getComponentURI().toString(); assertUriEquals(createEndpointUri(), normalizeUri(componentURI)); }
String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class); if (queryString != null) { skipRequestHeaders = URISupport.parseQuery(queryString, false, true); final Iterator<?> it = ObjectHelper.createIterator(headerValue, null, true); String value = exchange.getContext().getTypeConverter().convertTo(String.class, it.next()); Map<String, List<String>> cookieHeaders = getEndpoint().getCookieHandler().loadCookies(exchange, new URI(method.getURI().getEscapedURI())); for (Map.Entry<String, List<String>> entry : cookieHeaders.entrySet()) { String key = entry.getKey();