cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject cvs commit: cocoon-2.0/src/java/org/apache/cocoon/components/language/markup/xsp XSPUtil.java
Date Sat, 31 May 2003 00:24:53 GMT
joerg       2003/05/30 17:24:53

  Modified:    src/java/org/apache/cocoon/components/language/markup/xsp
                        XSPUtil.java
  Log:
  bug 15302 fixed: context.getResource(filename) on a non-existant file returns null,
  so testing for null and throwing a FileNotFoundException;
  fixed import java.io.*
  
  Revision  Changes    Path
  1.2       +25 -12    cocoon-2.0/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java
  
  Index: XSPUtil.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.0/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSPUtil.java	9 Mar 2003 00:01:58 -0000	1.1
  +++ XSPUtil.java	31 May 2003 00:24:52 -0000	1.2
  @@ -50,15 +50,25 @@
   */
   package org.apache.cocoon.components.language.markup.xsp;
   
  -import java.io.*;
  +import java.io.File;
  +import java.io.IOException;
  +import java.io.BufferedReader;
  +import java.io.FileReader;
  +import java.io.BufferedInputStream;
  +import java.io.FileInputStream;
  +import java.io.InputStream;
  +import java.io.InputStreamReader;
  +import java.io.Reader;
  +import java.io.StringReader;
  +import java.io.FileNotFoundException;
   import java.net.URLDecoder;
   import java.net.URLEncoder;
  +import java.net.URL;
   import java.text.SimpleDateFormat;
   import java.util.Date;
   import java.util.Map;
   
   import org.apache.avalon.framework.CascadingRuntimeException;
  -import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.cocoon.components.parser.Parser;
   import org.apache.cocoon.components.url.URLFactory;
  @@ -129,14 +139,17 @@
           return buffer.toString();
       }
   
  -    public static String relativeFilename(String filename, Map objectModel)
  -        throws IOException {
  -            File file = new File(filename);
  -            if (file.isAbsolute() && file.exists()) {
  -                return filename;
  -            }
  -            Context context = ObjectModelHelper.getContext(objectModel);
  -            return NetUtils.getPath(context.getResource(filename).toExternalForm());
  +    public static String relativeFilename(String filename, Map objectModel) throws IOException
{
  +        File file = new File(filename);
  +        if (file.isAbsolute() && file.exists()) {
  +            return filename;
  +        }
  +        Context context = ObjectModelHelper.getContext(objectModel);
  +        URL resource = context.getResource(filename);
  +        if (resource == null) {
  +            throw new FileNotFoundException("The file " + filename + " does not exist!");
  +        }
  +        return NetUtils.getPath(resource.toExternalForm());
       }
   
       public static boolean isAlphaNumeric(char c) {
  @@ -359,7 +372,7 @@
           } catch (Exception e) {
               throw new CascadingRuntimeException("Could not include page", e);
           } finally {
  -            if (newParser != null) manager.release((Component) newParser);
  +            if (newParser != null) manager.release(newParser);
           }
       }
           
  
  
  

Mime
View raw message