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 47a8c00 commit e541b37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.verapdf.model;

import org.verapdf.xmp.XMPException;
import org.verapdf.containers.StaticCoreContainers;
import org.verapdf.xmp.containers.StaticXmpCoreContainers;
import org.verapdf.xmp.impl.VeraPDFMeta;
import java.util.logging.Logger;
Expand Down Expand Up @@ -73,11 +74,13 @@ public final class ModelParser implements PDFAParser {
private ModelParser(final InputStream docStream, PDFAFlavour flavour, PDFAFlavour defaultFlavour) throws IOException {
this.document = PDDocument.load(docStream, false, true);
this.flavour = detectFlavour(this.document, flavour, defaultFlavour);
StaticCoreContainers.setFlavour(this.flavour);
}

private ModelParser(final File pdfFile, PDFAFlavour flavour, PDFAFlavour defaultFlavour) throws IOException {
this.document = PDDocument.load(pdfFile, false, true);
this.flavour = detectFlavour(this.document, flavour, defaultFlavour);
StaticCoreContainers.setFlavour(this.flavour);
}

public static ModelParser createModelWithFlavour(InputStream toLoad, PDFAFlavour flavour)
Expand Down Expand Up @@ -158,6 +161,7 @@ private static PDFAFlavour obtainFlavour(PDDocument document, PDFAFlavour defaul

private static void cleanUp() {
StaticContainers.clearAllContainers();
StaticCoreContainers.clearAllContainers();
StaticXmpCoreContainers.clearAllContainers();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private List<XMPPackage> getXMPPackage() {
if (stream != null) {
VeraPDFMeta metadata = VeraPDFMeta.parse(stream.getUnfilteredStream());
if (isMainMetadata) {
xmp.add(new AXLMainXMPPackage(metadata, true, this.flavour));
xmp.add(new AXLMainXMPPackage(metadata, true));
} else if (this.flavour == null || this.flavour.getPart() == null
|| this.flavour.getPart().getPartNumber() != 1) {
COSStream mainStream = mainMetadata.getStream();
Expand All @@ -112,16 +112,16 @@ private List<XMPPackage> getXMPPackage() {
VeraPDFMeta mainMeta = VeraPDFMeta.parse(mainStream.getUnfilteredStream());
mainExtensionNode = mainMeta.getExtensionSchemasNode();
}
xmp.add(new AXLXMPPackage(metadata, true, mainExtensionNode, this.flavour));
xmp.add(new AXLXMPPackage(metadata, true, mainExtensionNode));
}
}
} catch (XMPException | IOException e) {
LOGGER.log(java.util.logging.Level.INFO, "Problems with parsing metadata. " + e.getMessage());
if (isMainMetadata) {
xmp.add(new AXLMainXMPPackage(null, false, this.flavour));
xmp.add(new AXLMainXMPPackage(null, false));
} else if (this.flavour == null || this.flavour.getPart() == null
|| this.flavour.getPart().getPartNumber() != 1) {
xmp.add(new AXLXMPPackage(null, false, null, this.flavour));
xmp.add(new AXLXMPPackage(null, false, null));
}
}
return xmp;
Expand Down

0 comments on commit e541b37

Please sign in to comment.