You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by di...@apache.org on 2001/08/21 19:59:52 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/generation HTMLGenerator.java

dims        01/08/21 10:59:52

  Modified:    src/org/apache/cocoon/components/language/programming/java
                        JavaLanguage.java
               src/org/apache/cocoon/generation HTMLGenerator.java
  Log:
  - Patch for "JavaLanguage - Multiple Extension paths" from Stuart Roebuck <st...@adolos.co.uk>
  - Patch for HTML Generator from Gerd Mueller <ge...@smb-tec.com>
  
  Revision  Changes    Path
  1.6       +27 -12    xml-cocoon2/src/org/apache/cocoon/components/language/programming/java/JavaLanguage.java
  
  Index: JavaLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/programming/java/JavaLanguage.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JavaLanguage.java	2001/08/20 13:55:11	1.5
  +++ JavaLanguage.java	2001/08/21 17:59:52	1.6
  @@ -25,12 +25,13 @@
   import java.io.File;
   import java.io.IOException;
   import java.util.List;
  +import java.util.StringTokenizer;
   
   /**
    * The Java programming language processor
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.5 $ $Date: 2001/08/20 13:55:11 $
  + * @version CVS $Revision: 1.6 $ $Date: 2001/08/21 17:59:52 $
    */
   public class JavaLanguage extends CompiledProgrammingLanguage implements ThreadSafe, Composable, Disposable {
   
  @@ -275,18 +276,32 @@
       return buffer.toString();
     }
   
  -  private String expandDirs(String d) throws LanguageException {
  -    File dir = new File(d);
  -    if ( ! dir.isDirectory() ) {
  -        throw new LanguageException(
  -            "Attempted to retrieve directory listing of non-directory "
  -            + dir.toString()
  -        );
  -    }
  -    File[] files = dir.listFiles(new JavaArchiveFilter());
  +  /**
  +   * Expand a directory path or list of directory paths (File.pathSeparator
  +   * delimited) into a list of file paths of all the jar files in those
  +   * directories.
  +   *
  +   * @param dirPaths The string containing the directory path or list of
  +   * 		directory paths.
  +   * @return The file paths of the jar files in the directories. This is an
  +   *		empty string if no files were found, and is terminated by an
  +   *		additional pathSeparator in all other cases.
  +   */
  +  private String expandDirs(String dirPaths) throws LanguageException {
  +    StringTokenizer st = new StringTokenizer(dirPaths, File.pathSeparator);
       StringBuffer buffer = new StringBuffer();
  -    for (int i = 0; i < files.length; i++) {
  -        buffer.append(files[i]).append(File.pathSeparator);
  +    while (st.hasMoreTokens()) {
  +        String d = st.nextToken();
  +        File dir = new File(d);
  +        if ( ! dir.isDirectory() ) {
  +            // The absence of a listed directory may not be an error.
  +            if (getLogger().isWarnEnabled()) getLogger().warn("Attempted to retrieve directory listing of non-directory " + dir.toString());
  +        } else {
  +            File[] files = dir.listFiles(new JavaArchiveFilter());
  +            for (int i = 0; i < files.length; i++) {
  +                buffer.append(files[i]).append(File.pathSeparator);
  +            }
  +        }
       }
       return buffer.toString();
     }
  
  
  
  1.11      +23 -2     xml-cocoon2/src/org/apache/cocoon/generation/HTMLGenerator.java
  
  Index: HTMLGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/generation/HTMLGenerator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HTMLGenerator.java	2001/08/20 13:55:15	1.10
  +++ HTMLGenerator.java	2001/08/21 17:59:52	1.11
  @@ -34,11 +34,12 @@
   import java.io.BufferedInputStream;
   import java.io.IOException;
   import java.util.Map;
  +import java.util.Enumeration;
   
   /**
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.10 $ $Date: 2001/08/20 13:55:15 $
  + * @version CVS $Revision: 1.11 $ $Date: 2001/08/21 17:59:52 $
    */
   public class HTMLGenerator extends ComposerGenerator implements Cacheable, Recyclable {
   
  @@ -65,12 +66,32 @@
       public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
       throws ProcessingException, SAXException, IOException {
           super.setup(resolver, objectModel, src, par);
  -        this.inputSource = resolver.resolve(super.source);
           
           Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
           xpath = request.getParameter("xpath");
           if(xpath == null)
               xpath = par.getParameter("xpath",null);
  +
  +        // append the request parameter to the URL if necessary
  +        if (par.getParameterAsBoolean( "copy-parameters", false )) {
  +            StringBuffer query = new StringBuffer( 32 );
  +
  +            Enumeration params = request.getParameterNames();
  +            while (params.hasMoreElements()) {
  +                String name = (String)params.nextElement();
  +                String[] values = request.getParameterValues( name );
  +
  +                for (int i = 0; i < values.length; i++) {
  +                    query.append( name ).append( "=" ).append( values[i] ).append( "&" ); 
  +                }
  +            }
  +            
  +            if (query.length() > 0) {
  +                super.source += "?" + query.substring( 0, query.length() - 1 );
  +            }
  +        }
  +
  +        this.inputSource = resolver.resolve(super.source);
       }
   
       /**
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org