public String resolveSchema(String schemaText) throws InvalidSchemaException, SchemaNotFoundException { Map<String, SchemaParsingState> schemaParsingStates = new HashMap<>(); return getResultantSchema(schemaText, schemaParsingStates); }
public String resolveSchema(String schemaText) throws InvalidSchemaException, SchemaNotFoundException { Map<String, SchemaParsingState> schemaParsingStates = new HashMap<>(); return getResultantSchema(schemaText, schemaParsingStates); }
@Override public String resolveSchema(SchemaVersionKey schemaVersionKey) throws InvalidSchemaException, SchemaNotFoundException { Map<String, SchemaParsingState> schemaParsingStates = new HashMap<>(); schemaParsingStates.put(schemaVersionKey.getSchemaName(), SchemaParsingState.PARSING); return getResultantSchema(schemaVersionKey, schemaParsingStates); }
@Override public String resolveSchema(SchemaVersionKey schemaVersionKey) throws InvalidSchemaException, SchemaNotFoundException { Map<String, SchemaParsingState> schemaParsingStates = new HashMap<>(); schemaParsingStates.put(schemaVersionKey.getSchemaName(), SchemaParsingState.PARSING); return getResultantSchema(schemaVersionKey, schemaParsingStates); }
private String getResultantSchema(SchemaVersionKey schemaVersionKey, Map<String, SchemaParsingState> schemaParsingStates) throws InvalidSchemaException, SchemaNotFoundException { String schemaText = schemaVersionRetriever.retrieveSchemaVersion(schemaVersionKey).getSchemaText(); return getResultantSchema(schemaText, schemaParsingStates); }
private String getResultantSchema(SchemaVersionKey schemaVersionKey, Map<String, SchemaParsingState> schemaParsingStates) throws InvalidSchemaException, SchemaNotFoundException { String schemaText = schemaVersionRetriever.retrieveSchemaVersion(schemaVersionKey).getSchemaText(); return getResultantSchema(schemaText, schemaParsingStates); }
private Map<String, Schema> collectSchemaTypes(SchemaVersionKey schemaVersionKey, Map<String, SchemaParsingState> schemaParsingStates) throws SchemaNotFoundException, InvalidSchemaException { String schemaName = schemaVersionKey.getSchemaName(); SchemaParsingState schemaParsingState = schemaParsingStates.putIfAbsent(schemaName, SchemaParsingState.PARSING); // if it is already parsed then the respective schema types would have been already collected. if (SchemaParsingState.PARSED == schemaParsingState) { return null; } // if it is in parsing state earlier and it is visted again then ther eis circular dependency!! if (SchemaParsingState.PARSING == schemaParsingState) { throw new CyclicSchemaDependencyException("Cyclic dependency of schema imports with schema [" + schemaName + "]"); } // this schema is not yet parsed till now if (schemaParsingState == null) { Schema.Parser parser = new Schema.Parser(); Schema schema = parser.parse(getResultantSchema(schemaVersionKey, schemaParsingStates)); Map<String, Schema> complexTypes = new HashMap<>(); collectComplexTypes(schema, complexTypes); schemaParsingStates.put(schemaName, SchemaParsingState.PARSED); return complexTypes; } throw new IllegalStateException("Schema parsing with schema version " + schemaVersionKey + " is in invalid state!!"); }
private Map<String, Schema> collectSchemaTypes(SchemaVersionKey schemaVersionKey, Map<String, SchemaParsingState> schemaParsingStates) throws SchemaNotFoundException, InvalidSchemaException { String schemaName = schemaVersionKey.getSchemaName(); SchemaParsingState schemaParsingState = schemaParsingStates.putIfAbsent(schemaName, SchemaParsingState.PARSING); // if it is already parsed then the respective schema types would have been already collected. if (SchemaParsingState.PARSED == schemaParsingState) { return null; } // if it is in parsing state earlier and it is visted again then ther eis circular dependency!! if (SchemaParsingState.PARSING == schemaParsingState) { throw new CyclicSchemaDependencyException("Cyclic dependency of schema imports with schema [" + schemaName + "]"); } // this schema is not yet parsed till now if (schemaParsingState == null) { Schema.Parser parser = new Schema.Parser(); Schema schema = parser.parse(getResultantSchema(schemaVersionKey, schemaParsingStates)); Map<String, Schema> complexTypes = new HashMap<>(); collectComplexTypes(schema, complexTypes); schemaParsingStates.put(schemaName, SchemaParsingState.PARSED); return complexTypes; } throw new IllegalStateException("Schema parsing with schema version " + schemaVersionKey + " is in invalid state!!"); }