diff --git a/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java b/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java index dcfc9d917..543a9fc3e 100644 --- a/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java +++ b/metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java @@ -147,29 +147,41 @@ public void addPDFIdentificationSchema(MetadataFixerResultImpl.Builder resultBui addPDFUAIdentificationSchema(resultBuilder, flavour); } else { addPDFAIdentificationSchema(resultBuilder, flavour); - checkAndFixPrefixes(resultBuilder, flavour); + checkAndFixPDFAPrefixes(resultBuilder, flavour); } fixRevProperty(resultBuilder, flavour); } - public void checkAndFixPrefixes(MetadataFixerResultImpl.Builder resultBuilder, PDFAFlavour flavour) { + public void checkAndFixPDFAPrefixes(MetadataFixerResultImpl.Builder resultBuilder, PDFAFlavour flavour) { if (flavour.getPart() == PDFAFlavour.Specification.ISO_19005_1 || flavour.getPart() == PDFAFlavour.Specification.ISO_19005_2 || flavour.getPart() == PDFAFlavour.Specification.ISO_19005_3) { - fixPropertyPrefix(resultBuilder, VeraPDFMeta.PART, VeraPDFMeta.PDFAID_PREFIX); - fixPropertyPrefix(resultBuilder, VeraPDFMeta.CONFORMANCE, VeraPDFMeta.PDFAID_PREFIX); - fixPropertyPrefix(resultBuilder, VeraPDFMeta.AMD, VeraPDFMeta.PDFAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.PART, XMPConst.NS_PDFA_ID, VeraPDFMeta.PDFAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.CONFORMANCE, XMPConst.NS_PDFA_ID, VeraPDFMeta.PDFAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.AMD, XMPConst.NS_PDFA_ID, VeraPDFMeta.PDFAID_PREFIX); if (flavour.getPart() != PDFAFlavour.Specification.ISO_19005_1) { - fixPropertyPrefix(resultBuilder, VeraPDFMeta.CORR, VeraPDFMeta.PDFAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.CORR, XMPConst.NS_PDFA_ID, VeraPDFMeta.PDFAID_PREFIX); } } else if (flavour.getPart() == PDFAFlavour.Specification.ISO_19005_4) { - fixPropertyPrefix(resultBuilder, VeraPDFMeta.PART, VeraPDFMeta.PDFAID_PREFIX); - fixPropertyPrefix(resultBuilder, VeraPDFMeta.REVISION_YEAR, VeraPDFMeta.PDFAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.PART, XMPConst.NS_PDFA_ID, VeraPDFMeta.PDFAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.REVISION_YEAR, XMPConst.NS_PDFA_ID, VeraPDFMeta.PDFAID_PREFIX); } } - private void fixPropertyPrefix(MetadataFixerResultImpl.Builder resultBuilder, String propertyName, String propertyPrefix) { - VeraPDFXMPNode property = this.metadata.getProperty(XMPConst.NS_PDFA_ID, propertyName); + public void checkAndFixPDFUAPrefixes(MetadataFixerResultImpl.Builder resultBuilder, PDFAFlavour flavour) { + if (flavour.getPart() == PDFAFlavour.Specification.ISO_14289_1) { + fixPropertyPrefix(resultBuilder, VeraPDFMeta.PART, XMPConst.NS_PDFUA_ID, VeraPDFMeta.PDFUAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.CORR, XMPConst.NS_PDFUA_ID, VeraPDFMeta.PDFUAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.AMD, XMPConst.NS_PDFUA_ID, VeraPDFMeta.PDFUAID_PREFIX); + } else if (flavour.getPart() == PDFAFlavour.Specification.ISO_14289_2) { + fixPropertyPrefix(resultBuilder, VeraPDFMeta.PART, XMPConst.NS_PDFUA_ID, VeraPDFMeta.PDFUAID_PREFIX); + fixPropertyPrefix(resultBuilder, VeraPDFMeta.REVISION_YEAR, XMPConst.NS_PDFUA_ID, VeraPDFMeta.PDFUAID_PREFIX); + } + } + + private void fixPropertyPrefix(MetadataFixerResultImpl.Builder resultBuilder, String propertyName, String schemaId, + String propertyPrefix) { + VeraPDFXMPNode property = this.metadata.getProperty(schemaId, propertyName); if (property != null && !propertyPrefix.equals(property.getPrefix())) { property.setPrefix(propertyPrefix); this.setNeedToBeUpdated(true); @@ -198,15 +210,20 @@ public void addPDFAIdentificationSchema(MetadataFixerResultImpl.Builder resultBu int part = flavour.getPart().getPartNumber(); String conformance = flavour != PDFAFlavour.PDFA_4 ? flavour.getLevel().getCode().toUpperCase() : null; try { - resultBuilder.addFix(String.format(this.metadata.getPDFAIdentificationPart() == null ? - ADD_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE, VeraPDFMeta.PART, part)); - this.metadata.setPDFAIdentificationPart(part); + if (!Objects.equals(this.metadata.getPDFAIdentificationPart(), part)) { + resultBuilder.addFix(String.format(this.metadata.getPDFAIdentificationPart() == null ? + ADD_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE, VeraPDFMeta.PART, part)); + this.metadata.setPDFAIdentificationPart(part); + this.setNeedToBeUpdated(true); + } - resultBuilder.addFix(String.format(this.metadata.getPDFAIdentificationConformance() == null ? - ADD_PROPERTY_MESSAGE : (conformance == null ? REMOVE_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE), - VeraPDFMeta.CONFORMANCE, conformance)); - this.metadata.setPDFAIdentificationConformance(conformance); - this.setNeedToBeUpdated(true); + if (isWrongPDFAIdentification(flavour)) { + resultBuilder.addFix(String.format(this.metadata.getPDFAIdentificationConformance() == null ? + ADD_PROPERTY_MESSAGE : (conformance == null ? REMOVE_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE), + VeraPDFMeta.CONFORMANCE, conformance)); + this.metadata.setPDFAIdentificationConformance(conformance); + this.setNeedToBeUpdated(true); + } } catch (XMPException e) { LOGGER.log(Level.FINE, "Can not obtain identification fields.", e); } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/GFModelParser.java b/validation-model/src/main/java/org/verapdf/gf/model/GFModelParser.java index 1a21a19f5..6ce5857bb 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/GFModelParser.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/GFModelParser.java @@ -180,8 +180,7 @@ private static PDFAFlavour obtainFlavour(PDDocument document, PDFAFlavour defaul identificationConformance = ""; } PDFAFlavour pdfaFlavour = PDFAFlavour.byFlavourId(prefix + identificationPart + identificationConformance); - // TODO: remove that logic after updating NO_FLAVOUR into base pdf validation flavour - if (pdfaFlavour == PDFAFlavour.NO_FLAVOUR) { + if (pdfaFlavour == PDFAFlavour.NO_FLAVOUR || pdfaFlavour == PDFAFlavour.PDFUA_2) { return defaultFlavour; } return pdfaFlavour; diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/MarkedContentHelper.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/MarkedContentHelper.java index bcb6e7eee..e139d5e0f 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/MarkedContentHelper.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/MarkedContentHelper.java @@ -47,9 +47,9 @@ public static boolean containsStringKey(ASAtom key, GFOpMarkedContent markedCont Long mcid = markedContent.getInheritedMCID(); COSObject structureElement = accessObject.getStructureElement(parentTreeRoot, mcid); if (structureElement != null && !structureElement.empty()) { - COSObject actualText = structureElement.getKey(key); - return actualText != null && !actualText.empty() && - actualText.getType() == COSObjType.COS_STRING; + COSObject value = structureElement.getKey(key); + return value != null && !value.empty() && + value.getType() == COSObjType.COS_STRING; } } } diff --git a/wcag-validation/src/main/java/org/verapdf/gf/model/impl/sa/GFSAAnnotationNode.java b/wcag-validation/src/main/java/org/verapdf/gf/model/impl/sa/GFSAAnnotationNode.java index fe49f87a9..6ad4f4165 100644 --- a/wcag-validation/src/main/java/org/verapdf/gf/model/impl/sa/GFSAAnnotationNode.java +++ b/wcag-validation/src/main/java/org/verapdf/gf/model/impl/sa/GFSAAnnotationNode.java @@ -35,7 +35,7 @@ private static BoundingBox getBoundingBox(PDAnnotation annotation) { } private static Integer getAnnotationPageNumber(PDAnnotation annotation) { - Integer pageNumber = getPageNumber(annotation.getParent()); + Integer pageNumber = getPageNumber(annotation.getKey(ASAtom.P)); if (pageNumber != null) { return pageNumber; }