added some catch clauses to ensure the batch is processed :-)

This commit is contained in:
Jochen Staerk
2015-10-24 15:02:10 +02:00
parent ce955e32b1
commit 8ff7409892
3 changed files with 30 additions and 7 deletions

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.mustangproject.ZUGFeRD</groupId>
<artifactId>toecount</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.7-SNAPSHOT</version>
<name>ZUGFeRD PDF checker</name>
<description>Shows statistics on how many PDFs in a directory are ZUGFeRD-Compliant</description>
<repositories>

View File

@@ -30,11 +30,34 @@ public class FileChecker {
return false;
}
ZUGFeRDImporter zi=new ZUGFeRDImporter();
zi.extract(filename);
if (zi.canParse()) {
thisRun.incZUGFeRDCount();
return true;
} else {
try {
zi.extract(filename);
if (zi.canParse()) {
thisRun.incZUGFeRDCount();
return true;
} else {
return false;
}
} catch (NullPointerException e) {
// something really rare happened -- corrupted ZF?
/***
* e.g. Exception in thread "main" java.lang.NullPointerException
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extractLowLevel(ZUGFeRDImporter.java:90)
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extract(ZUGFeRDImporter.java:64)
at toecount.FileChecker.checkForZUGFeRD(FileChecker.java:33)
at toecount.Toecount.main(Toecount.java:111)
*
*/
// Ignore nevertheless, most likely we're batch processing
return false;
} catch (Exception e2) {
/**
* probably thrown up from
AM org.apache.pdfbox.pdfparser.PDFParser parse, most likely
INFORMATION: Document is encrypted
but also other internal PDF errors possible like
..Okt 23, 2015 11:17:53 AM org.apache.pdfbox.pdfparser.XrefTrailerResolver setStartxref
*/
return false;
}
}

View File

@@ -22,7 +22,7 @@ public class Toecount {
}
private static void printHelp() {
System.out
.println("Mustangproject.org's Toecount 0.0.6 \r\n"
.println("Mustangproject.org's Toecount 0.0.7 \r\n"
+ "A Apache Public License command line tool for statistics on PDF invoices with\r\n"
+ "ZUGFeRD Metadata (http://www.zugferd.de)\r\n"
+ "\r\n"