Examples of JsonSchema


Examples of uk.co.o2.json.schema.JsonSchema

        if (schemaAnnotation != null) {
            ObjectMapper mapper = locateMapper(type, mediaType);
            JsonParser jp = mapper.getFactory().createJsonParser(entityStream);
            jp.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
            URL schemaLocation = schemaLookup.getSchemaURL(schemaAnnotation.value());
            JsonSchema jsonSchema = cache.getSchema(schemaLocation);
            JsonNode jsonNode = mapper.readTree(jp);
            List<ErrorMessage> validationErrors = jsonSchema.validate(jsonNode);
            if (validationErrors.isEmpty()) {
                return mapper.reader().withType(mapper.constructType(genericType)).readValue(jsonNode);
            }

            throw new WebApplicationException(generateErrorMessage(validationErrors));
View Full Code Here

Examples of voldemort.store.readonly.mr.utils.JsonSchema

                                                       String url,
                                                       Path inputPath,
                                                       AdminClient adminClient) throws IOException {
        // create new json store def with schema from the metadata in the input
        // path
        JsonSchema schema = HadoopUtils.getSchemaFromPath(inputPath);
        int replicationFactor = props.getInt("build.replication.factor." + storeName,
                                             props.getInt("build.replication.factor", 2));
        int requiredReads = props.getInt("build.required.reads." + storeName,
                                         props.getInt("build.required.reads", 1));
        int requiredWrites = props.getInt("build.required.writes." + storeName,
                                          props.getInt("build.required.writes", 1));

        int preferredReads = props.getInt("build.preferred.reads." + storeName,
                                          props.getInt("build.preferred.reads", -1));
        int preferredWrites = props.getInt("build.preferred.writes." + storeName,
                                           props.getInt("build.preferred.writes", -1));

        String description = props.getString("push.store.description." + storeName,
                                             props.getString("push.store.description", ""));
        String owners = props.getString("push.store.owners." + storeName,
                                        props.getString("push.store.owners", ""));

        // Generate the key and value schema
        String keySchema = "\n\t\t<type>json</type>\n\t\t<schema-info version=\"0\">"
                           + schema.getKeyType() + "</schema-info>\n\t";
        String valSchema = "\n\t\t<type>json</type>\n\t\t<schema-info version=\"0\">"
                           + schema.getValueType() + "</schema-info>\n\t";

        String keySchemaCompression = "";
        if(props.containsKey("build.compress.key." + storeName)
           || (storeNames.size() == 1 && props.containsKey("build.compress.key"))) {
            keySchemaCompression = "\t<compression><type>gzip</type></compression>\n\t";
View Full Code Here

Examples of voldemort.store.readonly.mr.utils.JsonSchema

     * @return
     *
     */
    private void verifyOrAddStore(String url) throws Exception {
        // create new json store def with schema from the metadata in the input path
        JsonSchema schema = HadoopUtils.getSchemaFromPath(getInputPath());
        int replicationFactor = props.getInt("build.replication.factor", 2);
        int requiredReads = props.getInt("build.required.reads", 1);
        int requiredWrites = props.getInt("build.required.writes", 1);
        String description = props.getString("push.store.description", "");
        String owners = props.getString("push.store.owners", "");
        String keySchema = "\n\t\t<type>json</type>\n\t\t<schema-info version=\"0\">"
                           + schema.getKeyType() + "</schema-info>\n\t";

        if(jsonKeyField != null && jsonKeyField.length() > 0) {
            keySchema = "\n\t\t<type>json</type>\n\t\t<schema-info version=\"0\">"
                        + schema.getKeyType().subtype(jsonKeyField) + "</schema-info>\n\t";
        }

        String valSchema = "\n\t\t<type>json</type>\n\t\t<schema-info version=\"0\">"
                           + schema.getValueType() + "</schema-info>\n\t";

        if (jsonValueField != null && jsonValueField.length() > 0) {
            valSchema = "\n\t\t<type>json</type>\n\t\t<schema-info version=\"0\">"
                        + schema.getValueType().subtype(jsonValueField) + "</schema-info>\n\t";
        }

        boolean hasCompression = false;
        if (props.containsKey("build.compress.value")) {
            hasCompression = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.