cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r581942 - in /cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon: ConfigurationReader.java SourceResource.java SourceResourceLoader.java
Date Thu, 04 Oct 2007 15:04:58 GMT
Author: cziegeler
Date: Thu Oct  4 08:04:57 2007
New Revision: 581942

URL: http://svn.apache.org/viewvc?rev=581942&view=rev
Log:
Fix for COCOON-2138 - xmldb works now.

Added:
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java
  (with props)
Modified:
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResourceLoader.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=581942&r1=581941&r2=581942&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
Thu Oct  4 08:04:57 2007
@@ -165,10 +165,19 @@
     protected InputSource getInputSource(Resource rsrc)
     throws Exception {
         final InputSource is = new InputSource(rsrc.getInputStream());
-        is.setSystemId(rsrc.getURL().toExternalForm());
+        is.setSystemId(this.getUrl(rsrc));
         return is;
     }
 
+    protected String getUrl(Resource rsrc)
+    throws IOException {
+        if ( rsrc instanceof SourceResource ) {
+            return ((SourceResource)rsrc).getUrlString();
+        } else {
+            return rsrc.getURL().toExternalForm();
+        }
+    }
+
     protected String getUrl(String url, String base) {
         if ( url == null || base == null ) {
             return this.convertUrl(url);
@@ -206,7 +215,7 @@
                     "Invalid configuration schema version. Must be '"
                             + Constants.CONF_VERSION + "'.");
         }
-        this.convert(config, null, root.getURL().toExternalForm());
+        this.convert(config, null, this.getUrl(root));
     }
 
     protected void convertSitemap(String sitemapLocation)
@@ -228,7 +237,7 @@
         }
         final Configuration completeConfig = SitemapHelper.createSitemapConfiguration(config);
         if ( completeConfig != null ) {
-            this.convert(completeConfig, null, root.getURL().toExternalForm());
+            this.convert(completeConfig, null, this.getUrl(root));
         }
     }
 
@@ -260,7 +269,7 @@
                 final Resource userRolesSource = this.resolver.getResource(this.getUrl(userRoles,
rootUri));
                 final DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(true);
                 final Configuration userRolesConfig = b.build(this.getInputSource(userRolesSource));
