From d601a0d8f913b783c12fbc7c6c4593400ed50dee Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 8 Dec 2023 21:46:52 +0300 Subject: [PATCH] Add StaticXmpCoreContainers to library --- .../main/java/org/verapdf/gf/model/GFModelParser.java | 2 ++ .../verapdf/gf/model/impl/external/GFEmbeddedFile.java | 9 +++++++++ 2 files changed, 11 insertions(+) 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 39226123b..1dcf84092 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 @@ -23,6 +23,7 @@ import org.verapdf.parser.PDFFlavour; import org.verapdf.tools.StaticResources; import org.verapdf.xmp.XMPException; +import org.verapdf.xmp.containers.StaticXmpCoreContainers; import org.verapdf.xmp.impl.VeraPDFMeta; import org.verapdf.ReleaseDetails; import org.verapdf.component.ComponentDetails; @@ -206,6 +207,7 @@ private static void initializeStaticResources(String password) { private static void clearStaticContainers() { StaticContainers.clearAllContainers(); StaticResources.clear(); + StaticXmpCoreContainers.clearAllContainers(); } /** diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/external/GFEmbeddedFile.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/external/GFEmbeddedFile.java index ca93a7b53..5f87415f9 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/external/GFEmbeddedFile.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/external/GFEmbeddedFile.java @@ -42,6 +42,7 @@ import org.verapdf.pdfa.results.ValidationResult; import org.verapdf.pdfa.validation.validators.ValidatorFactory; import org.verapdf.tools.StaticResources; +import org.verapdf.xmp.containers.StaticXmpCoreContainers; import java.io.IOException; import java.io.InputStream; @@ -153,6 +154,8 @@ private static boolean isValidPdfaStream(final InputStream toValidate, final PDF private Map cMapCache; private Map structureNameSpaceCache; private Map cachedFonts; + private Map namespaceToPrefixMap; + private Map prefixToNamespaceMap; private void saveStaticContainersState() { this.document = StaticResources.getDocument(); @@ -182,6 +185,9 @@ private void saveStaticContainersState() { Map cachedFonts = StaticResources.getCachedFonts(); this.cachedFonts = cachedFonts == null ? null : new HashMap<>(cachedFonts); + + this.namespaceToPrefixMap = StaticXmpCoreContainers.getNamespaceToPrefixMap(); + this.prefixToNamespaceMap = StaticXmpCoreContainers.getPrefixToNamespaceMap(); } private void restoreSavedSCState() { @@ -207,5 +213,8 @@ private void restoreSavedSCState() { StaticResources.setStructureNameSpaceCache(this.structureNameSpaceCache); StaticResources.setCachedFonts(this.cachedFonts); StaticResources.setFlavour(this.flavour != null ? PDFFlavour.valueOf(this.flavour.name()) : null); + + StaticXmpCoreContainers.setNamespaceToPrefixMap(this.namespaceToPrefixMap); + StaticXmpCoreContainers.setPrefixToNamespaceMap(this.prefixToNamespaceMap); } }