Skip to content

Commit 9ac71b8

Browse files
LonelyMidoriyaGit User
authored andcommitted
Update fixRevProperty method (#726)
1 parent c9b6d9a commit 9ac71b8

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

  • metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model

metadata-fixer/src/main/java/org/verapdf/metadata/fixer/gf/impl/model/MetadataImpl.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public class MetadataImpl implements Metadata {
5656
private static final Logger LOGGER = Logger.getLogger(MetadataImpl.class.getCanonicalName());
5757

5858
private static final String YEAR_2020 = "2020";
59-
private static final String YEAR_202X = "0000";
60-
private static final String YEAR_REGEX = "^\\d{4}$";
59+
private static final String YEAR_2024 = "2024";
6160

6261
private static final String ADD_PROPERTY_MESSAGE = "Added property '%s' with value '%s' to Identification schema";
6362
private static final String REMOVE_PROPERTY_MESSAGE = "Removed property '%s' from Identification schema";
@@ -316,16 +315,14 @@ private void fixRevProperty(MetadataFixerResultImpl.Builder resultBuilder, PDFAF
316315
return;
317316
}
318317
String namespaceURI = PDFFlavours.isFlavour(flavour, PDFAFlavour.PDFUA_2) ? XMPConst.NS_PDFUA_ID : XMPConst.NS_PDFA_ID;
318+
String expectedRev = PDFFlavours.isFlavour(flavour, PDFAFlavour.PDFUA_2) ? YEAR_2024 : YEAR_2020;
319319
try {
320320
VeraPDFXMPNode rev = this.metadata.getProperty(namespaceURI, VeraPDFMeta.REVISION_YEAR);
321-
if (rev == null) {
322-
this.metadata.setIdentificationRevisionYear(namespaceURI, YEAR_202X);
321+
if (rev == null || !expectedRev.equals(rev.getValue())) {
322+
this.metadata.setIdentificationRevisionYear(namespaceURI, expectedRev);
323323
this.setNeedToBeUpdated(true);
324-
resultBuilder.addFix(String.format(ADD_PROPERTY_MESSAGE, VeraPDFMeta.REVISION_YEAR, YEAR_2020));
325-
} else if (!rev.getValue().matches(YEAR_REGEX)) {
326-
this.metadata.setIdentificationRevisionYear(namespaceURI, YEAR_202X);
327-
this.setNeedToBeUpdated(true);
328-
resultBuilder.addFix(String.format(SET_PROPERTY_MESSAGE, VeraPDFMeta.REVISION_YEAR, YEAR_2020));
324+
String message = String.format((rev == null) ? ADD_PROPERTY_MESSAGE : SET_PROPERTY_MESSAGE, VeraPDFMeta.REVISION_YEAR, expectedRev);
325+
resultBuilder.addFix(message);
329326
}
330327
} catch (XMPException e) {
331328
LOGGER.log(Level.FINE, "Can not obtain identification fields.", e);

0 commit comments

Comments
 (0)