corrently implement xmp exception
This commit is contained in:
@@ -134,8 +134,7 @@ public class PDFValidator extends Validator {
|
|||||||
if (xmp == null || xmp.isEmpty()) {
|
if (xmp == null || xmp.isEmpty()) {
|
||||||
context.addResultItem(new ValidationResultItem(ESeverity.error, "Invalid XMP Metadata not found")
|
context.addResultItem(new ValidationResultItem(ESeverity.error, "Invalid XMP Metadata not found")
|
||||||
.setSection(17).setPart(EPart.pdf));
|
.setSection(17).setPart(EPart.pdf));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/*
|
/*
|
||||||
* checking for sth like <zf:ConformanceLevel>EXTENDED</zf:ConformanceLevel>
|
* checking for sth like <zf:ConformanceLevel>EXTENDED</zf:ConformanceLevel>
|
||||||
* <zf:DocumentType>INVOICE</zf:DocumentType>
|
* <zf:DocumentType>INVOICE</zf:DocumentType>
|
||||||
@@ -150,14 +149,7 @@ public class PDFValidator extends Validator {
|
|||||||
|
|
||||||
final DocumentBuilder builder = factory.newDocumentBuilder();
|
final DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
final InputSource is = new InputSource(new StringReader(xmp));
|
final InputSource is = new InputSource(new StringReader(xmp));
|
||||||
try {
|
|
||||||
docXMP = builder.parse(is);
|
docXMP = builder.parse(is);
|
||||||
} catch (Exception e) {
|
|
||||||
context.addResultItem(
|
|
||||||
new ValidationResultItem(ESeverity.error, "XMP Metadata: Could not parse XMP metadata")
|
|
||||||
.setSection(10).setPart(EPart.pdf));
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
final XPathFactory xpathFactory = XPathFactory.newInstance();
|
final XPathFactory xpathFactory = XPathFactory.newInstance();
|
||||||
|
|
||||||
@@ -273,7 +265,11 @@ public class PDFValidator extends Validator {
|
|||||||
.setSection(16).setPart(EPart.pdf));
|
.setSection(16).setPart(EPart.pdf));
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (final SAXException | IOException | ParserConfigurationException | XPathExpressionException e) {
|
} catch (final SAXException e) {
|
||||||
|
context.addResultItem(
|
||||||
|
new ValidationResultItem(ESeverity.error, "XMP Metadata: Could not parse XMP metadata (XML invalid)")
|
||||||
|
.setSection(28).setPart(EPart.pdf));
|
||||||
|
} catch (IOException | ParserConfigurationException | XPathExpressionException e) {
|
||||||
LOGGER.error(e.getMessage(), e);
|
LOGGER.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class PDFValidatorTest extends ResourceCase {
|
|||||||
actual = pv.getXMLResult();
|
actual = pv.getXMLResult();
|
||||||
|
|
||||||
assertEquals(true, actual
|
assertEquals(true, actual
|
||||||
.contains("<error type=\"10\">XMP Metadata: Could not parse XMP metadata</error>"));
|
.contains("<error type=\"28\">XMP Metadata: Could not parse XMP metadata (XML invalid)</error>"));
|
||||||
} catch (final IrrecoverableValidationError e) {
|
} catch (final IrrecoverableValidationError e) {
|
||||||
// ignore, will be in XML output anyway
|
// ignore, will be in XML output anyway
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user