org.apache.camel.util.URISupport Java Examples
The following examples show how to use
org.apache.camel.util.URISupport.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FromStepParser.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@JsonIgnore public String getEndpointUri() { String answer = uri; if (parameters != null) { try { answer = URISupport.appendParametersToURI(answer, parameters); } catch (URISyntaxException | UnsupportedEncodingException e) { throw new RuntimeException(e); } } return answer; }
Example #2
Source File: WireTapStepParser.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@JsonIgnore public String getEndpointUri() { String answer = getUri(); if (parameters != null) { try { answer = URISupport.appendParametersToURI(answer, parameters); } catch (URISyntaxException | UnsupportedEncodingException e) { throw new RuntimeException(e); } } return answer; }
Example #3
Source File: ToDynamicStepParser.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@JsonIgnore public String getEndpointUri() { String answer = getUri(); if (parameters != null) { try { answer = URISupport.appendParametersToURI(answer, parameters); } catch (URISyntaxException | UnsupportedEncodingException e) { throw new RuntimeException(e); } } return answer; }
Example #4
Source File: ToStepParser.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@JsonIgnore public String getEndpointUri() { String answer = uri; if (parameters != null) { try { answer = URISupport.appendParametersToURI(answer, parameters); } catch (URISyntaxException | UnsupportedEncodingException e) { throw new RuntimeException(e); } } return answer; }
Example #5
Source File: Sources.java From camel-k-runtime with Apache License 2.0 | 5 votes |
private URI(String uri) throws Exception { final String location = StringSupport.substringBefore(uri, "?"); if (!location.startsWith(Constants.SCHEME_PREFIX_CLASSPATH) && !location.startsWith(Constants.SCHEME_PREFIX_FILE)) { throw new IllegalArgumentException("No valid resource format, expected scheme:path, found " + uri); } final String query = StringSupport.substringAfter(uri, "?"); final Map<String, Object> params = URISupport.parseQuery(query); final String languageName = (String) params.get("language"); final String compression = (String) params.get("compression"); final String loader = (String) params.get("loader"); final String interceptors = (String) params.get("interceptors"); String language = languageName; if (ObjectHelper.isEmpty(language)) { language = StringSupport.substringAfterLast(location, ":"); language = StringSupport.substringAfterLast(language, "."); } if (ObjectHelper.isEmpty(language)) { throw new IllegalArgumentException("Unknown language " + language); } String name = (String) params.get("name"); if (name == null) { name = StringSupport.substringAfter(location, ":"); name = StringSupport.substringBeforeLast(name, "."); if (name.contains("/")) { name = StringSupport.substringAfterLast(name, "/"); } } this.location = location; this.name = name; this.language = language; this.loader = loader; this.interceptors = interceptors != null ? Arrays.asList(interceptors.split(",", -1)) : Collections.emptyList(); this.compressed = Boolean.parseBoolean(compression); }
Example #6
Source File: KnativeStepParser.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@JsonIgnore public String getEndpointUri() { String answer = String.format("knative:%s/%s", type.name(), name); if (parameters != null) { try { answer = URISupport.appendParametersToURI(answer, parameters); } catch (URISyntaxException | UnsupportedEncodingException e) { throw new RuntimeException(e); } } return answer; }
Example #7
Source File: ComponentProxyComponent.java From syndesis with Apache License 2.0 | 5 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) { // merge parameters final Map<String, Object> options = new HashMap<>(); doAddOptions(options, this.remainingOptions); doAddOptions(options, parameters); // create the uri of the base component, DO NOT log the computed delegate final Map<String, String> endpointOptions = buildEndpointOptions(remaining, options); final String endpointScheme = componentSchemeAlias.orElse(componentScheme); ComponentDefinition definition = getDefinition(); final Endpoint delegate = createDelegateEndpoint(definition, endpointScheme, endpointOptions); LOGGER.info("Connector resolved: {} -> {}", URISupport.sanitizeUri(uri), URISupport.sanitizeUri(delegate.getEndpointUri())); // remove options already set on the endpoint options.keySet().removeIf(endpointOptions::containsKey); // Configure the delegated endpoint configureDelegateEndpoint(definition, delegate, options); final ComponentProxyEndpoint answer = new ComponentProxyEndpoint(uri, this, delegate); answer.setBeforeProducer(CamelContextAware.trySetCamelContext(getBeforeProducer(), getCamelContext())); answer.setAfterProducer(CamelContextAware.trySetCamelContext(getAfterProducer(), getCamelContext())); answer.setBeforeConsumer(CamelContextAware.trySetCamelContext(getBeforeConsumer(), getCamelContext())); answer.setAfterConsumer(CamelContextAware.trySetCamelContext(getAfterConsumer(), getCamelContext())); // clean-up parameters so that validation won't fail later on // in DefaultConnectorComponent.validateParameters() parameters.clear(); // remove temporary options this.remainingOptions.clear(); return answer; }
Example #8
Source File: KnativeComponentProxyFactory.java From syndesis with Apache License 2.0 | 5 votes |
public static String computeKnativeUri(String scheme, Map<String, String> options) { Map<String, Object> uriOptions = new HashMap<>(options); String type = (String) uriOptions.remove("type"); String name = (String) uriOptions.remove("name"); String uri = scheme + "://" + type + "/" + name; if (!uriOptions.isEmpty()) { try { return URISupport.appendParametersToURI(uri, uriOptions); } catch (UnsupportedEncodingException | URISyntaxException e) { throw new IllegalStateException("Unable to append parameters to URI", e); } } return uri; }
Example #9
Source File: TemplateStepHandler.java From syndesis with Apache License 2.0 | 4 votes |
@SuppressWarnings("PMD.AvoidReassigningParameters") private Optional<ProcessorDefinition<?>> handle(TemplateStepLanguage language, Step step, ProcessorDefinition<?> route, String flowIndex, String stepIndex) { Map<String, String> properties = step.getConfiguredProperties(); String template = properties.get(TEMPLATE_PROPERTY); try { /* * Pre-process the template to ensure it conforms to the standard. */ template = language.preProcess(template); } catch (Exception ex) { throw new IllegalStateException(ex); } // // Convert the exchange's in message from JSON // to a HashMap since this is required by camel modules // route = route.process(jsonToMapProcessor); // // Apply the template to the header property // Then add to the route path // route.setHeader(language.camelHeader()).constant(template); // // Encode the delimiters since they are applied as URI query parameters // try { String id = flowIndex + HYPHEN + stepIndex; String uri = language.generateUri(id); Map<String, Object> params = language.getUriParams(); if (params != null && !params.isEmpty()) { uri = URISupport.appendParametersToURI(uri, params); } route = route.to(uri); // // Post-process the output exchange into JSON // so it will be available as part of a JSON object // route = route.process(textToJsonProcessor); return Optional.ofNullable(route); } catch (UnsupportedEncodingException | URISyntaxException e) { throw new IllegalStateException(e); } }