Cleansing
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
package org.mustangproject.validator;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
@@ -20,20 +22,16 @@ import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
|
||||
import org.riversun.bigdoc.bin.BigFileSearcher;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.verapdf.core.VeraPDFException;
|
||||
import org.verapdf.features.FeatureExtractorConfig;
|
||||
import org.verapdf.features.FeatureFactory;
|
||||
import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider;
|
||||
import org.verapdf.metadata.fixer.FixerFactory;
|
||||
import org.verapdf.metadata.fixer.MetadataFixerConfig;
|
||||
import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider;
|
||||
import org.verapdf.pdfa.flavours.PDFAFlavour;
|
||||
import org.verapdf.pdfa.validation.validators.ValidatorConfig;
|
||||
import org.verapdf.pdfa.validation.validators.ValidatorFactory;
|
||||
import org.verapdf.processor.BatchProcessor;
|
||||
import org.verapdf.processor.FormatOption;
|
||||
import org.verapdf.processor.ItemProcessor;
|
||||
import org.verapdf.processor.ProcessorConfig;
|
||||
import org.verapdf.processor.ProcessorFactory;
|
||||
@@ -95,7 +93,7 @@ public class PDFValidator extends Validator {
|
||||
// Default fixer config
|
||||
final MetadataFixerConfig fixerConfig = FixerFactory.defaultConfig();
|
||||
// Tasks configuring
|
||||
final EnumSet tasks = EnumSet.noneOf(TaskType.class);
|
||||
final EnumSet<TaskType> tasks = EnumSet.noneOf(TaskType.class);
|
||||
tasks.add(TaskType.VALIDATE);
|
||||
// tasks.add(TaskType.EXTRACT_FEATURES);
|
||||
// tasks.add(TaskType.FIX_METADATA);
|
||||
@@ -104,7 +102,6 @@ public class PDFValidator extends Validator {
|
||||
fixerConfig, tasks
|
||||
);
|
||||
// Creating processor and output stream.
|
||||
final ByteArrayOutputStream reportStream = new ByteArrayOutputStream();
|
||||
final InputStream inputStream = new ByteArrayInputStream(fileContents);
|
||||
try (ItemProcessor processor = ProcessorFactory.createProcessor(processorConfig)) {
|
||||
// Generating list of files for processing
|
||||
|
||||
@@ -1,23 +1,4 @@
|
||||
package org.mustangproject.validator;
|
||||
import com.helger.schematron.ISchematronResource;
|
||||
import com.helger.schematron.svrl.SVRLHelper;
|
||||
import com.helger.schematron.svrl.SVRLMarshaller;
|
||||
import com.helger.schematron.svrl.jaxb.SchematronOutputType;
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.helger.schematron.xslt.SchematronResourceXSLT;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import javax.xml.xpath.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
@@ -28,6 +9,29 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpression;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import com.helger.schematron.ISchematronResource;
|
||||
import com.helger.schematron.svrl.SVRLMarshaller;
|
||||
import com.helger.schematron.svrl.jaxb.SchematronOutputType;
|
||||
import com.helger.schematron.xslt.SchematronResourceXSLT;
|
||||
|
||||
|
||||
public class XMLValidator extends Validator {
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package org.mustangproject.validator;
|
||||
|
||||
import org.xmlunit.builder.Input;
|
||||
import org.xmlunit.xpath.JAXPXPathEngine;
|
||||
import org.xmlunit.xpath.XPathEngine;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import java.io.File;
|
||||
|
||||
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
||||
|
||||
@@ -57,15 +57,13 @@ public class PDFValidatorTest extends ResourceCase {
|
||||
|
||||
byte [] contents = getResourceAsByteArray("XMLinvalidV2PDF.pdf");// need a more invalid file here
|
||||
|
||||
pv.setFilename("XMLinvalidV2PDF.pdf");
|
||||
pv.setFileContents(contents);
|
||||
pv.setFilenameAndContents("XMLinvalidV2PDF.pdf", contents);
|
||||
pv.validate();
|
||||
// assertEquals("", pv.getXMLResult());
|
||||
|
||||
//
|
||||
contents = getResourceAsByteArray("Facture_F20180027.pdf");
|
||||
pv.setFilename("Facture_F20180027.pdf");
|
||||
pv.setFileContents(contents);
|
||||
pv.setFilenameAndContents("Facture_F20180027.pdf", contents);
|
||||
pv.validate();
|
||||
String actual = pv.getXMLResult();
|
||||
assertEquals(true, actual.contains("summary status=\"valid"));
|
||||
@@ -91,8 +89,7 @@ public class PDFValidatorTest extends ResourceCase {
|
||||
// valid one
|
||||
contents = getResourceAsByteArray("validV2PDF.pdf");
|
||||
|
||||
pv.setFilename("validV2PDF.pdf");
|
||||
pv.setFileContents(contents);
|
||||
pv.setFilenameAndContents("validV2PDF.pdf", contents);
|
||||
vc.clear();
|
||||
pv.validate();
|
||||
actual = pv.getXMLResult();
|
||||
@@ -115,8 +112,7 @@ public class PDFValidatorTest extends ResourceCase {
|
||||
// invalid file here
|
||||
byte [] contents = getResourceAsByteArray("attributeBasedXMP_zugferd_2p0_EN16931_Einfach.pdf");
|
||||
|
||||
pv.setFilename("attributeBasedXMP_zugferd_2p0_EN16931_Einfach.pdf");
|
||||
pv.setFileContents(contents);
|
||||
pv.setFilenameAndContents("attributeBasedXMP_zugferd_2p0_EN16931_Einfach.pdf", contents);
|
||||
pv.validate();
|
||||
String pdfvres = pv.getXMLResult();
|
||||
|
||||
@@ -132,8 +128,7 @@ public class PDFValidatorTest extends ResourceCase {
|
||||
vc.clear();
|
||||
contents = getResourceAsByteArray("validV1WithAdditionalData.pdf");// need a more invalid file here
|
||||
|
||||
pv.setFilename("validV1WithAdditionalData.pdf");
|
||||
pv.setFileContents(contents);
|
||||
pv.setFilenameAndContents("validV1WithAdditionalData.pdf", contents);
|
||||
pv.validate();
|
||||
pdfvres = pv.getXMLResult();
|
||||
|
||||
@@ -157,8 +152,7 @@ public class PDFValidatorTest extends ResourceCase {
|
||||
try {
|
||||
byte [] contents = getResourceAsByteArray("invalidXMP.pdf");
|
||||
|
||||
pv.setFilename("invalidXMP.pdf");
|
||||
pv.setFileContents(contents);
|
||||
pv.setFilenameAndContents("invalidXMP.pdf", contents);
|
||||
vc.clear();
|
||||
pv.validate();
|
||||
String actual = pv.getXMLResult();
|
||||
@@ -168,8 +162,7 @@ public class PDFValidatorTest extends ResourceCase {
|
||||
|
||||
contents = getResourceAsByteArray("attributeBasedXMP_zugferd_2p0_EN16931_Einfach.pdf");
|
||||
|
||||
pv.setFilename("attributeBasedXMP_zugferd_2p0_EN16931_Einfach.pdf");
|
||||
pv.setFileContents(contents);
|
||||
pv.setFilenameAndContents("attributeBasedXMP_zugferd_2p0_EN16931_Einfach.pdf", contents);
|
||||
vc.clear();
|
||||
pv.validate();
|
||||
actual = pv.getXMLResult();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.mustangproject.validator;
|
||||
|
||||
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
@@ -2,12 +2,6 @@ package org.mustangproject.validator;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.xmlunit.builder.Input;
|
||||
import org.xmlunit.xpath.JAXPXPathEngine;
|
||||
import org.xmlunit.xpath.XPathEngine;
|
||||
|
||||
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user