cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r596516 - /cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
Date Tue, 20 Nov 2007 02:39:06 GMT
Author: vgritsenko
Date: Mon Nov 19 18:39:04 2007
New Revision: 596516

URL: http://svn.apache.org/viewvc?rev=596516&view=rev
Log:
ResourceUtils.getUri() could not handle SourceResource,
which ConfigurationReader.getUrl() handles specially.
To avoid exception, copied correctUrl to ConfigurationReader.

Modified:
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java?rev=596516&r1=596515&r2=596516&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
Mon Nov 19 18:39:04 2007
@@ -168,6 +168,25 @@
         return url;
     }
 
+    /**
+     * Copied from {@link ResourceUtils#correctUri(String)}. Comment says:
+     * <br><blockquote>
+     * If it is a file we have to recreate the url, otherwise we get problems
+     * under windows with some file references starting with "/DRIVELETTER" and
+     * some just with "DRIVELETTER".
+     * </blockquote>
+     * @param url to correct
+     * @return corrected (or same) url
+     */
+    protected String correctUrl(String url) {
+        if (url.startsWith("file:")) {
+            final File f = new File(url.substring(5));
+            return "file://" + f.getAbsolutePath();
+        }
+
+        return url;
+    }
+
     protected String getUrl(Resource rsrc)
     throws IOException {
         if (rsrc instanceof SourceResource) {
@@ -526,7 +545,7 @@
                            final Configuration includeStatement)
     throws ConfigurationException, IOException {
         // If already loaded: do nothing
-        final String uri = ResourceUtils.getUri(src);
+        final String uri = correctUrl(getUrl(src));
         if (!loadedURIs.contains(uri)) {
             if (this.logger.isDebugEnabled()) {
                 this.logger.debug("Loading configuration: " + uri);
@@ -597,7 +616,7 @@
                     if ( resources != null ) {
                         Arrays.sort(resources, ResourceUtils.getResourceComparator());
                         for(int i=0; i < resources.length; i++) {
-                           this.configInfo.addImport(this.getUrl(resources[i]));
+                           this.configInfo.addImport(getUrl(resources[i]));
                         }
                     }
                 } catch (IOException ioe) {



Mime
View raw message