@Test public void parseValidEpub2ChecksumTest() throws Exception { File epubFile = new File(MINIMAL_EPUB_FILEPATH); EpubModule em = new EpubModule(); JhoveBase je = new JhoveBase(); je.setChecksumFlag(true); em.setBase(je); RepInfo info = new RepInfo(epubFile.getAbsolutePath()); em.parse(new FileInputStream(epubFile), info, 0); Map<ChecksumType, String> checksums = new HashMap<ChecksumType, String>(); info.getChecksum().forEach(cs -> checksums.put(cs.getType(), cs.getValue())); assertEquals("8b80b526", checksums.get(ChecksumType.CRC32)); assertEquals("b2110219d62c3c6ef1683c645636fd38", checksums.get(ChecksumType.MD5)); assertEquals("79f20f6a499a640019a9bb0334652edbb954c3c9", checksums.get(ChecksumType.SHA1)); assertEquals("4776bb33b1cce8598b31996ed0b4daf36e4b74e379b811a27e51efa15315744a", checksums.get(ChecksumType.SHA256)); final int expectedNumChecksum = 4; assertEquals(expectedNumChecksum, info.getChecksum().size()); }
@Override public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException { initParse(); info.setModule(this); info.setFormat(_format[0]); info.setWellFormed(false); info.setValid(false); _propList = new LinkedList<>(); _metadata = new Property(PROPNAME_EPUB_METADATA, PropertyType.PROPERTY, PropertyArity.LIST, _propList); _ckSummer = null; setupDataStream(stream, info); try { JhoveRepInfoReport report = new JhoveRepInfoReport(info.getUri()); EpubCheck epubCheck = new EpubCheck(_dstream, report, info.getUri()); epubCheck.doValidate(); info.setCreated(report.getCreationDate()); info.setLastModified(report.getLastModifiedDate()); info.setVersion(report.getVersion()); List<CheckMessage> epubMessages = report.getAllMessages(); int notWellFormedErrors = epubMessages.stream().filter(c -> triggerNotWellFormed(c)) .collect(Collectors.toSet()).size(); info.setWellFormed(report.getFatalErrorCount() == 0 && notWellFormedErrors == 0); info.setValid(info.getWellFormed() == RepInfo.TRUE && report.getErrorCount() == 0); Set<Message> msgs = new TreeSet<Message>(new MessageComparator()); for (CheckMessage msg : report.getAllMessages()) { msgs.addAll(toJhoveMessages(msg)); } msgs.forEach(jhoveMsg -> info.setMessage(jhoveMsg)); info.setMimeType(report.getFormat()); generateProperties(report).forEach(prop -> _propList.add(prop)); } catch (Exception f) { f.printStackTrace(); if (f.getMessage() != null) { info.setMessage(new ErrorMessage(f.getMessage())); } else { info.setMessage(new ErrorMessage(MessageConstants.ERR_UNKNOWN)); } info.setWellFormed(false); return 0; } if (_je != null && _je.getAbort()) { return 0; } info.setProperty(_metadata); setChecksums(_ckSummer, info); return 0; }
EpubModule extends ModuleBase { @Override public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException { initParse(); info.setModule(this); info.setFormat(_format[0]); info.setWellFormed(false); info.setValid(false); _propList = new LinkedList<>(); _metadata = new Property(PROPNAME_EPUB_METADATA, PropertyType.PROPERTY, PropertyArity.LIST, _propList); _ckSummer = null; setupDataStream(stream, info); try { JhoveRepInfoReport report = new JhoveRepInfoReport(info.getUri()); EpubCheck epubCheck = new EpubCheck(_dstream, report, info.getUri()); epubCheck.doValidate(); info.setCreated(report.getCreationDate()); info.setLastModified(report.getLastModifiedDate()); info.setVersion(report.getVersion()); List<CheckMessage> epubMessages = report.getAllMessages(); int notWellFormedErrors = epubMessages.stream().filter(c -> triggerNotWellFormed(c)) .collect(Collectors.toSet()).size(); info.setWellFormed(report.getFatalErrorCount() == 0 && notWellFormedErrors == 0); info.setValid(info.getWellFormed() == RepInfo.TRUE && report.getErrorCount() == 0); Set<Message> msgs = new TreeSet<Message>(new MessageComparator()); for (CheckMessage msg : report.getAllMessages()) { msgs.addAll(toJhoveMessages(msg)); } msgs.forEach(jhoveMsg -> info.setMessage(jhoveMsg)); info.setMimeType(report.getFormat()); generateProperties(report).forEach(prop -> _propList.add(prop)); } catch (Exception f) { f.printStackTrace(); if (f.getMessage() != null) { info.setMessage(new ErrorMessage(f.getMessage())); } else { info.setMessage(new ErrorMessage(MessageConstants.ERR_UNKNOWN)); } info.setWellFormed(false); return 0; } if (_je != null && _je.getAbort()) { return 0; } info.setProperty(_metadata); setChecksums(_ckSummer, info); return 0; } }
EpubModule extends ModuleBase { @Override public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException { initParse(); info.setModule(this); info.setFormat(_format[0]); info.setWellFormed(false); info.setValid(false); _propList = new LinkedList<>(); _metadata = new Property(PROPNAME_EPUB_METADATA, PropertyType.PROPERTY, PropertyArity.LIST, _propList); _ckSummer = null; setupDataStream(stream, info); try { JhoveRepInfoReport report = new JhoveRepInfoReport(info.getUri()); EpubCheck epubCheck = new EpubCheck(_dstream, report, info.getUri()); epubCheck.doValidate(); info.setCreated(report.getCreationDate()); info.setLastModified(report.getLastModifiedDate()); info.setVersion(report.getVersion()); List<CheckMessage> epubMessages = report.getAllMessages(); int notWellFormedErrors = epubMessages.stream().filter(c -> triggerNotWellFormed(c)) .collect(Collectors.toSet()).size(); info.setWellFormed(report.getFatalErrorCount() == 0 && notWellFormedErrors == 0); info.setValid(info.getWellFormed() == RepInfo.TRUE && report.getErrorCount() == 0); Set<Message> msgs = new TreeSet<Message>(new MessageComparator()); for (CheckMessage msg : report.getAllMessages()) { msgs.addAll(toJhoveMessages(msg)); } msgs.forEach(jhoveMsg -> info.setMessage(jhoveMsg)); info.setMimeType(report.getFormat()); generateProperties(report).forEach(prop -> _propList.add(prop)); } catch (Exception f) { f.printStackTrace(); if (f.getMessage() != null) { info.setMessage(new ErrorMessage(f.getMessage())); } else { info.setMessage(new ErrorMessage(MessageConstants.ERR_UNKNOWN)); } info.setWellFormed(false); return 0; } if (_je != null && _je.getAbort()) { return 0; } info.setProperty(_metadata); setChecksums(_ckSummer, info); return 0; } EpubModule();  EpubModule(String name, String release, int[] date,
            String[] format, String coverage,
            String[] mimetype, String wellformedNote,
            String validityNote, String repinfoNote, String note,
            String rights, boolean isRandomAccess, Agent moduleAgent); }
