Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 19676 invoked by uid 500); 31 May 2003 00:06:32 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 19665 invoked by uid 500); 31 May 2003 00:06:31 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 19662 invoked from network); 31 May 2003 00:06:31 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 31 May 2003 00:06:31 -0000 Received: (qmail 46400 invoked by uid 1672); 31 May 2003 00:06:30 -0000 Date: 31 May 2003 00:06:30 -0000 Message-ID: <20030531000630.46399.qmail@icarus.apache.org> From: joerg@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp XSPUtil.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N joerg 2003/05/30 17:06:30 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 Revision Changes Path 1.5 +14 -9 cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java Index: XSPUtil.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- XSPUtil.java 16 May 2003 07:04:55 -0000 1.4 +++ XSPUtil.java 31 May 2003 00:06:29 -0000 1.5 @@ -74,8 +74,10 @@ 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; @@ -136,14 +138,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) {