You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2012/04/03 11:52:14 UTC

svn commit: r1308793 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/

Author: sergeyb
Date: Tue Apr  3 09:52:14 2012
New Revision: 1308793

URL: http://svn.apache.org/viewvc?rev=1308793&view=rev
Log:
[CXF-4220] Updates to WADLGenerator to avoid duplicate slashes in modified schemaLocations and ignore empty schemaLocations

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1308793&r1=1308792&r2=1308793&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java Tue Apr  3 09:52:14 2012
@@ -882,9 +882,12 @@ public class WadlGenerator implements Re
         
         for (Element schemaRefEl : schemaRefEls) {
             String href = schemaRefEl.getAttribute(attrName);
-            String actualRef = parentRef + href;
-            schemaLocationMap.put(actualRef, parentDocLoc + href);    
-            DOMUtils.setAttribute(schemaRefEl, attrName, getBaseURI(ui) + "/" + actualRef);
+            if (!StringUtils.isEmpty(href)) {
+                String actualRef = parentRef + href;
+                schemaLocationMap.put(actualRef, parentDocLoc + href);   
+                URI schemaURI = ui.getBaseUriBuilder().path(actualRef).build();
+                DOMUtils.setAttribute(schemaRefEl, attrName, schemaURI.toString());
+            }
         }
     }
 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=1308793&r1=1308792&r2=1308793&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java Tue Apr  3 09:52:14 2012
@@ -66,6 +66,7 @@ public class CXFNonSpringJaxrsServlet ex
     private static final String LANGUAGES_PARAM = "jaxrs.languages";
     private static final String PROPERTIES_PARAM = "jaxrs.properties";
     private static final String SCHEMAS_PARAM = "jaxrs.schemaLocations";
+    private static final String DOC_LOCATION_PARAM = "jaxrs.documentLocation";
     private static final String STATIC_SUB_RESOLUTION_PARAM = "jaxrs.static.subresources";
     private static final String SERVICE_SCOPE_SINGLETON = "singleton";
     private static final String SERVICE_SCOPE_REQUEST = "prototype";
@@ -97,7 +98,7 @@ public class CXFNonSpringJaxrsServlet ex
         if (modelRef != null) {
             bean.setModelRef(modelRef.trim());
         }
-        
+        setDocLocation(bean, servletConfig);
         setSchemasLocations(bean, servletConfig);
         setAllInterceptors(bean, servletConfig);
         
@@ -175,6 +176,13 @@ public class CXFNonSpringJaxrsServlet ex
         }
     }
     
+    protected void setDocLocation(JAXRSServerFactoryBean bean, ServletConfig servletConfig) {
+        String wadlLoc = servletConfig.getInitParameter(DOC_LOCATION_PARAM);
+        if (wadlLoc != null) {
+            bean.setDocLocation(wadlLoc);
+        }
+    }
+    
     @SuppressWarnings("unchecked")
     protected void setInterceptors(JAXRSServerFactoryBean bean, ServletConfig servletConfig,
                                    String paramName) {
@@ -366,6 +374,7 @@ public class CXFNonSpringJaxrsServlet ex
                                             getStaticSubResolutionValue(servletConfig));
         setAllInterceptors(bean, servletConfig);
         setExtensions(bean, servletConfig);
+        setDocLocation(bean, servletConfig);
         setSchemasLocations(bean, servletConfig);
         
         bean.setBus(getBus());

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=1308793&r1=1308792&r2=1308793&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java Tue Apr  3 09:52:14 2012
@@ -65,7 +65,7 @@ public class JAXRSClientServerSpringBook
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerSpring.class, true));
+                   launchServer(BookServerSpring.class));
     }
     
     @Test
@@ -113,6 +113,7 @@ public class JAXRSClientServerSpringBook
     
         checkSchemas(address, "/book.xsd", "/bookid.xsd", "import");
         checkSchemas(address, "/bookid.xsd", null, null);
+        checkWadlResourcesInfo(address, address, "/book.xsd", 1);
     }
     
     private void checkSchemas(String address, String schemaSegment,