diff options
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/commandline')
-rw-r--r-- | src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java | 3 | ||||
-rw-r--r-- | src/main/java/at/gv/egiz/pdfas/commandline/Main.java | 23 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java b/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java index c0532a4..50678db 100644 --- a/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java +++ b/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java @@ -3,6 +3,7 @@ */
package at.gv.egiz.pdfas.commandline;
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.gv.egiz.pdfas.framework.ConnectorFactory;
import org.apache.commons.logging.Log;
@@ -118,7 +119,7 @@ public class CommandlineConnectorChooser return chooseDetachedMultipartConnector(connectorType);
}
- throw new ConnectorException(310, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown.");
+ throw new ConnectorException(ErrorCode.UNSUPPORTED_SIGNATURE_METHOD, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown.");
}
protected static String chooseEnvelopingBase64ConnectorOld(String sig_app) throws ConnectorException
diff --git a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java index c4895c0..2e0e674 100644 --- a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java +++ b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java @@ -519,9 +519,10 @@ public abstract class Main }
DataSink dataSink = null;
+ File outputFile = null;
try
{
- File outputFile = new File(output);
+ outputFile = new File(output);
dataSink = new FileBasedDataSink(outputFile);
}
@@ -530,7 +531,25 @@ public abstract class Main throw new PDFDocumentException(ErrorCode.CANNOT_WRITE_PDF, e);
}
- processSign(dataSource, connector, signature_mode, signature_type, pos_string, dataSink);
+ try {
+ processSign(dataSource, 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())
|