in streams-util/src/main/java/org/apache/streams/util/schema/SchemaStoreImpl.java [59:111]
public synchronized Schema create(URI uri) {
if (!getByUri(uri).isPresent()) {
URI baseUri = UriUtil.removeFragment(uri);
JsonNode baseNode = this.contentResolver.resolve(baseUri);
if (uri.toString().contains("#") && !uri.toString().endsWith("#")) {
Schema newSchema = new Schema(baseUri, baseNode, null, true);
this.schemas.put(baseUri, newSchema);
JsonNode childContent = this.fragmentResolver.resolve(baseNode, '#' + StringUtils.substringAfter(uri.toString(), "#"), "#");
this.schemas.put(uri, new Schema(uri, childContent, newSchema, false));
} else {
if ( baseNode.has("extends") && baseNode.get("extends").isObject()) {
URI ref = URI.create((baseNode.get("extends")).get("$ref").asText());
URI absoluteUri;
if ( ref.isAbsolute()) {
absoluteUri = ref;
} else {
absoluteUri = baseUri.resolve(ref);
}
JsonNode parentNode = this.contentResolver.resolve(absoluteUri);
Schema parentSchema;
if ( this.schemas.get(absoluteUri) != null ) {
parentSchema = this.schemas.get(absoluteUri);
} else {
parentSchema = create(absoluteUri);
}
this.schemas.put(uri, new Schema(uri, baseNode, parentSchema, true));
} else {
this.schemas.put(uri, new Schema(uri, baseNode, null, true));
}
}
List<JsonNode> refs = baseNode.findValues("$ref");
for ( JsonNode ref : refs ) {
if ( ref.isValueNode() ) {
String refVal = ref.asText();
URI refUri = null;
try {
refUri = URI.create(refVal);
} catch ( Exception ex ) {
LOGGER.info("Exception: {}", ex.getMessage());
}
if (refUri != null && !getByUri(refUri).isPresent()) {
if (refUri.isAbsolute()) {
create(refUri);
} else {
create(baseUri.resolve(refUri));
}
}
}
}
}
return this.schemas.get(uri);
}