EpubModule extends ModuleBase { @Override public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException { initParse(); info.setModule(this); info.setFormat(_format[0]); info.setWellFormed(false); info.setValid(false); _propList = new LinkedList<>(); _metadata = new Property(PROPNAME_EPUB_METADATA, PropertyType.PROPERTY, PropertyArity.LIST, _propList); _ckSummer = null; setupDataStream(stream, info); try { JhoveRepInfoReport report = new JhoveRepInfoReport(info.getUri()); EpubCheck epubCheck = new EpubCheck(_dstream, report, info.getUri()); epubCheck.doValidate(); info.setCreated(report.getCreationDate()); info.setLastModified(report.getLastModifiedDate()); info.setVersion(report.getVersion()); List<CheckMessage> epubMessages = report.getAllMessages(); int notWellFormedErrors = epubMessages.stream().filter(c -> triggerNotWellFormed(c)) .collect(Collectors.toSet()).size(); info.setWellFormed(report.getFatalErrorCount() == 0 && notWellFormedErrors == 0); info.setValid(info.getWellFormed() == RepInfo.TRUE && report.getErrorCount() == 0); Set<Message> msgs = new TreeSet<Message>(new MessageComparator()); for (CheckMessage msg : report.getAllMessages()) { msgs.addAll(toJhoveMessages(msg)); } msgs.forEach(jhoveMsg -> info.setMessage(jhoveMsg)); info.setMimeType(report.getFormat()); generateProperties(report).forEach(prop -> _propList.add(prop)); } catch (Exception f) { f.printStackTrace(); if (f.getMessage() != null) { info.setMessage(new ErrorMessage(f.getMessage())); } else { info.setMessage(new ErrorMessage(MessageConstants.ERR_UNKNOWN)); } info.setWellFormed(false); return 0; } if (_je != null && _je.getAbort()) { return 0; } info.setProperty(_metadata); setChecksums(_ckSummer, info); return 0; } EpubModule();  EpubModule(String name, String release, int[] date,
            String[] format, String coverage,
            String[] mimetype, String wellformedNote,
            String validityNote, String repinfoNote, String note,
            String rights, boolean isRandomAccess, Agent moduleAgent); @Override void checkSignatures(File file, InputStream stream, RepInfo info); @Override int parse(InputStream stream, RepInfo info, int parseIndex); @Override void parse(RandomAccessFile file, RepInfo info); static String toUtf8(String inputString); }
