cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6378] Fixing a relatve link resolution issue
Date Wed, 29 Apr 2015 12:37:35 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 0ce334ef4 -> 94a89c7dd


[CXF-6378] Fixing a relatve link resolution issue


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/94a89c7d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/94a89c7d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/94a89c7d

Branch: refs/heads/master
Commit: 94a89c7dd208998fcfc612d49e230ea33c7dc063
Parents: 0ce334e
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Apr 29 13:37:20 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Apr 29 13:37:20 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java   | 10 ++--------
 .../org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java    |  4 ++--
 .../org/apache/cxf/systest/jaxrs/BookStoreSpring.java     |  5 +++--
 3 files changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/94a89c7d/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
index edfc403..2363a7a 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
@@ -57,15 +57,9 @@ public class LinkBuilderImpl implements Builder {
     private URI getResolvedUri(Object... values) {
         URI uri = ub.build(values);
                 
-        if (baseUri != null) {
+        if (!uri.isAbsolute() && baseUri != null) {
             UriBuilder linkUriBuilder = UriBuilder.fromUri(baseUri);
-            String scheme = uri.getScheme();
-            if (scheme != null && scheme.startsWith("http")) {
-                return HttpUtils.resolve(linkUriBuilder, uri);    
-            } else {
-                String theUri = uri.toString();
-                return linkUriBuilder.path(theUri).build();
-            }
+            return HttpUtils.resolve(linkUriBuilder, uri);    
         } else {
             return uri;
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/94a89c7d/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
index 4d84863..a3790dc 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
@@ -79,7 +79,7 @@ public class LinkBuilderImplTest extends Assert {
         Link.Builder linkBuilder = Link.fromUri("relative");
         linkBuilder.baseUri("http://localhost:8080/base/path");
         Link link = linkBuilder.rel("next").build();
-        assertEquals("<http://localhost:8080/base/path/relative>;rel=\"next\"", link.toString());
+        assertEquals("<http://localhost:8080/base/relative>;rel=\"next\"", link.toString());
     }
     
     @Test
@@ -87,7 +87,7 @@ public class LinkBuilderImplTest extends Assert {
         Link.Builder linkBuilder = Link.fromUri("/relative");
         linkBuilder.baseUri("http://localhost:8080/base/path");
         Link link = linkBuilder.rel("next").build();
-        assertEquals("<http://localhost:8080/base/path/relative>;rel=\"next\"", link.toString());
+        assertEquals("<http://localhost:8080/relative>;rel=\"next\"", link.toString());
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/cxf/blob/94a89c7d/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
index d264d0b..ab08c96 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
@@ -21,6 +21,7 @@ package org.apache.cxf.systest.jaxrs;
 
 
 import java.io.ByteArrayOutputStream;
+import java.net.URI;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -95,8 +96,8 @@ public class BookStoreSpring {
     @GET
     @Path("/link")
     public Response getBookLink() {
-        Link link = Link.fromResource(BookStoreSpring.class)
-            .baseUri(ui.getBaseUri()).rel("self").build();
+        URI selfUri = ui.getBaseUriBuilder().path(BookStoreSpring.class).build();
+        Link link = Link.fromUri(selfUri).rel("self").build();
         return Response.ok().links(link).build();
     }
     


Mime
View raw message