Skip to content

Commit d28e20f

Browse files
committed
fix: report the container creation date
Fix #1532
1 parent f0fb7b7 commit d28e20f

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/main/java/com/adobe/epubcheck/ocf/OCFChecker.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,6 @@ private boolean checkContainerFile(OCFCheckerState state)
250250
}
251251
return false;
252252
}
253-
// FIXME 2022 - report container info
254-
// long l = container.getTimeEntry(OCFData.containerEntry);
255-
// if (l > 0)
256-
// {
257-
// Date d = new Date(l);
258-
// String formattedDate = new
259-
// SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(d);
260-
// report.info(OCFData.containerEntry, FeatureEnum.CREATION_DATE,
261-
// formattedDate);
262-
// }
263253

264254
ValidationContext containerFileContext = state.context()
265255
.url(OCFMetaFile.CONTAINER.asURL(container)).mimetype("application/xml").build();
@@ -559,9 +549,14 @@ private void reportFeatures(OCFResource resource)
559549
{
560550
for (FeatureEnum feature : resource.getProperties().keySet())
561551
{
562-
// report.info(context.path, feature,
563-
// resource.getProperties().get(feature));
564-
report.info(resource.getPath(), feature, resource.getProperties().get(feature));
552+
if (feature == FeatureEnum.CREATION_DATE
553+
&& !OCFMetaFile.CONTAINER.asPath().equals(resource.getPath()))
554+
{
555+
// we only report the creation date once
556+
continue;
557+
}
558+
report.info(resource.getPath(), feature,
559+
resource.getProperties().get(feature));
565560
}
566561
}
567562

src/main/java/com/adobe/epubcheck/ocf/OCFZipResources.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import java.io.InputStream;
66
import java.nio.charset.StandardCharsets;
77
import java.security.MessageDigest;
8+
import java.text.SimpleDateFormat;
9+
import java.util.Date;
810
import java.util.Enumeration;
911
import java.util.Iterator;
1012
import java.util.Map;
@@ -48,11 +50,14 @@ public OCFResource next()
4850
throws NoSuchElementException
4951
{
5052
final ZipEntry entry = entries.nextElement();
53+
5154
final Map<FeatureEnum, String> properties = ImmutableMap.<FeatureEnum, String> builder()
5255
.put(FeatureEnum.SIZE, String.valueOf(entry.getSize()))
5356
.put(FeatureEnum.COMPRESSED_SIZE, String.valueOf(entry.getCompressedSize()))
5457
.put(FeatureEnum.COMPRESSION_METHOD, getCompressionMethod(entry))
5558
.put(FeatureEnum.SHA_256, getSHAHash(entry, zip))
59+
.put(FeatureEnum.CREATION_DATE,
60+
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(new Date(entry.getTime())))
5661
.build();
5762

5863
return new OCFResource()
@@ -87,7 +92,7 @@ public String getPath()
8792
{
8893
return entry.getName();
8994
}
90-
95+
9196
@Override
9297
public String toString()
9398
{

src/test/resources/reporting/xml-report.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@
1414
Then the XML report is well-formed
1515
And XPath '//repInfo' exists
1616

17+
Scenario: Creation date is set
18+
When checking EPUB 'minimal'
19+
And XPath '//repInfo/created' exists
20+
21+

0 commit comments

Comments
 (0)