EpubModule extends ModuleBase { @Override public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException { initParse(); info.setModule(this); info.setFormat(_format[0]); info.setWellFormed(false); info.setValid(false); _propList = new LinkedList<>(); _metadata = new Property(PROPNAME_EPUB_METADATA, PropertyType.PROPERTY, PropertyArity.LIST, _propList); _ckSummer = null; setupDataStream(stream, info); try { JhoveRepInfoReport report = new JhoveRepInfoReport(info.getUri()); EpubCheck epubCheck = new EpubCheck(_dstream, report, info.getUri()); epubCheck.doValidate(); info.setCreated(report.getCreationDate()); info.setLastModified(report.getLastModifiedDate()); info.setVersion(report.getVersion()); List<CheckMessage> epubMessages = report.getAllMessages(); int notWellFormedErrors = epubMessages.stream().filter(c -> triggerNotWellFormed(c)) .collect(Collectors.toSet()).size(); info.setWellFormed(report.getFatalErrorCount() == 0 && notWellFormedErrors == 0); info.setValid(info.getWellFormed() == RepInfo.TRUE && report.getErrorCount() == 0); Set<Message> msgs = new TreeSet<Message>(new MessageComparator()); for (CheckMessage msg : report.getAllMessages()) { msgs.addAll(toJhoveMessages(msg)); } msgs.forEach(jhoveMsg -> info.setMessage(jhoveMsg)); info.setMimeType(report.getFormat()); generateProperties(report).forEach(prop -> _propList.add(prop)); } catch (Exception f) { f.printStackTrace(); if (f.getMessage() != null) { info.setMessage(new ErrorMessage(f.getMessage())); } else { info.setMessage(new ErrorMessage(MessageConstants.ERR_UNKNOWN)); } info.setWellFormed(false); return 0; } if (_je != null && _je.getAbort()) { return 0; } info.setProperty(_metadata); setChecksums(_ckSummer, info); return 0; } EpubModule();  EpubModule(String name, String release, int[] date,
            String[] format, String coverage,
            String[] mimetype, String wellformedNote,
            String validityNote, String repinfoNote, String note,
            String rights, boolean isRandomAccess, Agent moduleAgent); @Override void checkSignatures(File file, InputStream stream, RepInfo info); @Override int parse(InputStream stream, RepInfo info, int parseIndex); @Override void parse(RandomAccessFile file, RepInfo info); static String toUtf8(String inputString); static final String[] NOTWELLFORMED_ERRCODES; }