Skip to content

Commit

Permalink
Add StaticCoreContainers to library
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Jun 3, 2024
1 parent 63e3a9d commit 6c18b0e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.verapdf.pdfa.flavours.PDFFlavours;
import org.verapdf.tools.StaticResources;
import org.verapdf.xmp.XMPException;
import org.verapdf.containers.StaticCoreContainers;
import org.verapdf.xmp.containers.StaticXmpCoreContainers;
import org.verapdf.xmp.impl.VeraPDFMeta;
import org.verapdf.ReleaseDetails;
Expand Down Expand Up @@ -225,6 +226,7 @@ private static PDFAFlavour detectPDFUAFlavour(VeraPDFMeta veraPDFMeta) {
private static void initializeStaticContainers(final PDDocument document, final PDFAFlavour flavour) {
StaticResources.setDocument(document);
StaticContainers.setFlavour(flavour);
StaticCoreContainers.setFlavour(flavour);
StaticResources.setFlavour(flavour != null ? PDFFlavour.valueOf(flavour.name()) : null);
}

Expand All @@ -234,6 +236,7 @@ private static void initializeStaticResources(String password) {

private static void clearStaticContainers() {
StaticContainers.clearAllContainers();
StaticCoreContainers.clearAllContainers();
StaticResources.clear();
StaticXmpCoreContainers.clearAllContainers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.verapdf.pdfa.validation.validators.ValidatorFactory;
import org.verapdf.tools.StaticResources;
import org.verapdf.xmp.containers.StaticXmpCoreContainers;
import org.verapdf.containers.StaticCoreContainers;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -177,6 +178,7 @@ private void saveStaticContainersState() {

private void restoreSavedSCState() {
StaticContainers.setFlavour(this.flavour);
StaticCoreContainers.setFlavour(this.flavour);
StaticContainers.setSeparations(this.separations);
StaticContainers.setStructElementsRefs(this.structElementsRefs);
StaticContainers.setInconsistentSeparations(this.inconsistentSeparations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,24 @@ private List<XMPPackage> getXMPPackage() {
if (stream != null) {
VeraPDFMeta metadata = VeraPDFMeta.parse(stream);
if (isMainMetadata) {
xmp.add(new AXLMainXMPPackage(metadata, true, flavour));
xmp.add(new AXLMainXMPPackage(metadata, true));
} else if (!PDFFlavours.isFlavourPart(flavour, PDFAFlavour.Specification.ISO_19005_1)) {
try (InputStream mainStream = mainMetadata != null ? mainMetadata.getStream() : null) {
VeraPDFXMPNode mainExtensionNode = null;
if (mainStream != null) {
VeraPDFMeta mainMeta = VeraPDFMeta.parse(mainStream);
mainExtensionNode = mainMeta.getExtensionSchemasNode();
}
xmp.add(new AXLXMPPackage(metadata, true, mainExtensionNode, flavour));
xmp.add(new AXLXMPPackage(metadata, true, mainExtensionNode));
}
}
}
} catch (XMPException | IOException e) {
LOGGER.log(Level.WARNING, "Problems with parsing metadata. " + e.getMessage(), e);
if (isMainMetadata) {
xmp.add(new AXLMainXMPPackage(null, false, flavour));
xmp.add(new AXLMainXMPPackage(null, false));
} else if (!PDFFlavours.isFlavourPart(flavour, PDFAFlavour.Specification.ISO_19005_1)) {
xmp.add(new AXLXMPPackage(null, false, null, flavour));
xmp.add(new AXLXMPPackage(null, false, null));
}
}
return xmp;
Expand Down

0 comments on commit 6c18b0e

Please sign in to comment.