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));
}
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));
}
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));
}
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));
}
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();
}
Aggregations