Skip to content

Commit

Permalink
fix: report the container creation date
Browse files Browse the repository at this point in the history
Fix #1532
  • Loading branch information
rdeltour committed Dec 23, 2024
1 parent f0fb7b7 commit d28e20f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
21 changes: 8 additions & 13 deletions src/main/java/com/adobe/epubcheck/ocf/OCFChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,6 @@ private boolean checkContainerFile(OCFCheckerState state)
}
return false;
}
// FIXME 2022 - report container info
// long l = container.getTimeEntry(OCFData.containerEntry);
// if (l > 0)
// {
// Date d = new Date(l);
// String formattedDate = new
// SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(d);
// report.info(OCFData.containerEntry, FeatureEnum.CREATION_DATE,
// formattedDate);
// }

ValidationContext containerFileContext = state.context()
.url(OCFMetaFile.CONTAINER.asURL(container)).mimetype("application/xml").build();
Expand Down Expand Up @@ -559,9 +549,14 @@ private void reportFeatures(OCFResource resource)
{
for (FeatureEnum feature : resource.getProperties().keySet())
{
// report.info(context.path, feature,
// resource.getProperties().get(feature));
report.info(resource.getPath(), feature, resource.getProperties().get(feature));
if (feature == FeatureEnum.CREATION_DATE
&& !OCFMetaFile.CONTAINER.asPath().equals(resource.getPath()))
{
// we only report the creation date once
continue;
}
report.info(resource.getPath(), feature,
resource.getProperties().get(feature));
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/adobe/epubcheck/ocf/OCFZipResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -48,11 +50,14 @@ public OCFResource next()
throws NoSuchElementException
{
final ZipEntry entry = entries.nextElement();

final Map<FeatureEnum, String> properties = ImmutableMap.<FeatureEnum, String> builder()
.put(FeatureEnum.SIZE, String.valueOf(entry.getSize()))
.put(FeatureEnum.COMPRESSED_SIZE, String.valueOf(entry.getCompressedSize()))
.put(FeatureEnum.COMPRESSION_METHOD, getCompressionMethod(entry))
.put(FeatureEnum.SHA_256, getSHAHash(entry, zip))
.put(FeatureEnum.CREATION_DATE,
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(new Date(entry.getTime())))
.build();

return new OCFResource()
Expand Down Expand Up @@ -87,7 +92,7 @@ public String getPath()
{
return entry.getName();
}

@Override
public String toString()
{
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/reporting/xml-report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
Then the XML report is well-formed
And XPath '//repInfo' exists

Scenario: Creation date is set
When checking EPUB 'minimal'
And XPath '//repInfo/created' exists


0 comments on commit d28e20f

Please sign in to comment.