Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.Document


    }

    @Override
    public Document getChildren( PageKey pageKey ) {
        String parentId = pageKey.getParentId();
        Document doc = documentsById.get(parentId);
        assert doc != null;
        DocumentReader reader = readDocument(doc);
        List<? extends Document> children = reader.getChildren();

        int blockSize = (int)pageKey.getBlockSize();
View Full Code Here


    }

    @Override
    public Document put( String key,
                         Document document ) {
        Document result = documents.put(key, document);
        schemaDocuments.remove(key);
        return result;
    }
View Full Code Here

    }

    @Override
    public Document putIfAbsent( String key,
                                 Document document ) {
        Document result = documents.putIfAbsent(key, document);
        schemaDocuments.remove(key);
        return result;
    }
View Full Code Here

    }

    @Override
    public Document replace( String key,
                             Document document ) {
        Document result = documents.replace(key, document);
        schemaDocuments.remove(key);
        return result;
    }
View Full Code Here

        return result;
    }

    @Override
    public Document remove( String key ) {
        Document result = documents.remove(key);
        schemaDocuments.remove(key);
        return result;
    }
View Full Code Here

        if (result != null) {
            return result;
        }

        // Find the JSON Schema document ...
        Document doc = jsonSchemaDocuments.get(uri);
        if (doc == null) {
            problems.recordError(Paths.rootPath(), "Unable to find the JSON Schema document for '" + uri + "'");
            return null;
        }

        // Validate the JSON document, if required ...
        String id = doc.getString("id");
        String schemaRef = doc.getString("$schema");
        if (schemaRef == null) {
            schemaRef = defaultMetaSchemaUri;
        }
        if (!schemaRef.equals(id)) {
            // This is not the meta-schema, so we need to validate it ...
            SchemaDocument schemaOfSchema = get(schemaRef, problems);
            Document schemaOfSchemaDoc = schemaOfSchema.getDocument();
            schemaOfSchema.getValidator().validate(null, null, schemaOfSchemaDoc, Paths.rootPath(), problems, this);
        }

        // The schema was valid ...
        URI schemaRefUri = null;
View Full Code Here

            List<?> types = (List<?>)value;
            for (Object obj : types) {
                Validator validator = null;
                if (obj instanceof Document) {
                    // It's either a schema or a reference to a schema ...
                    Document schemaOrRef = (Document)obj;
                    validator = create(schemaOrRef, parentPath.with("type"));
                } else if (obj instanceof String) {
                    Type type = JsonSchema.Type.byName((String)obj);
                    if (type == Type.ANY || type == Type.UNKNOWN) continue;
                    validator = new TypeValidator(type);
View Full Code Here

    protected void addValidatorsForProperties( Document parent,
                                               Path parentPath,
                                               Problems problems,
                                               CompositeValidator validators ) {
        Document properties = parent.getDocument("properties");
        Set<String> propertiesWithSchemas = new HashSet<String>();
        if (properties != null && properties.size() != 0) {
            for (Field field : properties.fields()) {
                String name = field.getName();
                Object value = field.getValue();
                Path path = Paths.path(parentPath, "properties", name);
                if (!(value instanceof Document)) {
                    problems.recordError(path, "Expected a nested object");
                }
                Document propertySchema = (Document)value;
                Validator propertyValidator = create(propertySchema, path);
                if (propertyValidator != null) {
                    validators.add(new PropertyValidator(name, propertyValidator));
                }
                propertiesWithSchemas.add(name);
            }
        }

        // Check the additional properties ...
        boolean additionalPropertiesAllowed = parent.getBoolean("additionalProperties", true);
        if (!additionalPropertiesAllowed) {
            validators.add(new NoOtherAllowedPropertiesValidator(propertiesWithSchemas));
        } else {
            Document additionalSchema = parent.getDocument("additionalProperties");
            if (additionalSchema != null) {
                Path path = parentPath.with("additionalProperties");
                Validator additionalValidator = create(additionalSchema, path);
                if (additionalValidator != null) {
                    validators.add(new AllowedPropertiesValidator(propertiesWithSchemas, additionalValidator));
View Full Code Here

    protected void addValidatorsForPatternProperties( Document parent,
                                                      Path parentPath,
                                                      Problems problems,
                                                      CompositeValidator validators ) {
        Document properties = parent.getDocument("patternProperties");
        if (properties != null && properties.size() != 0) {
            for (Field field : properties.fields()) {
                String name = field.getName();
                Object value = field.getValue();
                Path path = Paths.path(parentPath, "patternProperties", name);
                if (!(value instanceof Document)) {
                    problems.recordError(path, "Expected a nested object");
                }
                Document propertySchema = (Document)value;
                try {
                    Pattern namePattern = Pattern.compile(name);
                    Validator propertyValidator = create(propertySchema, path);
                    if (propertyValidator != null) {
                        validators.add(new PatternPropertyValidator(namePattern, propertyValidator));
View Full Code Here

        String requiredName = parentPath.getLast();
        if (requiredName == null) return;

        // Either a schema or an array of schemas ...
        if (items instanceof Document) {
            Document schema = (Document)items;
            Validator validator = create(schema, path);
            if (validator != null) {
                validators.add(new AllItemsMatchValidator(requiredName, validator));
            }
        } else if (items instanceof List<?>) {
            // This is called "tuple typing" in the spec, and can also have 'additionalItems' ...
            List<?> array = (List<?>)items;
            List<Validator> itemValidators = new ArrayList<Validator>(array.size());
            for (Object item : array) {
                if (item instanceof Document) {
                    Validator validator = create((Document)item, path);
                    if (validator != null) {
                        itemValidators.add(validator);
                    }
                }
            }
            // Check the additional items ...
            boolean additionalItemsAllowed = parent.getBoolean("additionalItems", true);
            Validator additionalItemsValidator = null;
            if (!additionalItemsAllowed) {
                additionalItemsValidator = new NotValidValidator();
            } else {
                // additional items are allowed, but check whether there is a schema for the additional items ...
                Document additionalItems = parent.getDocument("additionalItems");
                if (additionalItems != null) {
                    Path additionalItemsPath = parentPath.with("additionalItems");
                    additionalItemsValidator = create(additionalItems, additionalItemsPath);
                }
            }
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.document.Document

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.