Package org.jwat.common

Examples of org.jwat.common.Diagnosis


            else {
                bSeekRecord = false;
            }
        }
        if (bInvalidDataBeforeVersion) {
            diagnostics.addError(new Diagnosis(DiagnosisType.INVALID, "Data before ARC record"));
        }
        if (bEmptyLinesBeforeVersion) {
            diagnostics.addError(new Diagnosis(DiagnosisType.INVALID, "Empty lines before ARC record"));
        }
        return bHeaderParsed;
    }
View Full Code Here


                    resultCodeStr = null;
                }
                resultCode = fieldParsers.parseInteger(
                        resultCodeStr, ArcConstants.FN_RESULT_CODE, false);
                if (resultCode != null && (resultCode < 100 || resultCode > 999)) {
                    diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_EXPECTED,
                            "'" + ArcConstants.FN_RESULT_CODE + "' value",
                            resultCodeStr,
                            "A number between 100 and 999"));
                }

                checksumStr = fields[ArcConstants.FN_IDX_CHECKSUM];
                if ("-".equals(checksumStr)) {
                    checksumStr = null;
                }
                checksumStr = fieldParsers.parseString(
                        checksumStr, ArcConstants.FN_CHECKSUM, true);

                locationStr = fields[ArcConstants.FN_IDX_LOCATION];
                if ("-".equals(locationStr)) {
                    locationStr = null;
                }
                locationStr = fieldParsers.parseString(
                        locationStr, ArcConstants.FN_LOCATION, true);

                offsetStr = fields[ArcConstants.FN_IDX_OFFSET];
                if ("-".equals(offsetStr)) {
                    offsetStr = null;
                }
                offset = fieldParsers.parseLong(
                        offsetStr, ArcConstants.FN_OFFSET, false);
                if (offset != null && offset < 0) {
                    diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_EXPECTED,
                            "'" + ArcConstants.FN_OFFSET + "' value",
                            offsetStr,
                            "A non negative number"));
                }

                filenameStr = fields[ArcConstants.FN_IDX_FILENAME];
                if ("-".equals(filenameStr)) {
                    filenameStr = null;
                }
                filenameStr = reader.fieldParsers.parseString(
                        filenameStr, ArcConstants.FN_FILENAME, false);
            }
            archiveLengthStr = fields[fields.length - 1];
            if ("-".equals(archiveLengthStr)) {
                archiveLengthStr = null;
            }
            archiveLength = reader.fieldParsers.parseLong(
                    archiveLengthStr, ArcConstants.FN_ARCHIVE_LENGTH, false);
            if (archiveLength != null && archiveLength < 0) {
                diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_EXPECTED,
                        "'" + ArcConstants.FN_ARCHIVE_LENGTH + "' value",
                        archiveLengthStr,
                        "A non negative number"));
            }
        }
View Full Code Here

    }

    @Test
    public void test_empty_warcfile() {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[0]);
        Diagnosis d;
        try {
            WarcReader reader = WarcReaderFactory.getReaderUncompressed(in);
            WarcRecord record = reader.getNextRecord();
            Assert.assertNull(record);
            Assert.assertFalse(reader.isCompliant());
View Full Code Here

     * more details and/or format information.
     * @param entity entity examined
     * @param information optional extra information
     */
    protected void addInvalidExpectedError(String entity, String... information) {
        diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_EXPECTED, entity, information));
    }
View Full Code Here

     * Add an error diagnosis on the given entity stating that it is required
     * but is missing.
     * @param entity entity examined
     */
    protected void addRequiredMissingError(String entity) {
        diagnostics.addError(new Diagnosis(DiagnosisType.REQUIRED_MISSING, entity));
    }
View Full Code Here

        WarcWriter writer;
        WarcRecord record;
        byte[] recordHeader;
        ByteArrayInputStream in;
        byte[] payload;
        Diagnosis diagnosis;
        try {
            payload = "Welcome to dænemark!".getBytes("UTF-8");

            /*
             * Exceptions enabled.
View Full Code Here

     * more details and/or format information.
     * @param entity entity examined
     * @param information optional extra information
     */
    protected void addInvalidExpectedError(String entity, String... information) {
        diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_EXPECTED, entity, information));
    }
View Full Code Here

    /**
     * Add a warning diagnosis on the given entity stating that it is empty.
     * @param entity entity examined
     */
    protected void addEmptyWarning(String entity) {
        diagnostics.addWarning(new Diagnosis(DiagnosisType.EMPTY, entity));
    }
View Full Code Here

     * Closes the WARC record by writing two newlines and comparing the amount of
     * payload data streamed with the content-length supplied with the header.
     * @throws IOException if an i/o exception occurs while closing the record
     */
    protected void closeRecord_impl() throws IOException {
        Diagnosis diagnosis = null;
        out.write(WarcConstants.endMark);
        out.flush();
        if (headerContentLength == null) {
            diagnosis = new Diagnosis(
                    DiagnosisType.ERROR_EXPECTED,
                    "'" + WarcConstants.FN_CONTENT_LENGTH + "' header",
                    "Mandatory!");
        } else {
            if (headerContentLength != payloadWrittenTotal) {
                diagnosis = new Diagnosis(
                        DiagnosisType.INVALID_EXPECTED,
                        "'" + WarcConstants.FN_CONTENT_LENGTH + "' header",
                        Long.toString(payloadWrittenTotal),
                        headerContentLength.toString());
            }
View Full Code Here

     * @param type diagnosis type
     * @param entity entity examined
     * @param information optional extra information
     */
    protected void addErrorDiagnosis(DiagnosisType type, String entity, String... information) {
        diagnostics.addError(new Diagnosis(type, entity, information));
    }
View Full Code Here

TOP

Related Classes of org.jwat.common.Diagnosis

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.