Search in sources :

Example 6 with RevisionSourceIdentifier

use of org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier in project netconf by opendaylight.

the class YangSchemaExportBodyWriter method writeTo.

@Override
public void writeTo(final SchemaExportContext context, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException {
    final RevisionSourceIdentifier sourceId = RevisionSourceIdentifier.create(context.getModule().getName(), context.getModule().getQNameModule().getRevision());
    final YangTextSchemaSource yangTextSchemaSource;
    try {
        yangTextSchemaSource = context.getSourceProvider().getSource(sourceId).get();
    } catch (InterruptedException | ExecutionException e) {
        throw new WebApplicationException("Unable to retrieve source from SourceProvider.", e);
    }
    yangTextSchemaSource.copyTo(entityStream);
}
Also used : YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) WebApplicationException(javax.ws.rs.WebApplicationException) ExecutionException(java.util.concurrent.ExecutionException) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier)

Aggregations

RevisionSourceIdentifier (org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier)6 ExecutionException (java.util.concurrent.ExecutionException)4 YangTextSchemaSource (org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource)4 WebApplicationException (javax.ws.rs.WebApplicationException)2 Test (org.junit.Test)2 URL (java.net.URL)1 HashSet (java.util.HashSet)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 YangModuleInfo (org.opendaylight.yangtools.yang.binding.YangModuleInfo)1 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)1 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)1 MissingSchemaSourceException (org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException)1 SourceIdentifier (org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier)1 IRSchemaSource (org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource)1 IRStatement (org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRStatement)1