You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2015/11/18 17:12:11 UTC

[jira] [Comment Edited] (CXF-6683) LinkBuilderImpl build strips last path segment with baseUri set

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

Sergey Beryozkin edited comment on CXF-6683 at 11/18/15 4:12 PM:
-----------------------------------------------------------------

To be honest, one should not use the builder impl directly, are you doing it to optimize the calls ? 


was (Author: sergey_beryozkin):
To be honest, one should not used the builder impl directly, are you doing it to optimize the calls ? 

> 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)