closes #908
This commit is contained in:
@@ -71,6 +71,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
protected CalculatedInvoice importedInvoice = null;
|
protected CalculatedInvoice importedInvoice = null;
|
||||||
protected boolean recalcPrice = false;
|
protected boolean recalcPrice = false;
|
||||||
protected boolean ignoreCalculationErrors = false;
|
protected boolean ignoreCalculationErrors = false;
|
||||||
|
protected boolean containsAXMLFileAttachment = false;
|
||||||
|
|
||||||
public ZUGFeRDInvoiceImporter() {
|
public ZUGFeRDInvoiceImporter() {
|
||||||
//constructor for extending classes
|
//constructor for extending classes
|
||||||
@@ -197,16 +198,31 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
ignoreCalculationErrors = true;
|
ignoreCalculationErrors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* if the file attachment is not in the list of allowed file names we can't import the XML,
|
||||||
|
* but the validator needs to know if maybe some other .xml-File is embedded because it would
|
||||||
|
* raise an additional notice that the filename is probably wrong
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean hasXMLFileAttachment() {
|
||||||
|
return containsAXMLFileAttachment;
|
||||||
|
}
|
||||||
/***
|
/***
|
||||||
* sets th pdf attachments, and if a file is recognized (e.g. a factur-x.xml) triggers processing
|
* sets th pdf attachments, and if a file is recognized (e.g. a factur-x.xml) triggers processing
|
||||||
* @param names the Hashmap of String, PDComplexFileSpecification
|
* @param names the Hashmap of String, PDComplexFileSpecification
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void extractFiles(Map<String, PDComplexFileSpecification> names) throws IOException {
|
private void extractFiles(Map<String, PDComplexFileSpecification> names) throws IOException {
|
||||||
|
containsAXMLFileAttachment=false;
|
||||||
for (final String alias : names.keySet()) {
|
for (final String alias : names.keySet()) {
|
||||||
|
|
||||||
final PDComplexFileSpecification fileSpec = names.get(alias);
|
final PDComplexFileSpecification fileSpec = names.get(alias);
|
||||||
final String filename = fileSpec.getFilename();
|
final String filename = fileSpec.getFilename();
|
||||||
|
if (filename.toUpperCase().endsWith(".XML")) {
|
||||||
|
containsAXMLFileAttachment=true;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* filenames for invoice data (ZUGFeRD v1 and v2, Factur-X)
|
* filenames for invoice data (ZUGFeRD v1 and v2, Factur-X)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -226,6 +226,13 @@ public class PDFValidator extends Validator {
|
|||||||
}
|
}
|
||||||
if (!documentFilenameValid) {
|
if (!documentFilenameValid) {
|
||||||
|
|
||||||
|
if (zi.hasXMLFileAttachment()) {
|
||||||
|
context.addResultItem(new ValidationResultItem(
|
||||||
|
ESeverity.notice,
|
||||||
|
"Potentially incorrectly named XML file attachments detected"
|
||||||
|
).setSection(17).setPart(EPart.pdf));
|
||||||
|
}
|
||||||
|
|
||||||
context.addResultItem(new ValidationResultItem(
|
context.addResultItem(new ValidationResultItem(
|
||||||
ESeverity.error,
|
ESeverity.error,
|
||||||
"XMP Metadata: DocumentFileName contains invalid value"
|
"XMP Metadata: DocumentFileName contains invalid value"
|
||||||
|
|||||||
Reference in New Issue
Block a user