Java Code Examples for org.apache.camel.util.URISupport#appendParametersToURI()

The following examples show how to use org.apache.camel.util.URISupport#appendParametersToURI() . 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 vote down vote up
@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 vote down vote up
@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 vote down vote up
@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 vote down vote up
@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: KnativeStepParser.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: KnativeComponentProxyFactory.java    From syndesis with Apache License 2.0 5 votes vote down vote up
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 7
Source File: TemplateStepHandler.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@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);
    }
}