From ad50af1a88dc8426ee49c63eba8efce5790a5e86 Mon Sep 17 00:00:00 2001 From: pdanner Date: Mon, 29 Nov 2010 14:21:37 +0000 Subject: added datasourceholder git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@623 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../pdfas/framework/input/ExtractionStage.java | 20 ++++++++++------- .../pdfas/framework/input/PdfDataSourceHolder.java | 26 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSourceHolder.java (limited to 'src/main/java') diff --git a/src/main/java/at/gv/egiz/pdfas/framework/input/ExtractionStage.java b/src/main/java/at/gv/egiz/pdfas/framework/input/ExtractionStage.java index 36d9bd8..7d58d2a 100644 --- a/src/main/java/at/gv/egiz/pdfas/framework/input/ExtractionStage.java +++ b/src/main/java/at/gv/egiz/pdfas/framework/input/ExtractionStage.java @@ -10,6 +10,7 @@ import org.apache.commons.logging.LogFactory; import at.gv.egiz.pdfas.exceptions.ErrorCode; import at.gv.egiz.pdfas.exceptions.framework.VerificationFilterException; +import at.gv.egiz.pdfas.framework.DataSourceHolder; import at.gv.egiz.pdfas.framework.vfilter.VerificationFilter; import at.gv.egiz.pdfas.framework.vfilter.VerificationFilterParameters; import at.gv.egiz.pdfas.impl.input.IncrementalUpdateParser; @@ -29,23 +30,26 @@ public class ExtractionStage */ private static final Log log = LogFactory.getLog(ExtractionStage.class); - public List extractSignatureHolders(final DataSource dataSource, VerificationFilterParameters parameters) throws PresentableException + public List extractSignatureHolders(final DataSourceHolder dataSource, VerificationFilterParameters parameters) throws PresentableException { - if (dataSource instanceof PdfDataSource) + if (dataSource.getDataSource() instanceof PdfDataSource) { - PdfDataSource pdfDataSource = (PdfDataSource) dataSource; + PdfDataSource pdfDataSource = (PdfDataSource) dataSource.getDataSource(); - List blocks = parsePdfIntoBlocks(pdfDataSource); + PdfDataSourceHolder pdsh = new PdfDataSourceHolder(pdfDataSource); + List blocks = parsePdfIntoBlocks(pdsh); + dataSource.setDataSource(pdsh.getDataSource()); + parameters.setBeenCorrected(pdsh.hasChanged()); VerificationFilter vf = new VerificationFilterImpl(); - List signatures = vf.extractSignatureHolders(pdfDataSource, blocks, parameters); + List signatures = vf.extractSignatureHolders(pdsh.getDataSource(), blocks, parameters); return signatures; } - if (dataSource instanceof TextDataSource) + if (dataSource.getDataSource() instanceof TextDataSource) { - TextDataSource textDataSource = (TextDataSource) dataSource; + TextDataSource textDataSource = (TextDataSource) dataSource.getDataSource(); VerificationFilter vf = new VerificationFilterImpl(); List signatures = vf.extractSignaturHolders(textDataSource, parameters); @@ -58,7 +62,7 @@ public class ExtractionStage throw new VerificationFilterException(ErrorCode.DOCUMENT_CANNOT_BE_READ, msg); } - protected List parsePdfIntoBlocks(PdfDataSource pdfDataSource) throws PDFDocumentException + protected List parsePdfIntoBlocks(PdfDataSourceHolder pdfDataSource) throws PDFDocumentException { List blocks = IncrementalUpdateParser.parsePdfIntoIUBlocks(pdfDataSource); return blocks; diff --git a/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSourceHolder.java b/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSourceHolder.java new file mode 100644 index 0000000..84ebce1 --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSourceHolder.java @@ -0,0 +1,26 @@ +package at.gv.egiz.pdfas.framework.input; + +public class PdfDataSourceHolder { + private PdfDataSource dataSource; + private boolean hasChanged = false; + + public PdfDataSourceHolder(PdfDataSource dataSource) { + this.dataSource = dataSource; + } + + public PdfDataSource getDataSource() { + return dataSource; + } + + public void setDataSource(PdfDataSource dataSource) { + this.dataSource = dataSource; + this.hasChanged = true; + } + + public boolean hasChanged() { + return this.hasChanged; + } + + + +} -- cgit v1.2.3