Hi

Ah okay, yeah its not very common to use placeholders for ids and therefore
it's not resolved there before.
Yes you are welcome to create a JIRA and send a PR for this improvement

On Mon, Dec 12, 2022 at 1:28 PM Nikola Glidzic <nikola.glid...@ikor.one>
wrote:

> Sorry guys, I didn't know image can't be sent. Combine this email with
> previous one. Here is the relevant part of code of method forceAssignIds(),
> mentioned lines are marked with arrows:
>
> public static void forceAssignIds(CamelContext context,
> List<RouteDefinition> routes) throws Exception {
>         ExtendedCamelContext ecc =
> context.adapt(ExtendedCamelContext.class);
>
>         // handle custom assigned id's first, and then afterwards assign
> auto
>         // generated ids
>         Set<String> customIds = new HashSet<>();
>
>         for (final RouteDefinition route : routes) {
>             // if there was a custom id assigned, then make sure to support
>             // property placeholders
>             if (route.hasCustomIdAssigned()) {
>                 final String originalId = route.getId();
>                 final String id =
> context.resolvePropertyPlaceholders(originalId);
>
>   <- line 142
>                 // only set id if its changed, such as we did property
>                 // placeholder
>                 if (!originalId.equals(id)) {
>                     route.setId(id);
>                 }
>                 customIds.add(id);
>             } else {
>                 RestDefinition rest = route.getRestDefinition();
>                 if (rest != null && route.isRest()) {
>                     VerbDefinition verb = findVerbDefinition(rest,
> route.getInput().getEndpointUri());
>                     if (verb != null) {
>                         String id = verb.getId();
>
>
>  <- line 154
>                         if (verb.hasCustomIdAssigned() &&
> ObjectHelper.isNotEmpty(id) && !customIds.contains(id)) {
>                             route.setId(id);
>                             customIds.add(id);
>                         }
>                     }
>                 }
>             }
>         }
>
>
> From: Nikola Glidzic
> Sent: Monday, December 12, 2022 1:13 PM
> To: users@camel.apache.org
> Subject: BUG - missing configuration placeholder possibility for id in
> REST DSL
>
> Hello Camel crew,
>
> I think there is a bug when using placeholder for route id in REST DSL
> route. I am using Camel 3.18.4, but same problem exists in previous
> versions as well.
>
> I want my REST route to have my custom route id loaded from configuration
> by using configuration placeholder, like this:
>
> rest()
>                 .post("{{endpoint.uri}}")                            <-
> loaded nice
>                 .id("{{endpoint.id}}")
>  <- NOT loaded
>                 .type(Claim.class)
>                 .consumes("application/json")
>                 .bindingMode(RestBindingMode.json)
>                 .to("direct:some_channel")
>
> Endpoint uri placeholder will be loaded good, but placeholder for id will
> not be loaded and my route id will remain as "{{endpoint.id}}".
>
> I think mistake and fix solution for this stands in class
> RouteDefinitionHelper, in method forceAssignIds():
>
> If you check the provided image, I think that line 154 for resolving REST
> route id should have the same placeholder resolving logic as it is in line
> 142.
>
> Should I create JIRA ticket for this or will you do it? It is probably
> better if you do it, but please provide us link of JIRA ticket in response
> so we can track the progress.
>
> Thanks in advance!
> Kind Regards,
> Nikola Glidzic
>
>
>
>

-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to