IOException, YangSyntaxErrorException {
checkArgument(url != null, "Supplied URL must not be null");
- final SourceIdentifier guessedId = RevisionSourceIdentifier.create(url.getFile(), Optional.absent());
+ final SourceIdentifier guessedId = guessSourceIdentifier(url.getFile());
return registerSource(new YangTextSchemaSource(guessedId) {
@Override
public InputStream openStream() throws IOException {
});
}
+ private static SourceIdentifier guessSourceIdentifier(final String fileName) {
+ try {
+ return YangTextSchemaSource.identifierFromFilename(fileName);
+ } catch (IllegalArgumentException e) {
+ LOG.warn("Invalid file name format in '{}'", fileName, e);
+ return RevisionSourceIdentifier.create(fileName);
+ }
+ }
+
/**
* Try to parse all currently available yang files and build new schema context.
* @return new schema context iif there is at least 1 yang file registered and