cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christoph Berg (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-6683) LinkBuilderImpl build strips last path segment with baseUri set
Date Thu, 19 Nov 2015 06:22:11 GMT

    [ https://issues.apache.org/jira/browse/CXF-6683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15012954#comment-15012954
] 

Christoph Berg edited comment on CXF-6683 at 11/19/15 6:21 AM:
---------------------------------------------------------------

We use a {{Provider<Link.Builder>}} to get a concrete implementation of the Link.Builder
implementation, which abstracts this from our code. I just wanted to avoid having all our
indirections here in the ticket.

But it sounds like this is also not the correct approach. So is it better to use {{RuntimeDelegate.getLinkBuilder()}}
or what did your question imply?


was (Author: cberg):
We use a Provider<Link.Builder> to get a concrete implementation of the Link.Builder
implementation, which abstracts this from our code. I just wanted to avoid having all our
indirections here in the ticket.

But it sounds like this is also not the correct approach. So is it better to use {{RuntimeDelegate.getLinkBuilder()}}
or what did your question imply?

> LinkBuilderImpl build strips last path segment with baseUri set
> ---------------------------------------------------------------
>
>                 Key: CXF-6683
>                 URL: https://issues.apache.org/jira/browse/CXF-6683
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.1.4
>            Reporter: Christoph Berg
>            Assignee: Sergey Beryozkin
>
> After I applied the fix I proposed in CXF-6682, I tried building a link to point to a
specific entity of a REST resource, e.g. http://localhost:8080/resource/1.
> We currently build the Link as follows:
> {code}
> new LinkBuilderImpl().baseUri("http://localhost:8080/resource/1").rel("self").build();
> {code}
> I would expect that the Link would then contain the value of the {{baseUri}}, but the
last path segment is stripped.
> The {{LinkerBuilderImpl#getResolvedUri(Object… values)}} creates an URI, which will
have an empty path. If this is given to the {{HttpUtils.resolve}} method, it strips the last
path component.
> If I change the method to look like this, everything works as expected:
> {code}
>     private URI getResolvedUri(Object... values) {
>         URI uri = ub.build(values);
>                 
>         if (!uri.isAbsolute() && baseUri != null) {
>             UriBuilder linkUriBuilder = UriBuilder.fromUri(baseUri);
>             String path = uri.getPath();
>             if (path == null || path.isEmpty()) {
>                 return linkUriBuilder.build();
>             }
>             return HttpUtils.resolve(linkUriBuilder, uri);    
>         } else {
>             return uri;
>         }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message