Skip to content

Commit

Permalink
Fixing metadata. Support fixing non-integer parts
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Jul 9, 2024
1 parent 9e01a86 commit 1c82220
Showing 1 changed file with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,25 @@ public void addPDFUAIdentificationSchema(MetadataFixerResultImpl.Builder resultB
if (!XMPMetaFactory.getSchemaRegistry().getNamespaces().containsKey(XMPConst.NS_PDFUA_ID)) {
XMPMetaFactory.getSchemaRegistry().registerNamespace(XMPConst.NS_PDFUA_ID, VeraPDFMeta.PDFUAID_PREFIX, false);
}
int part = flavour.getPart().getPartNumber();
if (!Objects.equals(this.metadata.getPDFUAIdentificationPart(), part)) {
resultBuilder.addFix(String.format(this.metadata.getPDFUAIdentificationPart() == null ?
ADD_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE, VeraPDFMeta.PART, part));
} catch (XMPException e) {
LOGGER.log(Level.FINE, "Can not register " + XMPConst.NS_PDFUA_ID + " namespace.", e);
}
boolean isBadPart = true;
boolean isMissingPart = false;
int part = flavour.getPart().getPartNumber();
try {
if (Objects.equals(this.metadata.getPDFUAIdentificationPart(), part)) {
isBadPart = false;
} else {
isMissingPart = this.metadata.getPDFUAIdentificationPart() == null;
}
} catch (XMPException e) {
LOGGER.log(Level.FINE, "Can not obtain identification fields.", e);
}
try {
if (isBadPart) {
resultBuilder.addFix(String.format(isMissingPart ? ADD_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE,
VeraPDFMeta.PART, part));
this.metadata.setPDFUAIdentificationPart(part);
this.setNeedToBeUpdated(true);
}
Expand Down Expand Up @@ -264,10 +279,21 @@ private boolean addPropertyDefinition(MetadataFixerResultImpl.Builder resultBuil
public void addPDFAIdentificationSchema(MetadataFixerResultImpl.Builder resultBuilder, PDFAFlavour flavour) {
int part = flavour.getPart().getPartNumber();
String conformance = !PDFFlavours.isFlavour(flavour, PDFAFlavour.PDFA_4) ? flavour.getLevel().getCode().toUpperCase() : null;
boolean isBadPart = true;
boolean isMissingPart = false;
try {
if (Objects.equals(this.metadata.getPDFAIdentificationPart(), part)) {
isBadPart = false;
} else {
isMissingPart = this.metadata.getPDFAIdentificationPart() == null;
}
} catch (XMPException e) {
LOGGER.log(Level.FINE, "Can not obtain identification fields.", e);
}
try {
if (!Objects.equals(this.metadata.getPDFAIdentificationPart(), part)) {
resultBuilder.addFix(String.format(this.metadata.getPDFAIdentificationPart() == null ?
ADD_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE, VeraPDFMeta.PART, part));
if (isBadPart) {
resultBuilder.addFix(String.format(isMissingPart ? ADD_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE,
VeraPDFMeta.PART, part));
this.metadata.setPDFAIdentificationPart(part);
this.setNeedToBeUpdated(true);
}
Expand Down

0 comments on commit 1c82220

Please sign in to comment.