vgritsenko 01/08/14 20:19:36 Modified: src/org/apache/cocoon/generation DirectoryGenerator.java FileGenerator.java Log: Error handling Revision Changes Path 1.9 +15 -31 xml-cocoon2/src/org/apache/cocoon/generation/DirectoryGenerator.java Index: DirectoryGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/generation/DirectoryGenerator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DirectoryGenerator.java 2001/08/11 19:01:07 1.8 +++ DirectoryGenerator.java 2001/08/15 03:19:36 1.9 @@ -62,7 +62,7 @@ * (Apache Software Foundation, Exoffice Technologies) * @author <a href="mailto:[EMAIL PROTECTED]">Conny Krappatsch</a> * (SMB GmbH) for Virbus AG - * @version CVS $Revision: 1.8 $ $Date: 2001/08/11 19:01:07 $ */ + * @version CVS $Revision: 1.9 $ $Date: 2001/08/15 03:19:36 $ */ public class DirectoryGenerator extends ComposerGenerator implements Recyclable { @@ -115,7 +115,6 @@ super.setup(resolver, objectModel, src, par); String dateFormatString = par.getParameter("dateFormat", null); - if (dateFormatString != null) { this.dateFormatter = new SimpleDateFormat(dateFormatString); } else { @@ -129,30 +128,18 @@ try { getLogger().debug("root pattern: " + rePattern); this.rootRE = (rePattern == null)?null:new RE(rePattern); - } catch (RESyntaxException rese) { - getLogger().error("Syntax error in root pattern!'", rese); - throw new ProcessingException("Syntax error in root pattern!'", - rese); - } - rePattern = par.getParameter("include", null); - try { + rePattern = par.getParameter("include", null); getLogger().debug("include pattern: " + rePattern); this.includeRE = (rePattern == null)?null:new RE(rePattern); - } catch (RESyntaxException rese) { - getLogger().error("Syntax error in include pattern!'", rese); - throw new ProcessingException("Syntax error in include pattern!'", - rese); - } - rePattern = par.getParameter("exclude", null); - try { + rePattern = par.getParameter("exclude", null); getLogger().debug("exclude pattern: " + rePattern); this.excludeRE = (rePattern == null)?null:new RE(rePattern); } catch (RESyntaxException rese) { - getLogger().error("Syntax error in exlcude pattern!'", rese); - throw new ProcessingException("Syntax error in exclude pattern!'", - rese); + getLogger().error("Syntax error in regexp pattern '" + rePattern + "'", rese); + throw new ProcessingException("Syntax error in regexp pattern '" + + rePattern + "'", rese); } this.isRequestedDirectory = false; @@ -173,19 +160,16 @@ */ public void generate() throws SAXException, ProcessingException { + String directory = super.source; try { - Source inputSource; - File path; - - inputSource = this.resolver.resolve(super.source); + Source inputSource = this.resolver.resolve(directory); + directory = inputSource.getSystemId(); if (inputSource.isFile() == false) { - throw new ResourceNotFoundException(inputSource.getSystemId() - + " is not a directory."); + throw new ResourceNotFoundException(directory + " is not a directory."); } - path = inputSource.getFile(); + File path = inputSource.getFile(); if (!path.isDirectory()) { - throw new ResourceNotFoundException(inputSource.getSystemId() - + " is not a directory."); + throw new ResourceNotFoundException(directory + " is not a directory."); } this.contentHandler.startDocument(); @@ -197,8 +181,9 @@ this.contentHandler.endPrefixMapping(PREFIX); this.contentHandler.endDocument(); } catch (IOException ioe) { - getLogger().warn("Could not get resource", ioe); - throw new ResourceNotFoundException("Could not get directory", ioe); + getLogger().warn("Could not read directory " + directory, ioe); + throw new ResourceNotFoundException("Could not read directory " + + directory, ioe); } } @@ -387,5 +372,4 @@ ? false : this.excludeRE.match(path.getName()); } - } 1.17 +7 -9 xml-cocoon2/src/org/apache/cocoon/generation/FileGenerator.java Index: FileGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/generation/FileGenerator.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- FileGenerator.java 2001/07/07 11:43:29 1.16 +++ FileGenerator.java 2001/08/15 03:19:36 1.17 @@ -37,7 +37,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> * (Apache Software Foundation, Exoffice Technologies) * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Revision: 1.16 $ $Date: 2001/07/07 11:43:29 $ + * @version CVS $Revision: 1.17 $ $Date: 2001/08/15 03:19:36 $ */ public class FileGenerator extends ComposerGenerator implements Cacheable, Recyclable { @@ -98,7 +98,7 @@ return null; } - /** + /** * Generate XML data. */ public void generate() @@ -110,15 +110,13 @@ this.inputSource.stream(super.xmlConsumer); } catch (FileNotFoundException e) { - getLogger().warn("FileGenerator could not find resource " + this.inputSource.getSystemId(), e); - throw new ResourceNotFoundException("FileGenerator could not find resource " + getLogger().warn("Could not find resource " + this.inputSource.getSystemId(), e); + throw new ResourceNotFoundException("Could not find resource " + this.inputSource.getSystemId(), e); } catch (IOException e) { - getLogger().error("FileGenerator.generate()", e); - throw new ResourceNotFoundException("FileGenerator could not read resource", e); - } catch (SAXException e) { - getLogger().error("FileGenerator.generate()", e); - throw(e); + getLogger().error("Could not read resource " + this.inputSource.getSystemId(), e); + throw new ResourceNotFoundException("Could not read resource " + + this.inputSource.getSystemId(), e); } } } ---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]