cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1360653 - in /cxf/branches/2.6.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Date Thu, 12 Jul 2012 12:23:36 GMT
Author: sergeyb
Date: Thu Jul 12 12:23:35 2012
New Revision: 1360653

URL: http://svn.apache.org/viewvc?rev=1360653&view=rev
Log:
Merged revisions 1360444 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1360444 | sergeyb | 2012-07-11 23:18:03 +0100 (Wed, 11 Jul 2012) | 1 line
  
  Updating ResourceUtils to try to convet a given resource to URL first before trying other
options
........

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1360444

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=1360653&r1=1360652&r2=1360653&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Thu Jul 12 12:23:35 2012
@@ -412,18 +412,22 @@ public final class ResourceUtils {
         if (loc.startsWith(CLASSPATH_PREFIX)) {
             String path = loc.substring(CLASSPATH_PREFIX.length());
             url = ResourceUtils.getClasspathResourceURL(path, ResourceUtils.class, bus);
-            if (url == null) {
-                LOG.warning("No classpath resource " + loc + " is available on classpath");
-                return null;
-            }
         } else {
-            String actualLoc = loc.startsWith("file:") ? loc.substring(5) : loc;
-            File f = new File(actualLoc);
-            if (!f.exists()) {
-                LOG.warning("No file resource " + loc + " is available on local disk");
-                return null;
+            try {
+                url = new URL(loc);
+            } catch (Exception ex) {
+                // it can be either a classpath or file resource without a scheme
+                url = ResourceUtils.getClasspathResourceURL(loc, ResourceUtils.class, bus);
+                if (url == null) {
+                    File file = new File(loc);
+                    if (file.exists()) {
+                        url = file.toURI().toURL();
+                    }
+                }
             }
-            url = f.toURI().toURL();
+        }
+        if (url == null) {
+            LOG.warning("No resource " + loc + " is available");
         }
         return url;
     }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1360653&r1=1360652&r2=1360653&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Thu Jul 12 12:23:35 2012
@@ -1180,7 +1180,7 @@ public class JAXBElementProviderTest ext
         List<String> locations = new ArrayList<String>();
         String loc = getClass().getClassLoader().getResource("test.xsd").toURI().getPath();
         
-        locations.add(loc);
+        locations.add("file:" + loc);
         provider.setSchemas(locations);
         Schema s = provider.getSchema();
         assertNotNull("schema can not be read from disk", s);
@@ -1213,7 +1213,7 @@ public class JAXBElementProviderTest ext
         JAXBElementProvider<Book2> provider = new JAXBElementProvider<Book2>();
         List<String> locations = new ArrayList<String>();
         String loc = getClass().getClassLoader().getResource("test.xsd").toURI().getPath();
-        locations.add(loc);
+        locations.add("file:" + loc);
         provider.setSchemas(locations);
         Schema s = provider.getSchema();
         assertNotNull("schema can not be read from disk", s);



Mime
View raw message