use of org.opendaylight.netconf.sal.connect.netconf.schema.NetconfRemoteSchemaYangSourceProvider.NetconfYangTextSchemaSource in project netconf by opendaylight.
the class YangLibrarySchemaYangSourceProvider method getSource.
@Override
public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
final URL url = availableSources.get(requireNonNull(sourceIdentifier));
checkArgument(url != null);
try (InputStream in = url.openStream()) {
final byte[] schemaContent = in.readAllBytes();
final NetconfYangTextSchemaSource yangSource = new NetconfYangTextSchemaSource(id, sourceIdentifier, url.toString(), schemaContent);
LOG.debug("Source {} downloaded from a yang library's url {}", sourceIdentifier, url);
return Futures.immediateFuture(yangSource);
} catch (IOException e) {
LOG.warn("Unable to download source {} from a yang library's url {}", sourceIdentifier, url, e);
return Futures.immediateFailedFuture(new SchemaSourceException("Unable to download remote schema for " + sourceIdentifier + " from " + url, e));
}
}
Aggregations