Search in sources :

Example 1 with RestConfModule

use of org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule in project netconf by opendaylight.

the class RestconfImpl method getAvailableStreams.

@Override
@Deprecated
public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) {
    final EffectiveModelContext schemaContext = controllerContext.getGlobalSchema();
    final Set<String> availableStreams = Notificator.getStreamNames();
    final Module restconfModule = getRestconfModule();
    final DataSchemaNode streamSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, RestConfModule.STREAM_LIST_SCHEMA_NODE);
    checkState(streamSchemaNode instanceof ListSchemaNode);
    final CollectionNodeBuilder<MapEntryNode, SystemMapNode> listStreamsBuilder = SchemaAwareBuilders.mapBuilder((ListSchemaNode) streamSchemaNode);
    for (final String streamName : availableStreams) {
        listStreamsBuilder.withChild(toStreamEntryNode(streamName, streamSchemaNode));
    }
    final DataSchemaNode streamsContainerSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
    checkState(streamsContainerSchemaNode instanceof ContainerSchemaNode);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> streamsContainerBuilder = SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) streamsContainerSchemaNode);
    streamsContainerBuilder.withChild(listStreamsBuilder.build());
    return new NormalizedNodeContext(new InstanceIdentifierContext<>(STREAMS, streamsContainerSchemaNode, null, schemaContext), streamsContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo));
}
Also used : SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) RestConfModule(org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)

Example 2 with RestConfModule

use of org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule in project netconf by opendaylight.

the class RestconfImpl method getModule.

@Override
@Deprecated
public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) {
    final Entry<String, Revision> nameRev = getModuleNameAndRevision(requireNonNull(identifier));
    Module module = null;
    DOMMountPoint mountPoint = null;
    final EffectiveModelContext schemaContext;
    if (identifier.contains(ControllerContext.MOUNT)) {
        final InstanceIdentifierContext<?> mountPointIdentifier = controllerContext.toMountPointIdentifier(identifier);
        mountPoint = mountPointIdentifier.getMountPoint();
        module = controllerContext.findModuleByNameAndRevision(mountPoint, nameRev.getKey(), nameRev.getValue());
        schemaContext = modelContext(mountPoint);
    } else {
        module = controllerContext.findModuleByNameAndRevision(nameRev.getKey(), nameRev.getValue());
        schemaContext = controllerContext.getGlobalSchema();
    }
    if (module == null) {
        LOG.debug("Module with name '{}' and revision '{}' was not found.", nameRev.getKey(), nameRev.getValue());
        throw new RestconfDocumentedException("Module with name '" + nameRev.getKey() + "' and revision '" + nameRev.getValue() + "' was not found.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
    }
    final Module restconfModule = getRestconfModule();
    final Set<Module> modules = Collections.singleton(module);
    final MapNode moduleMap = makeModuleMapNode(modules);
    final DataSchemaNode moduleSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, RestConfModule.MODULE_LIST_SCHEMA_NODE);
    checkState(moduleSchemaNode instanceof ListSchemaNode);
    return new NormalizedNodeContext(new InstanceIdentifierContext<>(MODULE, moduleSchemaNode, mountPoint, schemaContext), moduleMap, QueryParametersParser.parseWriterParameters(uriInfo));
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) Revision(org.opendaylight.yangtools.yang.common.Revision) LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) RestConfModule(org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)

Example 3 with RestConfModule

use of org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule in project netconf by opendaylight.

the class RestconfImpl method getModules.

@Override
@Deprecated
public NormalizedNodeContext getModules(final UriInfo uriInfo) {
    final MapNode allModuleMap = makeModuleMapNode(controllerContext.getAllModules());
    final EffectiveModelContext schemaContext = controllerContext.getGlobalSchema();
    final Module restconfModule = getRestconfModule();
    final DataSchemaNode modulesSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
    checkState(modulesSchemaNode instanceof ContainerSchemaNode);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> moduleContainerBuilder = SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) modulesSchemaNode);
    moduleContainerBuilder.withChild(allModuleMap);
    return new NormalizedNodeContext(new InstanceIdentifierContext<>(MODULES, modulesSchemaNode, null, schemaContext), moduleContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo));
}
Also used : ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) RestConfModule(org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext)

Example 4 with RestConfModule

use of org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule in project netconf by opendaylight.

the class RestconfImpl method getModules.

/**
 * Valid only for mount point.
 */
@Override
@Deprecated
public NormalizedNodeContext getModules(final String identifier, final UriInfo uriInfo) {
    if (!identifier.contains(ControllerContext.MOUNT)) {
        final String errMsg = "URI has bad format. If modules behind mount point should be showed," + " URI has to end with " + ControllerContext.MOUNT;
        LOG.debug("{} for {}", errMsg, identifier);
        throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
    }
    final InstanceIdentifierContext<?> mountPointIdentifier = controllerContext.toMountPointIdentifier(identifier);
    final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint();
    final MapNode mountPointModulesMap = makeModuleMapNode(controllerContext.getAllModules(mountPoint));
    final Module restconfModule = getRestconfModule();
    final DataSchemaNode modulesSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
    checkState(modulesSchemaNode instanceof ContainerSchemaNode);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> moduleContainerBuilder = SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) modulesSchemaNode);
    moduleContainerBuilder.withChild(mountPointModulesMap);
    return new NormalizedNodeContext(new InstanceIdentifierContext<>(MODULES, modulesSchemaNode, mountPoint, controllerContext.getGlobalSchema()), moduleContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo));
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) RestConfModule(org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule)

Example 5 with RestConfModule

use of org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule in project netconf by opendaylight.

the class RestconfImpl method makeModuleMapNode.

private MapNode makeModuleMapNode(final Collection<? extends Module> modules) {
    requireNonNull(modules);
    final Module restconfModule = getRestconfModule();
    final DataSchemaNode moduleSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, RestConfModule.MODULE_LIST_SCHEMA_NODE);
    checkState(moduleSchemaNode instanceof ListSchemaNode);
    final CollectionNodeBuilder<MapEntryNode, SystemMapNode> listModuleBuilder = SchemaAwareBuilders.mapBuilder((ListSchemaNode) moduleSchemaNode);
    for (final Module module : modules) {
        listModuleBuilder.withChild(toModuleEntryNode(module, moduleSchemaNode));
    }
    return listModuleBuilder.build();
}
Also used : SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) RestConfModule(org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)

Aggregations

RestConfModule (org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule)7 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)7 Module (org.opendaylight.yangtools.yang.model.api.Module)7 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)5 SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)5 NormalizedNodeContext (org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext)4 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)3 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)3 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)3 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)3 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)3 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)3 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)3 DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)2 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)2 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)2 GroupingDefinition (org.opendaylight.yangtools.yang.model.api.GroupingDefinition)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Revision (org.opendaylight.yangtools.yang.common.Revision)1