-                this.parseConfiguration(userRolesConfig, userRolesSource.getURL().toExternalForm(),
loadedConfigs);
+                this.parseConfiguration(userRolesConfig, this.getUrl(userRolesSource), loadedConfigs);
             }
         }
         if ( additionalConfig != null ) {
@@ -547,7 +556,7 @@
             try {
                 src = this.resolver.getResource(this.getUrl(includeURI, contextURI));
 
-                this.configInfo.addImport(src.getURL().toExternalForm());
+                this.configInfo.addImport(this.getUrl(src));
             } catch (Exception e) {
                 throw new ConfigurationException("Cannot load '" + includeURI + "' at "
                         + includeStatement.getLocation(), e);
@@ -563,7 +572,7 @@
                     if ( resources != null ) {
                         Arrays.sort(resources, ResourceUtils.getResourceComparator());
                         for(int i=0; i < resources.length; i++) {
-                           this.configInfo.addImport(resources[i].getURL().toExternalForm());
+                           this.configInfo.addImport(this.getUrl(resources[i]));
                         }
                     }
                 } catch (IOException ioe) {

Added: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.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/SourceResource.java?rev=581942&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java
(added)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java
Thu Oct  4 08:04:57 2007
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.container.spring.avalon;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceUtil;
+import org.springframework.core.io.Resource;
+
+public class SourceResource implements Resource {
+
+    protected Source source;
+    protected SourceResolver resolver;
+    protected boolean open = false;
+
+    public SourceResource(Source s, SourceResolver r) {
+        this.source = s;
+        this.resolver =r;
+    }
+
+    /**
+     * @see org.springframework.core.io.InputStreamSource#getInputStream()
+     */
+    public InputStream getInputStream() throws IOException {
+        this.open = true;
+        return new SourceIOInputStream(this.resolver, this.source);
+    }
+
+    /**
+     * @see org.springframework.core.io.Resource#createRelative(java.lang.String)
+     */
+    public Resource createRelative(String uri) throws IOException {
+        int pos = this.source.getURI().lastIndexOf('/');
+        return new SourceResource(this.resolver.resolveURI(uri, this.source.getURI().substring(0,
pos), null), this.resolver);
+    }
+
+    /**
+     * @see org.springframework.core.io.Resource#exists()
+     */
+    public boolean exists() {
+        return this.source.exists();
+    }
+
+    /**
+     * @see org.springframework.core.io.Resource#getDescription()
+     */
+    public String getDescription() {
+        return "Source: " + this.source;
+    }
+
+    /**
+     * @see org.springframework.core.io.Resource#getFile()
+     */
+    public File getFile() throws IOException {
+        return SourceUtil.getFile(this.source);
+    }
+
+    /**
+     * @see org.springframework.core.io.Resource#getFilename()
+     */
+    public String getFilename() {
+        int pos = this.source.getURI().lastIndexOf('/');
+        return this.source.getURI().substring(pos + 1);
+    }
+
+    /**
+     * @see org.springframework.core.io.Resource#getURL()
+     */
+    public URL getURL() throws IOException {
+        return new URL(this.source.getURI());
+    }
+
+    public String getUrlString() {
+        return this.source.getURI();
+    }
+
+    /**
+     * @see org.springframework.core.io.Resource#isOpen()
+     */
+    public boolean isOpen() {
+        return this.open;
+    }
+
+}

Propchange: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResourceLoader.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/SourceResourceLoader.java?rev=581942&r1=581941&r2=581942&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResourceLoader.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResourceLoader.java
Thu Oct  4 08:04:57 2007
@@ -18,18 +18,11 @@
  */
 package org.apache.cocoon.core.container.spring.avalon;
 
-import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
 
-import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.SourceUtil;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.ResourceLoader;
-import org.springframework.core.io.UrlResource;
 
 public class SourceResourceLoader implements ResourceLoader {
 
@@ -53,85 +46,13 @@
      * @see org.springframework.core.io.ResourceLoader#getResource(java.lang.String)
      */
     public Resource getResource(String location) {
-        if ( location != null && location.indexOf(':') > 0 ) {
+        if ( location != null && (location.indexOf(':') > 0 || !location.startsWith("/")))
{
             try {
-                return new UrlResource(location);
-            } catch (MalformedURLException e) {
+                return new SourceResource(this.resolver.resolveURI(location), this.resolver);
+            } catch (IOException e) {
                 // we ignore it and leave it up to the wrapped loader
             }
         }
         return this.wrappedLoader.getResource(location);
-    }
-
-    public static class SourceResource implements Resource {
-
-        protected Source source;
-        protected SourceResolver resolver;
-        protected boolean open = false;
-
-        public SourceResource(Source s, SourceResolver r) {
-            this.source = s;
-            this.resolver =r;
-        }
-
-        /**
-         * @see org.springframework.core.io.InputStreamSource#getInputStream()
-         */
-        public InputStream getInputStream() throws IOException {
-            this.open = true;
-            return new SourceIOInputStream(this.resolver, this.source);
-        }
-
-        /**
-         * @see org.springframework.core.io.Resource#createRelative(java.lang.String)
-         */
-        public Resource createRelative(String uri) throws IOException {
-            int pos = this.source.getURI().lastIndexOf('/');
-            return new SourceResource(this.resolver.resolveURI(uri, this.source.getURI().substring(0,
pos), null), this.resolver);
-        }
-
-        /**
-         * @see org.springframework.core.io.Resource#exists()
-         */
-        public boolean exists() {
-            return this.source.exists();
-        }
-
-        /**
-         * @see org.springframework.core.io.Resource#getDescription()
-         */
-        public String getDescription() {
-            return "Source: " + this.source;
-        }
-
-        /**
-         * @see org.springframework.core.io.Resource#getFile()
-         */
-        public File getFile() throws IOException {
-            return SourceUtil.getFile(this.source);
-        }
-
-        /**
-         * @see org.springframework.core.io.Resource#getFilename()
-         */
-        public String getFilename() {
-            int pos = this.source.getURI().lastIndexOf('/');
-            return this.source.getURI().substring(pos + 1);
-        }
-
-        /**
-         * @see org.springframework.core.io.Resource#getURL()
-         */
-        public URL getURL() throws IOException {
-            return new URL(this.source.getURI());
-        }
-
-        /**
-         * @see org.springframework.core.io.Resource#isOpen()
-         */
-        public boolean isOpen() {
-            return this.open;
-        }
-
     }
 }



Mime
View raw message