From 9ef042419014ebe9ea3e6ce0af5568de2d933c7d Mon Sep 17 00:00:00 2001 From: netconomy Date: Mon, 17 Dec 2007 15:43:39 +0000 Subject: Change Request "Document Correction" git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@239 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../framework/input/correction/Corrector.java | 41 +++++++++++++++++++++ .../input/correction/CorrectorFactory.java | 43 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/main/java/at/gv/egiz/pdfas/framework/input/correction/Corrector.java create mode 100644 src/main/java/at/gv/egiz/pdfas/framework/input/correction/CorrectorFactory.java (limited to 'src/main/java/at/gv/egiz/pdfas/framework') diff --git a/src/main/java/at/gv/egiz/pdfas/framework/input/correction/Corrector.java b/src/main/java/at/gv/egiz/pdfas/framework/input/correction/Corrector.java new file mode 100644 index 0000000..3b4d4b4 --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/framework/input/correction/Corrector.java @@ -0,0 +1,41 @@ +/** + * + */ +package at.gv.egiz.pdfas.framework.input.correction; + +import at.gv.egiz.pdfas.exceptions.framework.CorrectorException; +import at.gv.egiz.pdfas.framework.input.PdfDataSource; + +/** + * Interface for PDF corretors. + * + *

+ * Often PDF documents generated by various document to PDF converters have an + * invalid structure that upsets PDF-AS. The correction mechanism allows these + * documents to be corrected before being signed. + *

+ *

+ * A PDF corrector takes an incorrect PDF document and transforms it into a + * correct one. + *

+ *

+ * Note that correcting a document destroys all signatures in that document, so + * never correct an already signed document. + *

+ * + * @author wprinz + */ +public interface Corrector +{ + /** + * Corrects the given PDF document to a form that PDF-AS can use. + * + * @param document + * The (incorrect) PDF document. + * @return Returns the corrected PDF document. + * @throws CorrectorException + * Exception thrown if the document couldn't be corrected. + */ + public PdfDataSource correctDocument(PdfDataSource document) throws CorrectorException; + +} diff --git a/src/main/java/at/gv/egiz/pdfas/framework/input/correction/CorrectorFactory.java b/src/main/java/at/gv/egiz/pdfas/framework/input/correction/CorrectorFactory.java new file mode 100644 index 0000000..083713f --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/framework/input/correction/CorrectorFactory.java @@ -0,0 +1,43 @@ +/** + * + */ +package at.gv.egiz.pdfas.framework.input.correction; + +import at.gv.egiz.pdfas.impl.input.correction.ExternalCorrector; +import at.gv.egiz.pdfas.impl.input.correction.InternalCorrector; +import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; +import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; + +/** + * Factory for creating Correctors. + * + * @author wprinz + */ +public class CorrectorFactory +{ + public static final String INTERNAL_CORRECTOR = "internal"; + + public static final String EXTERNAL_CORRECTOR = "external"; + + public static final String CORRECTOR_KEY = "corrector"; + + public static Corrector createCorrector(String id) throws SettingsException + { + if (id.equals(INTERNAL_CORRECTOR)) + { + return new InternalCorrector(); + } + if (id.equals(EXTERNAL_CORRECTOR)) + { + return new ExternalCorrector(); + } + throw new SettingsException("The connector id '" + id + "' is not a valid corrector id."); + } + + public static Corrector createCorrector() throws SettingsException + { + String id = SettingsReader.getInstance().getSetting(CORRECTOR_KEY, INTERNAL_CORRECTOR); + return createCorrector(id); + } + +} -- cgit v1.2.3