Package org.fcrepo.server.storage.types

Examples of org.fcrepo.server.storage.types.Validation


            String msg =
                    "DOValidatorXMLSchema returned validation exception.\n"
                            + "The underlying exception was a "
                            + e.getClass().getName() + ".\n"
                            + "The message was " + "\"" + e.getMessage() + "\"";
            Validation validation = new Validation("unknown");
            List<String> problems = new ArrayList<String>();
            problems.add(msg);
            validation.setObjectProblems(problems);
            throw new ObjectValidityException(msg, validation, e);
        } catch (Exception e) {
            String msg =
                    "DOValidatorXMLSchema returned error.\n"
                            + "The underlying error was a "
View Full Code Here


    // (and prevents the server ingesting the initial system content model object)
    String pid = currentObjectReader.GetObjectPID();
    String objectUri = "info:fedora/" + pid;
    if (!contentmodels.contains(objectUri)) {

    Validation validation = doValidate(context, currentObjectReader, new Date(), contentmodels);

      if (!validation.isValid()) {
        throw new ObjectValidityException("ECM validation failure", validation);

      }
    }
View Full Code Here


    protected  Validation doValidate(Context context, DOReader reader, Date asOfDateTime, List<String> contentModels) throws ServerException {

      String pid = reader.GetObjectPID();
        Validation validation = new Validation(pid);
        validation.setAsOfDateTime(asOfDateTime);
        validation.setContentModels(contentModels);
        Date createDate = reader.getCreateDate();
        if (createDate.after(asOfDateTime)) {
            reportNonExistenceProblem(validation, pid, createDate, asOfDateTime);
            return validation;
        }
View Full Code Here

                    validatingStyleSheet.newTransformer();
            DOMResult validationResult = new DOMResult();
            vtransformer.transform(objectSource, validationResult);
            result = new DOValidatorSchematronResult(validationResult);
        } catch (Exception e) {
          Validation validation = new Validation("unknown");
          List<String> probs = new ArrayList<String>();
          probs.add("Schematron validation failed:" + e.getMessage());
          validation.setObjectProblems(probs);
            logger.error("Schematron validation failed", e);
            throw new ObjectValidityException(e.getMessage(), validation);
        }

        if (!result.isValid()) {
            String msg = null;
            try {
                msg = result.getXMLResult();
            } catch (Exception e) {
                logger.warn("Error getting XML result of schematron validation failure", e);
            }
          Validation validation = new Validation("unknown");
          List<String> probs = new ArrayList<String>();
          if (msg != null) {
            probs.add(msg);
          } else {
            probs.add("Unknown schematron error.  Error getting XML results of schematron validation");
View Full Code Here

        }
    }

    private void checkFormat(String format) throws ObjectValidityException {
        if (!m_xmlSchemaMap.containsKey(format)) {
          Validation validation = new Validation("unknown");
          List<String> probs = new ArrayList<String>();
          probs.add("Unsupported format: " + format);
          validation.setObjectProblems(probs);
            throw new ObjectValidityException("Unsupported format: " + format, validation);
        }
    }
View Full Code Here

        try {
            Context context = getContext();
            Date asOfDateTime = DateUtility.parseDateOrNull(dateTime);
            MediaType mediaType = TEXT_XML;

            Validation validation = m_management.validate(context, pid, asOfDateTime);

            String xml = getSerializer(context).objectValidationToXml(validation);
            return Response.ok(xml, mediaType).build();
        } catch (Exception ex) {
            return handleException(ex, flash);
View Full Code Here

    @Test
    public void testEcm1() throws Exception {
        EcmValidator ecm = new EcmValidator(reader,null);

        Validation validation1 = ecm.validate(null, "demo:dataObject1", null);
        assertTrue("Dataobject1 failed validation: " + objectValidationToXml(validation1), validation1.isValid());

    }
View Full Code Here

    @Test
    public void testEcm2() throws Exception {
        EcmValidator ecm = new EcmValidator(reader,null);


        Validation validation2 = ecm.validate(null, "demo:dataObject2", null);
        assertTrue("Dataobject2 failed validation: " + objectValidationToXml(validation2), validation2.isValid());

    }
View Full Code Here

    @Test
    public void testEcm3() throws Exception {
        EcmValidator ecm = new EcmValidator(reader,null);

        Validation validation = ecm.validate(null, "demo:contentModel1", null);
        assertTrue("contentmodel1 failed validation: " + objectValidationToXml(validation), validation.isValid());

    }
View Full Code Here

    @Test
    public void testEcm4() throws Exception {
        EcmValidator ecm = new EcmValidator(reader,null);

        Validation validation = ecm.validate(null, "demo:dataObject3", null);
        assertFalse("DataObject3 succeeded validation: " + objectValidationToXml(validation), validation.isValid());

    }
View Full Code Here

TOP

Related Classes of org.fcrepo.server.storage.types.Validation

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.