vgritsenko 01/08/14 20:21:01
Modified: src/org/apache/cocoon/generation Tag: cocoon_20_branch
DirectoryGenerator.java FileGenerator.java
Log:
Error handling
Revision Changes Path
No revision
No revision
1.6.2.3 +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.6.2.2
retrieving revision 1.6.2.3
diff -u -r1.6.2.2 -r1.6.2.3
--- DirectoryGenerator.java 2001/08/11 19:02:21 1.6.2.2
+++ DirectoryGenerator.java 2001/08/15 03:21:01 1.6.2.3
@@ -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.6.2.2 $ $Date: 2001/08/11 19:02:21 $ */
+ * @version CVS $Revision: 1.6.2.3 $ $Date: 2001/08/15 03:21:01 $ */
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.9.2.8 +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.9.2.7
retrieving revision 1.9.2.8
diff -u -r1.9.2.7 -r1.9.2.8
--- FileGenerator.java 2001/07/07 19:08:14 1.9.2.7
+++ FileGenerator.java 2001/08/15 03:21:01 1.9.2.8
@@ -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.9.2.7 $ $Date: 2001/07/07 19:08:14 $
+ * @version CVS $Revision: 1.9.2.8 $ $Date: 2001/08/15 03:21:01 $
*/
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]