commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1527237 - /commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/resolver/CatalogResolver.java
Date Sat, 28 Sep 2013 19:41:09 GMT
Author: oheger
Date: Sat Sep 28 19:41:08 2013
New Revision: 1527237

URL: http://svn.apache.org/r1527237
Log:
CatalogResolver now uses the locator-based method for locating files.

References to FileLocatorUtils.locate(FileSystem, String, String) have been
replaced by FileLocatorUtils.locate(FileLocator). This makes use of the
customizable location strategy.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/resolver/CatalogResolver.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/resolver/CatalogResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/resolver/CatalogResolver.java?rev=1527237&r1=1527236&r2=1527237&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/resolver/CatalogResolver.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/resolver/CatalogResolver.java
Sat Sep 28 19:41:08 2013
@@ -25,6 +25,7 @@ import java.util.Vector;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
+import org.apache.commons.configuration.io.FileLocator;
 import org.apache.commons.configuration.io.FileLocatorUtils;
 import org.apache.commons.configuration.io.FileSystem;
 import org.apache.commons.logging.Log;
@@ -190,7 +191,7 @@ public class CatalogResolver implements 
 
             try
             {
-                URL url = FileLocatorUtils.locate(fs, null, resolved);
+                URL url = locate(fs, null, resolved);
                 if (url == null)
                 {
                     throw new ConfigurationException("Could not locate "
@@ -246,6 +247,23 @@ public class CatalogResolver implements 
     }
 
     /**
+     * Helper method for locating a given file. This implementation delegates to
+     * the corresponding method in {@link FileLocatorUtils}.
+     *
+     * @param fs the {@code FileSystem}
+     * @param basePath the base path
+     * @param name the file name
+     * @return the URL pointing to the file
+     */
+    private static URL locate(FileSystem fs, String basePath, String name)
+    {
+        FileLocator locator =
+                FileLocatorUtils.fileLocator().fileSystem(fs)
+                        .basePath(basePath).fileName(name).create();
+        return FileLocatorUtils.locate(locator);
+    }
+
+    /**
      * Extend the CatalogManager to make the FileSystem and base directory accessible.
      */
     public static class CatalogManager extends org.apache.xml.resolver.CatalogManager
@@ -397,7 +415,7 @@ public class CatalogResolver implements 
 
                     try
                     {
-                        url = FileLocatorUtils.locate(fs, base, fileName);
+                        url = locate(fs, base, fileName);
                         if (url != null)
                         {
                             is = fs.getInputStream(url);
@@ -447,7 +465,7 @@ public class CatalogResolver implements 
          */
         public void parseCatalog(String baseDir, String fileName) throws IOException
         {
-            base = FileLocatorUtils.locate(fs, baseDir, fileName);
+            base = locate(fs, baseDir, fileName);
             catalogCwd = base;
             default_override = catalogManager.getPreferPublic();
             catalogManager.debug.message(DEBUG_NORMAL, "Parse catalog: " + fileName);



Mime
View raw message