Search in sources :

Example 1 with SourceReference

use of org.opendaylight.mdsal.yanglib.api.SourceReference in project mdsal by opendaylight.

the class MountPointContextFactoryImpl method fillSource.

private static void fillSource(final List<SourceReference> sources, final YangIdentifier sourceName, final Optional<Revision> revision, final Set<Uri> uris) {
    final var sourceId = RevisionSourceIdentifier.create(sourceName.getValue(), revision);
    final SourceReference sourceRef;
    if (uris != null && uris.isEmpty()) {
        final var locations = new ArrayList<URL>();
        for (Uri uri : uris) {
            try {
                locations.add(new URL(uri.getValue()));
            } catch (MalformedURLException e) {
                LOG.debug("Ignoring invalid schema location {}", uri, e);
            }
        }
        sourceRef = SourceReference.of(sourceId, locations);
    } else {
        sourceRef = SourceReference.of(sourceId);
    }
    sources.add(sourceRef);
}
Also used : MalformedURLException(java.net.MalformedURLException) SourceReference(org.opendaylight.mdsal.yanglib.api.SourceReference) ArrayList(java.util.ArrayList) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) URL(java.net.URL)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 SourceReference (org.opendaylight.mdsal.yanglib.api.SourceReference)1 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)1