Skip to content

Commit

Permalink
Merge pull request #320 from veraPDF/metadata_methods
Browse files Browse the repository at this point in the history
Update metadata fixer method names
  • Loading branch information
MaximPlusov authored Sep 14, 2023
2 parents 7fddf61 + b057b0c commit 3d32332
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public void removePDFIdentificationSchema(
try {
if (isValidIdentification()) {
int part = flavour.getPart().getPartNumber();
Integer schemaPart = this.metadata.getIdentificationPart();
Integer schemaPart = this.metadata.getPDFAIdentificationPart();

if (schemaPart != null &&
schemaPart.intValue() != part) {
return;
}
}

boolean isDeleted = this.metadata.deleteIdentificationSchema();
boolean isDeleted = this.metadata.deletePDFAIdentificationSchema();
if (isDeleted) {
this.setNeedToBeUpdated(true);
resultBuilder.addFix("Identification schema removed");
Expand All @@ -141,8 +141,8 @@ public void addPDFIdentificationSchema(

try {
if (isValidIdentification()) {
Integer schemaPart = this.metadata.getIdentificationPart();
String schemaConformance = this.metadata.getIdentificationConformance();
Integer schemaPart = this.metadata.getPDFAIdentificationPart();
String schemaConformance = this.metadata.getPDFAIdentificationConformance();

if (schemaPart != null &&
schemaConformance != null &&
Expand All @@ -152,8 +152,8 @@ public void addPDFIdentificationSchema(
}
}

this.metadata.setIdentificationPart(Integer.valueOf(part));
this.metadata.setIdentificationConformance(conformance);
this.metadata.setPDFAIdentificationPart(Integer.valueOf(part));
this.metadata.setPDFAIdentificationConformance(conformance);
this.setNeedToBeUpdated(true);
resultBuilder.addFix("Identification schema added");

Expand Down Expand Up @@ -184,16 +184,15 @@ private static int confToInt(String conf) {

private boolean isValidIdentification() {
try {
Integer identificationPart = this.metadata.getIdentificationPart();
Integer identificationPart = this.metadata.getPDFAIdentificationPart();
if (identificationPart == null) {
return false;
}
String identificationConformance = this.metadata.getIdentificationConformance();
String identificationConformance = this.metadata.getPDFAIdentificationConformance();
if (identificationPart.intValue() == 1) {
return "A".equals(identificationConformance) || "B".equals(identificationConformance);
} else if (identificationPart.intValue() == 2 || identificationPart.intValue() == 3) {
return "A".equals(this.metadata.getIdentificationConformance()) ||
"U".equals(identificationConformance) ||
return "A".equals(identificationConformance) || "U".equals(identificationConformance) ||
"B".equals(identificationConformance);
} else {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public void addPDFIdentificationSchemaTest() throws IOException, XMPException {
MetadataFixerResultImpl.Builder builder = new MetadataFixerResultImpl.Builder();
impl.addPDFIdentificationSchema(builder, PDFAFlavour.PDFA_1_B);

assertEquals(filePart, xmp.getIdentificationPart());
assertEquals(fileConformance, xmp.getIdentificationConformance());
assertEquals(filePart, xmp.getPDFAIdentificationPart());
assertEquals(fileConformance, xmp.getPDFAIdentificationConformance());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ private static PDFAFlavour obtainFlavour(PDDocument document, PDFAFlavour defaul
}
try (InputStream is = metadata.exportXMPMetadata()) {
VeraPDFMeta veraPDFMeta = VeraPDFMeta.parse(is);
Integer identificationPart = veraPDFMeta.getIdentificationPart();
String identificationConformance = veraPDFMeta.getIdentificationConformance();
Integer identificationPart = veraPDFMeta.getPDFAIdentificationPart();
String identificationConformance = veraPDFMeta.getPDFAIdentificationConformance();
String prefix = "";
if (identificationPart == null && identificationConformance == null) {
identificationPart = veraPDFMeta.getUAIdentificationPart();
identificationPart = veraPDFMeta.getPDFUAIdentificationPart();
if (identificationPart != null) {
prefix = PDFUA_PREFIX;
}
Expand Down

0 comments on commit 3d32332

Please sign in to comment.