From 3231b0d2c665d5493e3a1e63106b8bc934d9094b Mon Sep 17 00:00:00 2001 From: tknall Date: Thu, 14 Jan 2010 17:03:02 +0000 Subject: - Errorcode for unsupported signature method introduced - Errorcode for unknown (internal error) introduced - Fixed issue: in case of unexpected error (RunTimeException for instance) the output file was not deleted - Some System.out.println commands replaced by log.debug messages - Typos fixed - "can-break-after" character list extended: "." added - Configuration updated - DefaultConfiguration updated - internal version set to 3.1 in preparation for release - maven2-repository updated (pdfbox-0.7.2-pdfas-2 compiled for log4j) - pdfbox-0.7.2-pdfas-2 updated (some debug messages) git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@552 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../knowcenter/wag/egov/egiz/commandline/Main.java | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/commandline') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java b/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java index 21dd5bf..a746612 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java @@ -482,9 +482,10 @@ public abstract class Main } FileBasedDataSink dataSink = null; + File outputFile = null; try { - File outputFile = new File(output); + outputFile = new File(output); dataSink = new FileBasedDataSink(outputFile); } @@ -493,7 +494,25 @@ public abstract class Main throw new PDFDocumentException(ErrorCode.CANNOT_WRITE_PDF, e); } - processSign(pdfDataSource, connector, signature_mode, signature_type, pos_string, dataSink); + try { + processSign(pdfDataSource, connector, signature_mode, signature_type, pos_string, dataSink); + } catch (Exception e) { + // Exception caught in order to delete file based datasink + if (outputFile != null && outputFile.exists()) + { + logger_.debug("Deleting output file on error."); + boolean deleted = outputFile.delete(); + if (!deleted) + { + logger_.error("Couldn't delete output file " + output); + } + } + if (e instanceof PresentableException) { + throw (PresentableException)e; + } else { + throw new PresentableException(ErrorCode.UNKNOWN_ERROR, e); + } + } // for performance measurement if (logger_.isInfoEnabled()) { -- cgit v1.2.3