output = new PrintWriter(osw); } catch (UnsupportedEncodingException uee) { throw new JhoveException(CoreMessageConstants.EXC_CHAR_ENC_UNSPPTD + encoding); } catch (FileNotFoundException fnfe) { throw new JhoveException(CoreMessageConstants.EXC_FILE_OPEN + outputFile); osw = new OutputStreamWriter(System.out, encoding); } catch (UnsupportedEncodingException uee) { throw new JhoveException(CoreMessageConstants.EXC_CHAR_ENC_UNSPPTD + encoding);
errorAlert (e.getMessage ());
@Override public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException { WarcReader reader = WarcReaderFactory.getReader(new InputStreamNoSkip(stream), 8192); try { info.setFormat(_format[0]); info.setMimeType(_mimeType[0]); info.setModule(this); setReaderOptions(reader); parseRecords(reader); info.setValid(reader.isCompliant()); info.setWellFormed(reader.isCompliant()); reportResults(reader, info); if (reader.isCompliant()) { info.setSigMatch(_name); } } catch (JhoveException e) { info.setMessage(new ErrorMessage(e.getMessage())); info.setValid(false); info.setWellFormed(false); } finally { if(reader != null) { reader.close(); reader = null; } } return 0; }
if (version.compareTo("1.8.0") < 0) { _logger.severe(CoreMessageConstants.EXC_JAVA_VER_INCMPT); throw new JhoveException(CoreMessageConstants.EXC_JAVA_VER_INCMPT);
/** * Parse WARC records. Parsing should be straight forward with all records accessible through the same source. * @param reader WARC reader used to parse records * @throws EOFException if EOF occurs prematurely * @throws IOException if an IO error occurs while processing * @throws JhoveException if a serious problem needs to be reported */ protected void parseRecords(WarcReader reader) throws IOException, JhoveException { if (reader != null) { WarcRecord record; while ((record = reader.getNextRecord()) != null) { processRecord(record); reader.diagnostics.addAll(record.diagnostics); } } else { throw new JhoveException(MessageConstants.ERR_RECORD_NULL); } }
/** * Parses GZIP entries. Parsing should be straight forward with all records accessible through the same source. * @param reader GZIP reader used to parse records * @throws EOFException if EOF occurs prematurely * @throws IOException if an IO error occurs while processing * @throws JhoveException if a serious problem needs to be reported */ protected void parseRecords(GzipReader reader) throws EOFException, IOException, JhoveException { if (reader != null) { GzipEntry entry; while ((entry = reader.getNextEntry()) != null) { processEntry(entry); reader.diagnostics.addAll(entry.diagnostics); } } else { throw new JhoveException(MessageConstants.ERR_RECORD_NULL); } }
throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_LOC_MISS); throw new JhoveException(config.getAbsolutePath() + CoreMessageConstants.EXC_CONF_FILE_INVAL); throw new JhoveException(CoreMessageConstants.EXC_SAX_PRSR_MISS + saxClass, e); parser.parse(fileURL); } catch (IOException ioe) { throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_UNRDBL + configFile, ioe); } catch (SAXException saxe) { throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_UNPRS + saxe.getMessage(), saxe); _logger.info("Initialized " + module.getName()); } catch (Exception e) { throw new JhoveException(CoreMessageConstants.EXC_MODL_INST_FAIL + modInfo.clas, e); _handlerMap.put(handler.getName().toLowerCase(), handler); } catch (Exception e) { throw new JhoveException(CoreMessageConstants.EXC_HNDL_INST_FAIL + tuple[0], e);
url = uri.toURL(); } catch (Exception e) { throw new JhoveException(CoreMessageConstants.EXC_URI_CONV_FAIL + dirFileOrUri); int code = ((HttpsURLConnection) conn).getResponseCode(); if (200 > code || code >= 300) { throw new JhoveException(CoreMessageConstants.EXC_URL_NOT_FND + dirFileOrUri); throw new JhoveException(CoreMessageConstants.EXC_URL_NOT_FND + dirFileOrUri); message += " (" + ioeMessage + ")"; throw new JhoveException(message);
/** * Set digest options for WARC reader. * @param reader WARC reader instance */ protected void setReaderOptions(WarcReader reader) throws JhoveException { reader.setBlockDigestEnabled(bComputeBlockDigest); reader.setPayloadDigestEnabled(bComputePayloadDigest); if (!reader.setBlockDigestAlgorithm(blockDigestAlgorithm)) { throw new JhoveException(MessageConstants.ERR_BLOCK_DIGEST_INVALID + blockDigestAlgorithm); } if (!reader.setPayloadDigestAlgorithm(payloadDigestAlgorithm)) { throw new JhoveException(MessageConstants.ERR_PAYLOAD_DIGEST_INVALID + payloadDigestAlgorithm); } reader.setBlockDigestEncoding(blockDigestEncoding); reader.setPayloadDigestEncoding(payloadDigestEncoding); if (bStrictTargetUriValidation) { reader.setWarcTargetUriProfile(UriProfile.RFC3986); } else { reader.setWarcTargetUriProfile(UriProfile.RFC3986_ABS_16BIT_LAX); } if (bStrictUriValidation) { reader.setUriProfile(UriProfile.RFC3986); } else { reader.setUriProfile(UriProfile.RFC3986_ABS_16BIT_LAX); } }