You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2004/08/11 15:11:32 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/components/modules/input FallbackModule.java

andreas     2004/08/11 06:11:31

  Modified:    src/java/org/apache/lenya/cms/cocoon/components/modules/input
                        FallbackModule.java
  Log:
  refactoring: extracted method
  
  Revision  Changes    Path
  1.4       +19 -7     cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/components/modules/input/FallbackModule.java
  
  Index: FallbackModule.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/components/modules/input/FallbackModule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FallbackModule.java	9 Aug 2004 10:28:11 -0000	1.3
  +++ FallbackModule.java	11 Aug 2004 13:11:31 -0000	1.4
  @@ -115,6 +115,18 @@
               getLogger().debug("Resolving file for path [" + name + "]");
           }
   
  +        String resolvedUri = resolveURI(name, objectModel);
  +        return resolvedUri;
  +    }
  +
  +    /**
  +     * Resolves the URI for a certain path.
  +     * @param path The path.
  +     * @param objectModel The object model.
  +     * @return A string.
  +     * @throws ConfigurationException if an error occurs.
  +     */
  +    protected String resolveURI(String path, Map objectModel) throws ConfigurationException {
           String resolvedUri = null;
           String checkedUris = "\n";
   
  @@ -124,8 +136,9 @@
   
               String[] baseUris = getBaseURIs(objectModel);
               Source source = null;
  -            for (int i = 0; i < baseUris.length; i++) {
  -                String uri = baseUris[i] + "/" + name;
  +            int i = 0;
  +            while (resolvedUri == null && i < baseUris.length) {
  +                String uri = baseUris[i] + "/" + path;
   
                   checkedUris += uri + "\n";
   
  @@ -150,11 +163,11 @@
                           resolver.release(source);
                       }
                   }
  -
  +                i++;
               }
   
           } catch (Exception e) {
  -            throw new ConfigurationException("Resolving attribute [" + name + "] failed: ", e);
  +            throw new ConfigurationException("Resolving attribute [" + path + "] failed: ", e);
           } finally {
               if (resolver != null) {
                   manager.release(resolver);
  @@ -162,7 +175,7 @@
           }
   
           if (resolvedUri == null) {
  -            throw new ConfigurationException("Could not resolve file for path [" + name + "]."
  +            throw new ConfigurationException("Could not resolve file for path [" + path + "]."
                       + "\nChecked URIs:" + checkedUris);
           }
           else {
  @@ -170,7 +183,6 @@
                   getLogger().debug("Resolved URI: [" + resolvedUri + "]");
               }
           }
  -
           return resolvedUri;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org