use of com.linkedin.data.schema.resolver.FileDataSchemaLocation in project rest.li by linkedin.
the class RequestBuilderSpecGenerator method generate.
public void generate(ResourceSchema resource, File sourceFile) {
try {
_currentSchemaLocation = new FileDataSchemaLocation(sourceFile);
generateRootRequestBuilder(null, resource, sourceFile.getAbsolutePath(), new HashMap<>());
} catch (IOException e) {
throw new RuntimeException("Error processing file [" + sourceFile.getAbsolutePath() + "] " + e.getMessage(), e);
}
}
use of com.linkedin.data.schema.resolver.FileDataSchemaLocation in project rest.li by linkedin.
the class AvroSchemaGenerator method parseFile.
@Override
protected void parseFile(File schemaSourceFile) throws IOException {
super.parseFile(schemaSourceFile);
_sourceLocations.add(new FileDataSchemaLocation(schemaSourceFile));
}
use of com.linkedin.data.schema.resolver.FileDataSchemaLocation in project rest.li by linkedin.
the class AbstractGenerator method parseSchema.
/**
* Parse a source file to obtain the data schemas contained within.
*
* @param schemaSourceFile provides the source file.
* @return the data schemas within the source file.
* @throws IOException if there is a file access error.
*/
protected List<DataSchema> parseSchema(final File schemaSourceFile) throws IOException {
PegasusSchemaParser parser = AbstractSchemaParser.parserForFile(schemaSourceFile, getSchemaResolver());
FileInputStream schemaStream = new SchemaFileInputStream(schemaSourceFile);
try {
parser.setLocation(new FileDataSchemaLocation(schemaSourceFile));
parser.parse(schemaStream);
if (parser.hasError()) {
return Collections.emptyList();
}
return parser.topLevelDataSchemas();
} finally {
schemaStream.close();
if (parser.hasError()) {
getMessage().append(schemaSourceFile.getPath() + ",");
getMessage().append(parser.errorMessage());
}
}
}
Aggregations