From: Tomas Cere Date: Mon, 7 Sep 2015 10:44:42 +0000 (+0200) Subject: Delete restconf X-Git-Tag: release/beryllium~325 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=89b8b59cd26fd4810293ff14386eb29a71da9fac Delete restconf Change-Id: I0cc4ea8375ec22b67ee93e1a02a9131f56f044c2 Signed-off-by: Tomas Cere --- diff --git a/features/pom.xml b/features/pom.xml index 4cc357b32e..c03e7cf9f7 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -17,7 +17,6 @@ mdsal protocol-framework akka - restconf extras diff --git a/features/restconf/pom.xml b/features/restconf/pom.xml deleted file mode 100644 index 55414066ec..0000000000 --- a/features/restconf/pom.xml +++ /dev/null @@ -1,345 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - sal-parent - 1.3.0-SNAPSHOT - ../../opendaylight/md-sal - - - features-restconf - org.opendaylight.controller - - jar - - features.xml - - - - - - - - - org.opendaylight.yangtools - features-yangtools - ${yangtools.version} - features - xml - - - org.opendaylight.controller - features-mdsal - ${mdsal.version} - features - xml - - - - - org.opendaylight.controller - sal-remote - - - - org.opendaylight.controller - sal-rest-connector - - - - com.google.code.gson - gson - - - - com.sun.jersey - jersey-core - - - com.sun.jersey - jersey-server - - - com.sun.jersey - jersey-servlet - - - io.netty - netty-buffer - - - io.netty - netty-codec - - - io.netty - netty-codec-http - - - io.netty - netty-common - - - io.netty - netty-handler - - - io.netty - netty-transport - - - - org.opendaylight.controller - sal-rest-connector-config - ${mdsal.version} - xml - config - - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.datatype - jackson-datatype-json-org - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - com.fasterxml.jackson.jaxrs - jackson-jaxrs-base - - - com.fasterxml.jackson.jaxrs - jackson-jaxrs-json-provider - - - org.json - json - - - - org.opendaylight.yangtools - yang-data-codec-gson - - - - org.opendaylight.controller.samples - clustering-it-model - ${mdsal.version} - - - org.opendaylight.controller.samples - clustering-it-provider - ${mdsal.version} - - - org.opendaylight.controller.samples - clustering-it-config - ${mdsal.version} - xml - config - - - org.opendaylight.controller.samples - clustering-it-config - ${mdsal.version} - xml - testmoduleshardconf - - - org.opendaylight.controller.samples - clustering-it-config - ${mdsal.version} - xml - testmoduleconf - - - org.opendaylight.controller - sal-rest-docgen - - - - - - org.opendaylight.odlparent - features-test - test - - - - org.opendaylight.controller - opendaylight-karaf-empty - ${commons.opendaylight.version} - zip - - - - - - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - generate-resources - - resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - package - - attach-artifact - - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - org.opendaylight.controller - opendaylight-karaf-empty - ${commons.opendaylight.version} - - - org.opendaylight.odlparent:features-test - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=summary - - diff --git a/features/restconf/src/main/resources/features.xml b/features/restconf/src/main/resources/features.xml deleted file mode 100644 index 87cab842d9..0000000000 --- a/features/restconf/src/main/resources/features.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features - mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features - - - - odl-restconf - odl-mdsal-apidocs - - - - - - odl-restconf-noauth - - - odl-mdsal-broker - war - - mvn:org.opendaylight.controller/sal-remote/${project.version} - mvn:org.opendaylight.controller/sal-rest-connector/${project.version} - mvn:com.google.code.gson/gson/${gson.version} - mvn:org.opendaylight.yangtools/yang-data-codec-gson/${yangtools.version} - mvn:org.opendaylight.yangtools/yang-model-export/${yangtools.version} - mvn:com.sun.jersey/jersey-core/${jersey.version} - mvn:com.sun.jersey/jersey-server/${jersey.version} - mvn:com.sun.jersey/jersey-servlet/${jersey.version} - mvn:io.netty/netty-buffer/${netty.version} - mvn:io.netty/netty-codec/${netty.version} - mvn:io.netty/netty-codec-http/${netty.version} - mvn:io.netty/netty-common/${netty.version} - mvn:io.netty/netty-handler/${netty.version} - mvn:io.netty/netty-transport/${netty.version} - mvn:org.opendaylight.controller/sal-rest-connector-config/${mdsal.version}/xml/config - - - odl-restconf - mvn:org.opendaylight.controller/sal-rest-docgen/${project.version} - mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version} - mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version} - mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version} - mvn:com.fasterxml.jackson.datatype/jackson-datatype-json-org/${jackson.version} - mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/${jackson.version} - mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/${jackson.version} - mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/${jackson.version} - mvn:com.sun.jersey/jersey-core/${jersey.version} - mvn:com.sun.jersey/jersey-server/${jersey.version} - mvn:com.sun.jersey/jersey-servlet/${jersey.version} - wrap:mvn:org.json/json/${org.json.version} - - - - odl-restconf - odl-toaster - - - - odl-mdsal-apidocs - odl-mdsal-xsql - odl-toaster-rest - - - - diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index baa85ff788..6df1185663 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -45,16 +45,9 @@ sal-remote - sal-restconf-broker sal-connector-api - sal-rest-connector - sal-rest-connector-config - - - sal-rest-docgen - sal-rest-docgen-maven sal-akka-raft sal-akka-raft-example diff --git a/opendaylight/md-sal/sal-rest-connector-config/pom.xml b/opendaylight/md-sal/sal-rest-connector-config/pom.xml deleted file mode 100644 index 7be6cecc8c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector-config/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - 4.0.0 - - org.opendaylight.controller - sal-parent - 1.3.0-SNAPSHOT - - sal-rest-connector-config - Configuration files for sal-rest-connector - jar - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/initial/10-rest-connector.xml - xml - config - - - - - - - - - diff --git a/opendaylight/md-sal/sal-rest-connector-config/src/main/resources/initial/10-rest-connector.xml b/opendaylight/md-sal/sal-rest-connector-config/src/main/resources/initial/10-rest-connector.xml deleted file mode 100644 index 3be423c356..0000000000 --- a/opendaylight/md-sal/sal-rest-connector-config/src/main/resources/initial/10-rest-connector.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - rest:rest-connector-impl - rest-connector-default-impl - 8185 - - dom:dom-broker-osgi-registry - dom-broker - - - - - - - rest:rest-connector - - rest-connector-default - - /modules/module[type='rest-connector-impl'][name='rest-connector-default-impl'] - - - - - - - - urn:opendaylight:params:xml:ns:yang:controller:md:sal:rest:connector?module=opendaylight-rest-connector&revision=2014-07-24 - - diff --git a/opendaylight/md-sal/sal-rest-connector/pom.xml b/opendaylight/md-sal/sal-rest-connector/pom.xml deleted file mode 100644 index 49c654c680..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/pom.xml +++ /dev/null @@ -1,193 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - sal-parent - 1.3.0-SNAPSHOT - - sal-rest-connector - bundle - - - - ${project.groupId} - sal-connector-api - - - ${project.groupId} - sal-core-api - - - ${project.groupId} - sal-dom-config - - - ${project.groupId} - config-api - - - com.google.code.gson - gson - - - io.netty - netty-codec-http - - - org.apache.commons - commons-lang3 - - - org.opendaylight.controller - sal-common-util - - - org.opendaylight.controller - sal-common-impl - - - org.opendaylight.controller - sal-binding-broker-impl - - - org.opendaylight.controller - sal-remote - - - org.opendaylight.yangtools - yang-data-impl - - - org.opendaylight.yangtools - yang-model-util - - - org.opendaylight.yangtools - yang-parser-impl - - - org.opendaylight.yangtools.model - ietf-restconf - - - org.opendaylight.yangtools.model - ietf-yang-types-20130715 - - - org.opendaylight.yangtools.model - ietf-inet-types - - - org.slf4j - slf4j-api - - - org.jboss.resteasy - jaxrs-api - provided - - - org.opendaylight.controller - sal-core-spi - - - org.opendaylight.yangtools - yang-data-codec-gson - - - org.opendaylight.yangtools - yang-model-export - - 0.8.0-SNAPSHOT - - - - net.java.dev.stax-utils - stax-utils - 20070216 - - - - ch.qos.logback - logback-classic - test - - - - - junit - junit - test - - - org.glassfish.jersey.test-framework.providers - jersey-test-framework-provider-grizzly2 - test - - - org.mockito - mockito-all - test - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - MD SAL Restconf Connector - org.opendaylight.controller.sal.rest.*, - org.opendaylight.controller.sal.restconf.rpc.*, - org.opendaylight.controller.sal.restconf.impl, - org.opendaylight.controller.md.sal.rest.common.*, - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.rest.connector.rev140724.*, - - *, - com.sun.jersey.spi.container.servlet, org.eclipse.jetty.servlets - stax-utils - /restconf - - - - - org.opendaylight.yangtools - yang-maven-plugin - - - config - - generate-sources - - - - - org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - ${jmxGeneratorPath} - - urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang - - - - org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - ${salGeneratorPath} - - - true - - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModule.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModule.java deleted file mode 100644 index fe20e3a441..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModule.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.opendaylight.controller.config.yang.md.sal.rest.connector; - -import org.opendaylight.controller.sal.restconf.impl.RestconfProviderImpl; - - -public class RestConnectorModule extends org.opendaylight.controller.config.yang.md.sal.rest.connector.AbstractRestConnectorModule { - - private static RestConnectorRuntimeRegistration runtimeRegistration; - - public RestConnectorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public RestConnectorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorModule oldModule, java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - // Create an instance of our provider - RestconfProviderImpl instance = new RestconfProviderImpl(); - // Set its port - instance.setWebsocketPort(getWebsocketPort()); - // Register it with the Broker - getDomBrokerDependency().registerProvider(instance); - - if(runtimeRegistration != null){ - runtimeRegistration.close(); - } - - runtimeRegistration = - getRootRuntimeBeanRegistratorWrapper().register(instance); - - return instance; - } -} - diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModuleFactory.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModuleFactory.java deleted file mode 100644 index 1964a17472..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModuleFactory.java +++ /dev/null @@ -1,14 +0,0 @@ -/* -* Generated file -* -* Generated from: yang module name: opendaylight-rest-connector yang module local name: rest-connector-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Fri Jul 25 04:33:31 CDT 2014 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.md.sal.rest.connector; - -public class RestConnectorModuleFactory extends org.opendaylight.controller.config.yang.md.sal.rest.connector.AbstractRestConnectorModuleFactory { - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/common/RestconfValidationUtils.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/common/RestconfValidationUtils.java deleted file mode 100644 index 0d53c9c486..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/common/RestconfValidationUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.rest.common; - -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; - -/** - * sal-rest-connector - * org.opendaylight.controller.md.sal.rest.common - * - * Utility class is centralizing all needed validation functionality for a Restconf osgi module. - * All methods have to throw {@link RestconfDocumentedException} only, which is a representation - * for all error situation followed by restconf-netconf specification. - * @see {@link https://tools.ietf.org/html/draft-bierman-netconf-restconf-02} - * - * @author Vaclav Demcak - * - * Created: Feb 24, 2015 - */ -public class RestconfValidationUtils { - - private RestconfValidationUtils () { - throw new UnsupportedOperationException("Utility class"); - } - - /** - * Method returns {@link RestconfDocumentedException} for a false condition. - * - * @param condition - condition for rise {@link RestconfDocumentedException} - * @param type - input {@link ErrorType} for create {@link RestconfDocumentedException} - * @param tag - input {@link ErrorTag} for create {@link RestconfDocumentedException} - * @param message - input error message for create {@link RestconfDocumentedException} - */ - public static void checkDocumentedError(final boolean condition, final ErrorType type, - final ErrorTag tag, final String message) { - if(!condition) { - throw new RestconfDocumentedException(message, type, tag); - } - } - - /** - * Method returns {@link RestconfDocumentedException} if value is NULL or same input value. - * {@link ErrorType} is relevant for server application layer - * {@link ErrorTag} is 404 data-missing - * @see {@link https://tools.ietf.org/html/draft-bierman-netconf-restconf-02} - * - * @param value - some value from {@link org.opendaylight.yangtools.yang.model.api.Module} - * @param moduleName - name of {@link org.opendaylight.yangtools.yang.model.api.Module} - * @return - T value (same input value) - */ - public static T checkNotNullDocumented(final T value, final String moduleName) { - if(value == null) { - final String errMsg = "Module " + moduleName + "was not found."; - throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.DATA_MISSING); - } - return value; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java deleted file mode 100644 index 20300e24f6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.rest.schema; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; - -@Provider -@Produces(SchemaRetrievalService.YANG_MEDIA_TYPE) -public class SchemaExportContentYangBodyWriter implements MessageBodyWriter { - - @Override - public boolean isWriteable(final Class type, final Type genericType, final Annotation[] annotations, - final MediaType mediaType) { - return type.equals(SchemaExportContext.class); - } - - @Override - public long getSize(final SchemaExportContext t, final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType) { - return -1; - } - - @Override - public void writeTo(final SchemaExportContext t, final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType, - final MultivaluedMap httpHeaders, final OutputStream entityStream) throws IOException, - WebApplicationException { - final PrintWriter writer = new PrintWriter(entityStream); - writer.write(t.getModule().getSource()); - - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContentYinBodyWriter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContentYinBodyWriter.java deleted file mode 100644 index 9773c0afc0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContentYinBodyWriter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.rest.schema; - -import java.io.IOException; -import java.io.OutputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; -import javax.xml.stream.XMLStreamException; -import org.opendaylight.yangtools.yang.model.export.YinExportUtils; - -@Provider -@Produces(SchemaRetrievalService.YIN_MEDIA_TYPE) -public class SchemaExportContentYinBodyWriter implements MessageBodyWriter { - - @Override - public boolean isWriteable(final Class type, final Type genericType, final Annotation[] annotations, - final MediaType mediaType) { - return type.equals(SchemaExportContext.class); - } - - @Override - public long getSize(final SchemaExportContext t, final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType) { - return -1; - } - - @Override - public void writeTo(final SchemaExportContext t, final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType, - final MultivaluedMap httpHeaders, final OutputStream entityStream) throws IOException, - WebApplicationException { - try { - YinExportUtils.writeModuleToOutputStream(t.getSchemaContext(), t.getModule(), entityStream); - } catch (final XMLStreamException e) { - throw new IllegalStateException(e); - } - - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContext.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContext.java deleted file mode 100644 index 4d3c95faa9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaExportContext.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.rest.schema; - -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class SchemaExportContext { - - private final SchemaContext schemaContext; - private final Module module; - - public SchemaExportContext(final SchemaContext ctx, final Module module) { - schemaContext = ctx; - this.module = module; - } - - public SchemaContext getSchemaContext() { - return schemaContext; - } - - public Module getModule() { - return module; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaRetrievalService.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaRetrievalService.java deleted file mode 100644 index b268247d51..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaRetrievalService.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.rest.schema; - -import com.google.common.annotations.Beta; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; - -@Beta -public interface SchemaRetrievalService { - - public static final String YANG_MEDIA_TYPE = "application/yang"; - public static final String YIN_MEDIA_TYPE = "application/yin+xml"; - - @GET - @Produces({YIN_MEDIA_TYPE,YANG_MEDIA_TYPE}) - @Path("/modules/module/{identifier:.+}/schema") - SchemaExportContext getSchema(@PathParam("identifier") String mountAndModuleId); -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaRetrievalServiceImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaRetrievalServiceImpl.java deleted file mode 100644 index 3d32427b18..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/md/sal/rest/schema/SchemaRetrievalServiceImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.rest.schema; - -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; -import java.text.ParseException; -import java.util.Date; -import java.util.Iterator; -import org.opendaylight.controller.md.sal.rest.common.RestconfValidationUtils; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class SchemaRetrievalServiceImpl implements SchemaRetrievalService { - - private final ControllerContext salContext; - - private static final Splitter SLASH_SPLITTER = Splitter.on("/"); - private static final String MOUNT_ARG = ControllerContext.MOUNT; - - public SchemaRetrievalServiceImpl(final ControllerContext controllerContext) { - salContext = controllerContext; - } - - - @Override - public SchemaExportContext getSchema(final String mountAndModule) { - final SchemaContext schemaContext; - final Iterable pathComponents = SLASH_SPLITTER.split(mountAndModule); - final Iterator componentIter = pathComponents.iterator(); - if(!Iterables.contains(pathComponents, MOUNT_ARG)) { - schemaContext = salContext.getGlobalSchema(); - } else { - final StringBuilder pathBuilder = new StringBuilder(); - while(componentIter.hasNext()) { - final String current = componentIter.next(); - // It is argument, not last element. - if(pathBuilder.length() != 0) { - pathBuilder.append("/"); - } - pathBuilder.append(current); - if(MOUNT_ARG.equals(current)) { - // We stop right at mountpoint, last two arguments should - // be module name and revision - break; - } - } - schemaContext = getMountSchemaContext(pathBuilder.toString()); - - } - - RestconfValidationUtils.checkDocumentedError(componentIter.hasNext(), - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, "Module name must be supplied."); - final String moduleName = componentIter.next(); - RestconfValidationUtils.checkDocumentedError(componentIter.hasNext(), - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, "Revision date must be supplied."); - final String revisionString = componentIter.next(); - return getExportUsingNameAndRevision(schemaContext, moduleName, revisionString); - } - - private SchemaExportContext getExportUsingNameAndRevision(final SchemaContext schemaContext, final String moduleName, - final String revisionStr) { - try { - final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse(revisionStr); - final Module module = schemaContext.findModuleByName(moduleName, revision); - return new SchemaExportContext(schemaContext, RestconfValidationUtils.checkNotNullDocumented(module, moduleName)); - } catch (final ParseException e) { - throw new RestconfDocumentedException("Supplied revision is not in expected date format YYYY-mm-dd", e); - } - } - - private SchemaContext getMountSchemaContext(final String identifier) { - final InstanceIdentifierContext mountContext = salContext.toMountPointIdentifier(identifier); - return mountContext.getSchemaContext(); - } - - - -} - diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/Draft02.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/Draft02.java deleted file mode 100644 index 51ac43be7c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/Draft02.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.api; - -import org.opendaylight.yangtools.yang.common.QName; - -public class Draft02 { - public static interface MediaTypes { - String API = "application/yang.api"; - String DATASTORE = "application/yang.datastore"; - String DATA = "application/yang.data"; - String OPERATION = "application/yang.operation"; - String PATCH = "application/yang.patch"; - String PATCH_STATUS = "application/yang.patch-status"; - String STREAM = "application/yang.stream"; - } - - public static interface RestConfModule { - String REVISION = "2013-10-19"; - - String NAME = "ietf-restconf"; - - String NAMESPACE = "urn:ietf:params:xml:ns:yang:ietf-restconf"; - - String RESTCONF_GROUPING_SCHEMA_NODE = "restconf"; - - String RESTCONF_CONTAINER_SCHEMA_NODE = "restconf"; - - String MODULES_CONTAINER_SCHEMA_NODE = "modules"; - - String MODULE_LIST_SCHEMA_NODE = "module"; - - String STREAMS_CONTAINER_SCHEMA_NODE = "streams"; - - String STREAM_LIST_SCHEMA_NODE = "stream"; - - String OPERATIONS_CONTAINER_SCHEMA_NODE = "operations"; - - String ERRORS_GROUPING_SCHEMA_NODE = "errors"; - - String ERRORS_CONTAINER_SCHEMA_NODE = "errors"; - - String ERROR_LIST_SCHEMA_NODE = "error"; - - QName IETF_RESTCONF_QNAME = QName.create(Draft02.RestConfModule.NAMESPACE, Draft02.RestConfModule.REVISION, - Draft02.RestConfModule.NAME); - - QName ERRORS_CONTAINER_QNAME = QName.create(IETF_RESTCONF_QNAME, ERRORS_CONTAINER_SCHEMA_NODE); - - QName ERROR_LIST_QNAME = QName.create(IETF_RESTCONF_QNAME, ERROR_LIST_SCHEMA_NODE); - - QName ERROR_TYPE_QNAME = QName.create(IETF_RESTCONF_QNAME, "error-type"); - - QName ERROR_TAG_QNAME = QName.create(IETF_RESTCONF_QNAME, "error-tag"); - - QName ERROR_APP_TAG_QNAME = QName.create(IETF_RESTCONF_QNAME, "error-app-tag"); - - QName ERROR_MESSAGE_QNAME = QName.create(IETF_RESTCONF_QNAME, "error-message"); - - QName ERROR_INFO_QNAME = QName.create(IETF_RESTCONF_QNAME, "error-info"); - } - - public static interface Paths { - - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestConnector.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestConnector.java deleted file mode 100644 index 73906d79ed..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestConnector.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.api; - -/* - * This is a simple dummy interface to allow us to create instances of RestconfProvider - * via the config subsystem. - */ -public interface RestConnector { - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfConstants.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfConstants.java deleted file mode 100644 index 206c2cdcee..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.api; - -public interface RestconfConstants { - - - public static String IDENTIFIER = "identifier"; -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfNormalizedNodeWriter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfNormalizedNodeWriter.java deleted file mode 100644 index 5fb01767a9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfNormalizedNodeWriter.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.api; - -import java.io.Closeable; -import java.io.Flushable; -import java.io.IOException; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -public interface RestconfNormalizedNodeWriter extends Flushable, Closeable { - - RestconfNormalizedNodeWriter write(final NormalizedNode node) throws IOException; -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java deleted file mode 100644 index e95d61cae0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.api; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.Encoded; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; - -/** - * The URI hierarchy for the RESTCONF resources consists of an entry point container, 4 top-level resources, and 1 - * field. - *
    - *
  • /restconf - {@link #getRoot()} - *
      - *
    • /config - {@link #readConfigurationData(String)} - * {@link #updateConfigurationData(String, NormalizedNodeContext)} - * {@link #createConfigurationData(NormalizedNodeContext)} - * {@link #createConfigurationData(String, NormalizedNodeContext)} - * {@link #deleteConfigurationData(String)} - *
    • /operational - {@link #readOperationalData(String)} - *
    • /modules - {@link #getModules()} - *
        - *
      • /module - *
      - *
    • /operations - {@link #invokeRpc(String, NormalizedNodeContext)} - * {@link #invokeRpc(String, NormalizedNodeContext)} - *
    • /version (field) - *
    - *
- */ -@Path("/") -public interface RestconfService { - - public static final String XML = "+xml"; - public static final String JSON = "+json"; - - @GET - public Object getRoot(); - - @GET - @Path("/modules") - @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext getModules(@Context UriInfo uriInfo); - - @GET - @Path("/modules/{identifier:.+}") - @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext getModules(@PathParam("identifier") String identifier, @Context UriInfo uriInfo); - - @GET - @Path("/modules/module/{identifier:.+}") - @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext getModule(@PathParam("identifier") String identifier, @Context UriInfo uriInfo); - - @GET - @Path("/operations") - @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext getOperations(@Context UriInfo uriInfo); - - @GET - @Path("/operations/{identifier:.+}") - @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext getOperations(@PathParam("identifier") String identifier, @Context UriInfo uriInfo); - - @POST - @Path("/operations/{identifier:.+}") - @Produces({ Draft02.MediaTypes.OPERATION + JSON, Draft02.MediaTypes.OPERATION + XML, - Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - @Consumes({ Draft02.MediaTypes.OPERATION + JSON, Draft02.MediaTypes.OPERATION + XML, - Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext invokeRpc(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload, - @Context UriInfo uriInfo); - - @POST - @Path("/operations/{identifier:.+}") - @Produces({ Draft02.MediaTypes.OPERATION + JSON, Draft02.MediaTypes.OPERATION + XML, - Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - @Deprecated // method isn't use anywhere - public NormalizedNodeContext invokeRpc(@Encoded @PathParam("identifier") String identifier, - @DefaultValue("") String noPayload, @Context UriInfo uriInfo); - - @GET - @Path("/config/{identifier:.+}") - @Produces({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext readConfigurationData(@Encoded @PathParam("identifier") String identifier, - @Context UriInfo uriInfo); - - @GET - @Path("/operational/{identifier:.+}") - @Produces({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext readOperationalData(@Encoded @PathParam("identifier") String identifier, - @Context UriInfo uriInfo); - - @PUT - @Path("/config/{identifier:.+}") - @Consumes({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response updateConfigurationData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload); - - @POST - @Path("/config/{identifier:.+}") - @Consumes({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response createConfigurationData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload, - @Context UriInfo uriInfo); - - @POST - @Path("/config") - @Consumes({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response createConfigurationData(NormalizedNodeContext payload, @Context UriInfo uriInfo); - - @DELETE - @Path("/config/{identifier:.+}") - public Response deleteConfigurationData(@Encoded @PathParam("identifier") String identifier); - - @GET - @Path("/streams/stream/{identifier:.+}") - public Response subscribeToStream(@Encoded @PathParam("identifier") String identifier, @Context UriInfo uriInfo); - - @GET - @Path("/streams") - @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public NormalizedNodeContext getAvailableStreams(@Context UriInfo uriInfo); - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/package-info.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/package-info.java deleted file mode 100644 index 49d8d66a3f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.api; - diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/AbstractIdentifierAwareJaxRsProvider.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/AbstractIdentifierAwareJaxRsProvider.java deleted file mode 100644 index bb41209aee..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/AbstractIdentifierAwareJaxRsProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Request; -import javax.ws.rs.core.UriInfo; -import org.opendaylight.controller.sal.rest.api.RestconfConstants; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; - -public class AbstractIdentifierAwareJaxRsProvider { - - private static final String POST = "POST"; - - @Context - private UriInfo uriInfo; - - @Context - private Request request; - - protected final String getIdentifier() { - return uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER); - } - - protected InstanceIdentifierContext getInstanceIdentifierContext() { - return ControllerContext.getInstance().toInstanceIdentifier(getIdentifier()); - } - - protected UriInfo getUriInfo() { - return uriInfo; - } - - protected boolean isPost() { - return POST.equals(request.getMethod()); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/DepthAwareNormalizedNodeWriter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/DepthAwareNormalizedNodeWriter.java deleted file mode 100644 index c439ee66e3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/DepthAwareNormalizedNodeWriter.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -import static org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter.UNKNOWN_SIZE; -import com.google.common.annotations.Beta; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import java.io.IOException; -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import org.opendaylight.controller.sal.rest.api.RestconfNormalizedNodeWriter; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; -import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; -import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamAttributeWriter; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This is an experimental iterator over a {@link NormalizedNode}. This is essentially - * the opposite of a {@link XMLStreamReader} -- unlike instantiating an iterator over - * the backing data, this encapsulates a {@link NormalizedNodeStreamWriter} and allows - * us to write multiple nodes. - */ -@Beta -public class DepthAwareNormalizedNodeWriter implements RestconfNormalizedNodeWriter { - private final NormalizedNodeStreamWriter writer; - protected int currentDepth = 0; - protected final int maxDepth; - - private DepthAwareNormalizedNodeWriter(final NormalizedNodeStreamWriter writer, final int maxDepth) { - this.writer = Preconditions.checkNotNull(writer); - this.maxDepth = maxDepth; - } - - protected final NormalizedNodeStreamWriter getWriter() { - return writer; - } - - /** - * Create a new writer backed by a {@link NormalizedNodeStreamWriter}. - * - * @param writer Back-end writer - * @return A new instance. - */ - public static DepthAwareNormalizedNodeWriter forStreamWriter(final NormalizedNodeStreamWriter writer, final int maxDepth) { - return forStreamWriter(writer, true, maxDepth); - } - - /** - * Create a new writer backed by a {@link NormalizedNodeStreamWriter}. Unlike the simple {@link #forStreamWriter(NormalizedNodeStreamWriter)} - * method, this allows the caller to switch off RFC6020 XML compliance, providing better - * throughput. The reason is that the XML mapping rules in RFC6020 require the encoding - * to emit leaf nodes which participate in a list's key first and in the order in which - * they are defined in the key. For JSON, this requirement is completely relaxed and leaves - * can be ordered in any way we see fit. The former requires a bit of work: first a lookup - * for each key and then for each emitted node we need to check whether it was already - * emitted. - * - * @param writer Back-end writer - * @param orderKeyLeaves whether the returned instance should be RFC6020 XML compliant. - * @return A new instance. - */ - public static DepthAwareNormalizedNodeWriter forStreamWriter(final NormalizedNodeStreamWriter writer, final boolean - orderKeyLeaves, final int maxDepth) { - if (orderKeyLeaves) { - return new OrderedDepthAwareNormalizedNodeWriter(writer, maxDepth); - } else { - return new DepthAwareNormalizedNodeWriter(writer, maxDepth); - } - } - - /** - * Iterate over the provided {@link NormalizedNode} and emit write - * events to the encapsulated {@link NormalizedNodeStreamWriter}. - * - * @param node Node - * @return - * @throws IOException when thrown from the backing writer. - */ - public final DepthAwareNormalizedNodeWriter write(final NormalizedNode node) throws IOException { - if (wasProcessedAsCompositeNode(node)) { - return this; - } - - if (wasProcessAsSimpleNode(node)) { - return this; - } - - throw new IllegalStateException("It wasn't possible to serialize node " + node); - } - - @Override - public void flush() throws IOException { - writer.flush(); - } - - @Override - public void close() throws IOException { - writer.flush(); - writer.close(); - } - - /** - * Emit a best guess of a hint for a particular set of children. It evaluates the - * iterable to see if the size can be easily gotten to. If it is, we hint at the - * real number of child nodes. Otherwise we emit UNKNOWN_SIZE. - * - * @param children Child nodes - * @return Best estimate of the collection size required to hold all the children. - */ - static final int childSizeHint(final Iterable children) { - return (children instanceof Collection) ? ((Collection) children).size() : UNKNOWN_SIZE; - } - - private boolean wasProcessAsSimpleNode(final NormalizedNode node) throws IOException { - if (node instanceof LeafSetEntryNode) { - if (currentDepth < maxDepth) { - final LeafSetEntryNode nodeAsLeafList = (LeafSetEntryNode) node; - if (writer instanceof NormalizedNodeStreamAttributeWriter) { - ((NormalizedNodeStreamAttributeWriter) writer).leafSetEntryNode(nodeAsLeafList.getValue(), nodeAsLeafList.getAttributes()); - } else { - writer.leafSetEntryNode(nodeAsLeafList.getValue()); - } - } - return true; - } else if (node instanceof LeafNode) { - final LeafNode nodeAsLeaf = (LeafNode)node; - if(writer instanceof NormalizedNodeStreamAttributeWriter) { - ((NormalizedNodeStreamAttributeWriter) writer).leafNode(nodeAsLeaf.getIdentifier(), nodeAsLeaf.getValue(), nodeAsLeaf.getAttributes()); - } else { - writer.leafNode(nodeAsLeaf.getIdentifier(), nodeAsLeaf.getValue()); - } - return true; - } else if (node instanceof AnyXmlNode) { - final AnyXmlNode anyXmlNode = (AnyXmlNode)node; - writer.anyxmlNode(anyXmlNode.getIdentifier(), anyXmlNode.getValue()); - return true; - } - - return false; - } - - /** - * Emit events for all children and then emit an endNode() event. - * - * @param children Child iterable - * @return True - * @throws IOException when the writer reports it - */ - protected final boolean writeChildren(final Iterable> children) throws IOException { - if (currentDepth < maxDepth) { - for (NormalizedNode child : children) { - write(child); - } - } - writer.endNode(); - return true; - } - - protected boolean writeMapEntryChildren(final MapEntryNode mapEntryNode) throws IOException { - if (currentDepth < maxDepth) { - writeChildren(mapEntryNode.getValue()); - } else if (currentDepth == maxDepth) { - writeOnlyKeys(mapEntryNode.getIdentifier().getKeyValues()); - } - return true; - } - - private void writeOnlyKeys(Map keyValues) throws IllegalArgumentException, IOException { - for (Map.Entry entry : keyValues.entrySet()) { - writer.leafNode(new NodeIdentifier(entry.getKey()), entry.getValue()); - } - writer.endNode(); - - } - - protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException { - if(writer instanceof NormalizedNodeStreamAttributeWriter) { - ((NormalizedNodeStreamAttributeWriter) writer) - .startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); - } else { - writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); - } - currentDepth++; - writeMapEntryChildren(node); - currentDepth--; - return true; - } - - private boolean wasProcessedAsCompositeNode(final NormalizedNode node) throws IOException { - boolean processedAsCompositeNode = false; - if (node instanceof ContainerNode) { - final ContainerNode n = (ContainerNode) node; - if(writer instanceof NormalizedNodeStreamAttributeWriter) { - ((NormalizedNodeStreamAttributeWriter) writer).startContainerNode(n.getIdentifier(), childSizeHint(n.getValue()), n.getAttributes()); - } else { - writer.startContainerNode(n.getIdentifier(), childSizeHint(n.getValue())); - } - currentDepth++; - processedAsCompositeNode = writeChildren(n.getValue()); - currentDepth--; - } - else if (node instanceof MapEntryNode) { - processedAsCompositeNode = writeMapEntryNode((MapEntryNode) node); - } - else if (node instanceof UnkeyedListEntryNode) { - final UnkeyedListEntryNode n = (UnkeyedListEntryNode) node; - writer.startUnkeyedListItem(n.getIdentifier(), childSizeHint(n.getValue())); - currentDepth++; - processedAsCompositeNode = writeChildren(n.getValue()); - currentDepth--; - } - else if (node instanceof ChoiceNode) { - final ChoiceNode n = (ChoiceNode) node; - writer.startChoiceNode(n.getIdentifier(), childSizeHint(n.getValue())); - processedAsCompositeNode = writeChildren(n.getValue()); - } - else if (node instanceof AugmentationNode) { - final AugmentationNode n = (AugmentationNode) node; - writer.startAugmentationNode(n.getIdentifier()); - processedAsCompositeNode = writeChildren(n.getValue()); - } - else if (node instanceof UnkeyedListNode) { - final UnkeyedListNode n = (UnkeyedListNode) node; - writer.startUnkeyedList(n.getIdentifier(), childSizeHint(n.getValue())); - processedAsCompositeNode = writeChildren(n.getValue()); - } - else if (node instanceof OrderedMapNode) { - final OrderedMapNode n = (OrderedMapNode) node; - writer.startOrderedMapNode(n.getIdentifier(), childSizeHint(n.getValue())); - processedAsCompositeNode = writeChildren(n.getValue()); - } - else if (node instanceof MapNode) { - final MapNode n = (MapNode) node; - writer.startMapNode(n.getIdentifier(), childSizeHint(n.getValue())); - processedAsCompositeNode = writeChildren(n.getValue()); - } - else if (node instanceof LeafSetNode) { - //covers also OrderedLeafSetNode for which doesn't exist start* method - final LeafSetNode n = (LeafSetNode) node; - writer.startLeafSet(n.getIdentifier(), childSizeHint(n.getValue())); - currentDepth++; - processedAsCompositeNode = writeChildren(n.getValue()); - currentDepth--; - } - - return processedAsCompositeNode; - } - - private static final class OrderedDepthAwareNormalizedNodeWriter extends DepthAwareNormalizedNodeWriter { - private static final Logger LOG = LoggerFactory.getLogger(OrderedDepthAwareNormalizedNodeWriter.class); - - OrderedDepthAwareNormalizedNodeWriter(final NormalizedNodeStreamWriter writer, final int maxDepth) { - super(writer, maxDepth); - } - - @Override - protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException { - final NormalizedNodeStreamWriter writer = getWriter(); - if(writer instanceof NormalizedNodeStreamAttributeWriter) { - ((NormalizedNodeStreamAttributeWriter) writer).startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); - } else { - writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); - } - - final Set qnames = node.getIdentifier().getKeyValues().keySet(); - // Write out all the key children - for (QName qname : qnames) { - final Optional> child = node.getChild(new NodeIdentifier(qname)); - if (child.isPresent()) { - write(child.get()); - } else { - LOG.info("No child for key element {} found", qname); - } - } - - // Write all the rest - currentDepth++; - boolean result = writeChildren(Iterables.filter(node.getValue(), new Predicate>() { - @Override - public boolean apply(final NormalizedNode input) { - if (input instanceof AugmentationNode) { - return true; - } - if (!qnames.contains(input.getNodeType())) { - return true; - } - - LOG.debug("Skipping key child {}", input); - return false; - } - })); - currentDepth--; - return result; - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java deleted file mode 100644 index 42024cab08..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -import com.google.common.collect.Iterables; -import com.google.gson.stream.JsonReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.Provider; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.api.RestconfService; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; -import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult; -import org.opendaylight.yangtools.yang.data.impl.schema.ResultAlreadySetException; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Provider -@Consumes({ Draft02.MediaTypes.DATA + RestconfService.JSON, Draft02.MediaTypes.OPERATION + RestconfService.JSON, - MediaType.APPLICATION_JSON }) -public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsProvider implements MessageBodyReader { - - private final static Logger LOG = LoggerFactory.getLogger(JsonNormalizedNodeBodyReader.class); - - @Override - public boolean isReadable(final Class type, final Type genericType, final Annotation[] annotations, - final MediaType mediaType) { - return true; - } - - @Override - public NormalizedNodeContext readFrom(final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType, - final MultivaluedMap httpHeaders, final InputStream entityStream) throws IOException, - WebApplicationException { - try { - final InstanceIdentifierContext path = getInstanceIdentifierContext(); - if (entityStream.available() < 1) { - return new NormalizedNodeContext(path, null); - } - final NormalizedNodeResult resultHolder = new NormalizedNodeResult(); - final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder); - - final SchemaNode parentSchema; - if(isPost()) { - // FIXME: We need dispatch for RPC. - parentSchema = path.getSchemaNode(); - } else if(path.getSchemaNode() instanceof SchemaContext) { - parentSchema = path.getSchemaContext(); - } else { - if (SchemaPath.ROOT.equals(path.getSchemaNode().getPath().getParent())) { - parentSchema = path.getSchemaContext(); - } else { - parentSchema = SchemaContextUtil.findDataSchemaNode(path.getSchemaContext(), path.getSchemaNode().getPath().getParent()); - } - } - - final JsonParserStream jsonParser = JsonParserStream.create(writer, path.getSchemaContext(), parentSchema); - final JsonReader reader = new JsonReader(new InputStreamReader(entityStream)); - jsonParser.parse(reader); - - NormalizedNode result = resultHolder.getResult(); - final List iiToDataList = new ArrayList<>(); - InstanceIdentifierContext newIIContext; - - while (result instanceof AugmentationNode || result instanceof ChoiceNode) { - final Object childNode = ((DataContainerNode) result).getValue().iterator().next(); - if (isPost()) { - iiToDataList.add(result.getIdentifier()); - } - result = (NormalizedNode) childNode; - } - - if (isPost()) { - if (result instanceof MapEntryNode) { - iiToDataList.add(new YangInstanceIdentifier.NodeIdentifier(result.getNodeType())); - iiToDataList.add(result.getIdentifier()); - } else { - iiToDataList.add(result.getIdentifier()); - } - } else { - if (result instanceof MapNode) { - result = Iterables.getOnlyElement(((MapNode) result).getValue()); - } - } - - final YangInstanceIdentifier fullIIToData = YangInstanceIdentifier.create(Iterables.concat( - path.getInstanceIdentifier().getPathArguments(), iiToDataList)); - - newIIContext = new InstanceIdentifierContext<>(fullIIToData, path.getSchemaNode(), path.getMountPoint(), - path.getSchemaContext()); - - return new NormalizedNodeContext(newIIContext, result); - } catch (final RestconfDocumentedException e) { - throw e; - } catch (final ResultAlreadySetException e) { - LOG.debug("Error parsing json input:", e); - - throw new RestconfDocumentedException("Error parsing json input: Failed to create new parse result data. " + - "Are you creating multiple resources/subresources in POST request?"); - } catch (final Exception e) { - LOG.debug("Error parsing json input", e); - - throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL, - ErrorTag.MALFORMED_MESSAGE); - } - } -} - diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeJsonBodyWriter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeJsonBodyWriter.java deleted file mode 100644 index 2cdded2813..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeJsonBodyWriter.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -import com.google.common.base.Charsets; -import com.google.common.base.Optional; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.net.URI; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.api.RestconfNormalizedNodeWriter; -import org.opendaylight.controller.sal.rest.api.RestconfService; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory; -import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Provider -@Produces({ Draft02.MediaTypes.API + RestconfService.JSON, Draft02.MediaTypes.DATA + RestconfService.JSON, - Draft02.MediaTypes.OPERATION + RestconfService.JSON, MediaType.APPLICATION_JSON }) -public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter { - - private static final int DEFAULT_INDENT_SPACES_NUM = 2; - - @Override - public boolean isWriteable(final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) { - return type.equals(NormalizedNodeContext.class); - } - - @Override - public long getSize(final NormalizedNodeContext t, final Class type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) { - return -1; - } - - @Override - public void writeTo(final NormalizedNodeContext t, final Class type, final Type genericType, final Annotation[] annotations, - final MediaType mediaType, final MultivaluedMap httpHeaders, final OutputStream entityStream) - throws IOException, WebApplicationException { - NormalizedNode data = t.getData(); - if (data == null) { - return; - } - - @SuppressWarnings("unchecked") - final InstanceIdentifierContext context = (InstanceIdentifierContext) t.getInstanceIdentifierContext(); - - SchemaPath path = context.getSchemaNode().getPath(); - final JsonWriter jsonWriter = createJsonWriter(entityStream, t.getWriterParameters().isPrettyPrint()); - jsonWriter.beginObject(); - writeNormalizedNode(jsonWriter,path,context,data, t.getWriterParameters().getDepth()); - jsonWriter.endObject(); - jsonWriter.flush(); - } - - private void writeNormalizedNode(JsonWriter jsonWriter, SchemaPath path, - InstanceIdentifierContext context, NormalizedNode data, Optional depth) throws - IOException { - final RestconfNormalizedNodeWriter nnWriter; - if (SchemaPath.ROOT.equals(path)) { - /* - * Creates writer without initialNs and we write children of root data container - * which is not visible in restconf - */ - nnWriter = createNormalizedNodeWriter(context,path,jsonWriter, depth); - writeChildren(nnWriter,(ContainerNode) data); - } else if (context.getSchemaNode() instanceof RpcDefinition) { - /* - * RpcDefinition is not supported as initial codec in JSONStreamWriter, - * so we need to emit initial output declaratation.. - */ - path = ((RpcDefinition) context.getSchemaNode()).getOutput().getPath(); - nnWriter = createNormalizedNodeWriter(context,path,jsonWriter, depth); - jsonWriter.name("output"); - jsonWriter.beginObject(); - writeChildren(nnWriter, (ContainerNode) data); - jsonWriter.endObject(); - } else { - path = path.getParent(); - - if(data instanceof MapEntryNode) { - data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).withChild(((MapEntryNode) data)).build(); - } - nnWriter = createNormalizedNodeWriter(context,path,jsonWriter, depth); - nnWriter.write(data); - } - nnWriter.flush(); - } - - private void writeChildren(final RestconfNormalizedNodeWriter nnWriter, final ContainerNode data) throws IOException { - for(final DataContainerChild child : data.getValue()) { - nnWriter.write(child); - } - } - - private RestconfNormalizedNodeWriter createNormalizedNodeWriter(final InstanceIdentifierContext context, - final SchemaPath path, final JsonWriter jsonWriter, Optional depth) { - - final SchemaNode schema = context.getSchemaNode(); - final JSONCodecFactory codecs = getCodecFactory(context); - - final URI initialNs; - if ((schema instanceof DataSchemaNode) - && !((DataSchemaNode)schema).isAugmenting() - && !(schema instanceof SchemaContext)) { - initialNs = schema.getQName().getNamespace(); - } else if (schema instanceof RpcDefinition) { - initialNs = schema.getQName().getNamespace(); - } else { - initialNs = null; - } - final NormalizedNodeStreamWriter streamWriter = JSONNormalizedNodeStreamWriter.createNestedWriter(codecs,path,initialNs,jsonWriter); - if (depth.isPresent()) { - return DepthAwareNormalizedNodeWriter.forStreamWriter(streamWriter, depth.get()); - } else { - return RestconfDelegatingNormalizedNodeWriter.forStreamWriter(streamWriter); - } - } - - private JsonWriter createJsonWriter(final OutputStream entityStream, boolean prettyPrint) { - if (prettyPrint) { - return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, Charsets.UTF_8), - DEFAULT_INDENT_SPACES_NUM); - } else { - return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, Charsets.UTF_8)); - } - } - - private JSONCodecFactory getCodecFactory(final InstanceIdentifierContext context) { - // TODO: Performance: Cache JSON Codec factory and schema context - return JSONCodecFactory.create(context.getSchemaContext()); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeXmlBodyWriter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeXmlBodyWriter.java deleted file mode 100644 index 6d04baf0fe..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeXmlBodyWriter.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -import com.google.common.base.Optional; -import com.google.common.base.Throwables; -import java.io.IOException; -import java.io.OutputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import javanet.staxutils.IndentingXMLStreamWriter; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; -import javax.xml.XMLConstants; -import javax.xml.stream.FactoryConfigurationError; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.api.RestconfNormalizedNodeWriter; -import org.opendaylight.controller.sal.rest.api.RestconfService; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@Provider -@Produces({ Draft02.MediaTypes.API + RestconfService.XML, Draft02.MediaTypes.DATA + RestconfService.XML, - Draft02.MediaTypes.OPERATION + RestconfService.XML, MediaType.APPLICATION_XML, MediaType.TEXT_XML }) -public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter { - - private static final XMLOutputFactory XML_FACTORY; - - static { - XML_FACTORY = XMLOutputFactory.newFactory(); - XML_FACTORY.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); - } - - @Override - public boolean isWriteable(final Class type, final Type genericType, final Annotation[] annotations, - final MediaType mediaType) { - return type.equals(NormalizedNodeContext.class); - } - - @Override - public long getSize(final NormalizedNodeContext t, final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType) { - return -1; - } - - @Override - public void writeTo(final NormalizedNodeContext t, final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType, - final MultivaluedMap httpHeaders, final OutputStream entityStream) throws IOException, - WebApplicationException { - final InstanceIdentifierContext pathContext = t.getInstanceIdentifierContext(); - if (t.getData() == null) { - return; - } - - XMLStreamWriter xmlWriter; - try { - xmlWriter = XML_FACTORY.createXMLStreamWriter(entityStream); - if (t.getWriterParameters().isPrettyPrint()) { - xmlWriter = new IndentingXMLStreamWriter(xmlWriter); - } - } catch (final XMLStreamException e) { - throw new IllegalStateException(e); - } catch (final FactoryConfigurationError e) { - throw new IllegalStateException(e); - } - NormalizedNode data = t.getData(); - SchemaPath schemaPath = pathContext.getSchemaNode().getPath(); - - - - writeNormalizedNode(xmlWriter, schemaPath, pathContext, data, t.getWriterParameters().getDepth()); - - } - - private void writeNormalizedNode(XMLStreamWriter xmlWriter, SchemaPath schemaPath, InstanceIdentifierContext - pathContext, NormalizedNode data, Optional depth) throws IOException { - final RestconfNormalizedNodeWriter nnWriter; - final SchemaContext schemaCtx = pathContext.getSchemaContext(); - if (SchemaPath.ROOT.equals(schemaPath)) { - nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath, depth); - writeElements(xmlWriter, nnWriter, (ContainerNode) data); - } else if (pathContext.getSchemaNode() instanceof RpcDefinition) { - nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, - ((RpcDefinition) pathContext.getSchemaNode()).getOutput().getPath(), depth); - writeElements(xmlWriter, nnWriter, (ContainerNode) data); - } else { - nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath.getParent(), depth); - if (data instanceof MapEntryNode) { - // Restconf allows returning one list item. We need to wrap it - // in map node in order to serialize it properly - data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build(); - } - nnWriter.write(data); - } - nnWriter.flush(); - } - - private RestconfNormalizedNodeWriter createNormalizedNodeWriter(XMLStreamWriter xmlWriter, - SchemaContext schemaContext, SchemaPath schemaPath, Optional depth) { - NormalizedNodeStreamWriter xmlStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, schemaContext, schemaPath); - if (depth.isPresent()) { - return DepthAwareNormalizedNodeWriter.forStreamWriter(xmlStreamWriter, depth.get()); - } else { - return RestconfDelegatingNormalizedNodeWriter.forStreamWriter(xmlStreamWriter); - } - } - - private void writeElements(final XMLStreamWriter xmlWriter, final RestconfNormalizedNodeWriter nnWriter, - final ContainerNode data) - throws IOException { - try { - final QName name = data.getNodeType(); - xmlWriter.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, name.getLocalName(), name.getNamespace().toString()); - xmlWriter.writeDefaultNamespace(name.getNamespace().toString()); - for(NormalizedNode child : data.getValue()) { - nnWriter.write(child); - } - nnWriter.flush(); - xmlWriter.writeEndElement(); - xmlWriter.flush(); - } catch (final XMLStreamException e) { - Throwables.propagate(e); - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestUtil.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestUtil.java deleted file mode 100644 index b5a2b42a64..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestUtil.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.xml.stream.events.StartElement; -import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO; -import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO.IdentityValue; -import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO.Predicate; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; - -public final class RestUtil { - - // FIXME: BUG-1275: this is code duplicates data.impl.codec - - public static final String SQUOTE = "'"; - public static final String DQUOTE = "\""; - private static final Pattern PREDICATE_PATTERN = Pattern.compile("\\[(.*?)\\]"); - - public final static TypeDefinition resolveBaseTypeFrom(final TypeDefinition type) { - TypeDefinition superType = type; - while (superType.getBaseType() != null) { - superType = superType.getBaseType(); - } - return superType; - } - - public static IdentityValuesDTO asInstanceIdentifier(final String value, final PrefixesMaping prefixMap) { - final String valueTrimmed = value.trim(); - if (!valueTrimmed.startsWith("/")) { - return null; - } - final String[] xPathParts = valueTrimmed.split("/"); - if (xPathParts.length < 2) { // must be at least "/pr:node" - return null; - } - final IdentityValuesDTO identityValuesDTO = new IdentityValuesDTO(value); - for (int i = 1; i < xPathParts.length; i++) { - final String xPathPartTrimmed = xPathParts[i].trim(); - - final String xPathPartStr = getIdAndPrefixAsStr(xPathPartTrimmed); - final IdentityValue identityValue = toIdentity(xPathPartStr, prefixMap); - if (identityValue == null) { - return null; - } - - final List predicates = toPredicates(xPathPartTrimmed, prefixMap); - if (predicates == null) { - return null; - } - identityValue.setPredicates(predicates); - - identityValuesDTO.add(identityValue); - } - return identityValuesDTO.getValuesWithNamespaces().isEmpty() ? null : identityValuesDTO; - } - - private static String getIdAndPrefixAsStr(final String pathPart) { - final int predicateStartIndex = pathPart.indexOf("["); - return predicateStartIndex == -1 ? pathPart : pathPart.substring(0, predicateStartIndex); - } - - private static IdentityValue toIdentity(final String xPathPart, final PrefixesMaping prefixMap) { - final String xPathPartTrimmed = xPathPart.trim(); - if (xPathPartTrimmed.isEmpty()) { - return null; - } - final String[] prefixAndIdentifier = xPathPartTrimmed.split(":"); - // it is not "prefix:value" - if (prefixAndIdentifier.length != 2) { - return null; - } - final String prefix = prefixAndIdentifier[0].trim(); - final String identifier = prefixAndIdentifier[1].trim(); - if (prefix.isEmpty() || identifier.isEmpty()) { - return null; - } - final String namespace = prefixMap.getNamespace(prefix); - return new IdentityValue(namespace, identifier); - } - - private static List toPredicates(final String predicatesStr, final PrefixesMaping prefixMap) { - final List result = new ArrayList<>(); - final List predicates = new ArrayList<>(); - final Matcher matcher = PREDICATE_PATTERN.matcher(predicatesStr); - while (matcher.find()) { - predicates.add(matcher.group(1).trim()); - } - for (final String predicate : predicates) { - final int indexOfEqualityMark = predicate.indexOf("="); - if (indexOfEqualityMark != -1) { - final String predicateValue = toPredicateValue(predicate.substring(indexOfEqualityMark + 1)); - if (predicate.startsWith(".")) { // it is leaf-list - if (predicateValue == null) { - return null; - } - result.add(new Predicate(null, predicateValue)); - } else { - final IdentityValue identityValue = toIdentity(predicate.substring(0, indexOfEqualityMark), prefixMap); - if (identityValue == null || predicateValue == null) { - return null; - } - result.add(new Predicate(identityValue, predicateValue)); - } - } - } - return result; - } - - private static String toPredicateValue(final String predicatedValue) { - final String predicatedValueTrimmed = predicatedValue.trim(); - if ((predicatedValueTrimmed.startsWith(DQUOTE) || predicatedValueTrimmed.startsWith(SQUOTE)) - && (predicatedValueTrimmed.endsWith(DQUOTE) || predicatedValueTrimmed.endsWith(SQUOTE))) { - return predicatedValueTrimmed.substring(1, predicatedValueTrimmed.length() - 1); - } - return null; - } - - public interface PrefixesMaping { - public String getNamespace(String prefix); - } - - public static class PrefixMapingFromXml implements PrefixesMaping { - StartElement startElement = null; - - public PrefixMapingFromXml(final StartElement startElement) { - this.startElement = startElement; - } - - @Override - public String getNamespace(final String prefix) { - return startElement.getNamespaceContext().getNamespaceURI(prefix); - } - } - - public static class PrefixMapingFromJson implements PrefixesMaping { - - @Override - public String getNamespace(final String prefix) { - return prefix; - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfApplication.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfApplication.java deleted file mode 100644 index 52cd96b53a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfApplication.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -import com.google.common.collect.ImmutableSet; -import java.util.HashSet; -import java.util.Set; -import javax.ws.rs.core.Application; -import org.opendaylight.controller.md.sal.rest.schema.SchemaExportContentYangBodyWriter; -import org.opendaylight.controller.md.sal.rest.schema.SchemaExportContentYinBodyWriter; -import org.opendaylight.controller.md.sal.rest.schema.SchemaRetrievalServiceImpl; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.controller.sal.restconf.impl.StatisticsRestconfServiceWrapper; - -public class RestconfApplication extends Application { - - @Override - public Set> getClasses() { - return ImmutableSet.> builder() - .add(RestconfDocumentedExceptionMapper.class) - .add(XmlNormalizedNodeBodyReader.class) - .add(JsonNormalizedNodeBodyReader.class) - .add(NormalizedNodeJsonBodyWriter.class) - .add(NormalizedNodeXmlBodyWriter.class) - .add(SchemaExportContentYinBodyWriter.class) - .add(SchemaExportContentYangBodyWriter.class) - .build(); - } - - @Override - public Set getSingletons() { - final Set singletons = new HashSet<>(); - final ControllerContext controllerContext = ControllerContext.getInstance(); - final BrokerFacade brokerFacade = BrokerFacade.getInstance(); - final RestconfImpl restconfImpl = RestconfImpl.getInstance(); - final SchemaRetrievalServiceImpl schemaRetrieval = new SchemaRetrievalServiceImpl(controllerContext); - restconfImpl.setBroker(brokerFacade); - restconfImpl.setControllerContext(controllerContext); - singletons.add(controllerContext); - singletons.add(brokerFacade); - singletons.add(schemaRetrieval); - singletons.add(new RestconfCompositeWrapper(StatisticsRestconfServiceWrapper.getInstance(), schemaRetrieval)); -// singletons.add(StructuredDataToXmlProvider.INSTANCE); -// singletons.add(StructuredDataToJsonProvider.INSTANCE); -// singletons.add(JsonToCompositeNodeProvider.INSTANCE); -// singletons.add(XmlToCompositeNodeProvider.INSTANCE); - return singletons; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfCompositeWrapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfCompositeWrapper.java deleted file mode 100644 index 1339d7a200..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfCompositeWrapper.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl; - -import com.google.common.base.Preconditions; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import org.opendaylight.controller.md.sal.rest.schema.SchemaExportContext; -import org.opendaylight.controller.md.sal.rest.schema.SchemaRetrievalService; -import org.opendaylight.controller.sal.rest.api.RestconfService; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; - -public class RestconfCompositeWrapper implements RestconfService, SchemaRetrievalService { - - private final RestconfService restconf; - private final SchemaRetrievalService schema; - - public RestconfCompositeWrapper(final RestconfService restconf, final SchemaRetrievalService schema) { - this.restconf = Preconditions.checkNotNull(restconf); - this.schema = Preconditions.checkNotNull(schema); - } - - @Override - public Object getRoot() { - return restconf.getRoot(); - } - - @Override - public NormalizedNodeContext getModules(final UriInfo uriInfo) { - return restconf.getModules(uriInfo); - } - - @Override - public NormalizedNodeContext getModules(final String identifier, final UriInfo uriInfo) { - return restconf.getModules(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) { - return restconf.getModule(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext getOperations(final UriInfo uriInfo) { - return restconf.getOperations(uriInfo); - } - - @Override - public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) { - return restconf.getOperations(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { - return restconf.invokeRpc(identifier, payload, uriInfo); - } - - @Override - @Deprecated - public NormalizedNodeContext invokeRpc(final String identifier, final String noPayload, final UriInfo uriInfo) { - return restconf.invokeRpc(identifier, noPayload, uriInfo); - } - - @Override - public NormalizedNodeContext readConfigurationData(final String identifier, final UriInfo uriInfo) { - return restconf.readConfigurationData(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext readOperationalData(final String identifier, final UriInfo uriInfo) { - return restconf.readOperationalData(identifier, uriInfo); - } - - @Override - public Response updateConfigurationData(final String identifier, final NormalizedNodeContext payload) { - return restconf.updateConfigurationData(identifier, payload); - } - - @Override - public Response createConfigurationData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { - return restconf.createConfigurationData(identifier, payload, uriInfo); - } - - @Override - public Response createConfigurationData(final NormalizedNodeContext payload, final UriInfo uriInfo) { - return restconf.createConfigurationData(payload, uriInfo); - } - - @Override - public Response deleteConfigurationData(final String identifier) { - return restconf.deleteConfigurationData(identifier); - } - - @Override - public Response subscribeToStream(final String identifier, final UriInfo uriInfo) { - return restconf.subscribeToStream(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) { - return restconf.getAvailableStreams(uriInfo); - } - - @Override - public SchemaExportContext getSchema(final String mountId) { - return schema.getSchema(mountId); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDelegatingNormalizedNodeWriter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDelegatingNormalizedNodeWriter.java deleted file mode 100644 index d916a7cc05..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDelegatingNormalizedNodeWriter.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -import java.io.IOException; -import org.opendaylight.controller.sal.rest.api.RestconfNormalizedNodeWriter; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter; - -/** - * This class just delegates all of the functionality to Yangtools normalized node writer - */ -public class RestconfDelegatingNormalizedNodeWriter implements RestconfNormalizedNodeWriter { - private NormalizedNodeWriter delegNNWriter; - - private RestconfDelegatingNormalizedNodeWriter(NormalizedNodeStreamWriter streamWriter, final boolean - orderKeyLeaves) { - this.delegNNWriter = NormalizedNodeWriter.forStreamWriter(streamWriter, orderKeyLeaves); - } - - public static RestconfDelegatingNormalizedNodeWriter forStreamWriter(final NormalizedNodeStreamWriter writer) { - return forStreamWriter(writer, true); - } - - public static RestconfDelegatingNormalizedNodeWriter forStreamWriter(final NormalizedNodeStreamWriter writer, final boolean - orderKeyLeaves) { - return new RestconfDelegatingNormalizedNodeWriter(writer, orderKeyLeaves); - } - - public RestconfDelegatingNormalizedNodeWriter write(final NormalizedNode node) throws IOException { - delegNNWriter.write(node); - return this; - } - - @Override - public void flush() throws IOException { - delegNNWriter.flush(); - } - - @Override - public void close() throws IOException { - delegNNWriter.close(); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDocumentedExceptionMapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDocumentedExceptionMapper.java deleted file mode 100644 index 2e4e00de90..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfDocumentedExceptionMapper.java +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl; - -import com.google.common.base.Charsets; -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; -import com.google.common.collect.Iterables; -import com.google.gson.stream.JsonWriter; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.net.URI; -import java.util.Iterator; -import java.util.List; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; -import javax.xml.XMLConstants; -import javax.xml.stream.FactoryConfigurationError; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter; -import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory; -import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory; -import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class defines an ExceptionMapper that handles RestconfDocumentedExceptions thrown by resource implementations - * and translates appropriately to restconf error response as defined in the RESTCONF RFC draft. - * - * @author Thomas Pantelis - */ -@Provider -public class RestconfDocumentedExceptionMapper implements ExceptionMapper { - - private final static Logger LOG = LoggerFactory.getLogger(RestconfDocumentedExceptionMapper.class); - - private static final XMLOutputFactory XML_FACTORY; - - static { - XML_FACTORY = XMLOutputFactory.newFactory(); - XML_FACTORY.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); - } - - @Context - private HttpHeaders headers; - - @Override - public Response toResponse(final RestconfDocumentedException exception) { - - LOG.debug("In toResponse: {}", exception.getMessage()); - - final List accepts = headers.getAcceptableMediaTypes(); - accepts.remove(MediaType.WILDCARD_TYPE); - - LOG.debug("Accept headers: {}", accepts); - - final MediaType mediaType; - if (accepts != null && accepts.size() > 0) { - mediaType = accepts.get(0); // just pick the first one - } else { - // Default to the content type if there's no Accept header - mediaType = MediaType.APPLICATION_JSON_TYPE; - } - - LOG.debug("Using MediaType: {}", mediaType); - - final List errors = exception.getErrors(); - if (errors.isEmpty()) { - // We don't actually want to send any content but, if we don't set any content here, - // the tomcat front-end will send back an html error report. To prevent that, set a - // single space char in the entity. - - return Response.status(exception.getStatus()).type(MediaType.TEXT_PLAIN_TYPE).entity(" ").build(); - } - - final int status = errors.iterator().next().getErrorTag().getStatusCode(); - - final ControllerContext context = ControllerContext.getInstance(); - final DataNodeContainer errorsSchemaNode = (DataNodeContainer) context.getRestconfModuleErrorsSchemaNode(); - - if (errorsSchemaNode == null) { - return Response.status(status).type(MediaType.TEXT_PLAIN_TYPE).entity(exception.getMessage()).build(); - } - - Preconditions.checkState(errorsSchemaNode instanceof ContainerSchemaNode, - "Found Errors SchemaNode isn't ContainerNode"); - final DataContainerNodeAttrBuilder errContBuild = - Builders.containerBuilder((ContainerSchemaNode) errorsSchemaNode); - - final List schemaList = ControllerContext.findInstanceDataChildrenByName(errorsSchemaNode, - Draft02.RestConfModule.ERROR_LIST_SCHEMA_NODE); - final DataSchemaNode errListSchemaNode = Iterables.getFirst(schemaList, null); - Preconditions.checkState(errListSchemaNode instanceof ListSchemaNode, "Found Error SchemaNode isn't ListSchemaNode"); - final CollectionNodeBuilder listErorsBuilder = Builders - .mapBuilder((ListSchemaNode) errListSchemaNode); - - - for (final RestconfError error : errors) { - listErorsBuilder.withChild(toErrorEntryNode(error, errListSchemaNode)); - } - errContBuild.withChild(listErorsBuilder.build()); - - final NormalizedNodeContext errContext = new NormalizedNodeContext(new InstanceIdentifierContext<>(null, - (DataSchemaNode) errorsSchemaNode, null, context.getGlobalSchema()), errContBuild.build()); - - Object responseBody; - if (mediaType.getSubtype().endsWith("json")) { - responseBody = toJsonResponseBody(errContext, errorsSchemaNode); - } else { - responseBody = toXMLResponseBody(errContext, errorsSchemaNode); - } - - return Response.status(status).type(mediaType).entity(responseBody).build(); - } - - private MapEntryNode toErrorEntryNode(final RestconfError error, final DataSchemaNode errListSchemaNode) { - Preconditions.checkArgument(errListSchemaNode instanceof ListSchemaNode, - "errListSchemaNode has to be of type ListSchemaNode"); - final ListSchemaNode listStreamSchemaNode = (ListSchemaNode) errListSchemaNode; - final DataContainerNodeAttrBuilder errNodeValues = Builders - .mapEntryBuilder(listStreamSchemaNode); - - List lsChildDataSchemaNode = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "error-type"); - final DataSchemaNode errTypSchemaNode = Iterables.getFirst(lsChildDataSchemaNode, null); - Preconditions.checkState(errTypSchemaNode instanceof LeafSchemaNode); - errNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) errTypSchemaNode) - .withValue(error.getErrorType().getErrorTypeTag()).build()); - - lsChildDataSchemaNode = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "error-tag"); - final DataSchemaNode errTagSchemaNode = Iterables.getFirst(lsChildDataSchemaNode, null); - Preconditions.checkState(errTagSchemaNode instanceof LeafSchemaNode); - errNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) errTagSchemaNode) - .withValue(error.getErrorTag().getTagValue()).build()); - - if (error.getErrorAppTag() != null) { - lsChildDataSchemaNode = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "error-app-tag"); - final DataSchemaNode errAppTagSchemaNode = Iterables.getFirst(lsChildDataSchemaNode, null); - Preconditions.checkState(errAppTagSchemaNode instanceof LeafSchemaNode); - errNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) errAppTagSchemaNode) - .withValue(error.getErrorAppTag()).build()); - } - - lsChildDataSchemaNode = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "error-message"); - final DataSchemaNode errMsgSchemaNode = Iterables.getFirst(lsChildDataSchemaNode, null); - Preconditions.checkState(errMsgSchemaNode instanceof LeafSchemaNode); - errNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) errMsgSchemaNode) - .withValue(error.getErrorMessage()).build()); - - if(error.getErrorInfo() != null) { - // Oddly, error-info is defined as an empty container in the restconf yang. Apparently the - // intention is for implementors to define their own data content so we'll just treat it as a leaf - // with string data. - errNodeValues.withChild(ImmutableNodes.leafNode(Draft02.RestConfModule.ERROR_INFO_QNAME, - error.getErrorInfo())); - } - - // TODO : find how could we add possible "error-path" - - return errNodeValues.build(); - } - - private Object toJsonResponseBody(final NormalizedNodeContext errorsNode, final DataNodeContainer errorsSchemaNode) { - - final ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - NormalizedNode data = errorsNode.getData(); - final InstanceIdentifierContext context = errorsNode.getInstanceIdentifierContext(); - final DataSchemaNode schema = (DataSchemaNode) context.getSchemaNode(); - - SchemaPath path = context.getSchemaNode().getPath(); - final OutputStreamWriter outputWriter = new OutputStreamWriter(outStream, Charsets.UTF_8); - if (data == null) { - throw new RestconfDocumentedException(Response.Status.NOT_FOUND); - } - - boolean isDataRoot = false; - URI initialNs = null; - if (SchemaPath.ROOT.equals(path)) { - isDataRoot = true; - } else { - path = path.getParent(); - // FIXME: Add proper handling of reading root. - } - if(!schema.isAugmenting() && !(schema instanceof SchemaContext)) { - initialNs = schema.getQName().getNamespace(); - } - - final JsonWriter jsonWriter = JsonWriterFactory.createJsonWriter(outputWriter); - final NormalizedNodeStreamWriter jsonStreamWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter( - JSONCodecFactory.create(context.getSchemaContext()), path, initialNs, jsonWriter); - - // We create a delegating writer to special-case error-info as error-info is defined as an empty - // container in the restconf yang schema but we create a leaf node so we can output it. The delegate - // stream writer validates the node type against the schema and thus will expect a LeafSchemaNode but - // the schema has a ContainerSchemaNode so, to avoid an error, we override the leafNode behavior - // for error-info. - final NormalizedNodeStreamWriter streamWriter = new DelegatingNormalizedNodeStreamWriter(jsonStreamWriter) { - @Override - public void leafNode(final NodeIdentifier name, final Object value) throws IOException { - if(name.getNodeType().equals(Draft02.RestConfModule.ERROR_INFO_QNAME)) { - jsonWriter.name(Draft02.RestConfModule.ERROR_INFO_QNAME.getLocalName()); - jsonWriter.value(value.toString()); - } else { - super.leafNode(name, value); - } - } - }; - - final NormalizedNodeWriter nnWriter = NormalizedNodeWriter.forStreamWriter(streamWriter); - try { - if(isDataRoot) { - writeDataRoot(outputWriter,nnWriter,(ContainerNode) data); - } else { - if(data instanceof MapEntryNode) { - data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).withChild(((MapEntryNode) data)).build(); - } - nnWriter.write(data); - } - nnWriter.flush(); - outputWriter.flush(); - } - catch (final IOException e) { - LOG.warn("Error writing error response body", e); - } - - return outStream.toString(); - - } - - private Object toXMLResponseBody(final NormalizedNodeContext errorsNode, final DataNodeContainer errorsSchemaNode) { - - final InstanceIdentifierContext pathContext = errorsNode.getInstanceIdentifierContext(); - final ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - - final XMLStreamWriter xmlWriter; - try { - xmlWriter = XML_FACTORY.createXMLStreamWriter(outStream, "UTF-8"); - } catch (final XMLStreamException e) { - throw new IllegalStateException(e); - } catch (final FactoryConfigurationError e) { - throw new IllegalStateException(e); - } - NormalizedNode data = errorsNode.getData(); - SchemaPath schemaPath = pathContext.getSchemaNode().getPath(); - - boolean isDataRoot = false; - if (SchemaPath.ROOT.equals(schemaPath)) { - isDataRoot = true; - } else { - schemaPath = schemaPath.getParent(); - } - - final NormalizedNodeStreamWriter xmlStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, - pathContext.getSchemaContext(), schemaPath); - - // We create a delegating writer to special-case error-info as error-info is defined as an empty - // container in the restconf yang schema but we create a leaf node so we can output it. The delegate - // stream writer validates the node type against the schema and thus will expect a LeafSchemaNode but - // the schema has a ContainerSchemaNode so, to avoid an error, we override the leafNode behavior - // for error-info. - final NormalizedNodeStreamWriter streamWriter = new DelegatingNormalizedNodeStreamWriter(xmlStreamWriter) { - @Override - public void leafNode(final NodeIdentifier name, final Object value) throws IOException { - if(name.getNodeType().equals(Draft02.RestConfModule.ERROR_INFO_QNAME)) { - String ns = Draft02.RestConfModule.ERROR_INFO_QNAME.getNamespace().toString(); - try { - xmlWriter.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, - Draft02.RestConfModule.ERROR_INFO_QNAME.getLocalName(), ns); - xmlWriter.writeCharacters(value.toString()); - xmlWriter.writeEndElement(); - } catch (XMLStreamException e) { - throw new IOException("Error writing error-info", e); - } - } else { - super.leafNode(name, value); - } - } - }; - - final NormalizedNodeWriter nnWriter = NormalizedNodeWriter.forStreamWriter(streamWriter); - try { - if (isDataRoot) { - writeRootElement(xmlWriter, nnWriter, (ContainerNode) data); - } else { - if (data instanceof MapEntryNode) { - // Restconf allows returning one list item. We need to wrap it - // in map node in order to serialize it properly - data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build(); - } - nnWriter.write(data); - nnWriter.flush(); - } - } - catch (final IOException e) { - LOG.warn("Error writing error response body.", e); - } - - return outStream.toString(); - } - - private void writeRootElement(final XMLStreamWriter xmlWriter, final NormalizedNodeWriter nnWriter, final ContainerNode data) - throws IOException { - try { - final QName name = SchemaContext.NAME; - xmlWriter.writeStartElement(name.getNamespace().toString(), name.getLocalName()); - for (final DataContainerChild child : data.getValue()) { - nnWriter.write(child); - } - nnWriter.flush(); - xmlWriter.writeEndElement(); - xmlWriter.flush(); - } catch (final XMLStreamException e) { - Throwables.propagate(e); - } - } - - private void writeDataRoot(final OutputStreamWriter outputWriter, final NormalizedNodeWriter nnWriter, final ContainerNode data) throws IOException { - final Iterator> iterator = data.getValue().iterator(); - while(iterator.hasNext()) { - final DataContainerChild child = iterator.next(); - nnWriter.write(child); - nnWriter.flush(); - } - } - - private static class DelegatingNormalizedNodeStreamWriter implements NormalizedNodeStreamWriter { - private final NormalizedNodeStreamWriter delegate; - - DelegatingNormalizedNodeStreamWriter(NormalizedNodeStreamWriter delegate) { - this.delegate = delegate; - } - - @Override - public void leafNode(NodeIdentifier name, Object value) throws IOException, IllegalArgumentException { - delegate.leafNode(name, value); - } - - @Override - public void startLeafSet(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException { - delegate.startLeafSet(name, childSizeHint); - } - - @Override - public void leafSetEntryNode(Object value) throws IOException, IllegalArgumentException { - delegate.leafSetEntryNode(value); - } - - @Override - public void startContainerNode(NodeIdentifier name, int childSizeHint) throws IOException, - IllegalArgumentException { - delegate.startContainerNode(name, childSizeHint); - } - - @Override - public void startUnkeyedList(NodeIdentifier name, int childSizeHint) throws IOException, - IllegalArgumentException { - delegate.startUnkeyedList(name, childSizeHint); - } - - @Override - public void startUnkeyedListItem(NodeIdentifier name, int childSizeHint) throws IOException, - IllegalStateException { - delegate.startUnkeyedListItem(name, childSizeHint); - } - - @Override - public void startMapNode(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException { - delegate.startMapNode(name, childSizeHint); - } - - @Override - public void startMapEntryNode(NodeIdentifierWithPredicates identifier, int childSizeHint) throws IOException, - IllegalArgumentException { - delegate.startMapEntryNode(identifier, childSizeHint); - } - - @Override - public void startOrderedMapNode(NodeIdentifier name, int childSizeHint) throws IOException, - IllegalArgumentException { - delegate.startOrderedMapNode(name, childSizeHint); - } - - @Override - public void startChoiceNode(NodeIdentifier name, int childSizeHint) throws IOException, - IllegalArgumentException { - delegate.startChoiceNode(name, childSizeHint); - } - - @Override - public void startAugmentationNode(AugmentationIdentifier identifier) throws IOException, - IllegalArgumentException { - delegate.startAugmentationNode(identifier); - } - - @Override - public void anyxmlNode(NodeIdentifier name, Object value) throws IOException, IllegalArgumentException { - delegate.anyxmlNode(name, value); - } - - @Override - public void endNode() throws IOException, IllegalStateException { - delegate.endNode(); - } - - @Override - public void close() throws IOException { - delegate.close(); - } - - @Override - public void flush() throws IOException { - delegate.flush(); - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/UnsupportedFormatException.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/UnsupportedFormatException.java deleted file mode 100644 index aad5a0f71d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/UnsupportedFormatException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -public class UnsupportedFormatException extends Exception { - - private static final long serialVersionUID = -1741388894406313402L; - - public UnsupportedFormatException() { - super(); - } - - public UnsupportedFormatException(String message, Throwable cause) { - super(message, cause); - } - - public UnsupportedFormatException(String message) { - super(message); - } - - public UnsupportedFormatException(Throwable cause) { - super(cause); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java deleted file mode 100644 index 294e56a651..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; - -import com.google.common.collect.Iterables; -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Deque; -import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.Provider; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.api.RestconfService; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlUtils; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils; -import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.DomToNormalizedNodeParserFactory; -import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; -import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; -import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -@Provider -@Consumes({ Draft02.MediaTypes.DATA + RestconfService.XML, Draft02.MediaTypes.OPERATION + RestconfService.XML, - MediaType.APPLICATION_XML, MediaType.TEXT_XML }) -public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsProvider implements MessageBodyReader { - - private final static Logger LOG = LoggerFactory.getLogger(XmlNormalizedNodeBodyReader.class); - private static final DocumentBuilderFactory BUILDERFACTORY; - - static { - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - try { - factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - factory.setFeature("http://xml.org/sax/features/external-general-entities", false); - factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - factory.setXIncludeAware(false); - factory.setExpandEntityReferences(false); - } catch (final ParserConfigurationException e) { - throw new ExceptionInInitializerError(e); - } - factory.setNamespaceAware(true); - factory.setCoalescing(true); - factory.setIgnoringElementContentWhitespace(true); - factory.setIgnoringComments(true); - BUILDERFACTORY = factory; - } - - @Override - public boolean isReadable(final Class type, final Type genericType, final Annotation[] annotations, - final MediaType mediaType) { - return true; - } - - @Override - public NormalizedNodeContext readFrom(final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType, - final MultivaluedMap httpHeaders, final InputStream entityStream) throws IOException, - WebApplicationException { - try { - final InstanceIdentifierContext path = getInstanceIdentifierContext(); - - if (entityStream.available() < 1) { - // represent empty nopayload input - return new NormalizedNodeContext(path, null); - } - - final DocumentBuilder dBuilder; - try { - dBuilder = BUILDERFACTORY.newDocumentBuilder(); - } catch (final ParserConfigurationException e) { - throw new RuntimeException("Failed to parse XML document", e); - } - final Document doc = dBuilder.parse(entityStream); - - return parse(path,doc); - } catch (final RestconfDocumentedException e){ - throw e; - } catch (final Exception e) { - LOG.debug("Error parsing xml input", e); - - throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL, - ErrorTag.MALFORMED_MESSAGE); - } - } - - private NormalizedNodeContext parse(final InstanceIdentifierContext pathContext,final Document doc) { - - final List elements = Collections.singletonList(doc.getDocumentElement()); - final SchemaNode schemaNodeContext = pathContext.getSchemaNode(); - DataSchemaNode schemaNode; - boolean isRpc = false; - if (schemaNodeContext instanceof RpcDefinition) { - schemaNode = ((RpcDefinition) schemaNodeContext).getInput(); - isRpc = true; - } else if (schemaNodeContext instanceof DataSchemaNode) { - schemaNode = (DataSchemaNode) schemaNodeContext; - } else { - throw new IllegalStateException("Unknow SchemaNode"); - } - - final String docRootElm = doc.getDocumentElement().getLocalName(); - final List iiToDataList = new ArrayList<>(); - InstanceIdentifierContext outIIContext; - - - // FIXME the factory instance should be cached if the schema context is the same - final DomToNormalizedNodeParserFactory parserFactory = - DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, pathContext.getSchemaContext()); - - if (isPost() && !isRpc) { - final Deque foundSchemaNodes = findPathToSchemaNodeByName(schemaNode, docRootElm); - if (foundSchemaNodes.isEmpty()) { - throw new IllegalStateException(String.format("Child \"%s\" was not found in parent schema node \"%s\"", - docRootElm, schemaNode.getQName())); - } - while (!foundSchemaNodes.isEmpty()) { - final Object child = foundSchemaNodes.pop(); - if (child instanceof AugmentationSchema) { - final AugmentationSchema augmentSchemaNode = (AugmentationSchema) child; - iiToDataList.add(SchemaUtils.getNodeIdentifierForAugmentation(augmentSchemaNode)); - } else if (child instanceof DataSchemaNode) { - schemaNode = (DataSchemaNode) child; - iiToDataList.add(new YangInstanceIdentifier.NodeIdentifier(schemaNode.getQName())); - } - } - } - - NormalizedNode parsed = null; - - if(schemaNode instanceof ContainerSchemaNode) { - parsed = parserFactory.getContainerNodeParser().parse(Collections.singletonList(doc.getDocumentElement()), (ContainerSchemaNode) schemaNode); - } else if(schemaNode instanceof ListSchemaNode) { - final ListSchemaNode casted = (ListSchemaNode) schemaNode; - parsed = parserFactory.getMapEntryNodeParser().parse(elements, casted); - if (isPost()) { - iiToDataList.add(parsed.getIdentifier()); - } - } - // FIXME : add another DataSchemaNode extensions e.g. LeafSchemaNode - - final YangInstanceIdentifier fullIIToData = YangInstanceIdentifier.create(Iterables.concat( - pathContext.getInstanceIdentifier().getPathArguments(), iiToDataList)); - - outIIContext = new InstanceIdentifierContext<>(fullIIToData, pathContext.getSchemaNode(), pathContext.getMountPoint(), - pathContext.getSchemaContext()); - - return new NormalizedNodeContext(outIIContext, parsed); - } - - private static Deque findPathToSchemaNodeByName(final DataSchemaNode schemaNode, final String elementName) { - final Deque result = new ArrayDeque<>(); - final ArrayList choiceSchemaNodes = new ArrayList<>(); - final Collection children = ((DataNodeContainer) schemaNode).getChildNodes(); - for (final DataSchemaNode child : children) { - if (child instanceof ChoiceSchemaNode) { - choiceSchemaNodes.add((ChoiceSchemaNode) child); - } else if (child.getQName().getLocalName().equalsIgnoreCase(elementName)) { - result.push(child); - if (child.isAugmenting()) { - final AugmentationSchema augment = findCorrespondingAugment(schemaNode, child); - if (augment != null) { - result.push(augment); - } - } - return result; - } - } - - for (final ChoiceSchemaNode choiceNode : choiceSchemaNodes) { - for (final ChoiceCaseNode caseNode : choiceNode.getCases()) { - final Deque resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName); - if (!resultFromRecursion.isEmpty()) { - resultFromRecursion.push(choiceNode); - if (choiceNode.isAugmenting()) { - final AugmentationSchema augment = findCorrespondingAugment(schemaNode, choiceNode); - if (augment != null) { - resultFromRecursion.push(augment); - } - } - return resultFromRecursion; - } - } - } - return result; - } - - private static AugmentationSchema findCorrespondingAugment(final DataSchemaNode parent, final DataSchemaNode child) { - if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) { - for (final AugmentationSchema augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) { - final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName()); - if (childInAugmentation != null) { - return augmentation; - } - } - } - return null; - } -} - diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/package-info.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/package-info.java deleted file mode 100644 index 9560333e71..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.impl; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java deleted file mode 100644 index b8d9561a26..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java +++ /dev/null @@ -1,302 +0,0 @@ -/** - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; -import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ExecutionException; -import javax.ws.rs.core.Response.Status; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.controller.sal.streams.listeners.ListenerAdapter; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BrokerFacade { - private final static Logger LOG = LoggerFactory.getLogger(BrokerFacade.class); - - private final static BrokerFacade INSTANCE = new BrokerFacade(); - private volatile DOMRpcService rpcService; - private volatile ConsumerSession context; - private DOMDataBroker domDataBroker; - - private BrokerFacade() { - } - - public void setRpcService(final DOMRpcService router) { - rpcService = router; - } - - public void setContext(final ConsumerSession context) { - this.context = context; - } - - public static BrokerFacade getInstance() { - return BrokerFacade.INSTANCE; - } - - private void checkPreconditions() { - if (context == null || domDataBroker == null) { - throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE); - } - } - - // READ configuration - public NormalizedNode readConfigurationData(final YangInstanceIdentifier path) { - checkPreconditions(); - return readDataViaTransaction(domDataBroker.newReadOnlyTransaction(), CONFIGURATION, path); - } - - public NormalizedNode readConfigurationData(final DOMMountPoint mountPoint, final YangInstanceIdentifier path) { - final Optional domDataBrokerService = mountPoint.getService(DOMDataBroker.class); - if (domDataBrokerService.isPresent()) { - return readDataViaTransaction(domDataBrokerService.get().newReadOnlyTransaction(), CONFIGURATION, path); - } - final String errMsg = "DOM data broker service isn't available for mount point " + path; - LOG.warn(errMsg); - throw new RestconfDocumentedException(errMsg); - } - - // READ operational - public NormalizedNode readOperationalData(final YangInstanceIdentifier path) { - checkPreconditions(); - return readDataViaTransaction(domDataBroker.newReadOnlyTransaction(), OPERATIONAL, path); - } - - public NormalizedNode readOperationalData(final DOMMountPoint mountPoint, final YangInstanceIdentifier path) { - final Optional domDataBrokerService = mountPoint.getService(DOMDataBroker.class); - if (domDataBrokerService.isPresent()) { - return readDataViaTransaction(domDataBrokerService.get().newReadOnlyTransaction(), OPERATIONAL, path); - } - final String errMsg = "DOM data broker service isn't available for mount point " + path; - LOG.warn(errMsg); - throw new RestconfDocumentedException(errMsg); - } - - // PUT configuration - public CheckedFuture commitConfigurationDataPut( - final SchemaContext globalSchema, final YangInstanceIdentifier path, final NormalizedNode payload) { - checkPreconditions(); - return putDataViaTransaction(domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload, globalSchema); - } - - public CheckedFuture commitConfigurationDataPut( - final DOMMountPoint mountPoint, final YangInstanceIdentifier path, final NormalizedNode payload) { - final Optional domDataBrokerService = mountPoint.getService(DOMDataBroker.class); - if (domDataBrokerService.isPresent()) { - return putDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path, - payload, mountPoint.getSchemaContext()); - } - final String errMsg = "DOM data broker service isn't available for mount point " + path; - LOG.warn(errMsg); - throw new RestconfDocumentedException(errMsg); - } - - // POST configuration - public CheckedFuture commitConfigurationDataPost( - final SchemaContext globalSchema, final YangInstanceIdentifier path, final NormalizedNode payload) { - checkPreconditions(); - return postDataViaTransaction(domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload, globalSchema); - } - - public CheckedFuture commitConfigurationDataPost( - final DOMMountPoint mountPoint, final YangInstanceIdentifier path, final NormalizedNode payload) { - final Optional domDataBrokerService = mountPoint.getService(DOMDataBroker.class); - if (domDataBrokerService.isPresent()) { - return postDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path, - payload, mountPoint.getSchemaContext()); - } - final String errMsg = "DOM data broker service isn't available for mount point " + path; - LOG.warn(errMsg); - throw new RestconfDocumentedException(errMsg); - } - - // DELETE configuration - public CheckedFuture commitConfigurationDataDelete( - final YangInstanceIdentifier path) { - checkPreconditions(); - return deleteDataViaTransaction(domDataBroker.newWriteOnlyTransaction(), CONFIGURATION, path); - } - - public CheckedFuture commitConfigurationDataDelete( - final DOMMountPoint mountPoint, final YangInstanceIdentifier path) { - final Optional domDataBrokerService = mountPoint.getService(DOMDataBroker.class); - if (domDataBrokerService.isPresent()) { - return deleteDataViaTransaction(domDataBrokerService.get().newWriteOnlyTransaction(), CONFIGURATION, path); - } - final String errMsg = "DOM data broker service isn't available for mount point " + path; - LOG.warn(errMsg); - throw new RestconfDocumentedException(errMsg); - } - - // RPC - public CheckedFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { - checkPreconditions(); - if (rpcService == null) { - throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE); - } - return rpcService.invokeRpc(type, input); - } - - public void registerToListenDataChanges(final LogicalDatastoreType datastore, final DataChangeScope scope, - final ListenerAdapter listener) { - checkPreconditions(); - - if (listener.isListening()) { - return; - } - - final YangInstanceIdentifier path = listener.getPath(); - final ListenerRegistration registration = domDataBroker.registerDataChangeListener( - datastore, path, listener, scope); - - listener.setRegistration(registration); - } - - private NormalizedNode readDataViaTransaction(final DOMDataReadTransaction transaction, - final LogicalDatastoreType datastore, final YangInstanceIdentifier path) { - LOG.trace("Read " + datastore.name() + " via Restconf: {}", path); - final ListenableFuture>> listenableFuture = transaction.read(datastore, path); - if (listenableFuture != null) { - Optional> optional; - try { - LOG.debug("Reading result data from transaction."); - optional = listenableFuture.get(); - } catch (InterruptedException | ExecutionException e) { - LOG.warn("Exception by reading " + datastore.name() + " via Restconf: {}", path, e); - throw new RestconfDocumentedException("Problem to get data from transaction.", e.getCause()); - - } - if (optional != null) { - if (optional.isPresent()) { - return optional.get(); - } - } - } - return null; - } - - private CheckedFuture postDataViaTransaction( - final DOMDataReadWriteTransaction rWTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext) { - // FIXME: This is doing correct post for container and list children - // not sure if this will work for choice case - if(payload instanceof MapNode) { - final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path); - rWTransaction.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree); - ensureParentsByMerge(datastore, path, rWTransaction, schemaContext); - for(final MapEntryNode child : ((MapNode) payload).getValue()) { - final YangInstanceIdentifier childPath = path.node(child.getIdentifier()); - checkItemDoesNotExists(rWTransaction, datastore, childPath); - rWTransaction.put(datastore, childPath, child); - } - } else { - checkItemDoesNotExists(rWTransaction,datastore, path); - ensureParentsByMerge(datastore, path, rWTransaction, schemaContext); - rWTransaction.put(datastore, path, payload); - } - return rWTransaction.submit(); - } - - private void checkItemDoesNotExists(final DOMDataReadWriteTransaction rWTransaction,final LogicalDatastoreType store, final YangInstanceIdentifier path) { - final ListenableFuture futureDatastoreData = rWTransaction.exists(store, path); - try { - if (futureDatastoreData.get()) { - final String errMsg = "Post Configuration via Restconf was not executed because data already exists"; - LOG.trace(errMsg + ":{}", path); - rWTransaction.cancel(); - throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL, - ErrorTag.DATA_EXISTS); - } - } catch (InterruptedException | ExecutionException e) { - LOG.warn("It wasn't possible to get data loaded from datastore at path " + path, e); - } - - } - - private CheckedFuture putDataViaTransaction( - final DOMDataReadWriteTransaction writeTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext) { - LOG.trace("Put " + datastore.name() + " via Restconf: {}", path); - ensureParentsByMerge(datastore, path, writeTransaction, schemaContext); - writeTransaction.put(datastore, path, payload); - return writeTransaction.submit(); - } - - private CheckedFuture deleteDataViaTransaction( - final DOMDataWriteTransaction writeTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path) { - LOG.trace("Delete " + datastore.name() + " via Restconf: {}", path); - writeTransaction.delete(datastore, path); - return writeTransaction.submit(); - } - - public void setDomDataBroker(final DOMDataBroker domDataBroker) { - this.domDataBroker = domDataBroker; - } - - private void ensureParentsByMerge(final LogicalDatastoreType store, - final YangInstanceIdentifier normalizedPath, final DOMDataReadWriteTransaction rwTx, final SchemaContext schemaContext) { - final List normalizedPathWithoutChildArgs = new ArrayList<>(); - YangInstanceIdentifier rootNormalizedPath = null; - - final Iterator it = normalizedPath.getPathArguments().iterator(); - - while(it.hasNext()) { - final PathArgument pathArgument = it.next(); - if(rootNormalizedPath == null) { - rootNormalizedPath = YangInstanceIdentifier.create(pathArgument); - } - - // Skip last element, its not a parent - if(it.hasNext()) { - normalizedPathWithoutChildArgs.add(pathArgument); - } - } - - // No parent structure involved, no need to ensure parents - if(normalizedPathWithoutChildArgs.isEmpty()) { - return; - } - - Preconditions.checkArgument(rootNormalizedPath != null, "Empty path received"); - - final NormalizedNode parentStructure = - ImmutableNodes.fromInstanceId(schemaContext, YangInstanceIdentifier.create(normalizedPathWithoutChildArgs)); - rwTx.merge(store, rootNormalizedPath, parentStructure); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java deleted file mode 100644 index b33d79e1d0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java +++ /dev/null @@ -1,979 +0,0 @@ -/** - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; -import com.google.common.base.Splitter; -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; -import javax.ws.rs.core.Response.Status; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.impl.RestUtil; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.yangtools.concepts.Codec; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.GroupingDefinition; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition; -import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ControllerContext implements SchemaContextListener { - private final static Logger LOG = LoggerFactory.getLogger(ControllerContext.class); - - private final static ControllerContext INSTANCE = new ControllerContext(); - - private final static String NULL_VALUE = "null"; - - private final static String MOUNT_MODULE = "yang-ext"; - - private final static String MOUNT_NODE = "mount"; - - public final static String MOUNT = "yang-ext:mount"; - - private final static String URI_ENCODING_CHAR_SET = "ISO-8859-1"; - - private static final Splitter SLASH_SPLITTER = Splitter.on('/'); - - private static final YangInstanceIdentifier ROOT = YangInstanceIdentifier.builder().build(); - - private final AtomicReference> qnameToRpc = - new AtomicReference<>(Collections.emptyMap()); - - private volatile SchemaContext globalSchema; - private volatile DOMMountPointService mountService; - - private DataNormalizer dataNormalizer; - - public void setGlobalSchema(final SchemaContext globalSchema) { - this.globalSchema = globalSchema; - dataNormalizer = new DataNormalizer(globalSchema); - } - - public void setMountService(final DOMMountPointService mountService) { - this.mountService = mountService; - } - - private ControllerContext() { - } - - public static ControllerContext getInstance() { - return ControllerContext.INSTANCE; - } - - private void checkPreconditions() { - if (globalSchema == null) { - throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE); - } - } - - public void setSchemas(final SchemaContext schemas) { - onGlobalContextUpdated(schemas); - } - - public InstanceIdentifierContext toInstanceIdentifier(final String restconfInstance) { - return toIdentifier(restconfInstance, false); - } - - public SchemaContext getGlobalSchema() { - return globalSchema; - } - - public InstanceIdentifierContext toMountPointIdentifier(final String restconfInstance) { - return toIdentifier(restconfInstance, true); - } - - private InstanceIdentifierContext toIdentifier(final String restconfInstance, final boolean toMountPointIdentifier) { - checkPreconditions(); - - if(restconfInstance == null) { - return new InstanceIdentifierContext<>(ROOT, globalSchema, null, globalSchema); - } - - final List pathArgs = urlPathArgsDecode(SLASH_SPLITTER.split(restconfInstance)); - omitFirstAndLastEmptyString(pathArgs); - if (pathArgs.isEmpty()) { - return null; - } - - final String first = pathArgs.iterator().next(); - final String startModule = ControllerContext.toModuleName(first); - if (startModule == null) { - throw new RestconfDocumentedException("First node in URI has to be in format \"moduleName:nodeName\"", - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - final InstanceIdentifierBuilder builder = YangInstanceIdentifier.builder(); - final Module latestModule = globalSchema.findModuleByName(startModule, null); - - if (latestModule == null) { - throw new RestconfDocumentedException("The module named '" + startModule + "' does not exist.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); - } - - final InstanceIdentifierContext iiWithSchemaNode = collectPathArguments(builder, pathArgs, latestModule, null, - toMountPointIdentifier); - - if (iiWithSchemaNode == null) { - throw new RestconfDocumentedException("URI has bad format", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - return iiWithSchemaNode; - } - - private static List omitFirstAndLastEmptyString(final List list) { - if (list.isEmpty()) { - return list; - } - - final String head = list.iterator().next(); - if (head.isEmpty()) { - list.remove(0); - } - - if (list.isEmpty()) { - return list; - } - - final String last = list.get(list.size() - 1); - if (last.isEmpty()) { - list.remove(list.size() - 1); - } - - return list; - } - public Module findModuleByName(final String moduleName) { - checkPreconditions(); - Preconditions.checkArgument(moduleName != null && !moduleName.isEmpty()); - return globalSchema.findModuleByName(moduleName, null); - } - - public Module findModuleByName(final DOMMountPoint mountPoint, final String moduleName) { - Preconditions.checkArgument(moduleName != null && mountPoint != null); - - final SchemaContext mountPointSchema = mountPoint.getSchemaContext(); - if (mountPointSchema == null) { - return null; - } - - return mountPointSchema.findModuleByName(moduleName, null); - } - - public Module findModuleByNamespace(final URI namespace) { - checkPreconditions(); - Preconditions.checkArgument(namespace != null); - return globalSchema.findModuleByNamespaceAndRevision(namespace, null); - } - - public Module findModuleByNamespace(final DOMMountPoint mountPoint, final URI namespace) { - Preconditions.checkArgument(namespace != null && mountPoint != null); - - final SchemaContext mountPointSchema = mountPoint.getSchemaContext(); - if (mountPointSchema == null) { - return null; - } - - return mountPointSchema.findModuleByNamespaceAndRevision(namespace, null); - } - - public Module findModuleByNameAndRevision(final QName module) { - checkPreconditions(); - Preconditions.checkArgument(module != null && module.getLocalName() != null && module.getRevision() != null); - - return globalSchema.findModuleByName(module.getLocalName(), module.getRevision()); - } - - public Module findModuleByNameAndRevision(final DOMMountPoint mountPoint, final QName module) { - checkPreconditions(); - Preconditions.checkArgument(module != null && module.getLocalName() != null && module.getRevision() != null - && mountPoint != null); - - final SchemaContext schemaContext = mountPoint.getSchemaContext(); - return schemaContext == null ? null : schemaContext.findModuleByName(module.getLocalName(), - module.getRevision()); - } - - public DataNodeContainer getDataNodeContainerFor(final YangInstanceIdentifier path) { - checkPreconditions(); - - final Iterable elements = path.getPathArguments(); - final PathArgument head = elements.iterator().next(); - final QName startQName = head.getNodeType(); - final Module initialModule = globalSchema.findModuleByNamespaceAndRevision(startQName.getNamespace(), - startQName.getRevision()); - DataNodeContainer node = initialModule; - for (final PathArgument element : elements) { - final QName _nodeType = element.getNodeType(); - final DataSchemaNode potentialNode = ControllerContext.childByQName(node, _nodeType); - if (potentialNode == null || !ControllerContext.isListOrContainer(potentialNode)) { - return null; - } - node = (DataNodeContainer) potentialNode; - } - - return node; - } - - public String toFullRestconfIdentifier(final YangInstanceIdentifier path, final DOMMountPoint mount) { - checkPreconditions(); - - final Iterable elements = path.getPathArguments(); - final StringBuilder builder = new StringBuilder(); - final PathArgument head = elements.iterator().next(); - final QName startQName = head.getNodeType(); - final SchemaContext schemaContext; - if (mount != null) { - schemaContext = mount.getSchemaContext(); - } else { - schemaContext = globalSchema; - } - final Module initialModule = schemaContext.findModuleByNamespaceAndRevision(startQName.getNamespace(), - startQName.getRevision()); - DataNodeContainer node = initialModule; - for (final PathArgument element : elements) { - if (!(element instanceof AugmentationIdentifier)) { - final QName _nodeType = element.getNodeType(); - final DataSchemaNode potentialNode = ControllerContext.childByQName(node, _nodeType); - if (!(element instanceof NodeIdentifier && potentialNode instanceof ListSchemaNode) && - !(potentialNode instanceof ChoiceSchemaNode)) { - builder.append(convertToRestconfIdentifier(element, potentialNode, mount)); - if (potentialNode instanceof DataNodeContainer) { - node = (DataNodeContainer) potentialNode; - } - } - } - } - - return builder.toString(); - } - - public String findModuleNameByNamespace(final URI namespace) { - checkPreconditions(); - - final Module module = this.findModuleByNamespace(namespace); - return module == null ? null : module.getName(); - } - - public String findModuleNameByNamespace(final DOMMountPoint mountPoint, final URI namespace) { - final Module module = this.findModuleByNamespace(mountPoint, namespace); - return module == null ? null : module.getName(); - } - - public URI findNamespaceByModuleName(final String moduleName) { - final Module module = this.findModuleByName(moduleName); - return module == null ? null : module.getNamespace(); - } - - public URI findNamespaceByModuleName(final DOMMountPoint mountPoint, final String moduleName) { - final Module module = this.findModuleByName(mountPoint, moduleName); - return module == null ? null : module.getNamespace(); - } - - public Set getAllModules(final DOMMountPoint mountPoint) { - checkPreconditions(); - - final SchemaContext schemaContext = mountPoint == null ? null : mountPoint.getSchemaContext(); - return schemaContext == null ? null : schemaContext.getModules(); - } - - public Set getAllModules() { - checkPreconditions(); - return globalSchema.getModules(); - } - - private static final CharSequence toRestconfIdentifier(final SchemaContext context, final QName qname) { - final Module schema = context.findModuleByNamespaceAndRevision(qname.getNamespace(), qname.getRevision()); - return schema == null ? null : schema.getName() + ':' + qname.getLocalName(); - } - - public CharSequence toRestconfIdentifier(final QName qname, final DOMMountPoint mount) { - final SchemaContext schema; - if (mount != null) { - schema = mount.getSchemaContext(); - } else { - checkPreconditions(); - schema = globalSchema; - } - - return toRestconfIdentifier(schema, qname); - } - - public CharSequence toRestconfIdentifier(final QName qname) { - checkPreconditions(); - - return toRestconfIdentifier(globalSchema, qname); - } - - public CharSequence toRestconfIdentifier(final DOMMountPoint mountPoint, final QName qname) { - if (mountPoint == null) { - return null; - } - - return toRestconfIdentifier(mountPoint.getSchemaContext(), qname); - } - - public Module getRestconfModule() { - return findModuleByNameAndRevision(Draft02.RestConfModule.IETF_RESTCONF_QNAME); - } - - private static final Predicate ERRORS_GROUPING_FILTER = new Predicate() { - @Override - public boolean apply(final GroupingDefinition g) { - return Draft02.RestConfModule.ERRORS_GROUPING_SCHEMA_NODE.equals(g.getQName().getLocalName()); - } - }; - - public DataSchemaNode getRestconfModuleErrorsSchemaNode() { - final Module restconfModule = getRestconfModule(); - if (restconfModule == null) { - return null; - } - - final Set groupings = restconfModule.getGroupings(); - - final Iterable filteredGroups = Iterables.filter(groupings, ERRORS_GROUPING_FILTER); - - final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null); - - final List instanceDataChildrenByName = findInstanceDataChildrenByName(restconfGrouping, - Draft02.RestConfModule.ERRORS_CONTAINER_SCHEMA_NODE); - return Iterables.getFirst(instanceDataChildrenByName, null); - } - - private static final Predicate GROUPING_FILTER = new Predicate() { - @Override - public boolean apply(final GroupingDefinition g) { - return Draft02.RestConfModule.RESTCONF_GROUPING_SCHEMA_NODE.equals(g.getQName().getLocalName()); - } - }; - - public DataSchemaNode getRestconfModuleRestConfSchemaNode(final Module inRestconfModule, final String schemaNodeName) { - Module restconfModule = inRestconfModule; - if (restconfModule == null) { - restconfModule = getRestconfModule(); - } - - if (restconfModule == null) { - return null; - } - - final Set groupings = restconfModule.getGroupings(); - final Iterable filteredGroups = Iterables.filter(groupings, GROUPING_FILTER); - final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null); - - final List instanceDataChildrenByName = findInstanceDataChildrenByName(restconfGrouping, - Draft02.RestConfModule.RESTCONF_CONTAINER_SCHEMA_NODE); - final DataSchemaNode restconfContainer = Iterables.getFirst(instanceDataChildrenByName, null); - - if (Objects.equal(schemaNodeName, Draft02.RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE)) { - final List instances = findInstanceDataChildrenByName( - ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE); - return Iterables.getFirst(instances, null); - } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE)) { - final List instances = findInstanceDataChildrenByName( - ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE); - return Iterables.getFirst(instances, null); - } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.STREAM_LIST_SCHEMA_NODE)) { - List instances = findInstanceDataChildrenByName( - ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE); - final DataSchemaNode modules = Iterables.getFirst(instances, null); - instances = findInstanceDataChildrenByName(((DataNodeContainer) modules), - Draft02.RestConfModule.STREAM_LIST_SCHEMA_NODE); - return Iterables.getFirst(instances, null); - } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE)) { - final List instances = findInstanceDataChildrenByName( - ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE); - return Iterables.getFirst(instances, null); - } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE)) { - List instances = findInstanceDataChildrenByName( - ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE); - final DataSchemaNode modules = Iterables.getFirst(instances, null); - instances = findInstanceDataChildrenByName(((DataNodeContainer) modules), - Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE); - return Iterables.getFirst(instances, null); - } else if (Objects.equal(schemaNodeName, Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE)) { - final List instances = findInstanceDataChildrenByName( - ((DataNodeContainer) restconfContainer), Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE); - return Iterables.getFirst(instances, null); - } - - return null; - } - - private static DataSchemaNode childByQName(final ChoiceSchemaNode container, final QName name) { - for (final ChoiceCaseNode caze : container.getCases()) { - final DataSchemaNode ret = ControllerContext.childByQName(caze, name); - if (ret != null) { - return ret; - } - } - - return null; - } - - private static DataSchemaNode childByQName(final ChoiceCaseNode container, final QName name) { - return container.getDataChildByName(name); - } - - private static DataSchemaNode childByQName(final ContainerSchemaNode container, final QName name) { - return ControllerContext.dataNodeChildByQName(container, name); - } - - private static DataSchemaNode childByQName(final ListSchemaNode container, final QName name) { - return ControllerContext.dataNodeChildByQName(container, name); - } - - private static DataSchemaNode childByQName(final Module container, final QName name) { - return ControllerContext.dataNodeChildByQName(container, name); - } - - private static DataSchemaNode childByQName(final DataSchemaNode container, final QName name) { - return null; - } - - private static DataSchemaNode dataNodeChildByQName(final DataNodeContainer container, final QName name) { - final DataSchemaNode ret = container.getDataChildByName(name); - if (ret == null) { - for (final DataSchemaNode node : container.getChildNodes()) { - if ((node instanceof ChoiceSchemaNode)) { - final ChoiceSchemaNode choiceNode = ((ChoiceSchemaNode) node); - final DataSchemaNode childByQName = ControllerContext.childByQName(choiceNode, name); - if (childByQName != null) { - return childByQName; - } - } - } - } - return ret; - } - - private String toUriString(final Object object, final LeafSchemaNode leafNode, final DOMMountPoint mount) throws UnsupportedEncodingException { - final Codec codec = RestCodec.from(leafNode.getType(), mount); - return object == null ? "" : URLEncoder.encode(codec.serialize(object).toString(), ControllerContext.URI_ENCODING_CHAR_SET); - } - - private InstanceIdentifierContext collectPathArguments(final InstanceIdentifierBuilder builder, - final List strings, final DataNodeContainer parentNode, final DOMMountPoint mountPoint, - final boolean returnJustMountPoint) { - Preconditions.> checkNotNull(strings); - - if (parentNode == null) { - return null; - } - - if (strings.isEmpty()) { - return createContext(builder.toInstance(), ((DataSchemaNode) parentNode), mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : globalSchema); - } - - final String head = strings.iterator().next(); - final String nodeName = toNodeName(head); - final String moduleName = ControllerContext.toModuleName(head); - - DataSchemaNode targetNode = null; - if (!Strings.isNullOrEmpty(moduleName)) { - if (Objects.equal(moduleName, ControllerContext.MOUNT_MODULE) - && Objects.equal(nodeName, ControllerContext.MOUNT_NODE)) { - if (mountPoint != null) { - throw new RestconfDocumentedException("Restconf supports just one mount point in URI.", - ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED); - } - - if (mountService == null) { - throw new RestconfDocumentedException( - "MountService was not found. Finding behind mount points does not work.", - ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED); - } - - final YangInstanceIdentifier partialPath = dataNormalizer.toNormalized(builder.build()); - final Optional mountOpt = mountService.getMountPoint(partialPath); - if (!mountOpt.isPresent()) { - LOG.debug("Instance identifier to missing mount point: {}", partialPath); - throw new RestconfDocumentedException("Mount point does not exist.", ErrorType.PROTOCOL, - ErrorTag.DATA_MISSING); - } - final DOMMountPoint mount = mountOpt.get(); - - final SchemaContext mountPointSchema = mount.getSchemaContext(); - if (mountPointSchema == null) { - throw new RestconfDocumentedException("Mount point does not contain any schema with modules.", - ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT); - } - - if (returnJustMountPoint || strings.size() == 1) { - final YangInstanceIdentifier instance = YangInstanceIdentifier.builder().toInstance(); - return new InstanceIdentifierContext<>(instance, mountPointSchema, mount,mountPointSchema); - } - - final String moduleNameBehindMountPoint = toModuleName(strings.get(1)); - if (moduleNameBehindMountPoint == null) { - throw new RestconfDocumentedException( - "First node after mount point in URI has to be in format \"moduleName:nodeName\"", - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - final Module moduleBehindMountPoint = mountPointSchema.findModuleByName(moduleNameBehindMountPoint, null); - if (moduleBehindMountPoint == null) { - throw new RestconfDocumentedException("\"" + moduleName - + "\" module does not exist in mount point.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); - } - - final List subList = strings.subList(1, strings.size()); - return collectPathArguments(YangInstanceIdentifier.builder(), subList, moduleBehindMountPoint, mount, - returnJustMountPoint); - } - - Module module = null; - if (mountPoint == null) { - checkPreconditions(); - module = globalSchema.findModuleByName(moduleName, null); - if (module == null) { - throw new RestconfDocumentedException("\"" + moduleName + "\" module does not exist.", - ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); - } - } else { - final SchemaContext schemaContext = mountPoint.getSchemaContext(); - if (schemaContext != null) { - module = schemaContext.findModuleByName(moduleName, null); - } else { - module = null; - } - if (module == null) { - throw new RestconfDocumentedException("\"" + moduleName - + "\" module does not exist in mount point.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); - } - } - - targetNode = findInstanceDataChildByNameAndNamespace(parentNode, nodeName, module.getNamespace()); - - if (targetNode == null && parentNode instanceof Module) { - final RpcDefinition rpc = ControllerContext.getInstance().getRpcDefinition(head); - if (rpc != null) { - return new InstanceIdentifierContext(builder.build(), rpc, mountPoint, - mountPoint != null ? mountPoint.getSchemaContext() : globalSchema); - } - } - - if (targetNode == null) { - throw new RestconfDocumentedException("URI has bad format. Possible reasons:\n" + " 1. \"" + head - + "\" was not found in parent data node.\n" + " 2. \"" + head - + "\" is behind mount point. Then it should be in format \"/" + MOUNT + "/" + head + "\".", - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - } else { - final List potentialSchemaNodes = findInstanceDataChildrenByName(parentNode, nodeName); - if (potentialSchemaNodes.size() > 1) { - final StringBuilder strBuilder = new StringBuilder(); - for (final DataSchemaNode potentialNodeSchema : potentialSchemaNodes) { - strBuilder.append(" ").append(potentialNodeSchema.getQName().getNamespace()).append("\n"); - } - - throw new RestconfDocumentedException( - "URI has bad format. Node \"" - + nodeName - + "\" is added as augment from more than one module. " - + "Therefore the node must have module name and it has to be in format \"moduleName:nodeName\"." - + "\nThe node is added as augment from modules with namespaces:\n" - + strBuilder.toString(), ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - if (potentialSchemaNodes.isEmpty()) { - throw new RestconfDocumentedException("\"" + nodeName + "\" in URI was not found in parent data node", - ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); - } - - targetNode = potentialSchemaNodes.iterator().next(); - } - - if (!ControllerContext.isListOrContainer(targetNode)) { - throw new RestconfDocumentedException("URI has bad format. Node \"" + head - + "\" must be Container or List yang type.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - int consumed = 1; - if ((targetNode instanceof ListSchemaNode)) { - final ListSchemaNode listNode = ((ListSchemaNode) targetNode); - final int keysSize = listNode.getKeyDefinition().size(); - if ((strings.size() - consumed) < keysSize) { - throw new RestconfDocumentedException("Missing key for list \"" + listNode.getQName().getLocalName() - + "\".", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING); - } - - final List uriKeyValues = strings.subList(consumed, consumed + keysSize); - final HashMap keyValues = new HashMap(); - int i = 0; - for (final QName key : listNode.getKeyDefinition()) { - { - final String uriKeyValue = uriKeyValues.get(i); - if (uriKeyValue.equals(NULL_VALUE)) { - throw new RestconfDocumentedException("URI has bad format. List \"" - + listNode.getQName().getLocalName() + "\" cannot contain \"null\" value as a key.", - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - addKeyValue(keyValues, listNode.getDataChildByName(key), uriKeyValue, mountPoint); - i++; - } - } - - consumed = consumed + i; - builder.nodeWithKey(targetNode.getQName(), keyValues); - } else { - builder.node(targetNode.getQName()); - } - - if ((targetNode instanceof DataNodeContainer)) { - final List remaining = strings.subList(consumed, strings.size()); - return collectPathArguments(builder, remaining, ((DataNodeContainer) targetNode), mountPoint, - returnJustMountPoint); - } - - return createContext(builder.build(), targetNode, mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : globalSchema); - } - - private InstanceIdentifierContext createContext(final YangInstanceIdentifier instance, final DataSchemaNode dataSchemaNode, - final DOMMountPoint mountPoint, final SchemaContext schemaContext) { - - final YangInstanceIdentifier instanceIdentifier = new DataNormalizer(schemaContext).toNormalized(instance); - return new InstanceIdentifierContext<>(instanceIdentifier, dataSchemaNode, mountPoint,schemaContext); - } - - public static DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container, final String name, - final URI namespace) { - Preconditions. checkNotNull(namespace); - - final List potentialSchemaNodes = findInstanceDataChildrenByName(container, name); - - final Predicate filter = new Predicate() { - @Override - public boolean apply(final DataSchemaNode node) { - return Objects.equal(node.getQName().getNamespace(), namespace); - } - }; - - final Iterable result = Iterables.filter(potentialSchemaNodes, filter); - return Iterables.getFirst(result, null); - } - - public static List findInstanceDataChildrenByName(final DataNodeContainer container, final String name) { - Preconditions. checkNotNull(container); - Preconditions. checkNotNull(name); - - final List instantiatedDataNodeContainers = new ArrayList(); - collectInstanceDataNodeContainers(instantiatedDataNodeContainers, container, name); - return instantiatedDataNodeContainers; - } - - private static final Function> CHOICE_FUNCTION = new Function>() { - @Override - public Set apply(final ChoiceSchemaNode node) { - return node.getCases(); - } - }; - - private static void collectInstanceDataNodeContainers(final List potentialSchemaNodes, - final DataNodeContainer container, final String name) { - - final Predicate filter = new Predicate() { - @Override - public boolean apply(final DataSchemaNode node) { - return Objects.equal(node.getQName().getLocalName(), name); - } - }; - - final Iterable nodes = Iterables.filter(container.getChildNodes(), filter); - - // Can't combine this loop with the filter above because the filter is - // lazily-applied by Iterables.filter. - for (final DataSchemaNode potentialNode : nodes) { - if (isInstantiatedDataSchema(potentialNode)) { - potentialSchemaNodes.add(potentialNode); - } - } - - final Iterable choiceNodes = Iterables.filter(container.getChildNodes(), ChoiceSchemaNode.class); - final Iterable> map = Iterables.transform(choiceNodes, CHOICE_FUNCTION); - - final Iterable allCases = Iterables. concat(map); - for (final ChoiceCaseNode caze : allCases) { - collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name); - } - } - - public static boolean isInstantiatedDataSchema(final DataSchemaNode node) { - return node instanceof LeafSchemaNode || node instanceof LeafListSchemaNode - || node instanceof ContainerSchemaNode || node instanceof ListSchemaNode - || node instanceof AnyXmlSchemaNode; - } - - private void addKeyValue(final HashMap map, final DataSchemaNode node, final String uriValue, - final DOMMountPoint mountPoint) { - Preconditions.checkNotNull(uriValue); - Preconditions.checkArgument((node instanceof LeafSchemaNode)); - - final String urlDecoded = urlPathArgDecode(uriValue); - TypeDefinition typedef = ((LeafSchemaNode) node).getType(); - final TypeDefinition baseType = RestUtil.resolveBaseTypeFrom(typedef); - if (baseType instanceof LeafrefTypeDefinition) { - typedef = SchemaContextUtil.getBaseTypeForLeafRef((LeafrefTypeDefinition) baseType, globalSchema, node); - } - Codec codec = RestCodec.from(typedef, mountPoint); - Object decoded = codec.deserialize(urlDecoded); - String additionalInfo = ""; - if (decoded == null) { - if ((baseType instanceof IdentityrefTypeDefinition)) { - decoded = toQName(urlDecoded); - additionalInfo = "For key which is of type identityref it should be in format module_name:identity_name."; - } - } - - if (decoded == null) { - throw new RestconfDocumentedException(uriValue + " from URI can't be resolved. " + additionalInfo, - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - map.put(node.getQName(), decoded); - } - - private static String toModuleName(final String str) { - final int idx = str.indexOf(':'); - if (idx == -1) { - return null; - } - - // Make sure there is only one occurrence - if (str.indexOf(':', idx + 1) != -1) { - return null; - } - - return str.substring(0, idx); - } - - private static String toNodeName(final String str) { - final int idx = str.indexOf(':'); - if (idx == -1) { - return str; - } - - // Make sure there is only one occurrence - if (str.indexOf(':', idx + 1) != -1) { - return str; - } - - return str.substring(idx + 1); - } - - private QName toQName(final String name) { - checkPreconditions(); - final String module = toModuleName(name); - final String node = toNodeName(name); - final Module m = globalSchema.findModuleByName(module, null); - return m == null ? null : QName.create(m.getQNameModule(), node); - } - - private static boolean isListOrContainer(final DataSchemaNode node) { - return node instanceof ListSchemaNode || node instanceof ContainerSchemaNode; - } - - public RpcDefinition getRpcDefinition(final String name) { - final QName validName = toQName(name); - return validName == null ? null : qnameToRpc.get().get(validName); - } - - @Override - public void onGlobalContextUpdated(final SchemaContext context) { - if (context != null) { - final Collection defs = context.getOperations(); - final Map newMap = new HashMap<>(defs.size()); - - for (final RpcDefinition operation : defs) { - newMap.put(operation.getQName(), operation); - } - - // FIXME: still not completely atomic - qnameToRpc.set(ImmutableMap.copyOf(newMap)); - setGlobalSchema(context); - } - } - - public static List urlPathArgsDecode(final Iterable strings) { - try { - final List decodedPathArgs = new ArrayList(); - for (final String pathArg : strings) { - final String _decode = URLDecoder.decode(pathArg, URI_ENCODING_CHAR_SET); - decodedPathArgs.add(_decode); - } - return decodedPathArgs; - } catch (final UnsupportedEncodingException e) { - throw new RestconfDocumentedException("Invalid URL path '" + strings + "': " + e.getMessage(), - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - } - - public String urlPathArgDecode(final String pathArg) { - if (pathArg != null) { - try { - return URLDecoder.decode(pathArg, URI_ENCODING_CHAR_SET); - } catch (final UnsupportedEncodingException e) { - throw new RestconfDocumentedException("Invalid URL path arg '" + pathArg + "': " + e.getMessage(), - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - } - - return null; - } - - private CharSequence convertToRestconfIdentifier(final PathArgument argument, final DataSchemaNode node, final DOMMountPoint mount) { - if (argument instanceof NodeIdentifier) { - return convertToRestconfIdentifier((NodeIdentifier) argument, mount); - } else if (argument instanceof NodeIdentifierWithPredicates && node instanceof ListSchemaNode) { - return convertToRestconfIdentifierWithPredicates((NodeIdentifierWithPredicates) argument, (ListSchemaNode) node, mount); - } else if (argument != null && node != null) { - throw new IllegalArgumentException("Conversion of generic path argument is not supported"); - } else { - throw new IllegalArgumentException("Unhandled parameter types: " - + Arrays. asList(argument, node).toString()); - } - } - - private CharSequence convertToRestconfIdentifier(final NodeIdentifier argument, final DOMMountPoint node) { - return "/" + this.toRestconfIdentifier(argument.getNodeType(),node); - } - - private CharSequence convertToRestconfIdentifierWithPredicates(final NodeIdentifierWithPredicates argument, - final ListSchemaNode node, final DOMMountPoint mount) { - final QName nodeType = argument.getNodeType(); - final CharSequence nodeIdentifier = this.toRestconfIdentifier(nodeType, mount); - final Map keyValues = argument.getKeyValues(); - - final StringBuilder builder = new StringBuilder(); - builder.append('/'); - builder.append(nodeIdentifier); - builder.append('/'); - - final List keyDefinition = node.getKeyDefinition(); - boolean hasElements = false; - for (final QName key : keyDefinition) { - for (final DataSchemaNode listChild : node.getChildNodes()) { - if (listChild.getQName().equals(key)) { - if (!hasElements) { - hasElements = true; - } else { - builder.append('/'); - } - - try { - Preconditions.checkState(listChild instanceof LeafSchemaNode, "List key has to consist of leaves"); - builder.append(toUriString(keyValues.get(key), (LeafSchemaNode)listChild, mount)); - } catch (final UnsupportedEncodingException e) { - LOG.error("Error parsing URI: {}", keyValues.get(key), e); - return null; - } - break; - } - } - } - - return builder.toString(); - } - - private static DataSchemaNode childByQName(final Object container, final QName name) { - if (container instanceof ChoiceCaseNode) { - return childByQName((ChoiceCaseNode) container, name); - } else if (container instanceof ChoiceSchemaNode) { - return childByQName((ChoiceSchemaNode) container, name); - } else if (container instanceof ContainerSchemaNode) { - return childByQName((ContainerSchemaNode) container, name); - } else if (container instanceof ListSchemaNode) { - return childByQName((ListSchemaNode) container, name); - } else if (container instanceof DataSchemaNode) { - return childByQName((DataSchemaNode) container, name); - } else if (container instanceof Module) { - return childByQName((Module) container, name); - } else { - throw new IllegalArgumentException("Unhandled parameter types: " - + Arrays. asList(container, name).toString()); - } - } - - public YangInstanceIdentifier toNormalized(final YangInstanceIdentifier legacy) { - try { - return dataNormalizer.toNormalized(legacy); - } catch (final NullPointerException e) { - throw new RestconfDocumentedException("Data normalizer isn't set. Normalization isn't possible", e); - } - } - - public YangInstanceIdentifier toXpathRepresentation(final YangInstanceIdentifier instanceIdentifier) { - try { - return dataNormalizer.toLegacy(instanceIdentifier); - } catch (final NullPointerException e) { - throw new RestconfDocumentedException("Data normalizer isn't set. Normalization isn't possible", e); - } catch (final DataNormalizationException e) { - throw new RestconfDocumentedException("Data normalizer failed. Normalization isn't possible", e); - } - } - - public boolean isNodeMixin(final YangInstanceIdentifier path) { - final DataNormalizationOperation operation; - try { - operation = dataNormalizer.getOperation(path); - } catch (final DataNormalizationException e) { - throw new RestconfDocumentedException("Data normalizer failed. Normalization isn't possible", e); - } - return operation.isMixin(); - } - - public DataNormalizationOperation getRootOperation() { - return dataNormalizer.getRootOperation(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java deleted file mode 100644 index 248830830e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public final class IdentityValuesDTO { - - private final List elementData = new ArrayList<>(); - private final String originValue; - - public IdentityValuesDTO(final String namespace, final String value, final String prefix, final String originValue) { - elementData.add(new IdentityValue(namespace, value)); - this.originValue = originValue; - } - - public IdentityValuesDTO(final String originValue) { - this.originValue = originValue; - } - - public IdentityValuesDTO() { - originValue = null; - } - - public void add(final String namespace, final String value, final String prefix) { - elementData.add(new IdentityValue(namespace, value)); - } - - public void add(final IdentityValue identityValue) { - elementData.add(identityValue); - } - - public List getValuesWithNamespaces() { - return Collections.unmodifiableList(elementData); - } - - @Override - public String toString() { - return elementData.toString(); - } - - public String getOriginValue() { - return originValue; - } - - public static final class IdentityValue { - - private final String namespace; - private final String value; - private List predicates; - - public IdentityValue(final String namespace, final String value) { - this.namespace = namespace; - this.value = value; - } - - public String getNamespace() { - return namespace; - } - - public String getValue() { - return value; - } - - - public List getPredicates() { - if (predicates == null) { - return Collections.emptyList(); - } - return Collections.unmodifiableList(predicates); - } - - public void setPredicates(final List predicates) { - this.predicates = predicates; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - if (namespace != null) { - sb.append(namespace); - } - if (value != null) { - sb.append(" - ").append(value); - } - if (predicates != null && !predicates.isEmpty()) { - for (final Predicate predicate : predicates) { - sb.append("["); - predicate.toString(); - sb.append("]"); - } - } - return sb.toString(); - } - - } - - public static final class Predicate { - - private final IdentityValue name; - private final String value; - - public Predicate(final IdentityValue name, final String value) { - super(); - this.name = name; - this.value = value; - } - - public IdentityValue getName() { - return name; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - if (name != null) { - sb.append(name.toString()); - } - if (value != null) { - sb.append("=").append(value); - } - return sb.toString(); - } - - public boolean isLeafList() { - return name == null ? true : false; - } - - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/InstanceIdentifierContext.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/InstanceIdentifierContext.java deleted file mode 100644 index c7e5a2a002..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/InstanceIdentifierContext.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; - -public class InstanceIdentifierContext { - - private final YangInstanceIdentifier instanceIdentifier; - private final T schemaNode; - private final DOMMountPoint mountPoint; - private final SchemaContext schemaContext; - - public InstanceIdentifierContext(final YangInstanceIdentifier instanceIdentifier, final T schemaNode, - final DOMMountPoint mountPoint,final SchemaContext context) { - this.instanceIdentifier = instanceIdentifier; - this.schemaNode = schemaNode; - this.mountPoint = mountPoint; - this.schemaContext = context; - } - - public YangInstanceIdentifier getInstanceIdentifier() { - return instanceIdentifier; - } - - public T getSchemaNode() { - return schemaNode; - } - - public DOMMountPoint getMountPoint() { - return mountPoint; - } - - public SchemaContext getSchemaContext() { - return schemaContext; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NormalizedDataPrunner.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NormalizedDataPrunner.java deleted file mode 100644 index 5d0185b4cc..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NormalizedDataPrunner.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; -import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; -import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.MixinNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; - -class NormalizedDataPrunner { - - public DataContainerChild pruneDataAtDepth(final DataContainerChild node, final Integer depth) { - if (depth == null) { - return node; - } - - if (node instanceof LeafNode || node instanceof LeafSetNode || node instanceof AnyXmlNode - || node instanceof OrderedLeafSetNode) { - return node; - } else if (node instanceof MixinNode) { - return processMixinNode(node, depth); - } else if (node instanceof DataContainerNode) { - return processContainerNode(node, depth); - } - throw new IllegalStateException("Unexpected Mixin node occured why pruning data to requested depth"); - } - - private DataContainerChild processMixinNode(final NormalizedNode node, final Integer depth) { - if (node instanceof AugmentationNode) { - return processAugmentationNode(node, depth); - } else if (node instanceof ChoiceNode) { - return processChoiceNode(node, depth); - } else if (node instanceof OrderedMapNode) { - return processOrderedMapNode(node, depth); - } else if (node instanceof MapNode) { - return processMapNode(node, depth); - } else if (node instanceof UnkeyedListNode) { - return processUnkeyedListNode(node, depth); - } - throw new IllegalStateException("Unexpected Mixin node occured why pruning data to requested depth"); - } - - private DataContainerChild processContainerNode(final NormalizedNode node, final Integer depth) { - final ContainerNode containerNode = (ContainerNode) node; - DataContainerNodeAttrBuilder newContainerBuilder = Builders.containerBuilder() - .withNodeIdentifier(containerNode.getIdentifier()); - if (depth > 1) { - processDataContainerChild((DataContainerNode) node, depth, newContainerBuilder); - } - return newContainerBuilder.build(); - } - - private DataContainerChild processChoiceNode(final NormalizedNode node, final Integer depth) { - final ChoiceNode choiceNode = (ChoiceNode) node; - DataContainerNodeBuilder newChoiceBuilder = Builders.choiceBuilder() - .withNodeIdentifier(choiceNode.getIdentifier()); - - processDataContainerChild((DataContainerNode) node, depth, newChoiceBuilder); - - return newChoiceBuilder.build(); - } - - private DataContainerChild processAugmentationNode(final NormalizedNode node, final Integer depth) { - final AugmentationNode augmentationNode = (AugmentationNode) node; - DataContainerNodeBuilder> newAugmentationBuilder = Builders - .augmentationBuilder().withNodeIdentifier(augmentationNode.getIdentifier()); - - processDataContainerChild((DataContainerNode) node, depth, newAugmentationBuilder); - - return newAugmentationBuilder.build(); - } - - private void processDataContainerChild( - final DataContainerNode node, - final Integer depth, - final DataContainerNodeBuilder> newBuilder) { - - for (DataContainerChild nodeValue : node.getValue()) { - newBuilder.withChild(pruneDataAtDepth(nodeValue, depth - 1)); - } - - } - - private DataContainerChild processUnkeyedListNode(final NormalizedNode node, final Integer depth) { - CollectionNodeBuilder newUnkeyedListBuilder = Builders - .unkeyedListBuilder(); - if (depth > 1) { - for (UnkeyedListEntryNode oldUnkeyedListEntry : ((UnkeyedListNode) node).getValue()) { - DataContainerNodeAttrBuilder newUnkeyedListEntry = Builders - .unkeyedListEntryBuilder().withNodeIdentifier(oldUnkeyedListEntry.getIdentifier()); - for (DataContainerChild oldUnkeyedListEntryValue : oldUnkeyedListEntry - .getValue()) { - newUnkeyedListEntry.withChild(pruneDataAtDepth(oldUnkeyedListEntryValue, depth - 1)); - } - newUnkeyedListBuilder.addChild(newUnkeyedListEntry.build()); - } - } - return newUnkeyedListBuilder.build(); - } - - private DataContainerChild processOrderedMapNode(final NormalizedNode node, final Integer depth) { - CollectionNodeBuilder newOrderedMapNodeBuilder = Builders.orderedMapBuilder(); - processMapEntries(node, depth, newOrderedMapNodeBuilder); - return newOrderedMapNodeBuilder.build(); - } - - private DataContainerChild processMapNode(final NormalizedNode node, final Integer depth) { - CollectionNodeBuilder newMapNodeBuilder = Builders.mapBuilder(); - processMapEntries(node, depth, newMapNodeBuilder); - return newMapNodeBuilder.build(); - } - - private void processMapEntries(final NormalizedNode node, final Integer depth, - CollectionNodeBuilder newOrderedMapNodeBuilder) { - if (depth > 1) { - for (MapEntryNode oldMapEntryNode : ((MapNode) node).getValue()) { - DataContainerNodeAttrBuilder newMapEntryNodeBuilder = Builders - .mapEntryBuilder().withNodeIdentifier(oldMapEntryNode.getIdentifier()); - for (DataContainerChild mapEntryNodeValue : oldMapEntryNode.getValue()) { - newMapEntryNodeBuilder.withChild(pruneDataAtDepth(mapEntryNodeValue, depth - 1)); - } - newOrderedMapNodeBuilder.withChild(newMapEntryNodeBuilder.build()); - } - } - } - - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NormalizedNodeContext.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NormalizedNodeContext.java deleted file mode 100644 index 3adecaf8f3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NormalizedNodeContext.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; - -public class NormalizedNodeContext { - - private final InstanceIdentifierContext context; - private final NormalizedNode data; - private final WriterParameters writerParameters; - - public NormalizedNodeContext(final InstanceIdentifierContext context, - final NormalizedNode data, WriterParameters writerParameters) { - this.context = context; - this.data = data; - this.writerParameters = writerParameters; - } - - public NormalizedNodeContext(final InstanceIdentifierContext context, - final NormalizedNode data) { - this.context = context; - this.data = data; - // default writer parameters - this.writerParameters = new WriterParameters.WriterParametersBuilder().build(); - } - - public InstanceIdentifierContext getInstanceIdentifierContext() { - return context; - } - - public NormalizedNode getData() { - return data; - } - - public WriterParameters getWriterParameters() { - return writerParameters; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/QueryParametersParser.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/QueryParametersParser.java deleted file mode 100644 index 4fc716e78a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/QueryParametersParser.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import com.google.common.base.Strings; -import javax.ws.rs.core.UriInfo; - -public class QueryParametersParser { - - private enum UriParameters { - PRETTY_PRINT("prettyPrint"), - DEPTH("depth"); - - private String uriParameterName; - - UriParameters(final String uriParameterName) { - this.uriParameterName = uriParameterName; - } - - @Override - public String toString() { - return uriParameterName; - } - } - - public static WriterParameters parseWriterParameters(final UriInfo info) { - WriterParameters.WriterParametersBuilder wpBuilder = new WriterParameters.WriterParametersBuilder(); - String param = info.getQueryParameters(false).getFirst(UriParameters.DEPTH.toString()); - if (!Strings.isNullOrEmpty(param) && !"unbounded".equals(param)) { - try { - final int depth = Integer.valueOf(param); - if (depth < 1) { - throw new RestconfDocumentedException(new RestconfError(RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE, - "Invalid depth parameter: " + depth, null, - "The depth parameter must be an integer > 1 or \"unbounded\"")); - } - wpBuilder.setDepth(depth); - } catch (final NumberFormatException e) { - throw new RestconfDocumentedException(new RestconfError(RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.INVALID_VALUE, - "Invalid depth parameter: " + e.getMessage(), null, - "The depth parameter must be an integer > 1 or \"unbounded\"")); - } - } - param = info.getQueryParameters(false).getFirst(UriParameters.PRETTY_PRINT.toString()); - wpBuilder.setPrettyPrint("true".equals(param)); - return wpBuilder.build(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java deleted file mode 100644 index 763d1c604e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.sal.rest.impl.RestUtil; -import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO.IdentityValue; -import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO.Predicate; -import org.opendaylight.yangtools.concepts.Codec; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.codec.IdentityrefCodec; -import org.opendaylight.yangtools.yang.data.api.codec.InstanceIdentifierCodec; -import org.opendaylight.yangtools.yang.data.api.codec.LeafrefCodec; -import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RestCodec { - - private static final Logger logger = LoggerFactory.getLogger(RestCodec.class); - - private RestCodec() { - } - - public static final Codec from(final TypeDefinition typeDefinition, - final DOMMountPoint mountPoint) { - return new ObjectCodec(typeDefinition, mountPoint); - } - - @SuppressWarnings("rawtypes") - public static final class ObjectCodec implements Codec { - - private final Logger logger = LoggerFactory.getLogger(RestCodec.class); - - public static final Codec LEAFREF_DEFAULT_CODEC = new LeafrefCodecImpl(); - private final Codec instanceIdentifier; - private final Codec identityrefCodec; - - private final TypeDefinition type; - - private ObjectCodec(final TypeDefinition typeDefinition, final DOMMountPoint mountPoint) { - type = RestUtil.resolveBaseTypeFrom(typeDefinition); - if (type instanceof IdentityrefTypeDefinition) { - identityrefCodec = new IdentityrefCodecImpl(mountPoint); - } else { - identityrefCodec = null; - } - if (type instanceof InstanceIdentifierTypeDefinition) { - instanceIdentifier = new InstanceIdentifierCodecImpl(mountPoint); - } else { - instanceIdentifier = null; - } - } - - @SuppressWarnings("unchecked") - @Override - public Object deserialize(final Object input) { - try { - if (type instanceof IdentityrefTypeDefinition) { - if (input instanceof IdentityValuesDTO) { - return identityrefCodec.deserialize(input); - } - logger.debug( - "Value is not instance of IdentityrefTypeDefinition but is {}. Therefore NULL is used as translation of - {}", - input == null ? "null" : input.getClass(), String.valueOf(input)); - return null; - } else if (type instanceof InstanceIdentifierTypeDefinition) { - if (input instanceof IdentityValuesDTO) { - return instanceIdentifier.deserialize(input); - } - logger.info( - "Value is not instance of InstanceIdentifierTypeDefinition but is {}. Therefore NULL is used as translation of - {}", - input == null ? "null" : input.getClass(), String.valueOf(input)); - return null; - } else { - final TypeDefinitionAwareCodec> typeAwarecodec = TypeDefinitionAwareCodec - .from(type); - if (typeAwarecodec != null) { - if (input instanceof IdentityValuesDTO) { - return typeAwarecodec.deserialize(((IdentityValuesDTO) input).getOriginValue()); - } - return typeAwarecodec.deserialize(String.valueOf(input)); - } else { - logger.debug("Codec for type \"" + type.getQName().getLocalName() - + "\" is not implemented yet."); - return null; - } - } - } catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs - logger.error( - "ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input), - e); - return null; - } - } - - @SuppressWarnings("unchecked") - @Override - public Object serialize(final Object input) { - try { - if (type instanceof IdentityrefTypeDefinition) { - return identityrefCodec.serialize(input); - } else if (type instanceof LeafrefTypeDefinition) { - return LEAFREF_DEFAULT_CODEC.serialize(input); - } else if (type instanceof InstanceIdentifierTypeDefinition) { - return instanceIdentifier.serialize(input); - } else { - final TypeDefinitionAwareCodec> typeAwarecodec = TypeDefinitionAwareCodec - .from(type); - if (typeAwarecodec != null) { - return typeAwarecodec.serialize(input); - } else { - logger.debug("Codec for type \"" + type.getQName().getLocalName() - + "\" is not implemented yet."); - return null; - } - } - } catch (final ClassCastException e) { // TODO remove this catch when everyone use codecs - logger.error( - "ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input), - e); - return input; - } - } - - } - - public static class IdentityrefCodecImpl implements IdentityrefCodec { - - private final Logger logger = LoggerFactory.getLogger(IdentityrefCodecImpl.class); - - private final DOMMountPoint mountPoint; - - public IdentityrefCodecImpl(final DOMMountPoint mountPoint) { - this.mountPoint = mountPoint; - } - - @Override - public IdentityValuesDTO serialize(final QName data) { - return new IdentityValuesDTO(data.getNamespace().toString(), data.getLocalName(), null, null); - } - - @Override - public QName deserialize(final IdentityValuesDTO data) { - final IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0); - final Module module = getModuleByNamespace(valueWithNamespace.getNamespace(), mountPoint); - if (module == null) { - logger.info("Module was not found for namespace {}", valueWithNamespace.getNamespace()); - logger.info("Idenetityref will be translated as NULL for data - {}", String.valueOf(valueWithNamespace)); - return null; - } - - return QName.create(module.getNamespace(), module.getRevision(), valueWithNamespace.getValue()); - } - - } - - public static class LeafrefCodecImpl implements LeafrefCodec { - - @Override - public String serialize(final Object data) { - return String.valueOf(data); - } - - @Override - public Object deserialize(final String data) { - return data; - } - - } - - public static class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec { - private final Logger logger = LoggerFactory.getLogger(InstanceIdentifierCodecImpl.class); - private final DOMMountPoint mountPoint; - - public InstanceIdentifierCodecImpl(final DOMMountPoint mountPoint) { - this.mountPoint = mountPoint; - } - - @Override - public IdentityValuesDTO serialize(final YangInstanceIdentifier data) { - final IdentityValuesDTO identityValuesDTO = new IdentityValuesDTO(); - for (final PathArgument pathArgument : data.getPathArguments()) { - final IdentityValue identityValue = qNameToIdentityValue(pathArgument.getNodeType()); - if (pathArgument instanceof NodeIdentifierWithPredicates && identityValue != null) { - final List predicates = keyValuesToPredicateList(((NodeIdentifierWithPredicates) pathArgument) - .getKeyValues()); - identityValue.setPredicates(predicates); - } else if (pathArgument instanceof NodeWithValue && identityValue != null) { - final List predicates = new ArrayList<>(); - final String value = String.valueOf(((NodeWithValue) pathArgument).getValue()); - predicates.add(new Predicate(null, value)); - identityValue.setPredicates(predicates); - } - identityValuesDTO.add(identityValue); - } - return identityValuesDTO; - } - - @Override - public YangInstanceIdentifier deserialize(final IdentityValuesDTO data) { - final List result = new ArrayList(); - final IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0); - final Module module = getModuleByNamespace(valueWithNamespace.getNamespace(), mountPoint); - if (module == null) { - logger.info("Module by namespace '{}' of first node in instance-identifier was not found.", - valueWithNamespace.getNamespace()); - logger.info("Instance-identifier will be translated as NULL for data - {}", - String.valueOf(valueWithNamespace.getValue())); - return null; - } - - DataNodeContainer parentContainer = module; - final List identities = data.getValuesWithNamespaces(); - for (int i = 0; i < identities.size(); i++) { - final IdentityValue identityValue = identities.get(i); - URI validNamespace = resolveValidNamespace(identityValue.getNamespace(), mountPoint); - final DataSchemaNode node = ControllerContext.findInstanceDataChildByNameAndNamespace( - parentContainer, identityValue.getValue(), validNamespace); - if (node == null) { - logger.info("'{}' node was not found in {}", identityValue, parentContainer.getChildNodes()); - logger.info("Instance-identifier will be translated as NULL for data - {}", - String.valueOf(identityValue.getValue())); - return null; - } - final QName qName = node.getQName(); - PathArgument pathArgument = null; - if (identityValue.getPredicates().isEmpty()) { - pathArgument = new NodeIdentifier(qName); - } else { - if (node instanceof LeafListSchemaNode) { // predicate is value of leaf-list entry - final Predicate leafListPredicate = identityValue.getPredicates().get(0); - if (!leafListPredicate.isLeafList()) { - logger.info("Predicate's data is not type of leaf-list. It should be in format \".='value'\""); - logger.info("Instance-identifier will be translated as NULL for data - {}", - String.valueOf(identityValue.getValue())); - return null; - } - pathArgument = new NodeWithValue(qName, leafListPredicate.getValue()); - } else if (node instanceof ListSchemaNode) { // predicates are keys of list - final DataNodeContainer listNode = (DataNodeContainer) node; - final Map predicatesMap = new HashMap<>(); - for (final Predicate predicate : identityValue.getPredicates()) { - validNamespace = resolveValidNamespace(predicate.getName().getNamespace(), mountPoint); - final DataSchemaNode listKey = ControllerContext - .findInstanceDataChildByNameAndNamespace(listNode, predicate.getName().getValue(), - validNamespace); - predicatesMap.put(listKey.getQName(), predicate.getValue()); - } - pathArgument = new NodeIdentifierWithPredicates(qName, predicatesMap); - } else { - logger.info("Node {} is not List or Leaf-list.", node); - logger.info("Instance-identifier will be translated as NULL for data - {}", - String.valueOf(identityValue.getValue())); - return null; - } - } - result.add(pathArgument); - if (i < identities.size() - 1) { // last element in instance-identifier can be other than - // DataNodeContainer - if (node instanceof DataNodeContainer) { - parentContainer = (DataNodeContainer) node; - } else { - logger.info("Node {} isn't instance of DataNodeContainer", node); - logger.info("Instance-identifier will be translated as NULL for data - {}", - String.valueOf(identityValue.getValue())); - return null; - } - } - } - - return result.isEmpty() ? null : YangInstanceIdentifier.create(result); - } - - private List keyValuesToPredicateList(final Map keyValues) { - final List result = new ArrayList<>(); - for (final QName qName : keyValues.keySet()) { - final Object value = keyValues.get(qName); - result.add(new Predicate(qNameToIdentityValue(qName), String.valueOf(value))); - } - return result; - } - - private IdentityValue qNameToIdentityValue(final QName qName) { - if (qName != null) { - return new IdentityValue(qName.getNamespace().toString(), qName.getLocalName()); - } - return null; - } - } - - private static Module getModuleByNamespace(final String namespace, final DOMMountPoint mountPoint) { - final URI validNamespace = resolveValidNamespace(namespace, mountPoint); - - Module module = null; - if (mountPoint != null) { - module = ControllerContext.getInstance().findModuleByNamespace(mountPoint, validNamespace); - } else { - module = ControllerContext.getInstance().findModuleByNamespace(validNamespace); - } - if (module == null) { - logger.info("Module for namespace " + validNamespace + " wasn't found."); - return null; - } - return module; - } - - private static URI resolveValidNamespace(final String namespace, final DOMMountPoint mountPoint) { - URI validNamespace; - if (mountPoint != null) { - validNamespace = ControllerContext.getInstance().findNamespaceByModuleName(mountPoint, namespace); - } else { - validNamespace = ControllerContext.getInstance().findNamespaceByModuleName(namespace); - } - if (validNamespace == null) { - validNamespace = URI.create(namespace); - } - - return validNamespace; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfDocumentedException.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfDocumentedException.java deleted file mode 100644 index bfa987ab8d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfDocumentedException.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -import java.util.Collection; -import java.util.List; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response.Status; - -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcError; - -/** - * Unchecked exception to communicate error information, as defined in the ietf restcong draft, to be sent to the - * client. - * - * @author Devin Avery - * @author Thomas Pantelis - * @see {@link https://tools.ietf.org/html/draft-bierman-netconf-restconf-02} - */ -public class RestconfDocumentedException extends WebApplicationException { - - private static final long serialVersionUID = 1L; - - private final List errors; - private final Status status; - - /** - * Constructs an instance with an error message. The error type defaults to APPLICATION and the error tag defaults - * to OPERATION_FAILED. - * - * @param message - * A string which provides a plain text string describing the error. - */ - public RestconfDocumentedException(String message) { - this(message, RestconfError.ErrorType.APPLICATION, RestconfError.ErrorTag.OPERATION_FAILED); - } - - /** - * Constructs an instance with an error message, error type, and error tag. - * - * @param message - * A string which provides a plain text string describing the error. - * @param errorType - * The enumerated type indicating the layer where the error occurred. - * @param errorTag - * The enumerated tag representing a more specific error cause. - */ - public RestconfDocumentedException(String message, ErrorType errorType, ErrorTag errorTag) { - this(null, new RestconfError(errorType, errorTag, message)); - } - - /** - * Constructs an instance with an error message and exception cause. - * The stack trace of the exception is included in the error info. - * - * @param message - * A string which provides a plain text string describing the error. - * @param cause - * The underlying exception cause. - */ - public RestconfDocumentedException(String message, Throwable cause) { - this(cause, new RestconfError(RestconfError.ErrorType.APPLICATION, RestconfError.ErrorTag.OPERATION_FAILED, - message, null, RestconfError.toErrorInfo(cause))); - } - - /** - * Constructs an instance with the given error. - */ - public RestconfDocumentedException(RestconfError error) { - this(null, error); - } - - /** - * Constructs an instance with the given errors. - */ - public RestconfDocumentedException(String message, Throwable cause, List errors) { - // FIXME: We override getMessage so supplied message is lost for any public access - // this was lost also in original code. - super(cause); - if(!errors.isEmpty()) { - this.errors = ImmutableList.copyOf(errors); - } else { - this.errors = ImmutableList.of(new RestconfError(RestconfError.ErrorType.APPLICATION, - RestconfError.ErrorTag.OPERATION_FAILED, message)); - } - - status = null; - } - - /** - * Constructs an instance with the given RpcErrors. - */ - public RestconfDocumentedException(String message, Throwable cause, Collection rpcErrors) { - this(message, cause, convertToRestconfErrors(rpcErrors)); - } - - /** - * Constructs an instance with an HTTP status and no error information. - * - * @param status - * the HTTP status. - */ - public RestconfDocumentedException(Status status) { - Preconditions.checkNotNull(status, "Status can't be null"); - errors = ImmutableList.of(); - this.status = status; - } - - private RestconfDocumentedException(Throwable cause, RestconfError error) { - super(cause); - Preconditions.checkNotNull(error, "RestconfError can't be null"); - errors = ImmutableList.of(error); - status = null; - } - - private static List convertToRestconfErrors(Collection rpcErrors) { - List errorList = Lists.newArrayList(); - if(rpcErrors != null) { - for (RpcError rpcError : rpcErrors) { - errorList.add(new RestconfError(rpcError)); - } - } - - return errorList; - } - - - public List getErrors() { - return errors; - } - - public Status getStatus() { - return status; - } - - @Override - public String getMessage() { - return "errors: " + errors + (status != null ? ", status: " + status : ""); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfError.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfError.java deleted file mode 100644 index 544a144987..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfError.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import com.google.common.base.Preconditions; -import java.io.PrintWriter; -import java.io.StringWriter; -import org.opendaylight.yangtools.yang.common.RpcError; - -/** - * Encapsulates a restconf error as defined in the ietf restconf draft. - * - *
- *
- * Note: Enumerations defined within are provided by the ietf restconf draft. - * - * @author Devin Avery - * @see {@link https://tools.ietf.org/html/draft-bierman-netconf-restconf-02} - */ -public class RestconfError { - - public static enum ErrorType { - /** Errors relating to the transport layer */ - TRANSPORT, - /** Errors relating to the RPC or notification layer */ - RPC, - /** Errors relating to the protocol operation layer. */ - PROTOCOL, - /** Errors relating to the server application layer. */ - APPLICATION; - - public String getErrorTypeTag() { - return name().toLowerCase(); - } - - public static ErrorType valueOfCaseInsensitive(String value) { - try { - return ErrorType.valueOf(ErrorType.class, value.toUpperCase()); - } catch (IllegalArgumentException e) { - return APPLICATION; - } - } - } - - public static enum ErrorTag { - IN_USE("in-use", 409 /* Conflict */), - INVALID_VALUE("invalid-value", 400 /* Bad Request */), - TOO_BIG("too-big", 413 /* Request Entity Too Large */), - MISSING_ATTRIBUTE("missing-attribute", 400 /* Bad Request */), - BAD_ATTRIBUTE("bad-attribute", 400 /* Bad Request */), - UNKNOWN_ATTRIBUTE("unknown-attribute", 400 /* Bad Request */), - BAD_ELEMENT("bad-element", 400 /* Bad Request */), - UNKNOWN_ELEMENT("unknown-element", 400 /* Bad Request */), - UNKNOWN_NAMESPACE("unknown-namespace", 400 /* Bad Request */), - ACCESS_DENIED("access-denied", 403 /* Forbidden */), - LOCK_DENIED("lock-denied", 409 /* Conflict */), - RESOURCE_DENIED("resource-denied", 409 /* Conflict */), - ROLLBACK_FAILED("rollback-failed", 500 /* INTERNAL_SERVER_ERROR */), - DATA_EXISTS("data-exists", 409 /* Conflict */), - DATA_MISSING("data-missing", 404 /* Resource Not Found */), - OPERATION_NOT_SUPPORTED("operation-not-supported", 501 /* Not Implemented */), - OPERATION_FAILED("operation-failed", 500 /* INTERNAL_SERVER_ERROR */), - PARTIAL_OPERATION("partial-operation", 500 /* INTERNAL_SERVER_ERROR */), - MALFORMED_MESSAGE("malformed-message", 400 /* Bad Request */); - - private final String tagValue; - private final int statusCode; - - ErrorTag(final String tagValue, final int statusCode) { - this.tagValue = tagValue; - this.statusCode = statusCode; - } - - public String getTagValue() { - return this.tagValue.toLowerCase(); - } - - public static ErrorTag valueOfCaseInsensitive(String value) { - try { - return ErrorTag.valueOf(ErrorTag.class, value.toUpperCase().replaceAll("-", "_")); - } catch (IllegalArgumentException e) { - return OPERATION_FAILED; - } - } - - public int getStatusCode() { - return statusCode; - } - } - - private final ErrorType errorType; - private final ErrorTag errorTag; - private final String errorInfo; - private final String errorAppTag; - private final String errorMessage; - - // TODO: Add in the error-path concept as defined in the ietf draft. - - static String toErrorInfo(Throwable cause) { - StringWriter writer = new StringWriter(); - cause.printStackTrace(new PrintWriter(writer)); - return writer.toString(); - } - - /** - * Constructs a RestConfError - * - * @param errorType - * The enumerated type indicating the layer where the error occurred. - * @param errorTag - * The enumerated tag representing a more specific error cause. - * @param errorMessage - * A string which provides a plain text string describing the error. - */ - public RestconfError(ErrorType errorType, ErrorTag errorTag, String errorMessage) { - this(errorType, errorTag, errorMessage, null); - } - - /** - * Constructs a RestConfError object. - * - * @param errorType - * The enumerated type indicating the layer where the error occurred. - * @param errorTag - * The enumerated tag representing a more specific error cause. - * @param errorMessage - * A string which provides a plain text string describing the error. - * @param errorAppTag - * A string which represents an application-specific error tag that further specifies the error cause. - */ - public RestconfError(ErrorType errorType, ErrorTag errorTag, String errorMessage, String errorAppTag) { - this(errorType, errorTag, errorMessage, errorAppTag, null); - } - - /** - * Constructs a RestConfError object. - * - * @param errorType - * The enumerated type indicating the layer where the error occurred. - * @param errorTag - * The enumerated tag representing a more specific error cause. - * @param errorMessage - * A string which provides a plain text string describing the error. - * @param errorAppTag - * A string which represents an application-specific error tag that further specifies the error cause. - * @param errorInfo - * A string, formatted as XML, which contains additional error information. - */ - public RestconfError(ErrorType errorType, ErrorTag errorTag, String errorMessage, String errorAppTag, - String errorInfo) { - Preconditions.checkNotNull(errorType, "Error type is required for RestConfError"); - Preconditions.checkNotNull(errorTag, "Error tag is required for RestConfError"); - this.errorType = errorType; - this.errorTag = errorTag; - this.errorMessage = errorMessage; - this.errorAppTag = errorAppTag; - this.errorInfo = errorInfo; - } - - /** - * Constructs a RestConfError object from an RpcError. - */ - public RestconfError(RpcError rpcError) { - - this.errorType = rpcError.getErrorType() == null ? ErrorType.APPLICATION : ErrorType - .valueOfCaseInsensitive(rpcError.getErrorType().name()); - - this.errorTag = rpcError.getTag() == null ? ErrorTag.OPERATION_FAILED : ErrorTag - .valueOfCaseInsensitive(rpcError.getTag().toString()); - - this.errorMessage = rpcError.getMessage(); - this.errorAppTag = rpcError.getApplicationTag(); - - String errorInfo = null; - if (rpcError.getInfo() == null) { - if (rpcError.getCause() != null) { - errorInfo = toErrorInfo(rpcError.getCause()); - } else if (rpcError.getSeverity() != null) { - errorInfo = "" + rpcError.getSeverity().toString().toLowerCase() + ""; - } - } else { - errorInfo = rpcError.getInfo(); - } - - this.errorInfo = errorInfo; - } - - public ErrorType getErrorType() { - return errorType; - } - - public ErrorTag getErrorTag() { - return errorTag; - } - - public String getErrorInfo() { - return errorInfo; - } - - public String getErrorAppTag() { - return errorAppTag; - } - - public String getErrorMessage() { - return errorMessage; - } - - @Override - public String toString() { - return "error-type: " + errorType.getErrorTypeTag() + ", error-tag: " + errorTag.getTagValue() + ", " - + (errorAppTag != null ? "error-app-tag: " + errorAppTag + ", " : "") - + (errorMessage != null ? "error-message: " + errorMessage : "") - + (errorInfo != null ? "error-info: " + errorInfo + ", " : "") + "]"; - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java deleted file mode 100644 index bc84832b78..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java +++ /dev/null @@ -1,1160 +0,0 @@ -/** - * Copyright (c) 2014, 2015 Brocade Communication Systems, Inc., Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.base.Splitter; -import com.google.common.base.Strings; -import com.google.common.base.Throwables; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import java.math.BigInteger; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriInfo; -import org.apache.commons.lang3.StringUtils; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.controller.md.sal.rest.common.RestconfValidationUtils; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.api.RestconfService; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.controller.sal.streams.listeners.ListenerAdapter; -import org.opendaylight.controller.sal.streams.listeners.Notificator; -import org.opendaylight.controller.sal.streams.websockets.WebSocketServer; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.QNameModule; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.tree.ModifiedNodeDoesNotExistException; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.FeatureDefinition; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.util.EmptyType; -import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; -import org.opendaylight.yangtools.yang.parser.builder.api.GroupingBuilder; -import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder; -import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder; -import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RestconfImpl implements RestconfService { - - private static final RestconfImpl INSTANCE = new RestconfImpl(); - - private static final int NOTIFICATION_PORT = 8181; - - private static final int CHAR_NOT_FOUND = -1; - - private static final String MOUNT_POINT_MODULE_NAME = "ietf-netconf"; - - private static final SimpleDateFormat REVISION_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - - private static final String SAL_REMOTE_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote"; - - private static final String SAL_REMOTE_RPC_SUBSRCIBE = "create-data-change-event-subscription"; - - private BrokerFacade broker; - - private ControllerContext controllerContext; - - private static final Logger LOG = LoggerFactory.getLogger(RestconfImpl.class); - - private static final DataChangeScope DEFAULT_SCOPE = DataChangeScope.BASE; - - private static final LogicalDatastoreType DEFAULT_DATASTORE = LogicalDatastoreType.CONFIGURATION; - - private static final URI NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT = URI.create("urn:sal:restconf:event:subscription"); - - private static final String DATASTORE_PARAM_NAME = "datastore"; - - private static final String SCOPE_PARAM_NAME = "scope"; - - private static final String NETCONF_BASE = "urn:ietf:params:xml:ns:netconf:base:1.0"; - - private static final String NETCONF_BASE_PAYLOAD_NAME = "data"; - - private static final QName NETCONF_BASE_QNAME; - - private static final QNameModule SAL_REMOTE_AUGMENT; - - private static final YangInstanceIdentifier.AugmentationIdentifier SAL_REMOTE_AUG_IDENTIFIER; - - static { - try { - final Date eventSubscriptionAugRevision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-07-08"); - NETCONF_BASE_QNAME = QName.create(QNameModule.create(new URI(NETCONF_BASE), null), NETCONF_BASE_PAYLOAD_NAME ); - SAL_REMOTE_AUGMENT = QNameModule.create(NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT, - eventSubscriptionAugRevision); - SAL_REMOTE_AUG_IDENTIFIER = new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(QName.create(SAL_REMOTE_AUGMENT, "scope"), - QName.create(SAL_REMOTE_AUGMENT, "datastore"))); - } catch (final ParseException e) { - final String errMsg = "It wasn't possible to convert revision date of sal-remote-augment to date"; - LOG.debug(errMsg); - throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED); - } catch (final URISyntaxException e) { - final String errMsg = "It wasn't possible to create instance of URI class with "+NETCONF_BASE+" URI"; - throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED); - } - } - - public void setBroker(final BrokerFacade broker) { - this.broker = broker; - } - - public void setControllerContext(final ControllerContext controllerContext) { - this.controllerContext = controllerContext; - } - - private RestconfImpl() { - } - - public static RestconfImpl getInstance() { - return INSTANCE; - } - - @Override - public NormalizedNodeContext getModules(final UriInfo uriInfo) { - final Set allModules = controllerContext.getAllModules(); - final MapNode allModuleMap = makeModuleMapNode(allModules); - - final SchemaContext schemaContext = controllerContext.getGlobalSchema(); - - final Module restconfModule = getRestconfModule(); - final DataSchemaNode modulesSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode( - restconfModule, Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE); - Preconditions.checkState(modulesSchemaNode instanceof ContainerSchemaNode); - - final DataContainerNodeAttrBuilder moduleContainerBuilder = - Builders.containerBuilder((ContainerSchemaNode) modulesSchemaNode); - moduleContainerBuilder.withChild(allModuleMap); - - return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, modulesSchemaNode, - null, schemaContext), moduleContainerBuilder.build(), - QueryParametersParser.parseWriterParameters(uriInfo)); - } - - /** - * Valid only for mount point - */ - @Override - public NormalizedNodeContext getModules(final String identifier, final UriInfo uriInfo) { - Preconditions.checkNotNull(identifier); - 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(errMsg + " for " + identifier); - throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - final InstanceIdentifierContext mountPointIdentifier = controllerContext.toMountPointIdentifier(identifier); - final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint(); - final Set modules = controllerContext.getAllModules(mountPoint); - final MapNode mountPointModulesMap = makeModuleMapNode(modules); - - final Module restconfModule = getRestconfModule(); - final DataSchemaNode modulesSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode( - restconfModule, Draft02.RestConfModule.MODULES_CONTAINER_SCHEMA_NODE); - Preconditions.checkState(modulesSchemaNode instanceof ContainerSchemaNode); - - final DataContainerNodeAttrBuilder moduleContainerBuilder = - Builders.containerBuilder((ContainerSchemaNode) modulesSchemaNode); - moduleContainerBuilder.withChild(mountPointModulesMap); - - return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, modulesSchemaNode, - mountPoint, controllerContext.getGlobalSchema()), moduleContainerBuilder.build(), - QueryParametersParser.parseWriterParameters(uriInfo)); - } - - @Override - public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) { - Preconditions.checkNotNull(identifier); - final QName moduleNameAndRevision = getModuleNameAndRevision(identifier); - Module module = null; - DOMMountPoint mountPoint = null; - final SchemaContext schemaContext; - if (identifier.contains(ControllerContext.MOUNT)) { - final InstanceIdentifierContext mountPointIdentifier = controllerContext.toMountPointIdentifier(identifier); - mountPoint = mountPointIdentifier.getMountPoint(); - module = controllerContext.findModuleByNameAndRevision(mountPoint, moduleNameAndRevision); - schemaContext = mountPoint.getSchemaContext(); - } else { - module = controllerContext.findModuleByNameAndRevision(moduleNameAndRevision); - schemaContext = controllerContext.getGlobalSchema(); - } - - if (module == null) { - final String errMsg = "Module with name '" + moduleNameAndRevision.getLocalName() - + "' and revision '" + moduleNameAndRevision.getRevision() + "' was not found."; - LOG.debug(errMsg); - throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); - } - - final Module restconfModule = getRestconfModule(); - final Set modules = Collections.singleton(module); - final MapNode moduleMap = makeModuleMapNode(modules); - - final DataSchemaNode moduleSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode( - restconfModule, Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE); - Preconditions.checkState(moduleSchemaNode instanceof ListSchemaNode); - - return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, moduleSchemaNode, mountPoint, - schemaContext), moduleMap, QueryParametersParser.parseWriterParameters(uriInfo)); - } - - @Override - public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) { - final SchemaContext schemaContext = controllerContext.getGlobalSchema(); - final Set availableStreams = Notificator.getStreamNames(); - final Module restconfModule = getRestconfModule(); - final DataSchemaNode streamSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, - Draft02.RestConfModule.STREAM_LIST_SCHEMA_NODE); - Preconditions.checkState(streamSchemaNode instanceof ListSchemaNode); - - final CollectionNodeBuilder listStreamsBuilder = Builders - .mapBuilder((ListSchemaNode) streamSchemaNode); - - for (final String streamName : availableStreams) { - listStreamsBuilder.withChild(toStreamEntryNode(streamName, streamSchemaNode)); - } - - final DataSchemaNode streamsContainerSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode( - restconfModule, Draft02.RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE); - Preconditions.checkState(streamsContainerSchemaNode instanceof ContainerSchemaNode); - - final DataContainerNodeAttrBuilder streamsContainerBuilder = - Builders.containerBuilder((ContainerSchemaNode) streamsContainerSchemaNode); - streamsContainerBuilder.withChild(listStreamsBuilder.build()); - - - return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, streamsContainerSchemaNode, null, - schemaContext), streamsContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo)); - } - - @Override - public NormalizedNodeContext getOperations(final UriInfo uriInfo) { - final Set allModules = controllerContext.getAllModules(); - return operationsFromModulesToNormalizedContext(allModules, null); - } - - @Override - public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) { - Set modules = null; - DOMMountPoint mountPoint = null; - if (identifier.contains(ControllerContext.MOUNT)) { - final InstanceIdentifierContext mountPointIdentifier = controllerContext.toMountPointIdentifier(identifier); - mountPoint = mountPointIdentifier.getMountPoint(); - modules = controllerContext.getAllModules(mountPoint); - - } else { - final String errMsg = "URI has bad format. If operations behind mount point should be showed, URI has to end with "; - LOG.debug(errMsg + ControllerContext.MOUNT + " for " + identifier); - throw new RestconfDocumentedException(errMsg + ControllerContext.MOUNT, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - return operationsFromModulesToNormalizedContext(modules, mountPoint); - } - - private static final Predicate GROUPING_FILTER = new Predicate() { - @Override - public boolean apply(final GroupingBuilder g) { - return Draft02.RestConfModule.RESTCONF_GROUPING_SCHEMA_NODE.equals(g.getQName().getLocalName()); - } - }; - - private NormalizedNodeContext operationsFromModulesToNormalizedContext(final Set modules, - final DOMMountPoint mountPoint) { - - final Module restconfModule = getRestconfModule(); - final ModuleBuilder restConfModuleBuilder = new ModuleBuilder(restconfModule); - final Set gropingBuilders = restConfModuleBuilder.getGroupingBuilders(); - final Iterable filteredGroups = Iterables.filter(gropingBuilders, GROUPING_FILTER); - final GroupingBuilder restconfGroupingBuilder = Iterables.getFirst(filteredGroups, null); - final ContainerSchemaNodeBuilder restContainerSchemaNodeBuilder = (ContainerSchemaNodeBuilder) restconfGroupingBuilder - .getDataChildByName(Draft02.RestConfModule.RESTCONF_CONTAINER_SCHEMA_NODE); - final ContainerSchemaNodeBuilder containerSchemaNodeBuilder = (ContainerSchemaNodeBuilder) restContainerSchemaNodeBuilder - .getDataChildByName(Draft02.RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE); - - final ContainerSchemaNodeBuilder fakeOperationsSchemaNodeBuilder = containerSchemaNodeBuilder; - final SchemaPath fakeSchemaPath = fakeOperationsSchemaNodeBuilder.getPath().createChild(QName.create("dummy")); - - final List> operationsAsData = new ArrayList<>(); - - for (final Module module : modules) { - final Set rpcs = module.getRpcs(); - for (final RpcDefinition rpc : rpcs) { - final QName rpcQName = rpc.getQName(); - final String name = module.getName(); - - final QName qName = QName.create(restconfModule.getQNameModule(), rpcQName.getLocalName()); - final LeafSchemaNodeBuilder leafSchemaNodeBuilder = new LeafSchemaNodeBuilder(name, 0, qName, fakeSchemaPath); - final LeafSchemaNodeBuilder fakeRpcSchemaNodeBuilder = leafSchemaNodeBuilder; - fakeRpcSchemaNodeBuilder.setAugmenting(true); - - final EmptyType instance = EmptyType.getInstance(); - fakeRpcSchemaNodeBuilder.setType(instance); - final LeafSchemaNode fakeRpcSchemaNode = fakeRpcSchemaNodeBuilder.build(); - fakeOperationsSchemaNodeBuilder.addChildNode(fakeRpcSchemaNode); - - final LeafNode leaf = Builders.leafBuilder(fakeRpcSchemaNode).build(); - operationsAsData.add(leaf); - } - } - - final ContainerSchemaNode operContainerSchemaNode = fakeOperationsSchemaNodeBuilder.build(); - final DataContainerNodeAttrBuilder operContainerNode = Builders.containerBuilder(operContainerSchemaNode); - - for (final LeafNode oper : operationsAsData) { - operContainerNode.withChild(oper); - } - - final Set fakeRpcModules = Collections.singleton(restConfModuleBuilder.build()); - - final YangParserImpl yangParser = new YangParserImpl(); - final SchemaContext fakeSchemaCx = yangParser.resolveSchemaContext(fakeRpcModules); - - final InstanceIdentifierContext fakeIICx = new InstanceIdentifierContext<>(null, operContainerSchemaNode, mountPoint, fakeSchemaCx); - - return new NormalizedNodeContext(fakeIICx, operContainerNode.build()); - } - - private Module getRestconfModule() { - final Module restconfModule = controllerContext.getRestconfModule(); - if (restconfModule == null) { - LOG.debug("ietf-restconf module was not found."); - throw new RestconfDocumentedException("ietf-restconf module was not found.", ErrorType.APPLICATION, - ErrorTag.OPERATION_NOT_SUPPORTED); - } - - return restconfModule; - } - - private QName getModuleNameAndRevision(final String identifier) { - final int mountIndex = identifier.indexOf(ControllerContext.MOUNT); - String moduleNameAndRevision = ""; - if (mountIndex >= 0) { - moduleNameAndRevision = identifier.substring(mountIndex + ControllerContext.MOUNT.length()); - } else { - moduleNameAndRevision = identifier; - } - - final Splitter splitter = Splitter.on("/").omitEmptyStrings(); - final Iterable split = splitter.split(moduleNameAndRevision); - final List pathArgs = Lists. newArrayList(split); - if (pathArgs.size() < 2) { - LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' " + identifier); - throw new RestconfDocumentedException( - "URI has bad format. End of URI should be in format \'moduleName/yyyy-MM-dd\'", ErrorType.PROTOCOL, - ErrorTag.INVALID_VALUE); - } - - try { - final String moduleName = pathArgs.get(0); - final String revision = pathArgs.get(1); - final Date moduleRevision = REVISION_FORMAT.parse(revision); - return QName.create(null, moduleRevision, moduleName); - } catch (final ParseException e) { - LOG.debug("URI has bad format. It should be \'moduleName/yyyy-MM-dd\' " + identifier); - throw new RestconfDocumentedException("URI has bad format. It should be \'moduleName/yyyy-MM-dd\'", - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - } - - @Override - public Object getRoot() { - return null; - } - - @Override - public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { - final SchemaPath type = payload.getInstanceIdentifierContext().getSchemaNode().getPath(); - final URI namespace = payload.getInstanceIdentifierContext().getSchemaNode().getQName().getNamespace(); - final CheckedFuture response; - final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint(); - final SchemaContext schemaContext; - if (identifier.contains(MOUNT_POINT_MODULE_NAME) && mountPoint != null) { - final Optional mountRpcServices = mountPoint.getService(DOMRpcService.class); - if ( ! mountRpcServices.isPresent()) { - LOG.debug("Error: Rpc service is missing."); - throw new RestconfDocumentedException("Rpc service is missing."); - } - schemaContext = mountPoint.getSchemaContext(); - response = mountRpcServices.get().invokeRpc(type, payload.getData()); - } else { - if (namespace.toString().equals(SAL_REMOTE_NAMESPACE)) { - response = invokeSalRemoteRpcSubscribeRPC(payload); - } else { - response = broker.invokeRpc(type, payload.getData()); - } - schemaContext = controllerContext.getGlobalSchema(); - } - - final DOMRpcResult result = checkRpcResponse(response); - - RpcDefinition resultNodeSchema = null; - final NormalizedNode resultData = result.getResult(); - if (result != null && result.getResult() != null) { - resultNodeSchema = (RpcDefinition) payload.getInstanceIdentifierContext().getSchemaNode(); - } - - return new NormalizedNodeContext(new InstanceIdentifierContext(null, - resultNodeSchema, mountPoint, schemaContext), resultData, - QueryParametersParser.parseWriterParameters(uriInfo)); - } - - private DOMRpcResult checkRpcResponse(final CheckedFuture response) { - if (response == null) { - return null; - } - try { - final DOMRpcResult retValue = response.get(); - if (retValue.getErrors() == null || retValue.getErrors().isEmpty()) { - return retValue; - } - LOG.debug("RpcError message", retValue.getErrors()); - throw new RestconfDocumentedException("RpcError message", null, retValue.getErrors()); - } catch (final InterruptedException e) { - final String errMsg = "The operation was interrupted while executing and did not complete."; - LOG.debug("Rpc Interrupt - " + errMsg, e); - throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION); - } catch (final ExecutionException e) { - LOG.debug("Execution RpcError: ", e); - Throwable cause = e.getCause(); - if (cause != null) { - while (cause.getCause() != null) { - cause = cause.getCause(); - } - - if (cause instanceof IllegalArgumentException) { - throw new RestconfDocumentedException(cause.getMessage(), ErrorType.PROTOCOL, - ErrorTag.INVALID_VALUE); - } - throw new RestconfDocumentedException("The operation encountered an unexpected error while executing.",cause); - } else { - throw new RestconfDocumentedException("The operation encountered an unexpected error while executing.",e); - } - } catch (final CancellationException e) { - final String errMsg = "The operation was cancelled while executing."; - LOG.debug("Cancel RpcExecution: " + errMsg, e); - throw new RestconfDocumentedException(errMsg, ErrorType.RPC, ErrorTag.PARTIAL_OPERATION); - } - } - - private void validateInput(final SchemaNode inputSchema, final NormalizedNodeContext payload) { - if (inputSchema != null && payload.getData() == null) { - // expected a non null payload - throw new RestconfDocumentedException("Input is required.", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE); - } else if (inputSchema == null && payload.getData() != null) { - // did not expect any input - throw new RestconfDocumentedException("No input expected.", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE); - } - // else - // { - // TODO: Validate "mandatory" and "config" values here??? Or should those be - // those be - // validate in a more central location inside MD-SAL core. - // } - } - - private CheckedFuture invokeSalRemoteRpcSubscribeRPC(final NormalizedNodeContext payload) { - final ContainerNode value = (ContainerNode) payload.getData(); - final QName rpcQName = payload.getInstanceIdentifierContext().getSchemaNode().getQName(); - final Optional> path = value.getChild(new NodeIdentifier( - QName.create(payload.getInstanceIdentifierContext().getSchemaNode().getQName(), "path"))); - final Object pathValue = path.isPresent() ? path.get().getValue() : null; - - if (!(pathValue instanceof YangInstanceIdentifier)) { - final String errMsg = "Instance identifier was not normalized correctly "; - LOG.debug(errMsg + rpcQName); - throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED); - } - - final YangInstanceIdentifier pathIdentifier = ((YangInstanceIdentifier) pathValue); - String streamName = null; - if (!pathIdentifier.isEmpty()) { - final String fullRestconfIdentifier = controllerContext.toFullRestconfIdentifier(pathIdentifier, null); - - LogicalDatastoreType datastore = parseEnumTypeParameter(value, LogicalDatastoreType.class, DATASTORE_PARAM_NAME); - datastore = datastore == null ? DEFAULT_DATASTORE : datastore; - - DataChangeScope scope = parseEnumTypeParameter(value, DataChangeScope.class, SCOPE_PARAM_NAME); - scope = scope == null ? DEFAULT_SCOPE : scope; - - streamName = Notificator.createStreamNameFromUri(fullRestconfIdentifier + "/datastore=" + datastore - + "/scope=" + scope); - } - - if (Strings.isNullOrEmpty(streamName)) { - final String errMsg = "Path is empty or contains value node which is not Container or List build-in type."; - LOG.debug(errMsg + pathIdentifier); - throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - final QName outputQname = QName.create(rpcQName, "output"); - final QName streamNameQname = QName.create(rpcQName, "stream-name"); - - final ContainerNode output = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(outputQname)) - .withChild(ImmutableNodes.leafNode(streamNameQname, streamName)).build(); - - if (!Notificator.existListenerFor(streamName)) { - Notificator.createListener(pathIdentifier, streamName); - } - - final DOMRpcResult defaultDOMRpcResult = new DefaultDOMRpcResult(output); - - return Futures.immediateCheckedFuture(defaultDOMRpcResult); - } - - @Override - public NormalizedNodeContext invokeRpc(final String identifier, final String noPayload, final UriInfo uriInfo) { - if (StringUtils.isNotBlank(noPayload)) { - throw new RestconfDocumentedException("Content must be empty.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - String identifierEncoded = null; - DOMMountPoint mountPoint = null; - final SchemaContext schemaContext; - if (identifier.contains(ControllerContext.MOUNT)) { - // mounted RPC call - look up mount instance. - final InstanceIdentifierContext mountPointId = controllerContext.toMountPointIdentifier(identifier); - mountPoint = mountPointId.getMountPoint(); - schemaContext = mountPoint.getSchemaContext(); - final int startOfRemoteRpcName = identifier.lastIndexOf(ControllerContext.MOUNT) - + ControllerContext.MOUNT.length() + 1; - final String remoteRpcName = identifier.substring(startOfRemoteRpcName); - identifierEncoded = remoteRpcName; - - } else if (identifier.indexOf("/") != CHAR_NOT_FOUND) { - final String slashErrorMsg = String.format("Identifier %n%s%ncan\'t contain slash " - + "character (/).%nIf slash is part of identifier name then use %%2F placeholder.", identifier); - LOG.debug(slashErrorMsg); - throw new RestconfDocumentedException(slashErrorMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } else { - identifierEncoded = identifier; - schemaContext = controllerContext.getGlobalSchema(); - } - - final String identifierDecoded = controllerContext.urlPathArgDecode(identifierEncoded); - - RpcDefinition rpc = null; - if (mountPoint == null) { - rpc = controllerContext.getRpcDefinition(identifierDecoded); - } else { - rpc = findRpc(mountPoint.getSchemaContext(), identifierDecoded); - } - - if (rpc == null) { - LOG.debug("RPC " + identifierDecoded + " does not exist."); - throw new RestconfDocumentedException("RPC does not exist.", ErrorType.RPC, ErrorTag.UNKNOWN_ELEMENT); - } - - if (rpc.getInput() != null) { - LOG.debug("RPC " + rpc + " does not need input value."); - // FIXME : find a correct Error from specification - throw new IllegalStateException("RPC " + rpc + " does'n need input value!"); - } - - final CheckedFuture response; - if (mountPoint != null) { - final Optional mountRpcServices = mountPoint.getService(DOMRpcService.class); - if ( ! mountRpcServices.isPresent()) { - throw new RestconfDocumentedException("Rpc service is missing."); - } - response = mountRpcServices.get().invokeRpc(rpc.getPath(), null); - } else { - response = broker.invokeRpc(rpc.getPath(), null); - } - - final DOMRpcResult result = checkRpcResponse(response); - - DataSchemaNode resultNodeSchema = null; - NormalizedNode resultData = null; - if (result != null && result.getResult() != null) { - resultData = result.getResult(); - final ContainerSchemaNode rpcDataSchemaNode = - SchemaContextUtil.getRpcDataSchema(schemaContext, rpc.getOutput().getPath()); - resultNodeSchema = rpcDataSchemaNode.getDataChildByName(result.getResult().getNodeType()); - } - - return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, resultNodeSchema, mountPoint, - schemaContext), resultData, QueryParametersParser.parseWriterParameters(uriInfo)); - } - - private RpcDefinition findRpc(final SchemaContext schemaContext, final String identifierDecoded) { - final String[] splittedIdentifier = identifierDecoded.split(":"); - if (splittedIdentifier.length != 2) { - final String errMsg = identifierDecoded + " couldn't be splitted to 2 parts (module:rpc name)"; - LOG.debug(errMsg); - throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.INVALID_VALUE); - } - for (final Module module : schemaContext.getModules()) { - if (module.getName().equals(splittedIdentifier[0])) { - for (final RpcDefinition rpcDefinition : module.getRpcs()) { - if (rpcDefinition.getQName().getLocalName().equals(splittedIdentifier[1])) { - return rpcDefinition; - } - } - } - } - return null; - } - - @Override - public NormalizedNodeContext readConfigurationData(final String identifier, final UriInfo uriInfo) { - final InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier(identifier); - final DOMMountPoint mountPoint = iiWithData.getMountPoint(); - NormalizedNode data = null; - final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier(); - if (mountPoint != null) { - data = broker.readConfigurationData(mountPoint, normalizedII); - } else { - data = broker.readConfigurationData(normalizedII); - } - if(data == null) { - final String errMsg = "Request could not be completed because the relevant data model content does not exist "; - LOG.debug(errMsg + identifier); - throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.DATA_MISSING); - } - return new NormalizedNodeContext(iiWithData, data, QueryParametersParser.parseWriterParameters(uriInfo)); - } - - @Override - public NormalizedNodeContext readOperationalData(final String identifier, final UriInfo uriInfo) { - final InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier(identifier); - final DOMMountPoint mountPoint = iiWithData.getMountPoint(); - NormalizedNode data = null; - final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier(); - if (mountPoint != null) { - data = broker.readOperationalData(mountPoint, normalizedII); - } else { - data = broker.readOperationalData(normalizedII); - } - if(data == null) { - final String errMsg = "Request could not be completed because the relevant data model content does not exist "; - LOG.debug(errMsg + identifier); - throw new RestconfDocumentedException(errMsg , ErrorType.APPLICATION, ErrorTag.DATA_MISSING); - } - return new NormalizedNodeContext(iiWithData, data, QueryParametersParser.parseWriterParameters(uriInfo)); - } - - @Override - public Response updateConfigurationData(final String identifier, final NormalizedNodeContext payload) { - Preconditions.checkNotNull(identifier); - final InstanceIdentifierContext iiWithData = payload.getInstanceIdentifierContext(); - - validateInput(iiWithData.getSchemaNode(), payload); - validateTopLevelNodeName(payload, iiWithData.getInstanceIdentifier()); - validateListKeysEqualityInPayloadAndUri(payload); - - final DOMMountPoint mountPoint = iiWithData.getMountPoint(); - final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier(); - - /* - * There is a small window where another write transaction could be updating the same data - * simultaneously and we get an OptimisticLockFailedException. This error is likely - * transient and The WriteTransaction#submit API docs state that a retry will likely - * succeed. So we'll try again if that scenario occurs. If it fails a third time then it - * probably will never succeed so we'll fail in that case. - * - * By retrying we're attempting to hide the internal implementation of the data store and - * how it handles concurrent updates from the restconf client. The client has instructed us - * to put the data and we should make every effort to do so without pushing optimistic lock - * failures back to the client and forcing them to handle it via retry (and having to - * document the behavior). - */ - int tries = 2; - while(true) { - try { - if (mountPoint != null) { - broker.commitConfigurationDataPut(mountPoint, normalizedII, payload.getData()).checkedGet(); - } else { - broker.commitConfigurationDataPut(controllerContext.getGlobalSchema(), normalizedII, payload.getData()).checkedGet(); - } - - break; - } catch (final TransactionCommitFailedException e) { - if(e instanceof OptimisticLockFailedException) { - if(--tries <= 0) { - LOG.debug("Got OptimisticLockFailedException on last try - failing " + identifier); - throw new RestconfDocumentedException(e.getMessage(), e, e.getErrorList()); - } - - LOG.debug("Got OptimisticLockFailedException - trying again " + identifier); - } else { - LOG.debug("Update ConfigDataStore fail " + identifier, e); - throw new RestconfDocumentedException(e.getMessage(), e, e.getErrorList()); - } - } catch (Exception e) { - final String errMsg = "Error updating data "; - LOG.debug(errMsg + identifier, e); - throw new RestconfDocumentedException(errMsg, e); - } - } - - return Response.status(Status.OK).build(); - } - - private void validateTopLevelNodeName(final NormalizedNodeContext node, - final YangInstanceIdentifier identifier) { - - final String payloadName = node.getData().getNodeType().getLocalName(); - - //no arguments - if (identifier.isEmpty()) { - //no "data" payload - if (!node.getData().getNodeType().equals(NETCONF_BASE_QNAME)) { - throw new RestconfDocumentedException("Instance identifier has to contain at least one path argument", - ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE); - } - //any arguments - } else { - final String identifierName = identifier.getLastPathArgument().getNodeType().getLocalName(); - if (!payloadName.equals(identifierName)) { - throw new RestconfDocumentedException("Payload name (" + payloadName - + ") is different from identifier name (" + identifierName + ")", ErrorType.PROTOCOL, - ErrorTag.MALFORMED_MESSAGE); - } - } - } - - /** - * Validates whether keys in {@code payload} are equal to values of keys in {@code iiWithData} for list schema node - * - * @throws RestconfDocumentedException - * if key values or key count in payload and URI isn't equal - * - */ - private static void validateListKeysEqualityInPayloadAndUri(final NormalizedNodeContext payload) { - Preconditions.checkArgument(payload != null); - final InstanceIdentifierContext iiWithData = payload.getInstanceIdentifierContext(); - final PathArgument lastPathArgument = iiWithData.getInstanceIdentifier().getLastPathArgument(); - final SchemaNode schemaNode = iiWithData.getSchemaNode(); - final NormalizedNode data = payload.getData(); - if (schemaNode instanceof ListSchemaNode) { - final List keyDefinitions = ((ListSchemaNode) schemaNode).getKeyDefinition(); - if (lastPathArgument instanceof NodeIdentifierWithPredicates && data instanceof MapEntryNode) { - final Map uriKeyValues = ((NodeIdentifierWithPredicates) lastPathArgument).getKeyValues(); - isEqualUriAndPayloadKeyValues(uriKeyValues, (MapEntryNode) data, keyDefinitions); - } - } - } - - private static void isEqualUriAndPayloadKeyValues(final Map uriKeyValues, - final MapEntryNode payload, final List keyDefinitions) { - - final Map mutableCopyUriKeyValues = Maps.newHashMap(uriKeyValues); - for (final QName keyDefinition : keyDefinitions) { - final Object uriKeyValue = mutableCopyUriKeyValues.remove(keyDefinition); - // should be caught during parsing URI to InstanceIdentifier - RestconfValidationUtils.checkDocumentedError(uriKeyValue != null, ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, - "Missing key " + keyDefinition + " in URI."); - - final Object dataKeyValue = payload.getIdentifier().getKeyValues().get(keyDefinition); - - if ( ! uriKeyValue.equals(dataKeyValue)) { - final String errMsg = "The value '" + uriKeyValue + "' for key '" + keyDefinition.getLocalName() + - "' specified in the URI doesn't match the value '" + dataKeyValue + "' specified in the message body. "; - throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - } - } - - @Override - public Response createConfigurationData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { - return createConfigurationData(payload, uriInfo); - } - - // FIXME create RestconfIdetifierHelper and move this method there - private YangInstanceIdentifier checkConsistencyOfNormalizedNodeContext(final NormalizedNodeContext payload) { - Preconditions.checkArgument(payload != null); - Preconditions.checkArgument(payload.getData() != null); - Preconditions.checkArgument(payload.getData().getNodeType() != null); - Preconditions.checkArgument(payload.getInstanceIdentifierContext() != null); - Preconditions.checkArgument(payload.getInstanceIdentifierContext().getInstanceIdentifier() != null); - - final QName payloadNodeQname = payload.getData().getNodeType(); - final YangInstanceIdentifier yangIdent = payload.getInstanceIdentifierContext().getInstanceIdentifier(); - if (payloadNodeQname.compareTo(yangIdent.getLastPathArgument().getNodeType()) > 0) { - return yangIdent; - } - final InstanceIdentifierContext parentContext = payload.getInstanceIdentifierContext(); - final SchemaNode parentSchemaNode = parentContext.getSchemaNode(); - if(parentSchemaNode instanceof DataNodeContainer) { - final DataNodeContainer cast = (DataNodeContainer) parentSchemaNode; - for (final DataSchemaNode child : cast.getChildNodes()) { - if (payloadNodeQname.compareTo(child.getQName()) == 0) { - return YangInstanceIdentifier.builder(yangIdent).node(child.getQName()).build(); - } - } - } - if (parentSchemaNode instanceof RpcDefinition) { - return yangIdent; - } - final String errMsg = "Error parsing input: DataSchemaNode has not children "; - LOG.info(errMsg + yangIdent); - throw new RestconfDocumentedException(errMsg, ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE); - } - - @Override - public Response createConfigurationData(final NormalizedNodeContext payload, final UriInfo uriInfo) { - if (payload == null) { - throw new RestconfDocumentedException("Input is required.", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE); - } - - // FIXME: move this to parsing stage (we can have augmentation nodes here which do not have namespace) -// final URI payloadNS = payload.getData().getNodeType().getNamespace(); -// if (payloadNS == null) { -// throw new RestconfDocumentedException( -// "Data has bad format. Root element node must have namespace (XML format) or module name(JSON format)", -// ErrorType.PROTOCOL, ErrorTag.UNKNOWN_NAMESPACE); -// } - - final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint(); - final InstanceIdentifierContext iiWithData = payload.getInstanceIdentifierContext(); - final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier(); - try { - if (mountPoint != null) { - broker.commitConfigurationDataPost(mountPoint, normalizedII, payload.getData()).checkedGet(); - } else { - broker.commitConfigurationDataPost(controllerContext.getGlobalSchema(), normalizedII, payload.getData()).checkedGet(); - } - } catch(final RestconfDocumentedException e) { - throw e; - } catch (final Exception e) { - final String errMsg = "Error creating data "; - LOG.info(errMsg + (uriInfo != null ? uriInfo.getPath() : ""), e); - throw new RestconfDocumentedException(errMsg, e); - } - - final ResponseBuilder responseBuilder = Response.status(Status.NO_CONTENT); - // FIXME: Provide path to result. - final URI location = resolveLocation(uriInfo, "", mountPoint, normalizedII); - if (location != null) { - responseBuilder.location(location); - } - return responseBuilder.build(); - } - - private URI resolveLocation(final UriInfo uriInfo, final String uriBehindBase, final DOMMountPoint mountPoint, final YangInstanceIdentifier normalizedII) { - final UriBuilder uriBuilder = uriInfo.getBaseUriBuilder(); - uriBuilder.path("config"); - try { - uriBuilder.path(controllerContext.toFullRestconfIdentifier(normalizedII, mountPoint)); - } catch (final Exception e) { - LOG.info("Location for instance identifier" + normalizedII + "wasn't created", e); - return null; - } - return uriBuilder.build(); - } - - @Override - public Response deleteConfigurationData(final String identifier) { - final InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier(identifier); - final DOMMountPoint mountPoint = iiWithData.getMountPoint(); - final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier(); - - try { - if (mountPoint != null) { - broker.commitConfigurationDataDelete(mountPoint, normalizedII); - } else { - broker.commitConfigurationDataDelete(normalizedII).get(); - } - } catch (final Exception e) { - final Optional searchedException = Iterables.tryFind(Throwables.getCausalChain(e), - Predicates.instanceOf(ModifiedNodeDoesNotExistException.class)); - if (searchedException.isPresent()) { - throw new RestconfDocumentedException("Data specified for deleting doesn't exist.", ErrorType.APPLICATION, ErrorTag.DATA_MISSING); - } - final String errMsg = "Error while deleting data"; - LOG.info(errMsg, e); - throw new RestconfDocumentedException(errMsg, e); - } - return Response.status(Status.OK).build(); - } - - /** - * Subscribes to some path in schema context (stream) to listen on changes on this stream. - * - * Additional parameters for subscribing to stream are loaded via rpc input parameters: - *
    - *
  • datastore
  • - default CONFIGURATION (other values of {@link LogicalDatastoreType} enum type) - *
  • scope
  • - default BASE (other values of {@link DataChangeScope}) - *
- */ - @Override - public Response subscribeToStream(final String identifier, final UriInfo uriInfo) { - final String streamName = Notificator.createStreamNameFromUri(identifier); - if (Strings.isNullOrEmpty(streamName)) { - throw new RestconfDocumentedException("Stream name is empty.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - final ListenerAdapter listener = Notificator.getListenerFor(streamName); - if (listener == null) { - throw new RestconfDocumentedException("Stream was not found.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); - } - - final Map paramToValues = resolveValuesFromUri(identifier); - final LogicalDatastoreType datastore = parserURIEnumParameter(LogicalDatastoreType.class, - paramToValues.get(DATASTORE_PARAM_NAME)); - if (datastore == null) { - throw new RestconfDocumentedException("Stream name doesn't contains datastore value (pattern /datastore=)", - ErrorType.APPLICATION, ErrorTag.MISSING_ATTRIBUTE); - } - final DataChangeScope scope = parserURIEnumParameter(DataChangeScope.class, paramToValues.get(SCOPE_PARAM_NAME)); - if (scope == null) { - throw new RestconfDocumentedException("Stream name doesn't contains datastore value (pattern /scope=)", - ErrorType.APPLICATION, ErrorTag.MISSING_ATTRIBUTE); - } - - broker.registerToListenDataChanges(datastore, scope, listener); - - final UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder(); - int notificationPort = NOTIFICATION_PORT; - try { - final WebSocketServer webSocketServerInstance = WebSocketServer.getInstance(); - notificationPort = webSocketServerInstance.getPort(); - } catch (final NullPointerException e) { - WebSocketServer.createInstance(NOTIFICATION_PORT); - } - final UriBuilder uriToWebsocketServerBuilder = uriBuilder.port(notificationPort).scheme("ws"); - final URI uriToWebsocketServer = uriToWebsocketServerBuilder.replacePath(streamName).build(); - - return Response.status(Status.OK).location(uriToWebsocketServer).build(); - } - - /** - * Load parameter for subscribing to stream from input composite node - * - * @param compNode - * contains value - * @return enum object if its string value is equal to {@code paramName}. In other cases null. - */ - private T parseEnumTypeParameter(final ContainerNode value, final Class classDescriptor, - final String paramName) { - final Optional> augNode = value.getChild(SAL_REMOTE_AUG_IDENTIFIER); - if (!augNode.isPresent() && !(augNode instanceof AugmentationNode)) { - return null; - } - final Optional> enumNode = - ((AugmentationNode) augNode.get()).getChild(new NodeIdentifier(QName.create(SAL_REMOTE_AUGMENT, paramName))); - if (!enumNode.isPresent()) { - return null; - } - final Object rawValue = enumNode.get().getValue(); - if (!(rawValue instanceof String)) { - return null; - } - - return resolveAsEnum(classDescriptor, (String) rawValue); - } - - /** - * Checks whether {@code value} is one of the string representation of enumeration {@code classDescriptor} - * - * @return enum object if string value of {@code classDescriptor} enumeration is equal to {@code value}. Other cases - * null. - */ - private T parserURIEnumParameter(final Class classDescriptor, final String value) { - if (Strings.isNullOrEmpty(value)) { - return null; - } - return resolveAsEnum(classDescriptor, value); - } - - private T resolveAsEnum(final Class classDescriptor, final String value) { - final T[] enumConstants = classDescriptor.getEnumConstants(); - if (enumConstants != null) { - for (final T enm : classDescriptor.getEnumConstants()) { - if (((Enum) enm).name().equals(value)) { - return enm; - } - } - } - return null; - } - - private Map resolveValuesFromUri(final String uri) { - final Map result = new HashMap<>(); - final String[] tokens = uri.split("/"); - for (int i = 1; i < tokens.length; i++) { - final String[] parameterTokens = tokens[i].split("="); - if (parameterTokens.length == 2) { - result.put(parameterTokens[0], parameterTokens[1]); - } - } - return result; - } - - public BigInteger getOperationalReceived() { - // TODO Auto-generated method stub - return null; - } - - private MapNode makeModuleMapNode(final Set modules) { - Preconditions.checkNotNull(modules); - final Module restconfModule = getRestconfModule(); - final DataSchemaNode moduleSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode( - restconfModule, Draft02.RestConfModule.MODULE_LIST_SCHEMA_NODE); - Preconditions.checkState(moduleSchemaNode instanceof ListSchemaNode); - - final CollectionNodeBuilder listModuleBuilder = Builders - .mapBuilder((ListSchemaNode) moduleSchemaNode); - - for (final Module module : modules) { - listModuleBuilder.withChild(toModuleEntryNode(module, moduleSchemaNode)); - } - return listModuleBuilder.build(); - } - - protected MapEntryNode toModuleEntryNode(final Module module, final DataSchemaNode moduleSchemaNode) { - Preconditions.checkArgument(moduleSchemaNode instanceof ListSchemaNode, - "moduleSchemaNode has to be of type ListSchemaNode"); - final ListSchemaNode listModuleSchemaNode = (ListSchemaNode) moduleSchemaNode; - final DataContainerNodeAttrBuilder moduleNodeValues = Builders - .mapEntryBuilder(listModuleSchemaNode); - - List instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listModuleSchemaNode), "name"); - final DataSchemaNode nameSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(nameSchemaNode instanceof LeafSchemaNode); - moduleNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) nameSchemaNode).withValue(module.getName()) - .build()); - - instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listModuleSchemaNode), "revision"); - final DataSchemaNode revisionSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(revisionSchemaNode instanceof LeafSchemaNode); - final String revision = REVISION_FORMAT.format(module.getRevision()); - moduleNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) revisionSchemaNode).withValue(revision) - .build()); - - instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listModuleSchemaNode), "namespace"); - final DataSchemaNode namespaceSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(namespaceSchemaNode instanceof LeafSchemaNode); - moduleNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) namespaceSchemaNode) - .withValue(module.getNamespace().toString()).build()); - - instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listModuleSchemaNode), "feature"); - final DataSchemaNode featureSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(featureSchemaNode instanceof LeafListSchemaNode); - final ListNodeBuilder> featuresBuilder = Builders - .leafSetBuilder((LeafListSchemaNode) featureSchemaNode); - for (final FeatureDefinition feature : module.getFeatures()) { - featuresBuilder.withChild(Builders.leafSetEntryBuilder(((LeafListSchemaNode) featureSchemaNode)) - .withValue(feature.getQName().getLocalName()).build()); - } - moduleNodeValues.withChild(featuresBuilder.build()); - - return moduleNodeValues.build(); - } - - protected MapEntryNode toStreamEntryNode(final String streamName, final DataSchemaNode streamSchemaNode) { - Preconditions.checkArgument(streamSchemaNode instanceof ListSchemaNode, - "streamSchemaNode has to be of type ListSchemaNode"); - final ListSchemaNode listStreamSchemaNode = (ListSchemaNode) streamSchemaNode; - final DataContainerNodeAttrBuilder streamNodeValues = Builders - .mapEntryBuilder(listStreamSchemaNode); - - List instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "name"); - final DataSchemaNode nameSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(nameSchemaNode instanceof LeafSchemaNode); - streamNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) nameSchemaNode).withValue(streamName) - .build()); - - instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "description"); - final DataSchemaNode descriptionSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(descriptionSchemaNode instanceof LeafSchemaNode); - streamNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) nameSchemaNode) - .withValue("DESCRIPTION_PLACEHOLDER").build()); - - instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "replay-support"); - final DataSchemaNode replaySupportSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(replaySupportSchemaNode instanceof LeafSchemaNode); - streamNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) replaySupportSchemaNode) - .withValue(Boolean.valueOf(true)).build()); - - instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "replay-log-creation-time"); - final DataSchemaNode replayLogCreationTimeSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(replayLogCreationTimeSchemaNode instanceof LeafSchemaNode); - streamNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) replayLogCreationTimeSchemaNode) - .withValue("").build()); - - instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName( - (listStreamSchemaNode), "events"); - final DataSchemaNode eventsSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); - Preconditions.checkState(eventsSchemaNode instanceof LeafSchemaNode); - streamNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) eventsSchemaNode) - .withValue("").build()); - - return streamNodeValues.build(); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfProviderImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfProviderImpl.java deleted file mode 100644 index 624d709c60..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfProviderImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import java.math.BigInteger; -import java.util.Collection; -import java.util.Collections; -import org.opendaylight.controller.config.yang.md.sal.rest.connector.Config; -import org.opendaylight.controller.config.yang.md.sal.rest.connector.Delete; -import org.opendaylight.controller.config.yang.md.sal.rest.connector.Get; -import org.opendaylight.controller.config.yang.md.sal.rest.connector.Operational; -import org.opendaylight.controller.config.yang.md.sal.rest.connector.Post; -import org.opendaylight.controller.config.yang.md.sal.rest.connector.Put; -import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeMXBean; -import org.opendaylight.controller.config.yang.md.sal.rest.connector.Rpcs; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.rest.api.RestConnector; -import org.opendaylight.controller.sal.streams.websockets.WebSocketServer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; - -public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnector, RestConnectorRuntimeMXBean { - - private final StatisticsRestconfServiceWrapper stats = StatisticsRestconfServiceWrapper.getInstance(); - private ListenerRegistration listenerRegistration; - private PortNumber port; - private Thread webSocketServerThread; - - public void setWebsocketPort(final PortNumber port) { - this.port = port; - } - - @Override - public void onSessionInitiated(final ProviderSession session) { - final DOMDataBroker domDataBroker = session.getService(DOMDataBroker.class); - - BrokerFacade.getInstance().setContext(session); - BrokerFacade.getInstance().setDomDataBroker( domDataBroker); - final SchemaService schemaService = session.getService(SchemaService.class); - listenerRegistration = schemaService.registerSchemaContextListener(ControllerContext.getInstance()); - BrokerFacade.getInstance().setRpcService(session.getService(DOMRpcService.class)); - - - ControllerContext.getInstance().setSchemas(schemaService.getGlobalContext()); - ControllerContext.getInstance().setMountService(session.getService(DOMMountPointService.class)); - - webSocketServerThread = new Thread(WebSocketServer.createInstance(port.getValue().intValue())); - webSocketServerThread.setName("Web socket server on port " + port); - webSocketServerThread.start(); - } - - @Override - public Collection getProviderFunctionality() { - return Collections.emptySet(); - } - - @Override - public void close() { - - if (listenerRegistration != null) { - listenerRegistration.close(); - } - - WebSocketServer.destroyInstance(); - webSocketServerThread.interrupt(); - } - - @Override - public Config getConfig() { - final Config config = new Config(); - - final Get get = new Get(); - get.setReceivedRequests(stats.getConfigGet()); - get.setSuccessfulResponses(stats.getSuccessGetConfig()); - get.setFailedResponses(stats.getFailureGetConfig()); - config.setGet(get); - - final Post post = new Post(); - post.setReceivedRequests(stats.getConfigPost()); - post.setSuccessfulResponses(stats.getSuccessPost()); - post.setFailedResponses(stats.getFailurePost()); - config.setPost(post); - - final Put put = new Put(); - put.setReceivedRequests(stats.getConfigPut()); - put.setSuccessfulResponses(stats.getSuccessPut()); - put.setFailedResponses(stats.getFailurePut()); - config.setPut(put); - - final Delete delete = new Delete(); - delete.setReceivedRequests(stats.getConfigDelete()); - delete.setSuccessfulResponses(stats.getSuccessDelete()); - delete.setFailedResponses(stats.getFailureDelete()); - config.setDelete(delete); - - return config; - } - - @Override - public Operational getOperational() { - final BigInteger opGet = stats.getOperationalGet(); - final Operational operational = new Operational(); - final Get get = new Get(); - get.setReceivedRequests(opGet); - get.setSuccessfulResponses(stats.getSuccessGetOperational()); - get.setFailedResponses(stats.getFailureGetOperational()); - operational.setGet(get); - return operational; - } - - @Override - public Rpcs getRpcs() { - final BigInteger rpcInvoke = stats.getRpc(); - final Rpcs rpcs = new Rpcs(); - rpcs.setReceivedRequests(rpcInvoke); - return rpcs; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/StatisticsRestconfServiceWrapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/StatisticsRestconfServiceWrapper.java deleted file mode 100644 index f4a5fbc926..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/StatisticsRestconfServiceWrapper.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; - -import java.math.BigInteger; -import java.util.concurrent.atomic.AtomicLong; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriInfo; -import org.opendaylight.controller.sal.rest.api.RestconfService; - -public class StatisticsRestconfServiceWrapper implements RestconfService { - - AtomicLong operationalGet = new AtomicLong(); - AtomicLong configGet = new AtomicLong(); - AtomicLong rpc = new AtomicLong(); - AtomicLong configPost = new AtomicLong(); - AtomicLong configPut = new AtomicLong(); - AtomicLong configDelete = new AtomicLong(); - AtomicLong successGetConfig = new AtomicLong(); - AtomicLong successGetOperational = new AtomicLong(); - AtomicLong successPost = new AtomicLong(); - AtomicLong successPut = new AtomicLong(); - AtomicLong successDelete = new AtomicLong(); - AtomicLong failureGetConfig = new AtomicLong(); - AtomicLong failureGetOperational = new AtomicLong(); - AtomicLong failurePost = new AtomicLong(); - AtomicLong failurePut = new AtomicLong(); - AtomicLong failureDelete = new AtomicLong(); - - private static final StatisticsRestconfServiceWrapper INSTANCE = new StatisticsRestconfServiceWrapper(RestconfImpl.getInstance()); - - final RestconfService delegate; - - private StatisticsRestconfServiceWrapper(final RestconfService delegate) { - this.delegate = delegate; - } - - public static StatisticsRestconfServiceWrapper getInstance() { - return INSTANCE; - } - - @Override - public Object getRoot() { - return delegate.getRoot(); - } - - @Override - public NormalizedNodeContext getModules(final UriInfo uriInfo) { - return delegate.getModules(uriInfo); - } - - @Override - public NormalizedNodeContext getModules(final String identifier, final UriInfo uriInfo) { - return delegate.getModules(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) { - return delegate.getModule(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext getOperations(final UriInfo uriInfo) { - return delegate.getOperations(uriInfo); - } - - @Override - public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) { - return delegate.getOperations(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { - rpc.incrementAndGet(); - return delegate.invokeRpc(identifier, payload, uriInfo); - } - - @Override - public NormalizedNodeContext invokeRpc(final String identifier, final String noPayload, final UriInfo uriInfo) { - rpc.incrementAndGet(); - return delegate.invokeRpc(identifier, noPayload, uriInfo); - } - - @Override - public NormalizedNodeContext readConfigurationData(final String identifier, final UriInfo uriInfo) { - configGet.incrementAndGet(); - NormalizedNodeContext normalizedNodeContext = null; - try { - normalizedNodeContext = delegate.readConfigurationData(identifier, uriInfo); - if (normalizedNodeContext.getData() != null) { - successGetConfig.incrementAndGet(); - } - else { - failureGetConfig.incrementAndGet(); - } - } catch (Exception e) { - failureGetConfig.incrementAndGet(); - throw e; - } - return normalizedNodeContext; - } - - @Override - public NormalizedNodeContext readOperationalData(final String identifier, final UriInfo uriInfo) { - operationalGet.incrementAndGet(); - NormalizedNodeContext normalizedNodeContext = null; - try { - normalizedNodeContext = delegate.readOperationalData(identifier, uriInfo); - if (normalizedNodeContext.getData() != null) { - successGetOperational.incrementAndGet(); - } - else { - failureGetOperational.incrementAndGet(); - } - } catch (Exception e) { - failureGetOperational.incrementAndGet(); - throw e; - } - return normalizedNodeContext; - } - - @Override - public Response updateConfigurationData(final String identifier, final NormalizedNodeContext payload) { - configPut.incrementAndGet(); - Response response = null; - try { - response = delegate.updateConfigurationData(identifier, payload); - if (response.getStatus() == Status.OK.getStatusCode()) { - successPut.incrementAndGet(); - } - else { - failurePut.incrementAndGet(); - } - } catch (Exception e) { - failurePut.incrementAndGet(); - throw e; - } - return response; - } - - @Override - public Response createConfigurationData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { - configPost.incrementAndGet(); - Response response = null; - try { - response = delegate.createConfigurationData(identifier, payload, uriInfo); - if (response.getStatus() == Status.OK.getStatusCode()) { - successPost.incrementAndGet(); - } - else { - failurePost.incrementAndGet(); - } - } catch (Exception e) { - failurePost.incrementAndGet(); - throw e; - } - return response; - } - - @Override - public Response createConfigurationData(final NormalizedNodeContext payload, final UriInfo uriInfo) { - configPost.incrementAndGet(); - Response response = null; - try { - response = delegate.createConfigurationData(payload, uriInfo); - if (response.getStatus() == Status.OK.getStatusCode()) { - successPost.incrementAndGet(); - } - else { - failurePost.incrementAndGet(); - } - }catch (Exception e) { - failurePost.incrementAndGet(); - throw e; - } - return response; - } - - @Override - public Response deleteConfigurationData(final String identifier) { - configDelete.incrementAndGet(); - Response response = null; - try { - response = delegate.deleteConfigurationData(identifier); - if (response.getStatus() == Status.OK.getStatusCode()) { - successDelete.incrementAndGet(); - } - else { - failureDelete.incrementAndGet(); - } - } catch (Exception e) { - failureDelete.incrementAndGet(); - throw e; - } - return response; - } - - @Override - public Response subscribeToStream(final String identifier, final UriInfo uriInfo) { - return delegate.subscribeToStream(identifier, uriInfo); - } - - @Override - public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) { - return delegate.getAvailableStreams(uriInfo); - } - - public BigInteger getConfigDelete() { - return BigInteger.valueOf(configDelete.get()); - } - - public BigInteger getConfigGet() { - return BigInteger.valueOf(configGet.get()); - } - - public BigInteger getConfigPost() { - return BigInteger.valueOf(configPost.get()); - } - - public BigInteger getConfigPut() { - return BigInteger.valueOf(configPut.get()); - } - - public BigInteger getOperationalGet() { - return BigInteger.valueOf(operationalGet.get()); - } - - public BigInteger getRpc() { - return BigInteger.valueOf(rpc.get()); - } - - public BigInteger getSuccessGetConfig() { - return BigInteger.valueOf(successGetConfig.get()); - } - - public BigInteger getSuccessGetOperational() { - return BigInteger.valueOf(successGetOperational.get()); - } - - public BigInteger getSuccessPost() { - return BigInteger.valueOf(successPost.get()); - } - - public BigInteger getSuccessPut() { - return BigInteger.valueOf(successPut.get()); - } - - public BigInteger getSuccessDelete() { - return BigInteger.valueOf(successDelete.get()); - } - - public BigInteger getFailureGetConfig() { - return BigInteger.valueOf(failureGetConfig.get()); - } - - public BigInteger getFailureGetOperational() { - return BigInteger.valueOf(failureGetOperational.get()); - } - - public BigInteger getFailurePost() { - return BigInteger.valueOf(failurePost.get()); - } - - public BigInteger getFailurePut() { - return BigInteger.valueOf(failurePut.get()); - } - - public BigInteger getFailureDelete() { - return BigInteger.valueOf(failureDelete.get()); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/WriterParameters.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/WriterParameters.java deleted file mode 100644 index 721376745b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/WriterParameters.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl; - -import com.google.common.base.Optional; - -public class WriterParameters { - private final Optional depth; - private final boolean prettyPrint; - - private WriterParameters(final WriterParametersBuilder builder) { - this.prettyPrint = builder.prettyPrint; - this.depth = builder.depth; - } - - public Optional getDepth() { - return depth; - } - - public boolean isPrettyPrint() { - return prettyPrint; - } - - public static class WriterParametersBuilder { - private Optional depth = Optional.absent(); - private boolean prettyPrint; - - public WriterParametersBuilder() { - } - - public Optional getDepth() { - return depth; - } - - public WriterParametersBuilder setDepth(final int depth) { - this.depth = Optional.of(depth); - return this; - } - - public boolean isPrettyPrint() { - return prettyPrint; - } - - public WriterParametersBuilder setPrettyPrint(final boolean prettyPrint) { - this.prettyPrint = prettyPrint; - return this; - } - - public WriterParameters build() { - return new WriterParameters(this); - } - } -} - diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/package-info.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/package-info.java deleted file mode 100644 index 120c67d3d5..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java deleted file mode 100644 index bd33a2f40f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.streams.listeners; - -import com.google.common.base.Charsets; -import com.google.common.base.Preconditions; -import com.google.common.eventbus.AsyncEventBus; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; -import io.netty.channel.Channel; -import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; -import io.netty.util.internal.ConcurrentSet; -import java.io.ByteArrayOutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.Executors; -import java.util.regex.Pattern; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * {@link ListenerAdapter} is responsible to track events, which occurred by changing data in data source. - */ -public class ListenerAdapter implements DOMDataChangeListener { - - private static final Logger LOG = LoggerFactory.getLogger(ListenerAdapter.class); - private static final DocumentBuilderFactory DBF = DocumentBuilderFactory.newInstance(); - private static final TransformerFactory FACTORY = TransformerFactory.newInstance(); - private static final Pattern RFC3339_PATTERN = Pattern.compile("(\\d\\d)(\\d\\d)$"); - - private final SimpleDateFormat rfc3339 = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ"); - - private final YangInstanceIdentifier path; - private ListenerRegistration registration; - private final String streamName; - private Set subscribers = new ConcurrentSet<>(); - private final EventBus eventBus; - private final EventBusChangeRecorder eventBusChangeRecorder; - - /** - * Creates new {@link ListenerAdapter} listener specified by path and stream name. - * - * @param path - * Path to data in data store. - * @param streamName - * The name of the stream. - */ - ListenerAdapter(final YangInstanceIdentifier path, final String streamName) { - Preconditions.checkNotNull(path); - Preconditions.checkArgument(streamName != null && !streamName.isEmpty()); - this.path = path; - this.streamName = streamName; - eventBus = new AsyncEventBus(Executors.newSingleThreadExecutor()); - eventBusChangeRecorder = new EventBusChangeRecorder(); - eventBus.register(eventBusChangeRecorder); - } - - @Override - public void onDataChanged(final AsyncDataChangeEvent> change) { - // TODO Auto-generated method stub - - if (!change.getCreatedData().isEmpty() || !change.getUpdatedData().isEmpty() - || !change.getRemovedPaths().isEmpty()) { - final String xml = prepareXmlFrom(change); - final Event event = new Event(EventType.NOTIFY); - event.setData(xml); - eventBus.post(event); - } - } - - /** - * Tracks events of data change by customer. - */ - private final class EventBusChangeRecorder { - @Subscribe - public void recordCustomerChange(final Event event) { - if (event.getType() == EventType.REGISTER) { - final Channel subscriber = event.getSubscriber(); - if (!subscribers.contains(subscriber)) { - subscribers.add(subscriber); - } - } else if (event.getType() == EventType.DEREGISTER) { - subscribers.remove(event.getSubscriber()); - Notificator.removeListenerIfNoSubscriberExists(ListenerAdapter.this); - } else if (event.getType() == EventType.NOTIFY) { - for (final Channel subscriber : subscribers) { - if (subscriber.isActive()) { - LOG.debug("Data are sent to subscriber {}:", subscriber.remoteAddress()); - subscriber.writeAndFlush(new TextWebSocketFrame(event.getData())); - } else { - LOG.debug("Subscriber {} is removed - channel is not active yet.", subscriber.remoteAddress()); - subscribers.remove(subscriber); - } - } - } - } - } - - /** - * Represents event of specific {@link EventType} type, holds data and {@link Channel} subscriber. - */ - private final class Event { - private final EventType type; - private Channel subscriber; - private String data; - - /** - * Creates new event specified by {@link EventType} type. - * - * @param type - * EventType - */ - public Event(final EventType type) { - this.type = type; - } - - /** - * Gets the {@link Channel} subscriber. - * - * @return Channel - */ - public Channel getSubscriber() { - return subscriber; - } - - /** - * Sets subscriber for event. - * - * @param subscriber - * Channel - */ - public void setSubscriber(final Channel subscriber) { - this.subscriber = subscriber; - } - - /** - * Gets event String. - * - * @return String representation of event data. - */ - public String getData() { - return data; - } - - /** - * Sets event data. - * - * @param data String. - */ - public void setData(final String data) { - this.data = data; - } - - /** - * Gets event type. - * - * @return The type of the event. - */ - public EventType getType() { - return type; - } - } - - /** - * Type of the event. - */ - private enum EventType { - REGISTER, - DEREGISTER, - NOTIFY; - } - - /** - * Prepare data in printable form and transform it to String. - * - * @param change - * DataChangeEvent - * @return Data in printable form. - */ - private String prepareXmlFrom(final AsyncDataChangeEvent> change) { - final Document doc = createDocument(); - final Element notificationElement = doc.createElementNS("urn:ietf:params:xml:ns:netconf:notification:1.0", - "notification"); - doc.appendChild(notificationElement); - - final Element eventTimeElement = doc.createElement("eventTime"); - eventTimeElement.setTextContent(toRFC3339(new Date())); - notificationElement.appendChild(eventTimeElement); - - final Element dataChangedNotificationEventElement = doc.createElementNS( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "data-changed-notification"); - addValuesToDataChangedNotificationEventElement(doc, dataChangedNotificationEventElement, change); - notificationElement.appendChild(dataChangedNotificationEventElement); - - try { - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - final Transformer transformer = FACTORY.newTransformer(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, Charsets.UTF_8))); - final byte[] charData = out.toByteArray(); - return new String(charData, "UTF-8"); - } catch (TransformerException | UnsupportedEncodingException e) { - final String msg = "Error during transformation of Document into String"; - LOG.error(msg, e); - return msg; - } - } - - /** - * Formats data specified by RFC3339. - * - * @param d - * Date - * @return Data specified by RFC3339. - */ - private String toRFC3339(final Date d) { - return RFC3339_PATTERN.matcher(rfc3339.format(d)).replaceAll("$1:$2"); - } - - /** - * Creates {@link Document} document. - * @return {@link Document} document. - */ - private Document createDocument() { - final DocumentBuilder bob; - try { - bob = DBF.newDocumentBuilder(); - } catch (final ParserConfigurationException e) { - return null; - } - return bob.newDocument(); - } - - /** - * Adds values to data changed notification event element. - * - * @param doc - * {@link Document} - * @param dataChangedNotificationEventElement - * {@link Element} - * @param change - * {@link AsyncDataChangeEvent} - */ - private void addValuesToDataChangedNotificationEventElement(final Document doc, - final Element dataChangedNotificationEventElement, - final AsyncDataChangeEvent> change) { - addValuesFromDataToElement(doc, change.getCreatedData().keySet(), dataChangedNotificationEventElement, - Operation.CREATED); - if (change.getCreatedData().isEmpty()) { - addValuesFromDataToElement(doc, change.getUpdatedData().keySet(), dataChangedNotificationEventElement, - Operation.UPDATED); - } - addValuesFromDataToElement(doc, change.getRemovedPaths(), dataChangedNotificationEventElement, - Operation.DELETED); - } - - /** - * Adds values from data to element. - * - * @param doc - * {@link Document} - * @param data - * Set of {@link YangInstanceIdentifier}. - * @param element - * {@link Element} - * @param operation - * {@link Operation} - */ - private void addValuesFromDataToElement(final Document doc, final Set data, final Element element, - final Operation operation) { - if (data == null || data.isEmpty()) { - return; - } - for (final YangInstanceIdentifier path : data) { - if (!ControllerContext.getInstance().isNodeMixin(path)) { - final Node node = createDataChangeEventElement(doc, path, operation); - element.appendChild(node); - } - } - } - - - /** - * Creates changed event element from data. - * - * @param doc - * {@link Document} - * @param path - * Path to data in data store. - * @param operation - * {@link Operation} - * @return {@link Node} node represented by changed event element. - */ - private Node createDataChangeEventElement(final Document doc, final YangInstanceIdentifier path, final Operation operation) { - final Element dataChangeEventElement = doc.createElement("data-change-event"); - final Element pathElement = doc.createElement("path"); - addPathAsValueToElement(path, pathElement); - dataChangeEventElement.appendChild(pathElement); - - final Element operationElement = doc.createElement("operation"); - operationElement.setTextContent(operation.value); - dataChangeEventElement.appendChild(operationElement); - - return dataChangeEventElement; - } - - - /** - * Adds path as value to element. - * - * @param path - * Path to data in data store. - * @param element - * {@link Element} - */ - private void addPathAsValueToElement(final YangInstanceIdentifier path, final Element element) { - // Map< key = namespace, value = prefix> - final Map prefixes = new HashMap<>(); - final YangInstanceIdentifier normalizedPath = ControllerContext.getInstance().toXpathRepresentation(path); - final StringBuilder textContent = new StringBuilder(); - - // FIXME: BUG-1281: this is duplicated code from yangtools (BUG-1275) - for (final PathArgument pathArgument : normalizedPath.getPathArguments()) { - if (pathArgument instanceof YangInstanceIdentifier.AugmentationIdentifier) { - continue; - } - textContent.append("/"); - writeIdentifierWithNamespacePrefix(element, textContent, pathArgument.getNodeType(), prefixes); - if (pathArgument instanceof NodeIdentifierWithPredicates) { - final Map predicates = ((NodeIdentifierWithPredicates) pathArgument).getKeyValues(); - for (final QName keyValue : predicates.keySet()) { - final String predicateValue = String.valueOf(predicates.get(keyValue)); - textContent.append("["); - writeIdentifierWithNamespacePrefix(element, textContent, keyValue, prefixes); - textContent.append("='"); - textContent.append(predicateValue); - textContent.append("'"); - textContent.append("]"); - } - } else if (pathArgument instanceof NodeWithValue) { - textContent.append("[.='"); - textContent.append(((NodeWithValue) pathArgument).getValue()); - textContent.append("'"); - textContent.append("]"); - } - } - element.setTextContent(textContent.toString()); - } - - /** - * Writes identifier that consists of prefix and QName. - * - * @param element - * {@link Element} - * @param textContent - * StringBuilder - * @param qName - * QName - * @param prefixes - * Map of namespaces and prefixes. - */ - private static void writeIdentifierWithNamespacePrefix(final Element element, final StringBuilder textContent, - final QName qName, final Map prefixes) { - final String namespace = qName.getNamespace().toString(); - String prefix = prefixes.get(namespace); - if (prefix == null) { - prefix = generateNewPrefix(prefixes.values()); - } - - element.setAttribute("xmlns:" + prefix, namespace); - textContent.append(prefix); - prefixes.put(namespace, prefix); - - textContent.append(":"); - textContent.append(qName.getLocalName()); - } - - /** - * Generates new prefix which consists of four random characters . - * - * @param prefixes - * Collection of prefixes. - * @return New prefix which consists of four random characters . - */ - private static String generateNewPrefix(final Collection prefixes) { - StringBuilder result = null; - final Random random = new Random(); - do { - result = new StringBuilder(); - for (int i = 0; i < 4; i++) { - final int randomNumber = 0x61 + (Math.abs(random.nextInt()) % 26); - result.append(Character.toChars(randomNumber)); - } - } while (prefixes.contains(result.toString())); - - return result.toString(); - } - - /** - * Gets path pointed to data in data store. - * - * @return Path pointed to data in data store. - */ - public YangInstanceIdentifier getPath() { - return path; - } - - /** - * Sets {@link ListenerRegistration} registration. - * - * @param registration - * ListenerRegistration - */ - public void setRegistration(final ListenerRegistration registration) { - this.registration = registration; - } - - /** - * Gets the name of the stream. - * - * @return The name of the stream. - */ - public String getStreamName() { - return streamName; - } - - /** - * Removes all subscribers and unregisters event bus change recorder form event bus. - */ - public void close() throws Exception { - subscribers = new ConcurrentSet<>(); - registration.close(); - registration = null; - eventBus.unregister(eventBusChangeRecorder); - } - - /** - * Checks if {@link ListenerRegistration} registration exist. - * - * @return True if exist, false otherwise. - */ - public boolean isListening() { - return registration == null ? false : true; - } - - /** - * Creates event of type {@link EventType#REGISTER}, set {@link Channel} subscriber to the event and post event into - * event bus. - * - * @param subscriber - * Channel - */ - public void addSubscriber(final Channel subscriber) { - if (!subscriber.isActive()) { - LOG.debug("Channel is not active between websocket server and subscriber {}" + subscriber.remoteAddress()); - } - final Event event = new Event(EventType.REGISTER); - event.setSubscriber(subscriber); - eventBus.post(event); - } - - /** - * Creates event of type {@link EventType#DEREGISTER}, sets {@link Channel} subscriber to the event and posts event - * into event bus. - * - * @param subscriber - */ - public void removeSubscriber(final Channel subscriber) { - LOG.debug("Subscriber {} is removed.", subscriber.remoteAddress()); - final Event event = new Event(EventType.DEREGISTER); - event.setSubscriber(subscriber); - eventBus.post(event); - } - - /** - * Checks if exists at least one {@link Channel} subscriber. - * - * @return True if exist at least one {@link Channel} subscriber, false otherwise. - */ - public boolean hasSubscribers() { - return !subscribers.isEmpty(); - } - - /** - * Consists of two types {@link Store#CONFIG} and {@link Store#OPERATION}. - */ - private static enum Store { - CONFIG("config"), - OPERATION("operation"); - - private final String value; - - private Store(final String value) { - this.value = value; - } - } - - /** - * Consists of three types {@link Operation#CREATED}, {@link Operation#UPDATED} and {@link Operation#DELETED}. - */ - private static enum Operation { - CREATED("created"), - UPDATED("updated"), - DELETED("deleted"); - - private final String value; - - private Operation(final String value) { - this.value = value; - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java deleted file mode 100644 index 17565a6b8c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.streams.listeners; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * {@link Notificator} is responsible to create, remove and find - * {@link ListenerAdapter} listener. - */ -public class Notificator { - - private static Map listenersByStreamName = new ConcurrentHashMap<>(); - private static final Lock lock = new ReentrantLock(); - - private Notificator() { - } - - /** - * Returns list of all stream names - */ - public static Set getStreamNames() { - return listenersByStreamName.keySet(); - } - - /** - * Gets {@link ListenerAdapter} specified by stream name. - * - * @param streamName - * The name of the stream. - * @return {@link ListenerAdapter} specified by stream name. - */ - public static ListenerAdapter getListenerFor(String streamName) { - return listenersByStreamName.get(streamName); - } - - /** - * Checks if the listener specified by {@link YangInstanceIdentifier} path exist. - * - * @param streamName - * @return True if the listener exist, false otherwise. - */ - public static boolean existListenerFor(String streamName) { - return listenersByStreamName.containsKey(streamName); - } - - /** - * Creates new {@link ListenerAdapter} listener from {@link YangInstanceIdentifier} path and stream name. - * - * @param path - * Path to data in data repository. - * @param streamName - * The name of the stream. - * @return New {@link ListenerAdapter} listener from {@link YangInstanceIdentifier} path and stream name. - */ - public static ListenerAdapter createListener(YangInstanceIdentifier path, String streamName) { - ListenerAdapter listener = new ListenerAdapter(path, streamName); - try { - lock.lock(); - listenersByStreamName.put(streamName, listener); - } finally { - lock.unlock(); - } - return listener; - } - - /** - * Looks for listener determined by {@link YangInstanceIdentifier} path and removes it. - * Creates String representation of stream name from URI. Removes slash from URI in start and end position. - * - * @param uri - * URI for creation stream name. - * @return String representation of stream name. - */ - public static String createStreamNameFromUri(String uri) { - if (uri == null) { - return null; - } - String result = uri; - if (result.startsWith("/")) { - result = result.substring(1); - } - if (result.endsWith("/")) { - result = result.substring(0, result.length()-1); - } - return result; - } - - /** - * Removes all listeners. - */ - public static void removeAllListeners() { - for (ListenerAdapter listener : listenersByStreamName.values()) { - try { - listener.close(); - } catch (Exception e) { - } - } - try { - lock.lock(); - listenersByStreamName = new ConcurrentHashMap<>(); - } finally { - lock.unlock(); - } - } - - /** - * Checks if listener has at least one subscriber. In case it doesn't have any, delete listener. - * - * @param listener - * ListenerAdapter - */ - public static void removeListenerIfNoSubscriberExists(ListenerAdapter listener) { - if (!listener.hasSubscribers()) { - deleteListener(listener); - } - } - - /** - * Delete {@link ListenerAdapter} listener specified in parameter. - * - * @param listener - * ListenerAdapter - */ - private static void deleteListener(ListenerAdapter listener) { - if (listener != null) { - try { - listener.close(); - } catch (Exception e) { - } - try { - lock.lock(); - listenersByStreamName.remove(listener.getStreamName()); - } finally { - lock.unlock(); - } - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServer.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServer.java deleted file mode 100644 index 3f70c5afe7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.streams.websockets; - -import com.google.common.base.Preconditions; -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.Channel; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import org.opendaylight.controller.sal.streams.listeners.Notificator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * {@link WebSocketServer} is responsible to start and stop web socket server - */ -public class WebSocketServer implements Runnable { - - private static final Logger logger = LoggerFactory.getLogger(WebSocketServer.class); - public static final int DEFAULT_PORT = 8181; - private EventLoopGroup bossGroup; - private EventLoopGroup workerGroup; - private static WebSocketServer instance = null; - private int port = DEFAULT_PORT; - - private WebSocketServer(int port) { - this.port = port; - } - - /** - * Create instance of {@link WebSocketServer} - * - * @param port - * TCP port used for this server - * @return instance of {@link WebSocketServer} - */ - public static WebSocketServer createInstance(int port) { - Preconditions.checkState(instance == null, "createInstance() has already been called"); - Preconditions.checkArgument(port > 1024, "Privileged port (below 1024) is not allowed"); - - instance = new WebSocketServer(port); - return instance; - } - - /** - * Return websocket TCP port - */ - public int getPort() { - return port; - } - - /** - * Get instance of {@link WebSocketServer} created by {@link #createInstance(int)} - * - * @return instance of {@link WebSocketServer} - */ - public static WebSocketServer getInstance() { - Preconditions.checkNotNull(instance, "createInstance() must be called prior to getInstance()"); - return instance; - } - - /** - * Destroy this already created instance - */ - public static void destroyInstance() { - Preconditions.checkState(instance != null, "createInstance() must be called prior to destroyInstance()"); - - instance.stop(); - instance = null; - } - - @Override - public void run() { - bossGroup = new NioEventLoopGroup(); - workerGroup = new NioEventLoopGroup(); - try { - ServerBootstrap b = new ServerBootstrap(); - b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) - .childHandler(new WebSocketServerInitializer()); - - Channel ch = b.bind(port).sync().channel(); - logger.info("Web socket server started at port {}.", port); - - ch.closeFuture().sync(); - } catch (InterruptedException e) { - // NOOP - } finally { - stop(); - } - } - - /** - * Stops the web socket server and removes all listeners. - */ - private void stop() { - Notificator.removeAllListeners(); - if (bossGroup != null) { - bossGroup.shutdownGracefully(); - bossGroup = null; - } - if (workerGroup != null) { - workerGroup.shutdownGracefully(); - workerGroup = null; - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerHandler.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerHandler.java deleted file mode 100644 index 18ecd90368..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerHandler.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.streams.websockets; - -import static io.netty.handler.codec.http.HttpHeaders.isKeepAlive; -import static io.netty.handler.codec.http.HttpHeaders.setContentLength; -import static io.netty.handler.codec.http.HttpHeaders.Names.HOST; -import static io.netty.handler.codec.http.HttpMethod.GET; -import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST; -import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; -import static io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR; -import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.http.DefaultFullHttpResponse; -import io.netty.handler.codec.http.FullHttpRequest; -import io.netty.handler.codec.http.FullHttpResponse; -import io.netty.handler.codec.http.HttpRequest; -import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; -import io.netty.handler.codec.http.websocketx.PingWebSocketFrame; -import io.netty.handler.codec.http.websocketx.PongWebSocketFrame; -import io.netty.handler.codec.http.websocketx.WebSocketFrame; -import io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker; -import io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory; -import io.netty.util.CharsetUtil; -import java.io.IOException; -import org.opendaylight.controller.sal.streams.listeners.ListenerAdapter; -import org.opendaylight.controller.sal.streams.listeners.Notificator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * {@link WebSocketServerHandler} is implementation of {@link SimpleChannelInboundHandler} which allow handle - * {@link FullHttpRequest} and {@link WebSocketFrame} messages. - */ -public class WebSocketServerHandler extends SimpleChannelInboundHandler { - - private static final Logger logger = LoggerFactory.getLogger(WebSocketServerHandler.class); - - private WebSocketServerHandshaker handshaker; - - @Override - protected void channelRead0(final ChannelHandlerContext ctx, final Object msg) throws Exception { - if (msg instanceof FullHttpRequest) { - handleHttpRequest(ctx, (FullHttpRequest) msg); - } else if (msg instanceof WebSocketFrame) { - handleWebSocketFrame(ctx, (WebSocketFrame) msg); - } - } - - /** - * Checks if HTTP request method is GET and if is possible to decode HTTP result of request. - * - * @param ctx - * ChannelHandlerContext - * @param req - * FullHttpRequest - */ - private void handleHttpRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) throws Exception { - // Handle a bad request. - if (!req.getDecoderResult().isSuccess()) { - sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST)); - return; - } - - // Allow only GET methods. - if (req.getMethod() != GET) { - sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); - return; - } - - String streamName = Notificator.createStreamNameFromUri(req.getUri()); - ListenerAdapter listener = Notificator.getListenerFor(streamName); - if (listener != null) { - listener.addSubscriber(ctx.channel()); - logger.debug("Subscriber successfully registered."); - } else { - logger.error("Listener for stream with name '{}' was not found.", streamName); - sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, INTERNAL_SERVER_ERROR)); - } - - // Handshake - WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(getWebSocketLocation(req), - null, false); - handshaker = wsFactory.newHandshaker(req); - if (handshaker == null) { - WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel()); - } else { - handshaker.handshake(ctx.channel(), req); - } - - } - - /** - * Checks response status, send response and close connection if necessary - * - * @param ctx - * ChannelHandlerContext - * @param req - * HttpRequest - * @param res - * FullHttpResponse - */ - private static void sendHttpResponse(final ChannelHandlerContext ctx, final HttpRequest req, - final FullHttpResponse res) { - // Generate an error page if response getStatus code is not OK (200). - if (res.getStatus().code() != 200) { - ByteBuf buf = Unpooled.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8); - res.content().writeBytes(buf); - buf.release(); - setContentLength(res, res.content().readableBytes()); - } - - // Send the response and close the connection if necessary. - ChannelFuture f = ctx.channel().writeAndFlush(res); - if (!isKeepAlive(req) || res.getStatus().code() != 200) { - f.addListener(ChannelFutureListener.CLOSE); - } - } - - /** - * Handles web socket frame. - * - * @param ctx - * {@link ChannelHandlerContext} - * @param frame - * {@link WebSocketFrame} - */ - private void handleWebSocketFrame(final ChannelHandlerContext ctx, final WebSocketFrame frame) throws IOException { - if (frame instanceof CloseWebSocketFrame) { - handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain()); - String streamName = Notificator.createStreamNameFromUri(((CloseWebSocketFrame) frame).reasonText()); - ListenerAdapter listener = Notificator.getListenerFor(streamName); - if (listener != null) { - listener.removeSubscriber(ctx.channel()); - logger.debug("Subscriber successfully registered."); - } - Notificator.removeListenerIfNoSubscriberExists(listener); - return; - } else if (frame instanceof PingWebSocketFrame) { - ctx.channel().write(new PongWebSocketFrame(frame.content().retain())); - return; - } - } - - @Override - public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { - if (cause instanceof java.nio.channels.ClosedChannelException == false) { - // cause.printStackTrace(); - } - ctx.close(); - } - - /** - * Get web socket location from HTTP request. - * - * @param req - * HTTP request from which the location will be returned - * @return String representation of web socket location. - */ - private static String getWebSocketLocation(final HttpRequest req) { - return "ws://" + req.headers().get(HOST) + req.getUri(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerInitializer.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerInitializer.java deleted file mode 100644 index 1f265e610d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerInitializer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.streams.websockets; - -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.socket.SocketChannel; -import io.netty.handler.codec.http.HttpObjectAggregator; -import io.netty.handler.codec.http.HttpServerCodec; - -/** - * {@link WebSocketServerInitializer} is used to setup the {@link ChannelPipeline} of a {@link io.netty.channel.Channel} - * . - */ -public class WebSocketServerInitializer extends ChannelInitializer { - - @Override - protected void initChannel(final SocketChannel ch) throws Exception { - ChannelPipeline pipeline = ch.pipeline(); - pipeline.addLast("codec-http", new HttpServerCodec()); - pipeline.addLast("aggregator", new HttpObjectAggregator(65536)); - pipeline.addLast("handler", new WebSocketServerHandler()); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml b/opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml deleted file mode 100644 index 95960b2a55..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - JAXRSRestconf - com.sun.jersey.spi.container.servlet.ServletContainer - - javax.ws.rs.Application - org.opendaylight.controller.sal.rest.impl.RestconfApplication - - - - com.sun.jersey.spi.container.ContainerRequestFilters - org.opendaylight.aaa.sts.TokenAuthFilter - - 1 - - - - JAXRSRestconf - /* - - - - GzipFilter - org.eclipse.jetty.servlets.GzipFilter - - mimeTypes - application/xml,application/yang.data+xml,xml,application/json,application/yang.data+json - - - - GzipFilter - /* - - - - cross-origin-restconf - org.eclipse.jetty.servlets.CrossOriginFilter - - allowedOrigins - * - - - allowedMethods - GET,POST,OPTIONS,DELETE,PUT,HEAD - - - allowedHeaders - origin, content-type, accept, authorization - - - exposedHeaders - location - - - - cross-origin-restconf - /* - - - - - NB api - /* - POST - GET - PUT - PATCH - DELETE - HEAD - - - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang b/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang deleted file mode 100644 index 9e6a95acfb..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang +++ /dev/null @@ -1,93 +0,0 @@ -module opendaylight-rest-connector { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:rest:connector"; - prefix "md-sal-rest-connector"; - - import config { prefix config; revision-date 2013-04-05; } - import opendaylight-md-sal-dom {prefix dom; revision-date 2013-10-28;} - import ietf-inet-types {prefix inet; revision-date 2010-09-24;} - - description - "Service definition for Rest Connector"; - - revision "2014-07-24" { - description - "Initial revision"; - } - - identity rest-connector { - base "config:service-type"; - config:java-class "org.opendaylight.controller.sal.rest.api.RestConnector"; - } - - identity rest-connector-impl { - base config:module-type; - config:provided-service rest-connector; - config:java-name-prefix RestConnector; - } - - grouping statistics { - leaf received-requests { - type uint64; - } - - leaf successful-responses { - type uint64; - } - - leaf failed-responses { - type uint64; - } - } - - augment "/config:modules/config:module/config:configuration" { - case rest-connector-impl { - when "/config:modules/config:module/config:type = 'rest-connector-impl'"; - leaf websocket-port { - mandatory true; - type inet:port-number; - } - container dom-broker { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity dom:dom-broker-osgi-registry; - } - } - } - } - } - - augment "/config:modules/config:module/config:state" { - case rest-connector-impl { - when "/config:modules/config:module/config:type = 'rest-connector-impl'"; - container rpcs { - uses statistics; - } - - container config { - container get { - uses statistics; - } - - container post { - uses statistics; - } - - container put { - uses statistics; - } - - container delete { - uses statistics; - } - } - - container operational { - container get { - uses statistics; - } - } - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/yang/sal-remote-augment.yang b/opendaylight/md-sal/sal-rest-connector/src/main/yang/sal-remote-augment.yang deleted file mode 100644 index cc1d26fb97..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/yang/sal-remote-augment.yang +++ /dev/null @@ -1,31 +0,0 @@ -module sal-remote-augment { - - yang-version 1; - namespace "urn:sal:restconf:event:subscription"; - prefix "salrmt-aug-ev-subscr"; - - import sal-remote {prefix salrmt; revision-date "2014-01-14";} - - description - "Added input parameters to rpc create-data-change-event-subscription"; - - revision "2014-07-08" { - } - - augment "/salrmt:create-data-change-event-subscription/salrmt:input" { - leaf datastore { - type enumeration { - enum OPERATIONAL; - enum CONFIGURATION; - } - } - leaf scope { - type enumeration { - enum BASE; - enum ONE; - enum SUBTREE; - } - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java deleted file mode 100644 index 2b449ae265..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.md.sal.rest.common; - -import com.google.common.base.Preconditions; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.opendaylight.controller.sal.rest.impl.test.providers.TestJsonBodyWriter; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlUtils; -import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.DomToNormalizedNodeParserFactory; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser; -import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * sal-rest-connector - * org.opendaylight.controller.md.sal.rest.common - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 7, 2015 - */ -public class TestRestconfUtils { - - private static final Logger LOG = LoggerFactory.getLogger(TestRestconfUtils.class); - - private static final YangContextParser parser = new YangParserImpl(); - - private static final DocumentBuilderFactory BUILDERFACTORY; - - static { - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - try { - factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - factory.setFeature("http://xml.org/sax/features/external-general-entities", false); - factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - factory.setXIncludeAware(false); - factory.setExpandEntityReferences(false); - } catch (final ParserConfigurationException e) { - throw new ExceptionInInitializerError(e); - } - factory.setNamespaceAware(true); - factory.setCoalescing(true); - factory.setIgnoringElementContentWhitespace(true); - factory.setIgnoringComments(true); - BUILDERFACTORY = factory; - } - - private TestRestconfUtils () { - throw new UnsupportedOperationException("Test utility class"); - } - - public static SchemaContext loadSchemaContext(final String yangPath, final SchemaContext schemaContext) { - try { - Preconditions.checkArgument(yangPath != null, "Path can not be null."); - Preconditions.checkArgument(( ! yangPath.isEmpty()), "Path can not be empty."); - if (schemaContext == null) { - return loadSchemaContext(yangPath); - } else { - return addSchemaContext(yangPath, schemaContext); - } - } - catch (final Exception e) { - LOG.error("Yang files at path: " + yangPath + " weren't loaded."); - } - return schemaContext; - } - - public static NormalizedNodeContext loadNormalizedContextFromJsonFile() { - throw new AbstractMethodError("Not implemented yet"); - } - - public static NormalizedNodeContext loadNormalizedContextFromXmlFile(final String pathToInputFile, final String uri) { - final InstanceIdentifierContext iiContext = ControllerContext.getInstance().toInstanceIdentifier(uri); - final InputStream inputStream = TestJsonBodyWriter.class.getResourceAsStream(pathToInputFile); - try { - final DocumentBuilder dBuilder = BUILDERFACTORY.newDocumentBuilder(); - final Document doc = dBuilder.parse(inputStream); - final NormalizedNode nn = parse(iiContext, doc); - return new NormalizedNodeContext(iiContext, nn); - } - catch (final Exception e) { - LOG.error("Load xml file " + pathToInputFile + " fail.", e); - } - return null; - } - - private static NormalizedNode parse(final InstanceIdentifierContext iiContext, final Document doc) { - final List elements = Collections.singletonList(doc.getDocumentElement()); - final SchemaNode schemaNodeContext = iiContext.getSchemaNode(); - DataSchemaNode schemaNode = null; - if (schemaNodeContext instanceof RpcDefinition) { - if ("input".equalsIgnoreCase(doc.getDocumentElement().getLocalName())) { - schemaNode = ((RpcDefinition) schemaNodeContext).getInput(); - } else if ("output".equalsIgnoreCase(doc.getDocumentElement().getLocalName())) { - schemaNode = ((RpcDefinition) schemaNodeContext).getOutput(); - } else { - throw new IllegalStateException("Unknown Rpc input node"); - } - - } else if (schemaNodeContext instanceof DataSchemaNode) { - schemaNode = (DataSchemaNode) schemaNodeContext; - } else { - throw new IllegalStateException("Unknow SchemaNode"); - } - - final String docRootElm = doc.getDocumentElement().getLocalName(); - final String schemaNodeName = iiContext.getSchemaNode().getQName().getLocalName(); - - if (!schemaNodeName.equalsIgnoreCase(docRootElm)) { - final Collection children = ((DataNodeContainer) schemaNode).getChildNodes(); - for (final DataSchemaNode child : children) { - if (child.getQName().getLocalName().equalsIgnoreCase(docRootElm)) { - schemaNode = child; - break; - } - } - } - final DomToNormalizedNodeParserFactory parserFactory = - DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, iiContext.getSchemaContext()); - - if(schemaNode instanceof ContainerSchemaNode) { - return parserFactory.getContainerNodeParser().parse(Collections.singletonList(doc.getDocumentElement()), (ContainerSchemaNode) schemaNode); - } else if(schemaNode instanceof ListSchemaNode) { - final ListSchemaNode casted = (ListSchemaNode) schemaNode; - return parserFactory.getMapEntryNodeParser().parse(elements, casted); - } // FIXME : add another DataSchemaNode extensions e.g. LeafSchemaNode - return null; - } - - private static Collection loadFiles(final String resourceDirectory) throws FileNotFoundException { - final String path = TestRestconfUtils.class.getResource(resourceDirectory).getPath(); - final File testDir = new File(path); - final String[] fileList = testDir.list(); - final List testFiles = new ArrayList(); - if (fileList == null) { - throw new FileNotFoundException(resourceDirectory); - } - for (int i = 0; i < fileList.length; i++) { - final String fileName = fileList[i]; - if (new File(testDir, fileName).isDirectory() == false) { - testFiles.add(new File(testDir, fileName)); - } - } - return testFiles; - } - - private static SchemaContext loadSchemaContext(final String resourceDirectory) throws IOException { - final Collection testFiles = loadFiles(resourceDirectory); - return parser.parseFiles(testFiles); - } - - private static SchemaContext addSchemaContext(final String resourceDirectory, - final SchemaContext schemaContext) throws IOException, YangSyntaxErrorException { - final Collection testFiles = loadFiles(resourceDirectory); - return parser.parseFiles(testFiles, schemaContext); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/draft02/test/RestPostOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/draft02/test/RestPostOperationTest.java deleted file mode 100644 index 089fe0d10a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/draft02/test/RestPostOperationTest.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl.draft02.test; - -/** - * sal-rest-connector - * org.opendaylight.controller.sal.rest.impl.draft02.test - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 9, 2015 - */ -public class RestPostOperationTest { - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java deleted file mode 100644 index 35a6162c95..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl.test.providers; - -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.lang.reflect.Field; -import java.util.Collections; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Request; -import javax.ws.rs.core.UriInfo; - -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.rest.api.RestconfConstants; -import org.opendaylight.controller.sal.rest.impl.AbstractIdentifierAwareJaxRsProvider; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 7, 2015 - */ -public abstract class AbstractBodyReaderTest { - - protected final static ControllerContext controllerContext = ControllerContext - .getInstance(); - protected final MediaType mediaType; - private static Field uriField; - private static Field requestField; - - public AbstractBodyReaderTest() throws NoSuchFieldException, - SecurityException { - uriField = AbstractIdentifierAwareJaxRsProvider.class - .getDeclaredField("uriInfo"); - uriField.setAccessible(true); - requestField = AbstractIdentifierAwareJaxRsProvider.class - .getDeclaredField("request"); - requestField.setAccessible(true); - mediaType = getMediaType(); - } - - protected abstract MediaType getMediaType(); - - protected static SchemaContext schemaContextLoader(final String yangPath, - final SchemaContext schemaContext) { - return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext); - } - - protected static void mockBodyReader( - final String identifier, final T normalizedNodeProvider, - final boolean isPost) throws NoSuchFieldException, - SecurityException, IllegalArgumentException, IllegalAccessException { - final UriInfo uriInfoMock = mock(UriInfo.class); - final MultivaluedMap pathParm = new MultivaluedHashMap<>( - 1); - pathParm.put(RestconfConstants.IDENTIFIER, - Collections.singletonList(identifier)); - when(uriInfoMock.getPathParameters()).thenReturn(pathParm); - when(uriInfoMock.getPathParameters(false)).thenReturn(pathParm); - when(uriInfoMock.getPathParameters(true)).thenReturn(pathParm); - uriField.set(normalizedNodeProvider, uriInfoMock); - final Request request = mock(Request.class); - if (isPost) { - when(request.getMethod()).thenReturn("POST"); - } else { - when(request.getMethod()).thenReturn("PUT"); - } - requestField.set(normalizedNodeProvider, request); - } - - protected static void checkMountPointNormalizedNodeContext( - final NormalizedNodeContext nnContext) { - checkNormalizedNodeContext(nnContext); - assertNotNull(nnContext.getInstanceIdentifierContext().getMountPoint()); - } - - protected static void checkNormalizedNodeContext( - final NormalizedNodeContext nnContext) { - assertNotNull(nnContext.getData()); - assertNotNull(nnContext.getInstanceIdentifierContext() - .getInstanceIdentifier()); - assertNotNull(nnContext.getInstanceIdentifierContext() - .getSchemaContext()); - assertNotNull(nnContext.getInstanceIdentifierContext().getSchemaNode()); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java deleted file mode 100644 index c1f463309b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl.test.providers; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import com.google.common.base.Optional; -import com.google.common.collect.Sets; -import java.io.InputStream; -import java.net.URI; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * sal-rest-connector - * org.opendaylight.controller.sal.rest.impl.test.providers - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 11, 2015 - */ -public class TestJsonBodyReader extends AbstractBodyReaderTest { - - private final JsonNormalizedNodeBodyReader jsonBodyReader; - private static SchemaContext schemaContext; - - public TestJsonBodyReader () throws NoSuchFieldException, SecurityException { - super(); - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - } - - @Override - protected MediaType getMediaType() { - return new MediaType(MediaType.APPLICATION_XML, null); - } - - @BeforeClass - public static void initialization() throws NoSuchFieldException, SecurityException { - schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext); - schemaContext = schemaContextLoader("/modules", schemaContext); - schemaContext = schemaContextLoader("/invoke-rpc", schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void moduleDataTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()); - final String uri = "instance-identifier-module:cont"; - mockBodyReader(uri, jsonBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class - .getResourceAsStream("/instanceidentifier/json/jsondata.json"); - final NormalizedNodeContext returnValue = jsonBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII); - } - - @Test - public void moduleSubContainerDataPutTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1"); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName); - final DataSchemaNode dataSchemaNodeOnPath = ((DataNodeContainer) dataSchemaNode).getDataChildByName(cont1QName); - final String uri = "instance-identifier-module:cont/cont1"; - mockBodyReader(uri, jsonBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class - .getResourceAsStream("/instanceidentifier/json/json_sub_container.json"); - final NormalizedNodeContext returnValue = jsonBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNodeOnPath, returnValue, dataII); - } - - @Test - public void moduleSubContainerDataPostTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1"); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName); - final String uri = "instance-identifier-module:cont"; - mockBodyReader(uri, jsonBodyReader, true); - final InputStream inputStream = TestJsonBodyReader.class - .getResourceAsStream("/instanceidentifier/json/json_sub_container.json"); - final NormalizedNodeContext returnValue = jsonBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII); - } - - @Test - public void moduleSubContainerAugmentDataPostTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next(); - QName contAugmentQName = QName.create(augmentModule.getQNameModule(), "cont-augment"); - YangInstanceIdentifier.AugmentationIdentifier augII = new YangInstanceIdentifier.AugmentationIdentifier( - Sets.newHashSet(contAugmentQName)); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()) - .node(augII).node(contAugmentQName); - final String uri = "instance-identifier-module:cont"; - mockBodyReader(uri, jsonBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class - .getResourceAsStream("/instanceidentifier/json/json_augment_container.json"); - final NormalizedNodeContext returnValue = jsonBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII); - } - - //FIXME: Uncomment this when JsonParserStream works correctly with case augmentation with choice - //@Test - public void moduleSubContainerChoiceAugmentDataPostTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next(); - QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1"); - QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2"); - final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1"); - YangInstanceIdentifier.AugmentationIdentifier augChoice1II = new YangInstanceIdentifier.AugmentationIdentifier( - Sets.newHashSet(augmentChoice1QName)); - YangInstanceIdentifier.AugmentationIdentifier augChoice2II = new YangInstanceIdentifier.AugmentationIdentifier( - Sets.newHashSet(augmentChoice2QName)); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()) - .node(augChoice1II).node(augmentChoice1QName).node(augChoice2II).node(augmentChoice2QName) - .node(containerQName); - final String uri = "instance-identifier-module:cont"; - mockBodyReader(uri, jsonBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class - .getResourceAsStream("/instanceidentifier/json/json_augment_choice_container.json"); - final NormalizedNodeContext returnValue = jsonBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII); - } - - @Test - public void rpcModuleInputTest() throws Exception { - final String uri = "invoke-rpc-module:rpc-test"; - mockBodyReader(uri, jsonBodyReader, true); - final InputStream inputStream = TestJsonBodyReader.class - .getResourceAsStream("/invoke-rpc/json/rpc-input.json"); - final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - final ContainerNode inputNode = (ContainerNode) returnValue.getData(); - final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName - .create(inputNode.getNodeType(), "cont")); - final Optional> contDataNode = inputNode - .getChild(yangCont.getLastPathArgument()); - assertTrue(contDataNode.isPresent()); - assertTrue(contDataNode.get() instanceof ContainerNode); - final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName - .create(inputNode.getNodeType(), "lf")); - final Optional> leafDataNode = ((ContainerNode) contDataNode - .get()).getChild(yangleaf.getLastPathArgument()); - assertTrue(leafDataNode.isPresent()); - assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue() - .toString())); - } - - private void checkExpectValueNormalizeNodeContext( - final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext) { - checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null); - } - - private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext, - final YangInstanceIdentifier dataNodeIdent) { - assertEquals(dataSchemaNode, nnContext.getInstanceIdentifierContext().getSchemaNode()); - assertEquals(dataNodeIdent, nnContext.getInstanceIdentifierContext().getInstanceIdentifier()); - assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent)); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java deleted file mode 100644 index 9a6a3ff0ef..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl.test.providers; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.InputStream; - -import javax.ws.rs.core.MediaType; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -import com.google.common.base.Optional; - -/** - * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 11, 2015 - */ -public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest { - - private final JsonNormalizedNodeBodyReader jsonBodyReader; - private static SchemaContext schemaContext; - - public TestJsonBodyReaderMountPoint() throws NoSuchFieldException, - SecurityException { - super(); - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - } - - @Override - protected MediaType getMediaType() { - return new MediaType(MediaType.APPLICATION_XML, null); - } - - @BeforeClass - public static void initialization() throws NoSuchFieldException, - SecurityException { - schemaContext = schemaContextLoader("/instanceidentifier/yang", - schemaContext); - schemaContext = schemaContextLoader("/modules", schemaContext); - schemaContext = schemaContextLoader("/invoke-rpc", schemaContext); - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContext); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))) - .thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void moduleDataTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext - .getDataChildByName("cont"); - final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont"; - mockBodyReader(uri, jsonBodyReader, false); - final InputStream inputStream = TestJsonBodyReaderMountPoint.class - .getResourceAsStream("/instanceidentifier/json/jsondata.json"); - final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkMountPointNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue); - } - - @Test - public void moduleSubContainerDataPutTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext - .getDataChildByName("cont"); - final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1"; - mockBodyReader(uri, jsonBodyReader, false); - final InputStream inputStream = TestJsonBodyReaderMountPoint.class - .getResourceAsStream("/instanceidentifier/json/json_sub_container.json"); - final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkMountPointNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, - "cont1"); - } - - @Test - public void moduleSubContainerDataPostTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext - .getDataChildByName("cont"); - final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont"; - mockBodyReader(uri, jsonBodyReader, true); - final InputStream inputStream = TestJsonBodyReaderMountPoint.class - .getResourceAsStream("/instanceidentifier/json/json_sub_container.json"); - final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkMountPointNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue); - } - - @Test - public void rpcModuleInputTest() throws Exception { - final String uri = "instance-identifier-module:cont/yang-ext:mount/invoke-rpc-module:rpc-test"; - mockBodyReader(uri, jsonBodyReader, true); - final InputStream inputStream = TestJsonBodyReaderMountPoint.class - .getResourceAsStream("/invoke-rpc/json/rpc-input.json"); - final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - final ContainerNode inputNode = (ContainerNode) returnValue.getData(); - final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName - .create(inputNode.getNodeType(), "cont")); - final Optional> contDataNode = inputNode - .getChild(yangCont.getLastPathArgument()); - assertTrue(contDataNode.isPresent()); - assertTrue(contDataNode.get() instanceof ContainerNode); - final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName - .create(inputNode.getNodeType(), "lf")); - final Optional> leafDataNode = ((ContainerNode) contDataNode - .get()).getChild(yangleaf.getLastPathArgument()); - assertTrue(leafDataNode.isPresent()); - assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue() - .toString())); - } - - private void checkExpectValueNormalizeNodeContext( - final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext) { - checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null); - } - - protected void checkExpectValueNormalizeNodeContext( - final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext, final String localQname) { - YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier - .of(dataSchemaNode.getQName()); - final DOMMountPoint mountPoint = nnContext - .getInstanceIdentifierContext().getMountPoint(); - final DataSchemaNode mountDataSchemaNode = mountPoint - .getSchemaContext().getDataChildByName( - dataSchemaNode.getQName()); - assertNotNull(mountDataSchemaNode); - if (localQname != null && dataSchemaNode instanceof DataNodeContainer) { - final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode) - .getDataChildByName(localQname); - dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent) - .node(child.getQName()).build(); - assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode() - .equals(child)); - } else { - assertTrue(mountDataSchemaNode.equals(dataSchemaNode)); - } - assertNotNull(NormalizedNodes.findNode(nnContext.getData(), - dataNodeIdent)); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyWriter.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyWriter.java deleted file mode 100644 index e5cda6c94d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyWriter.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl.test.providers; - -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; - -import javax.ws.rs.core.MediaType; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 12, 2015 - */ -public class TestJsonBodyWriter extends AbstractBodyReaderTest { - - private final JsonNormalizedNodeBodyReader jsonBodyReader; - private final NormalizedNodeJsonBodyWriter jsonBodyWriter; - private static SchemaContext schemaContext; - - public TestJsonBodyWriter() throws NoSuchFieldException, SecurityException { - super(); - jsonBodyWriter = new NormalizedNodeJsonBodyWriter(); - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - } - - @Override - protected MediaType getMediaType() { - return new MediaType(MediaType.APPLICATION_XML, null); - } - - @BeforeClass - public static void initialization() throws NoSuchFieldException, - SecurityException { - schemaContext = schemaContextLoader("/instanceidentifier/yang", - schemaContext); - schemaContext = schemaContextLoader("/modules", schemaContext); - schemaContext = schemaContextLoader("/invoke-rpc", schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void rpcModuleInputTest() throws Exception { - final String uri = "invoke-rpc-module:rpc-test"; - mockBodyReader(uri, jsonBodyReader, true); - final InputStream inputStream = TestJsonBodyWriter.class - .getResourceAsStream("/invoke-rpc/json/rpc-output.json"); - final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - final OutputStream output = new ByteArrayOutputStream(); - jsonBodyWriter.writeTo(returnValue, null, null, null, mediaType, null, - output); - assertTrue(output.toString().contains("lf-test")); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java deleted file mode 100644 index 67f4822c30..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl.test.providers; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import com.google.common.base.Optional; -import com.google.common.collect.Sets; -import java.io.InputStream; -import java.net.URI; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * sal-rest-connector - * org.opendaylight.controller.sal.rest.impl.test.providers - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 7, 2015 - */ -public class TestXmlBodyReader extends AbstractBodyReaderTest { - - private final XmlNormalizedNodeBodyReader xmlBodyReader; - private static SchemaContext schemaContext; - - public TestXmlBodyReader () throws NoSuchFieldException, SecurityException { - super(); - xmlBodyReader = new XmlNormalizedNodeBodyReader(); - } - - @Override - protected MediaType getMediaType() { - return new MediaType(MediaType.APPLICATION_XML, null); - } - - @BeforeClass - public static void initialization() throws NoSuchFieldException, SecurityException { - schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext); - schemaContext = schemaContextLoader("/modules", schemaContext); - schemaContext = schemaContextLoader("/invoke-rpc", schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void moduleDataTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()); - final String uri = "instance-identifier-module:cont"; - mockBodyReader(uri, xmlBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class - .getResourceAsStream("/instanceidentifier/xml/xmldata.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII); - } - - @Test - public void moduleSubContainerDataPutTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1"); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName); - final DataSchemaNode dataSchemaNodeOnPath = ((DataNodeContainer) dataSchemaNode).getDataChildByName(cont1QName); - final String uri = "instance-identifier-module:cont/cont1"; - mockBodyReader(uri, xmlBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class - .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNodeOnPath, returnValue, dataII); - } - - @Test - public void moduleSubContainerDataPostTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1"); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName); - final String uri = "instance-identifier-module:cont"; - mockBodyReader(uri, xmlBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class - .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII); - } - - @Test - public void moduleSubContainerAugmentDataPostTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next(); - QName contAugmentQName = QName.create(augmentModule.getQNameModule(), "cont-augment"); - YangInstanceIdentifier.AugmentationIdentifier augII = new YangInstanceIdentifier.AugmentationIdentifier( - Sets.newHashSet(contAugmentQName)); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()) - .node(augII).node(contAugmentQName); - final String uri = "instance-identifier-module:cont"; - mockBodyReader(uri, xmlBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class - .getResourceAsStream("/instanceidentifier/xml/xml_augment_container.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII); - } - - @Test - public void moduleSubContainerChoiceAugmentDataPostTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont"); - final Module augmentModule = schemaContext.findModuleByNamespace(new URI("augment:module")).iterator().next(); - QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1"); - QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2"); - final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1"); - YangInstanceIdentifier.AugmentationIdentifier augChoice1II = new YangInstanceIdentifier.AugmentationIdentifier( - Sets.newHashSet(augmentChoice1QName)); - YangInstanceIdentifier.AugmentationIdentifier augChoice2II = new YangInstanceIdentifier.AugmentationIdentifier( - Sets.newHashSet(augmentChoice2QName)); - final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()) - .node(augChoice1II).node(augmentChoice1QName).node(augChoice2II).node(augmentChoice2QName) - .node(containerQName); - final String uri = "instance-identifier-module:cont"; - mockBodyReader(uri, xmlBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class - .getResourceAsStream("/instanceidentifier/xml/xml_augment_choice_container.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII); - } - - @Test - public void rpcModuleInputTest() throws Exception { - final String uri = "invoke-rpc-module:rpc-test"; - mockBodyReader(uri, xmlBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class - .getResourceAsStream("/invoke-rpc/xml/rpc-input.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader - .readFrom(null, null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - final ContainerNode contNode = (ContainerNode) returnValue.getData(); - final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont")); - final Optional> contDataNodePotential = contNode.getChild(yangCont - .getLastPathArgument()); - assertTrue(contDataNodePotential.isPresent()); - final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get(); - final YangInstanceIdentifier yangLeaf = YangInstanceIdentifier.of(QName.create(contDataNode.getNodeType(), "lf")); - final Optional> leafDataNode = contDataNode.getChild(yangLeaf - .getLastPathArgument()); - assertTrue(leafDataNode.isPresent()); - assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString())); - } - - private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext) { - checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null); - } - - private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext, - final YangInstanceIdentifier dataNodeIdent) { - assertEquals(dataSchemaNode, nnContext.getInstanceIdentifierContext().getSchemaNode()); - assertEquals(dataNodeIdent, nnContext.getInstanceIdentifierContext().getInstanceIdentifier()); - assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent)); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java deleted file mode 100644 index 888008ca60..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl.test.providers; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.InputStream; - -import javax.ws.rs.core.MediaType; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -import com.google.common.base.Optional; - -/** - * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 9, 2015 - */ -public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest { - - private final XmlNormalizedNodeBodyReader xmlBodyReader; - private static SchemaContext schemaContext; - - public TestXmlBodyReaderMountPoint() throws NoSuchFieldException, - SecurityException { - super(); - xmlBodyReader = new XmlNormalizedNodeBodyReader(); - } - - @Override - protected MediaType getMediaType() { - return new MediaType(MediaType.APPLICATION_XML, null); - } - - @BeforeClass - public static void initialization() throws NoSuchFieldException, - SecurityException { - schemaContext = schemaContextLoader("/instanceidentifier/yang", - schemaContext); - schemaContext = schemaContextLoader("/modules", schemaContext); - schemaContext = schemaContextLoader("/invoke-rpc", schemaContext); - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContext); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))) - .thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void moduleDataTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext - .getDataChildByName("cont"); - final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont"; - mockBodyReader(uri, xmlBodyReader, false); - final InputStream inputStream = TestXmlBodyReaderMountPoint.class - .getResourceAsStream("/instanceidentifier/xml/xmldata.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkMountPointNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue); - } - - @Test - public void moduleSubContainerDataPutTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext - .getDataChildByName("cont"); - final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1"; - mockBodyReader(uri, xmlBodyReader, false); - final InputStream inputStream = TestXmlBodyReaderMountPoint.class - .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkMountPointNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, - "cont1"); - } - - @Test - public void moduleSubContainerDataPostTest() throws Exception { - final DataSchemaNode dataSchemaNode = schemaContext - .getDataChildByName("cont"); - final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont"; - mockBodyReader(uri, xmlBodyReader, true); - final InputStream inputStream = TestXmlBodyReaderMountPoint.class - .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkMountPointNormalizedNodeContext(returnValue); - checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue); - } - - @Test - public void rpcModuleInputTest() throws Exception { - final String uri = "instance-identifier-module:cont/yang-ext:mount/invoke-rpc-module:rpc-test"; - mockBodyReader(uri, xmlBodyReader, true); - final InputStream inputStream = TestXmlBodyReaderMountPoint.class - .getResourceAsStream("/invoke-rpc/xml/rpc-input.xml"); - final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null, - null, null, mediaType, null, inputStream); - checkNormalizedNodeContext(returnValue); - final ContainerNode contNode = (ContainerNode) returnValue.getData(); - final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont")); - final Optional> contDataNodePotential = contNode.getChild(yangCont - .getLastPathArgument()); - assertTrue(contDataNodePotential.isPresent()); - final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get(); - final YangInstanceIdentifier yangLeaf = YangInstanceIdentifier.of(QName.create(contDataNode.getNodeType(), "lf")); - final Optional> leafDataNode = contDataNode.getChild(yangLeaf - .getLastPathArgument()); - assertTrue(leafDataNode.isPresent()); - assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString())); - } - - private void checkExpectValueNormalizeNodeContext( - final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext) { - checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null); - } - - protected void checkExpectValueNormalizeNodeContext( - final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext, final String localQname) { - YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier - .of(dataSchemaNode.getQName()); - final DOMMountPoint mountPoint = nnContext - .getInstanceIdentifierContext().getMountPoint(); - final DataSchemaNode mountDataSchemaNode = mountPoint - .getSchemaContext().getDataChildByName( - dataSchemaNode.getQName()); - assertNotNull(mountDataSchemaNode); - if (localQname != null && dataSchemaNode instanceof DataNodeContainer) { - final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode) - .getDataChildByName(localQname); - dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent) - .node(child.getQName()).build(); - assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode() - .equals(child)); - } else { - assertTrue(mountDataSchemaNode.equals(dataSchemaNode)); - } - assertNotNull(NormalizedNodes.findNode(nnContext.getData(), - dataNodeIdent)); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java deleted file mode 100644 index 8eac4511f1..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.rest.impl.test.providers; - -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; - -import javax.ws.rs.core.MediaType; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers - * - * - * - * @author Vaclav Demcak - * - * Created: Mar 12, 2015 - */ -public class TestXmlBodyWriter extends AbstractBodyReaderTest { - - private final NormalizedNodeXmlBodyWriter xmlBodyWriter; - private static SchemaContext schemaContext; - - public TestXmlBodyWriter() throws NoSuchFieldException, SecurityException { - super(); - xmlBodyWriter = new NormalizedNodeXmlBodyWriter(); - } - - @Override - protected MediaType getMediaType() { - return new MediaType(MediaType.APPLICATION_XML, null); - } - - @BeforeClass - public static void initialization() throws NoSuchFieldException, - SecurityException { - schemaContext = schemaContextLoader("/instanceidentifier/yang", - schemaContext); - schemaContext = schemaContextLoader("/modules", schemaContext); - schemaContext = schemaContextLoader("/invoke-rpc", schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void rpcModuleInputTest() throws Exception { - final String uri = "invoke-rpc-module:rpc-test"; - final String pathToInputFile = "/invoke-rpc/xml/rpc-output.xml"; - final NormalizedNodeContext nnContext = TestRestconfUtils - .loadNormalizedContextFromXmlFile(pathToInputFile, uri); - final OutputStream output = new ByteArrayOutputStream(); - xmlBodyWriter.writeTo(nnContext, null, null, null, mediaType, null, - output); - assertTrue(output.toString().contains("lf-test")); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java deleted file mode 100644 index 1b3af6aad6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.cnsn.to.json.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; -import com.google.common.collect.Maps; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import java.io.IOException; -import java.io.StringReader; -import java.util.Map; -import org.junit.BeforeClass; -import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader; - -public class CnSnToJsonBasicDataTypesTest extends YangAndXmlAndDataSchemaLoader { - - static abstract class LeafVerifier { - - Object expectedValue; - JsonToken expectedToken; - - LeafVerifier(final Object expectedValue, final JsonToken expectedToken) { - this.expectedValue = expectedValue; - this.expectedToken = expectedToken; - } - - abstract Object getActualValue(JsonReader reader) throws IOException; - - void verify(final JsonReader reader, final String keyName) throws IOException { - assertEquals("Json value for key " + keyName, expectedValue, getActualValue(reader)); - } - - JsonToken expectedTokenType() { - return expectedToken; - } - } - - static class BooleanVerifier extends LeafVerifier { - - public BooleanVerifier(final boolean expected) { - super(expected, JsonToken.BOOLEAN); - } - - @Override - Object getActualValue(final JsonReader reader) throws IOException { - return reader.nextBoolean(); - } - } - - static class NumberVerifier extends LeafVerifier { - - public NumberVerifier(final Number expected) { - super(expected, JsonToken.NUMBER); - } - - @Override - Object getActualValue(final JsonReader reader) throws IOException { - if (expectedValue instanceof Double) { - return reader.nextDouble(); - } else if (expectedValue instanceof Long) { - return reader.nextLong(); - } else if (expectedValue instanceof Integer) { - return reader.nextInt(); - } - - return null; - } - } - - static class StringVerifier extends LeafVerifier { - - StringVerifier(final String expected) { - super(expected, JsonToken.STRING); - } - - @Override - Object getActualValue(final JsonReader reader) throws IOException { - return reader.nextString(); - } - } - - static class EmptyVerifier extends LeafVerifier { - - EmptyVerifier() { - super(null, null); - } - - @Override - Object getActualValue(final JsonReader reader) throws IOException { - reader.beginArray(); - reader.nextNull(); - reader.endArray(); - return null; - } - - } - - static class ComplexAnyXmlVerifier extends LeafVerifier { - - ComplexAnyXmlVerifier() { - super(null, JsonToken.BEGIN_OBJECT); - } - - @Override - void verify(final JsonReader reader, final String keyName) throws IOException { - - reader.beginObject(); - final String innerKey = reader.nextName(); - assertEquals("Json reader child key for " + keyName, "data", innerKey); - assertEquals("Json token type for key " + innerKey, JsonToken.BEGIN_OBJECT, reader.peek()); - - reader.beginObject(); - verifyLeaf(reader, innerKey, "leaf1", "leaf1-value"); - verifyLeaf(reader, innerKey, "leaf2", "leaf2-value"); - - String nextName = reader.nextName(); - assertEquals("Json reader child key for " + innerKey, "leaf-list", nextName); - reader.beginArray(); - assertEquals("Json value for key " + nextName, "leaf-list-value1", reader.nextString()); - assertEquals("Json value for key " + nextName, "leaf-list-value2", reader.nextString()); - reader.endArray(); - - nextName = reader.nextName(); - assertEquals("Json reader child key for " + innerKey, "list", nextName); - reader.beginArray(); - verifyNestedLists(reader, 1); - verifyNestedLists(reader, 3); - reader.endArray(); - - reader.endObject(); - reader.endObject(); - } - - void verifyNestedLists(final JsonReader reader, int leafNum) throws IOException { - reader.beginObject(); - - final String nextName = reader.nextName(); - assertEquals("Json reader next name", "nested-list", nextName); - - reader.beginArray(); - - reader.beginObject(); - verifyLeaf(reader, "nested-list", "nested-leaf", "nested-value" + leafNum++); - reader.endObject(); - - reader.beginObject(); - verifyLeaf(reader, "nested-list", "nested-leaf", "nested-value" + leafNum); - reader.endObject(); - - reader.endArray(); - reader.endObject(); - } - - void verifyLeaf(final JsonReader reader, final String parent, final String name, final String value) throws IOException { - final String nextName = reader.nextName(); - assertEquals("Json reader child key for " + parent, name, nextName); - assertEquals("Json token type for key " + parent, JsonToken.STRING, reader.peek()); - assertEquals("Json value for key " + nextName, value, reader.nextString()); - } - - @Override - Object getActualValue(final JsonReader reader) throws IOException { - return null; - } - } - - @BeforeClass - public static void initialize() { - dataLoad("/cnsn-to-json/simple-data-types"); - } - - private void verifyJsonOutput(final String jsonOutput) { - final StringReader strReader = new StringReader(jsonOutput); - final JsonReader jReader = new JsonReader(strReader); - - String exception = null; - try { - jsonReadCont(jReader); - } catch (final IOException e) { - exception = e.getMessage(); - } - - assertNull("Error during reading Json output: " + exception, exception); - } - - private void jsonReadCont(final JsonReader jReader) throws IOException { - jReader.beginObject(); - assertNotNull("cont1 is missing.", jReader.hasNext()); - - // Cont dataFromJson = new Cont(jReader.nextName()); - jReader.nextName(); - jsonReadContElements(jReader); - - assertFalse("cont shouldn't have other element.", jReader.hasNext()); - jReader.endObject(); - // return dataFromJson; - } - - private void jsonReadContElements(final JsonReader jReader) throws IOException { - jReader.beginObject(); - - final Map expectedMap = Maps.newHashMap(); - expectedMap.put("lfnint8Min", new NumberVerifier(Integer.valueOf(-128))); - expectedMap.put("lfnint8Max", new NumberVerifier(Integer.valueOf(127))); - expectedMap.put("lfnint16Min", new NumberVerifier(Integer.valueOf(-32768))); - expectedMap.put("lfnint16Max", new NumberVerifier(Integer.valueOf(32767))); - expectedMap.put("lfnint32Min", new NumberVerifier(Integer.valueOf(-2147483648))); - expectedMap.put("lfnint32Max", new NumberVerifier(Long.valueOf(2147483647))); - expectedMap.put("lfnint64Min", new NumberVerifier(Long.valueOf(-9223372036854775808L))); - expectedMap.put("lfnint64Max", new NumberVerifier(Long.valueOf(9223372036854775807L))); - expectedMap.put("lfnuint8Max", new NumberVerifier(Integer.valueOf(255))); - expectedMap.put("lfnuint16Max", new NumberVerifier(Integer.valueOf(65535))); - expectedMap.put("lfnuint32Max", new NumberVerifier(Long.valueOf(4294967295L))); - expectedMap.put("lfstr", new StringVerifier("lfstr")); - expectedMap.put("lfstr1", new StringVerifier("")); - expectedMap.put("lfbool1", new BooleanVerifier(true)); - expectedMap.put("lfbool2", new BooleanVerifier(false)); - expectedMap.put("lfbool3", new BooleanVerifier(false)); - expectedMap.put("lfdecimal1", new NumberVerifier(new Double(43.32))); - expectedMap.put("lfdecimal2", new NumberVerifier(new Double(-0.43))); - expectedMap.put("lfdecimal3", new NumberVerifier(new Double(43))); - expectedMap.put("lfdecimal4", new NumberVerifier(new Double(43E3))); - expectedMap.put("lfdecimal6", new NumberVerifier(new Double(33.12345))); - expectedMap.put("lfenum", new StringVerifier("enum3")); - expectedMap.put("lfbits", new StringVerifier("bit3 bit2")); - expectedMap.put("lfbinary", new StringVerifier("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - expectedMap.put("lfunion1", new StringVerifier("324")); - expectedMap.put("lfunion2", new StringVerifier("33.3")); - expectedMap.put("lfunion3", new StringVerifier("55")); - expectedMap.put("lfunion4", new StringVerifier("true")); - expectedMap.put("lfunion5", new StringVerifier("true")); - expectedMap.put("lfunion6", new StringVerifier("10")); - expectedMap.put("lfunion7", new StringVerifier("")); - expectedMap.put("lfunion8", new StringVerifier("")); - expectedMap.put("lfunion9", new StringVerifier("")); - expectedMap.put("lfunion10", new StringVerifier("bt1")); - expectedMap.put("lfunion11", new StringVerifier("33")); - expectedMap.put("lfunion12", new StringVerifier("false")); - expectedMap.put("lfunion13", new StringVerifier("b1")); - expectedMap.put("lfunion14", new StringVerifier("zero")); - expectedMap.put("lfempty", new EmptyVerifier()); - expectedMap.put("identityref1", new StringVerifier("simple-data-types:iden")); - expectedMap.put("complex-any", new ComplexAnyXmlVerifier()); - expectedMap.put("simple-any", new StringVerifier("simple")); - expectedMap.put("empty-any", new StringVerifier("")); - - while (jReader.hasNext()) { - final String keyName = jReader.nextName(); - final JsonToken peek = jReader.peek(); - - final LeafVerifier verifier = expectedMap.remove(keyName); - assertNotNull("Found unexpected leaf: " + keyName, verifier); - - final JsonToken expToken = verifier.expectedTokenType(); - if (expToken != null) { - assertEquals("Json token type for key " + keyName, expToken, peek); - } - - verifier.verify(jReader, keyName); - } - - if (!expectedMap.isEmpty()) { - fail("Missing leaf nodes in Json output: " + expectedMap.keySet()); - } - - jReader.endObject(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonIdentityrefTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonIdentityrefTest.java deleted file mode 100644 index d13b7b3eaf..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonIdentityrefTest.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.cnsn.to.json.test; - -import org.junit.BeforeClass; -import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader; - -public class CnSnToJsonIdentityrefTest extends YangAndXmlAndDataSchemaLoader { - - @BeforeClass - public static void initialization() { - dataLoad("/cnsn-to-json/identityref", 2, "identityref-module", "cont"); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonWithDataFromSeveralModulesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonWithDataFromSeveralModulesTest.java deleted file mode 100644 index f0a4371944..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonWithDataFromSeveralModulesTest.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.cnsn.to.json.test; - -import org.junit.BeforeClass; -import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader; - -public class CnSnToJsonWithDataFromSeveralModulesTest extends YangAndXmlAndDataSchemaLoader { - - @BeforeClass - public static void initialize() { - dataLoad("/xml-to-cnsn/data-of-several-modules/yang", 2, "module1", "cont_m1"); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java deleted file mode 100644 index 8ccd4a1f41..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.input.to.cnsn.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.common.collect.Iterables; -import com.google.common.util.concurrent.CheckedFuture; -import java.io.FileNotFoundException; -import java.net.URI; -import java.util.List; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.controller.sal.restconf.impl.test.TestUtils; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class RestPutListDataTest { - - private static BrokerFacade brokerFacade; - private static RestconfImpl restconfImpl; - private static SchemaContext schemaContextTestModule; - - private static final String TEST_MODULE_NS_STRING = "test:module"; - private static final URI TEST_MODULE_NS; - private static final String TEST_MODULE_REVISION = "2014-01-09"; - - static { - TEST_MODULE_NS = URI.create("test:module"); - } - - @Before - public void initialize() throws FileNotFoundException { - final ControllerContext controllerContext = ControllerContext.getInstance(); - schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module"); - controllerContext.setSchemas(schemaContextTestModule); - brokerFacade = mock(BrokerFacade.class); - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setBroker(brokerFacade); - restconfImpl.setControllerContext(controllerContext); - when(brokerFacade.commitConfigurationDataPut(any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class))) - .thenReturn(mock(CheckedFuture.class)); - } - - /** - * Tests whether no exception is raised if number and values of keys in URI - * and payload are equal - */ - @Test - @Ignore - public void testValidKeys() { - putListDataTest("key1value", "15", "key1value", (short) 15); - } - - /** - * Tests whether an exception is raised if key values in URI and payload are - * different. - * - * The exception should be raised from validation method - * {@code RestconfImpl#validateListEqualityOfListInDataAndUri} - */ - @Test - @Ignore // RestconfDocumentedExceptionMapper needs update - public void testUriAndPayloadKeysDifferent() { - try { - putListDataTest("key1value", "15", "key1value", (short) 16); - fail("RestconfDocumentedException expected"); - } catch (final RestconfDocumentedException e) { - verifyException(e, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - - try { - putListDataTest("key1value", "15", "key1value1", (short) 16); - fail("RestconfDocumentedException expected"); - } catch (final RestconfDocumentedException e) { - verifyException(e, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); - } - } - - /** - * Tests whether an exception is raised if URI contains less key values then - * payload. - * - * The exception is raised during {@code InstanceIdentifier} instance is - * built from URI - */ - @Test - @Ignore - public void testMissingKeysInUri() { - try { - putListDataTest("key1value", null, "key1value", (short) 15); - fail("RestconfDocumentedException expected"); - } catch (final RestconfDocumentedException e) { - verifyException(e, ErrorType.PROTOCOL, ErrorTag.DATA_MISSING); - } - } - - /** - * Tests whether an exception is raised if URI contains more key values then - * payload. - * - * The exception should be raised from validation method - * {@code RestconfImpl#validateListEqualityOfListInDataAndUri} - */ - @Test - public void testMissingKeysInPayload() { - try { - putListDataTest("key1value", "15", "key1value", null); - fail("RestconfDocumentedException expected"); - } catch (final DataValidationException e) { - // FIXME: thing about different approach for testing the Exception states - // RestconfDocumentedException is not rise in new API because you get - // DataValidationException from putListDataTest before you call the real rest service -// verifyException(e, ErrorType.PROTOCOL, ErrorTag.DATA_MISSING); - } - } - - private void verifyException(final RestconfDocumentedException e, final ErrorType errorType, final ErrorTag errorTag) { - final List errors = e.getErrors(); - assertEquals("getErrors() size", 1, errors.size()); - assertEquals("RestconfError getErrorType()", errorType, errors.get(0).getErrorType()); - assertEquals("RestconfError getErrorTag()", errorTag, errors.get(0).getErrorTag()); - } - - public void putListDataTest(final String uriKey1, final String uriKey2, final String payloadKey1, - final Short payloadKey2) { - final QName lstWithCompositeKey = QName.create(TEST_MODULE_NS_STRING, TEST_MODULE_REVISION, "lst-with-composite-key"); - final QName key1 = QName.create(TEST_MODULE_NS_STRING, TEST_MODULE_REVISION, "key1"); - final QName key2 = QName.create(TEST_MODULE_NS_STRING, TEST_MODULE_REVISION, "key2"); - - final DataSchemaNode testNodeSchemaNode = schemaContextTestModule.getDataChildByName(lstWithCompositeKey); - assertTrue(testNodeSchemaNode != null); - assertTrue(testNodeSchemaNode instanceof ListSchemaNode); - final DataContainerNodeAttrBuilder testNodeContainer = - Builders.mapEntryBuilder((ListSchemaNode) testNodeSchemaNode); - - List testChildren = ControllerContext.findInstanceDataChildrenByName( - (ListSchemaNode) testNodeSchemaNode, key1.getLocalName()); - assertTrue(testChildren != null); - final DataSchemaNode testLeafKey1SchemaNode = Iterables.getFirst(testChildren, null); - assertTrue(testLeafKey1SchemaNode != null); - assertTrue(testLeafKey1SchemaNode instanceof LeafSchemaNode); - final NormalizedNodeAttrBuilder> leafKey1 = - Builders.leafBuilder((LeafSchemaNode) testLeafKey1SchemaNode); - leafKey1.withValue(payloadKey1); - testNodeContainer.withChild(leafKey1.build()); - - if (payloadKey2 != null) { - testChildren = ControllerContext.findInstanceDataChildrenByName( - (ListSchemaNode) testNodeSchemaNode, key2.getLocalName()); - assertTrue(testChildren != null); - final DataSchemaNode testLeafKey2SchemaNode = Iterables.getFirst(testChildren, null); - assertTrue(testLeafKey2SchemaNode != null); - assertTrue(testLeafKey2SchemaNode instanceof LeafSchemaNode); - final NormalizedNodeAttrBuilder> leafKey2 = - Builders.leafBuilder((LeafSchemaNode) testLeafKey2SchemaNode); - leafKey2.withValue(payloadKey2); - testNodeContainer.withChild(leafKey2.build()); - } - - final NormalizedNodeContext testCompositeContext = new NormalizedNodeContext(new InstanceIdentifierContext<>( - null, testNodeSchemaNode, null, schemaContextTestModule), testNodeContainer.build()); - - restconfImpl.updateConfigurationData(toUri(uriKey1, uriKey2), testCompositeContext); - } - - public void putListDataWithWrapperTest(final String uriKey1, final String uriKey2, final String payloadKey1, - final Short payloadKey2) { - putListDataTest(uriKey1, uriKey2, payloadKey1, payloadKey2); - } - - private String toUri(final String uriKey1, final String uriKey2) { - final StringBuilder uriBuilder = new StringBuilder("/test-module:lst-with-composite-key/"); - uriBuilder.append(uriKey1); - if (uriKey2 != null) { - uriBuilder.append("/"); - uriBuilder.append(uriKey2); - } - return uriBuilder.toString(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonIdentityrefToNnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonIdentityrefToNnTest.java deleted file mode 100644 index 6577355b4c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonIdentityrefToNnTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.json.to.nn.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.io.InputStream; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class JsonIdentityrefToNnTest extends AbstractBodyReaderTest { - - private final JsonNormalizedNodeBodyReader jsonBodyReader; - private static SchemaContext schemaContext; - - public JsonIdentityrefToNnTest() throws NoSuchFieldException, - SecurityException { - super(); - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - } - - @BeforeClass - public static void initialize() { - schemaContext = schemaContextLoader("/json-to-nn/identityref", - schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void jsonIdentityrefToNn() throws NoSuchFieldException, - SecurityException, IllegalArgumentException, - IllegalAccessException, WebApplicationException, IOException { - - String uri = "identityref-module:cont"; - mockBodyReader(uri, jsonBodyReader, false); - InputStream inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/identityref/json/data.json"); - - NormalizedNodeContext normalizedNodeContext = jsonBodyReader.readFrom( - null, null, null, mediaType, null, inputStream); - - assertEquals("cont", normalizedNodeContext.getData().getNodeType() - .getLocalName()); - - String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - - assertTrue(dataTree.contains("cont1")); - assertTrue(dataTree - .contains("lf11 (identity:module?revision=2013-12-02)iden")); - assertTrue(dataTree - .contains("lf12 (identityref:module?revision=2013-12-02)iden_local")); - assertTrue(dataTree - .contains("lf13 (identityref:module?revision=2013-12-02)iden_local")); - assertTrue(dataTree - .contains("lf14 (identity:module?revision=2013-12-02)iden")); - } - - @Override - protected MediaType getMediaType() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonLeafrefToNnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonLeafrefToNnTest.java deleted file mode 100644 index afeddc2960..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonLeafrefToNnTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.json.to.nn.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.io.InputStream; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class JsonLeafrefToNnTest extends AbstractBodyReaderTest { - - private final JsonNormalizedNodeBodyReader jsonBodyReader; - private static SchemaContext schemaContext; - - public JsonLeafrefToNnTest() throws NoSuchFieldException, SecurityException { - super(); - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - } - - @BeforeClass - public static void initialize() { - schemaContext = schemaContextLoader("/json-to-nn/leafref", - schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void jsonIdentityrefToNormalizeNode() throws NoSuchFieldException, - SecurityException, IllegalArgumentException, - IllegalAccessException, WebApplicationException, IOException { - - String uri = "leafref-module:cont"; - mockBodyReader(uri, jsonBodyReader, false); - InputStream inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/leafref/json/data.json"); - - NormalizedNodeContext normalizedNodeContext = jsonBodyReader.readFrom( - null, null, null, mediaType, null, inputStream); - - assertEquals("cont", normalizedNodeContext.getData().getNodeType() - .getLocalName()); - String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - assertTrue(dataTree.contains("lf2 121")); - } - - @Override - protected MediaType getMediaType() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonToNnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonToNnTest.java deleted file mode 100644 index 5f4945c812..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonToNnTest.java +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.json.to.nn.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.io.InputStream; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; - -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class JsonToNnTest extends AbstractBodyReaderTest { - - private JsonNormalizedNodeBodyReader jsonBodyReader; - private SchemaContext schemaContext; - - public JsonToNnTest() throws NoSuchFieldException, SecurityException { - super(); - } - - public static void initialize(final String path, SchemaContext schemaContext) { - schemaContext = schemaContextLoader(path, schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void simpleListTest() { - simpleTest("/json-to-nn/simple-list.json", - "/json-to-nn/simple-list-yang/1", "lst", "simple-list-yang1"); - } - - @Test - public void simpleContainerTest() { - simpleTest("/json-to-nn/simple-container.json", - "/json-to-nn/simple-container-yang", "cont", - "simple-container-yang"); - } - - @Test - public void multipleItemsInLeafListTest() { - - initialize("/json-to-nn/simple-list-yang/1", schemaContext); - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - "/json-to-nn/multiple-leaflist-items.json", - "simple-list-yang1:lst"); - assertNotNull(normalizedNodeContext); - - final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - assertTrue(dataTree.contains("45")); - assertTrue(dataTree.contains("55")); - assertTrue(dataTree.contains("66")); - } - - @Test - public void multipleItemsInListTest() { - initialize("/json-to-nn/simple-list-yang/3", schemaContext); - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - "/json-to-nn/multiple-items-in-list.json", - "multiple-items-yang:lst"); - assertNotNull(normalizedNodeContext); - - assertEquals("lst", normalizedNodeContext.getData().getNodeType() - .getLocalName()); - - verityMultipleItemsInList(normalizedNodeContext); - } - - @Test - public void nullArrayToSimpleNodeWithNullValueTest() { - initialize("/json-to-nn/simple-list-yang/4", schemaContext); - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - "/json-to-nn/array-with-null.json", "array-with-null-yang:cont"); - assertNotNull(normalizedNodeContext); - - assertEquals("cont", normalizedNodeContext.getData().getNodeType() - .getLocalName()); - - final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - assertTrue(dataTree.contains("lf")); - assertTrue(dataTree.contains("null")); - } - - @Test - public void incorrectTopLevelElementsTest() throws WebApplicationException, - IOException, NoSuchFieldException, SecurityException, - IllegalArgumentException, IllegalAccessException { - - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - initialize("/json-to-nn/simple-list-yang/1", schemaContext); - mockBodyReader("simple-list-yang1:lst", jsonBodyReader, false); - - InputStream inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/wrong-top-level1.json"); - - int countExceptions = 0; - RestconfDocumentedException exception = null; - - try { - jsonBodyReader.readFrom(null, null, null, mediaType, null, - inputStream); - } catch (final RestconfDocumentedException e) { - exception = e; - countExceptions++; - } - assertNotNull(exception); - assertEquals( - "Error parsing input: Schema node with name cont wasn't found under (urn:ietf:params:xml:ns:netconf:base:1.0)data.", - exception.getErrors().get(0).getErrorMessage()); - - inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/wrong-top-level2.json"); - exception = null; - try { - jsonBodyReader.readFrom(null, null, null, mediaType, null, - inputStream); - } catch (final RestconfDocumentedException e) { - exception = e; - countExceptions++; - } - assertNotNull(exception); - assertEquals( - "Error parsing input: Schema node with name lst1 wasn't found under (urn:ietf:params:xml:ns:netconf:base:1.0)data.", - exception.getErrors().get(0).getErrorMessage()); - - inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/wrong-top-level3.json"); - exception = null; - try { - jsonBodyReader.readFrom(null, null, null, mediaType, null, - inputStream); - } catch (final RestconfDocumentedException e) { - exception = e; - countExceptions++; - } - assertNotNull(exception); - assertEquals( - "Error parsing input: Schema node with name lf wasn't found under (urn:ietf:params:xml:ns:netconf:base:1.0)data.", - exception.getErrors().get(0).getErrorMessage()); - assertEquals(3, countExceptions); - } - - @Test - public void emptyDataReadTest() throws WebApplicationException, - IOException, NoSuchFieldException, SecurityException, - IllegalArgumentException, IllegalAccessException { - - initialize("/json-to-nn/simple-list-yang/4", schemaContext); - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - "/json-to-nn/empty-data.json", "array-with-null-yang:cont"); - assertNotNull(normalizedNodeContext); - - assertEquals("cont", normalizedNodeContext.getData().getNodeType() - .getLocalName()); - - final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - - assertTrue(dataTree.contains("lflst1")); - - assertTrue(dataTree.contains("lflst2 45")); - - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - RestconfDocumentedException exception = null; - mockBodyReader("array-with-null-yang:cont", jsonBodyReader, false); - final InputStream inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/empty-data.json1"); - - try { - jsonBodyReader.readFrom(null, null, null, mediaType, null, - inputStream); - } catch (final RestconfDocumentedException e) { - exception = e; - } - assertNotNull(exception); - assertEquals("Error parsing input: null", exception.getErrors().get(0) - .getErrorMessage()); - } - - @Test - public void testJsonBlankInput() throws NoSuchFieldException, - SecurityException, IllegalArgumentException, - IllegalAccessException, WebApplicationException, IOException { - initialize("/json-to-nn/simple-list-yang/4", schemaContext); - final NormalizedNodeContext normalizedNodeContext = prepareNNC("", - "array-with-null-yang:cont"); - assertNull(normalizedNodeContext); - } - - @Test - public void notSupplyNamespaceIfAlreadySupplied() - throws WebApplicationException, IOException, NoSuchFieldException, - SecurityException, IllegalArgumentException, IllegalAccessException { - - initialize("/json-to-nn/simple-list-yang/1", schemaContext); - - final String uri = "simple-list-yang1" + ":" + "lst"; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - "/json-to-nn/simple-list.json", uri); - assertNotNull(normalizedNodeContext); - - verifyNormaluizedNodeContext(normalizedNodeContext, "lst"); - - mockBodyReader("simple-list-yang2:lst", jsonBodyReader, false); - final InputStream inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/simple-list.json"); - - try { - jsonBodyReader.readFrom(null, null, null, mediaType, null, - inputStream); - fail("NormalizedNodeContext should not be create because of different namespace"); - } catch (final RestconfDocumentedException e) { - } - - verifyNormaluizedNodeContext(normalizedNodeContext, "lst"); - } - - @Test - public void dataAugmentedTest() { - - initialize("/common/augment/yang", schemaContext); - - NormalizedNodeContext normalizedNodeContext = prepareNNC( - "/common/augment/json/dataa.json", "main:cont"); - - assertNotNull(normalizedNodeContext); - assertEquals("cont", normalizedNodeContext.getData().getNodeType() - .getLocalName()); - - String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - assertTrue(dataTree.contains("cont1")); - assertTrue(dataTree.contains("lf11 lf11 value from a")); - - normalizedNodeContext = prepareNNC("/common/augment/json/datab.json", - "main:cont"); - - assertNotNull(normalizedNodeContext); - assertEquals("cont", normalizedNodeContext.getData().getNodeType() - .getLocalName()); - dataTree = NormalizedNodes - .toStringTree(normalizedNodeContext.getData()); - assertTrue(dataTree.contains("cont1")); - assertTrue(dataTree.contains("lf11 lf11 value from b")); - } - - private void simpleTest(final String jsonPath, final String yangPath, - final String topLevelElementName, final String moduleName) { - - initialize(yangPath, schemaContext); - - final String uri = moduleName + ":" + topLevelElementName; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC(jsonPath, uri); - assertNotNull(normalizedNodeContext); - - verifyNormaluizedNodeContext(normalizedNodeContext, topLevelElementName); - } - - private NormalizedNodeContext prepareNNC(final String jsonPath, final String uri) { - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - try { - mockBodyReader(uri, jsonBodyReader, false); - } catch (NoSuchFieldException | SecurityException - | IllegalArgumentException | IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - final InputStream inputStream = this.getClass().getResourceAsStream(jsonPath); - - NormalizedNodeContext normalizedNodeContext = null; - - try { - normalizedNodeContext = jsonBodyReader.readFrom(null, null, null, - mediaType, null, inputStream); - } catch (WebApplicationException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return normalizedNodeContext; - } - - private void verifyNormaluizedNodeContext( - final NormalizedNodeContext normalizedNodeContext, - final String topLevelElementName) { - assertEquals(topLevelElementName, normalizedNodeContext.getData() - .getNodeType().getLocalName()); - - final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - assertTrue(dataTree.contains("cont1")); - assertTrue(dataTree.contains("lst1")); - assertTrue(dataTree.contains("lflst1")); - assertTrue(dataTree.contains("lflst1_1")); - assertTrue(dataTree.contains("lflst1_2")); - assertTrue(dataTree.contains("lf1")); - } - - private void verityMultipleItemsInList( - final NormalizedNodeContext normalizedNodeContext) { - - final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - assertTrue(dataTree.contains("lf11")); - assertTrue(dataTree.contains("lf11_1")); - assertTrue(dataTree.contains("lflst11")); - assertTrue(dataTree.contains("45")); - assertTrue(dataTree.contains("cont11")); - assertTrue(dataTree.contains("lst11")); - } - - @Test - public void unsupportedDataFormatTest() throws NoSuchFieldException, - SecurityException, IllegalArgumentException, - IllegalAccessException, WebApplicationException, IOException { - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - initialize("/json-to-nn/simple-list-yang/1", schemaContext); - mockBodyReader("simple-list-yang1:lst", jsonBodyReader, false); - - final InputStream inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/unsupported-json-format.json"); - - RestconfDocumentedException exception = null; - - try { - jsonBodyReader.readFrom(null, null, null, mediaType, null, - inputStream); - } catch (final RestconfDocumentedException e) { - exception = e; - } - System.out.println(exception.getErrors().get(0).getErrorMessage()); - - assertTrue(exception.getErrors().get(0).getErrorMessage() - .contains("is not a simple type")); - } - - @Test - public void invalidUriCharacterInValue() throws NoSuchFieldException, - SecurityException, IllegalArgumentException, - IllegalAccessException, WebApplicationException, IOException { - - jsonBodyReader = new JsonNormalizedNodeBodyReader(); - initialize("/json-to-nn/simple-list-yang/4", schemaContext); - mockBodyReader("array-with-null-yang:cont", jsonBodyReader, false); - - final InputStream inputStream = this.getClass().getResourceAsStream( - "/json-to-nn/invalid-uri-character-in-value.json"); - - final NormalizedNodeContext normalizedNodeContext = jsonBodyReader.readFrom( - null, null, null, mediaType, null, inputStream); - assertNotNull(normalizedNodeContext); - - assertEquals("cont", normalizedNodeContext.getData().getNodeType() - .getLocalName()); - - final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - assertTrue(dataTree.contains("lf1 moduleName:value lf2")); - } - - @Override - protected MediaType getMediaType() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnJsonChoiceCaseTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnJsonChoiceCaseTest.java deleted file mode 100644 index 0787bf7fa5..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnJsonChoiceCaseTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl.nn.to.json.test; - -import static org.junit.Assert.assertTrue; -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class NnJsonChoiceCaseTest extends AbstractBodyReaderTest { - - private static SchemaContext schemaContext; - private final NormalizedNodeJsonBodyWriter jsonBodyWriter; - - public NnJsonChoiceCaseTest() throws NoSuchFieldException, - SecurityException { - super(); - jsonBodyWriter = new NormalizedNodeJsonBodyWriter(); - } - - @BeforeClass - public static void initialization() { - schemaContext = schemaContextLoader("/nn-to-json/choice", schemaContext); - controllerContext.setSchemas(schemaContext); - } - - /** - * Test when some data are in one case node and other in another. This isn't - * correct. Next Json validator should return error because nodes has to be - * from one case below concrete choice. - */ - @Test(expected = NullPointerException.class) - public void nodeSchemasOnVariousChoiceCasePathTest() throws Exception { - getJson("/nn-to-json/choice/xml/data_various_path_err.xml"); - } - - /** - * Test when some data are in one case node and other in another. - * Additionally data are loadef from various choices. This isn't correct. - * Next Json validator should return error because nodes has to be from one - * case below concrete choice. - */ - @Test(expected = NullPointerException.class) - public void nodeSchemasOnVariousChoiceCasePathAndMultipleChoicesTest() - throws Exception { - getJson("/nn-to-json/choice/xml/data_more_choices_same_level_various_paths_err.xml"); - } - - /** - * Test when second level data are red first, then first and at the end - * third level. Level represents pass through couple choice-case - */ - - @Test - public void nodeSchemasWithRandomOrderAccordingLevel() throws Exception { - final String json = getJson("/nn-to-json/choice/xml/data_random_level.xml"); - - assertTrue(json.contains("cont")); - assertTrue(json.contains("\"lf1\":\"lf1 val\"")); - assertTrue(json.contains("\"lf1aaa\":\"lf1aaa val\"")); - assertTrue(json.contains("\"lf1aa\":\"lf1aa val\"")); - assertTrue(json.contains("\"lf1a\":121")); - } - - /** - * Test when element from no first case is used - */ - @Test - public void nodeSchemasNotInFirstCase() throws Exception { - final String json = getJson("/nn-to-json/choice/xml/data_no_first_case.xml"); - - assertTrue(json.contains("cont")); - assertTrue(json.contains("\"lf1\":\"lf1 val\"")); - assertTrue(json.contains("\"lf1ab\":\"lf1ab val\"")); - assertTrue(json.contains("\"lf1a\":121")); - } - - /** - * Test when element in case is list - */ - @Test - public void nodeSchemaAsList() throws Exception { - final String json = getJson("/nn-to-json/choice/xml/data_list.xml"); - - assertTrue(json.contains("cont")); - assertTrue(json.contains("\"lst1b\":[")); - assertTrue(json.contains("{\"lf11b\":\"lf11b_1 val\"}")); - assertTrue(json.contains("{\"lf11b\":\"lf11b_2 val\"}")); - } - - /** - * Test when element in case is container - */ - @Test - public void nodeSchemaAsContainer() throws Exception { - final String json = getJson("/nn-to-json/choice/xml/data_container.xml"); - - assertTrue(json.contains("cont")); - assertTrue(json.contains("\"cont1c\":{")); - assertTrue(json.contains("\"lf11c\":\"lf11c val\"")); - } - - /** - * Test when element in case is leaflist - */ - @Test - public void nodeSchemaAsLeafList() throws Exception { - final String json = getJson("/nn-to-json/choice/xml/data_leaflist.xml"); - - assertTrue(json.contains("cont")); - assertTrue(json.contains("\"lflst1d\":[")); - assertTrue(json.contains("\"lflst1d_1 val\"")); - assertTrue(json.contains("\"lflst1d_2 val\"")); - } - - /** - * - */ - @Test - public void nodeSchemasInMultipleChoicesTest() throws Exception { - final String json = getJson("/nn-to-json/choice/xml/data_more_choices_same_level.xml"); - - assertTrue(json.contains("cont")); - assertTrue(json.contains("\"lf2b\":\"lf2b value\"")); - assertTrue(json.contains("\"cont1c\":{")); - assertTrue(json.contains("\"lf11c\":\"lf11c val\"")); - } - - /** - * Test whether is possible to find data schema for node which is specified - * as dirrect subnode of choice (case without CASE key word) - */ - @Test - public void nodeSchemasInCaseNotDefinedWithCaseKeyword() throws Exception { - final String json = getJson("/nn-to-json/choice/xml/data_case_defined_without_case.xml"); - - assertTrue(json.contains("cont")); - assertTrue(json.contains("\"lf2b\":\"lf2b val\"")); - assertTrue(json.contains("\"e1\":45")); - } - - /** - * Test of multiple use of choices - */ - @Test - public void nodeSchemasInThreeChoicesAtSameLevel() throws Exception { - final String json = getJson("/nn-to-json/choice/xml/data_three_choices_same_level.xml"); - - assertTrue(json.contains("cont")); - assertTrue(json.contains("lf2b\":\"lf2b value")); - assertTrue(json.contains("lst4a\":[{")); - assertTrue(json.contains("{\"lf4ab\":33}")); - assertTrue(json.contains("{\"lf4ab\":37}")); - assertTrue(json.contains("\"lf1aaa\":\"lf1aaa value\"")); - } - - private String getJson(final String xmlPath) throws Exception { - final String uri = "choice-case-test:cont"; - final NormalizedNodeContext testNN = TestRestconfUtils - .loadNormalizedContextFromXmlFile(xmlPath, uri); - - final OutputStream output = new ByteArrayOutputStream(); - jsonBodyWriter.writeTo(testNN, null, null, null, mediaType, null, - output); - - return output.toString(); - } - - @Override - protected MediaType getMediaType() { - return null; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonLeafrefType.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonLeafrefType.java deleted file mode 100644 index 65fcc668bc..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonLeafrefType.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.nn.to.json.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import com.google.common.util.concurrent.UncheckedExecutionException; -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class NnToJsonLeafrefType extends AbstractBodyReaderTest { - - private static SchemaContext schemaContext; - private final NormalizedNodeJsonBodyWriter jsonBodyWriter; - - public NnToJsonLeafrefType() throws NoSuchFieldException, SecurityException { - super(); - jsonBodyWriter = new NormalizedNodeJsonBodyWriter(); - } - - @BeforeClass - public static void initialization() { - schemaContext = schemaContextLoader("/nn-to-json/leafref", - schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void leafrefAbsolutePathToExistingLeafTest() - throws Exception { - final String json = toJson("/nn-to-json/leafref/xml/data_absolut_ref_to_existing_leaf.xml"); - validateJson(".*\"lf3\":\\p{Blank}*\"true\".*", json); - } - - @Test - public void leafrefRelativePathToExistingLeafTest() - throws Exception { - final String json = toJson("/nn-to-json/leafref/xml/data_relativ_ref_to_existing_leaf.xml"); - validateJson(".*\"lf2\":\\p{Blank}*\"121\".*", json); - } - - @Test(expected = UncheckedExecutionException.class) - public void leafrefToNonExistingLeafTest() throws Exception { - toJson("/nn-to-json/leafref/xml/data_ref_to_non_existing_leaf.xml"); - } - - @Test - public void leafrefToNotLeafTest() throws Exception { - final String json = toJson("/nn-to-json/leafref/xml/data_ref_to_not_leaf.xml"); - validateJson( - ".*\"cont-augment-module\\p{Blank}*:\\p{Blank}*lf6\":\\p{Blank}*\"44\".*", - json); - } - - @Test - public void leafrefFromLeafListToLeafTest() throws Exception { - final String json = toJson("/nn-to-json/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml"); - validateJson( - ".*\"cont-augment-module\\p{Blank}*:\\p{Blank}*lflst1\":\\p{Blank}*.*\"346\",*\"347\",*\"345\".*", - json); - } - - @Test - public void leafrefFromLeafrefToLeafrefTest() throws Exception { - final String json = toJson("/nn-to-json/leafref/xml/data_from_leafref_to_leafref.xml"); - validateJson( - ".*\"cont-augment-module\\p{Blank}*:\\p{Blank}*lf7\":\\p{Blank}*\"200\".*", - json); - } - - private void validateJson(final String regex, final String value) { - assertNotNull(value); - final Pattern ptrn = Pattern.compile(regex, Pattern.DOTALL); - final Matcher mtch = ptrn.matcher(value); - assertTrue(mtch.matches()); - } - - private String toJson(final String xmlDataPath) throws Exception { - final String uri = "main-module:cont"; - final String pathToInputFile = xmlDataPath; - - final NormalizedNodeContext testNN = TestRestconfUtils - .loadNormalizedContextFromXmlFile(pathToInputFile, uri); - - final OutputStream output = new ByteArrayOutputStream(); - jsonBodyWriter.writeTo(testNN, null, null, null, mediaType, null, - output); - final String jsonOutput = output.toString(); - - return jsonOutput; - } - - @Override - protected MediaType getMediaType() { - return new MediaType(MediaType.APPLICATION_XML, null); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonNotExistingLeafTypeTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonNotExistingLeafTypeTest.java deleted file mode 100644 index 94ad703e43..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonNotExistingLeafTypeTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.nn.to.json.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import com.google.common.base.Preconditions; -import org.junit.Test; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.test.DummyType; -import org.opendaylight.controller.sal.restconf.impl.test.TestUtils; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder; -import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder; - -public class NnToJsonNotExistingLeafTypeTest { - - @Test - public void incorrectTopLevelElementTest() { - final NormalizedNodeContext normalizedNodeContext = prepareNormalizedNode(); - assertNotNull(normalizedNodeContext); - assertEquals(normalizedNodeContext.getData().getNodeType() - .getLocalName(), "cont"); - - final String output = NormalizedNodes.toStringTree(normalizedNodeContext - .getData()); - assertNotNull(output); - assertTrue(output.contains("lf1")); - } - - private NormalizedNodeContext prepareNormalizedNode() { - final QName lf1 = QName.create("simple:uri", "2012-12-17", "lf1"); - - final DataSchemaNode contSchemaNode = prepareDataSchemaNode(); - - Preconditions.checkState(contSchemaNode instanceof ContainerSchemaNode); - final ContainerSchemaNode conContSchemaNode = (ContainerSchemaNode) contSchemaNode; - - final DataContainerNodeAttrBuilder contContBuilder = Builders - .containerBuilder(conContSchemaNode); - - final DataSchemaNode lf1SchemaNode = conContSchemaNode - .getDataChildByName(lf1); - Preconditions.checkState(lf1SchemaNode instanceof LeafSchemaNode); - - final String lf1String = ""; - contContBuilder.withChild(Builders - .leafBuilder((LeafSchemaNode) lf1SchemaNode) - .withValue(lf1String).build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, - contSchemaNode, null, null), contContBuilder.build()); - - return testNormalizedNodeContext; - } - - private DataSchemaNode prepareDataSchemaNode() { - final ContainerSchemaNodeBuilder contBuild = new ContainerSchemaNodeBuilder( - "module", 1, TestUtils.buildQName("cont", "simple:uri", - "2012-12-17"), SchemaPath.create(true, - QName.create("dummy"))); - final LeafSchemaNodeBuilder leafBuild = new LeafSchemaNodeBuilder("module", - 2, TestUtils.buildQName("lf1", "simple:uri", "2012-12-17"), - SchemaPath.create(true, QName.create("dummy"))); - leafBuild.setType(new DummyType()); - leafBuild.setConfiguration(true); - - contBuild.addChildNode(leafBuild); - return contBuild.build(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonWithAugmentTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonWithAugmentTest.java deleted file mode 100644 index f9bfb0b992..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonWithAugmentTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.nn.to.json.test; - -import static org.junit.Assert.assertTrue; -import com.google.common.base.Preconditions; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class NnToJsonWithAugmentTest extends AbstractBodyReaderTest { - - private static SchemaContext schemaContext; - private final NormalizedNodeJsonBodyWriter xmlBodyWriter; - - public NnToJsonWithAugmentTest() throws NoSuchFieldException, - SecurityException { - super(); - xmlBodyWriter = new NormalizedNodeJsonBodyWriter(); - } - - @BeforeClass - public static void initialize() { - schemaContext = schemaContextLoader("/nn-to-json/augmentation", - schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void augmentedElementsToJson() throws WebApplicationException, - IOException { - final String uri = "yang:cont"; - final String pathToInputFile = "/nn-to-json/augmentation/xml/data.xml"; - - final NormalizedNodeContext testNN = TestRestconfUtils - .loadNormalizedContextFromXmlFile(pathToInputFile, uri); - - final OutputStream output = new ByteArrayOutputStream(); - xmlBodyWriter - .writeTo(testNN, null, null, null, mediaType, null, output); - final String jsonOutput = output.toString(); - - Preconditions.checkNotNull(jsonOutput); - - assertTrue(jsonOutput.contains("\"cont1\"" + ":" + '{')); - assertTrue(jsonOutput.contains("\"lf11\"" + ":" + "\"lf11\"")); - assertTrue(jsonOutput.contains("\"lst1\"" + ":" + '[')); - assertTrue(jsonOutput.contains("\"lf11\"" + ":" + "\"lf1_1\"")); - assertTrue(jsonOutput.contains("\"lf11\"" + ":" + "\"lf1_2\"")); - assertTrue(jsonOutput.contains("\"lflst1\"" + ":" + "[")); - assertTrue(jsonOutput.contains("\"lf2\"" + ":" + "\"lf2\"")); - } - - @Override - protected MediaType getMediaType() { - return new MediaType(MediaType.APPLICATION_XML, null); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnInstanceIdentifierToXmlTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnInstanceIdentifierToXmlTest.java deleted file mode 100644 index db5e4d0a38..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnInstanceIdentifierToXmlTest.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.nn.to.xml.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import com.google.common.collect.Iterables; -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.net.URISyntaxException; -import java.util.List; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class NnInstanceIdentifierToXmlTest extends AbstractBodyReaderTest { - - private static SchemaContext schemaContext; - NormalizedNodeXmlBodyWriter xmlBodyWriter; - - public NnInstanceIdentifierToXmlTest() throws NoSuchFieldException, - SecurityException { - super(); - xmlBodyWriter = new NormalizedNodeXmlBodyWriter(); - } - - @BeforeClass - public static void initialization() throws URISyntaxException { - schemaContext = schemaContextLoader("/instanceidentifier/yang", - schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void nnAsYangInstanceIdentifierAugmentLeafList() throws Exception { - final NormalizedNodeContext normalizedNodeContext = prepareNNCLeafList(); - - final OutputStream output = new ByteArrayOutputStream(); - - xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null, - mediaType, null, output); - - assertNotNull(output); - - final String outputJson = output.toString(); - - assertTrue(outputJson.contains("")); - - assertTrue(outputJson.contains("")); - - assertTrue(outputJson.contains("")); - assertTrue(outputJson.contains("/instanceidentifier/")); - assertTrue(outputJson.contains("")); - - assertTrue(outputJson.contains("")); - assertTrue(outputJson.contains("lflst11 value")); - assertTrue(outputJson.contains("")); - - assertTrue(outputJson.contains("")); - assertTrue(outputJson.contains("")); - } - - private NormalizedNodeContext prepareNNCLeafList() - throws URISyntaxException { - final QName cont = QName.create("instance:identifier:module", "2014-01-17", - "cont"); - final QName cont1 = QName.create("instance:identifier:module", "2014-01-17", - "cont1"); - final QName lflst11 = QName.create("augment:module:leaf:list", "2014-01-17", - "lflst11"); - final QName lf11 = QName.create("augment:module:leaf:list", "2014-01-17", - "lf11"); - - final DataSchemaNode schemaCont = schemaContext.getDataChildByName(cont); - - final DataContainerNodeAttrBuilder dataCont = Builders - .containerBuilder((ContainerSchemaNode) schemaCont); - - final DataSchemaNode schemaCont1 = ((ContainerSchemaNode) schemaCont) - .getDataChildByName(cont1); - - final DataContainerNodeAttrBuilder dataCont1 = Builders - .containerBuilder((ContainerSchemaNode) schemaCont1); - - final List instanceLfLst11 = ControllerContext - .findInstanceDataChildrenByName( - (DataNodeContainer) schemaCont1, lflst11.getLocalName()); - - final DataSchemaNode lfLst11Schema = Iterables - .getFirst(instanceLfLst11, null); - final ListNodeBuilder> lfLst11Data = Builders - .leafSetBuilder((LeafListSchemaNode) lfLst11Schema); - - lfLst11Data.withChild(Builders - .leafSetEntryBuilder((LeafListSchemaNode) lfLst11Schema) - .withValue("lflst11 value").build()); - dataCont1.withChild(lfLst11Data.build()); - - final List instanceLf11 = ControllerContext - .findInstanceDataChildrenByName( - (DataNodeContainer) schemaCont1, lf11.getLocalName()); - final DataSchemaNode lf11Schema = Iterables.getFirst(instanceLf11, null); - - dataCont1.withChild(Builders.leafBuilder((LeafSchemaNode) lf11Schema) - .withValue("/instanceidentifier/").build()); - dataCont.withChild(dataCont1.build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, schemaCont, - null, schemaContext), dataCont.build()); - - return testNormalizedNodeContext; - } - - @Test - public void nnAsYangInstanceIdentifierAugment() throws Exception { - - final NormalizedNodeContext normalizedNodeContext = preparNNC(); - final NormalizedNodeXmlBodyWriter xmlBodyWriter = new NormalizedNodeXmlBodyWriter(); - final OutputStream output = new ByteArrayOutputStream(); - - xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null, - mediaType, null, output); - - assertNotNull(output); - - final String outputJson = output.toString(); - - assertTrue(outputJson.contains("")); - - assertTrue(outputJson.contains("")); - - assertTrue(outputJson.contains("")); - - assertTrue(outputJson.contains( - "keyvalue111")); - assertTrue(outputJson.contains( - "keyvalue112")); - - assertTrue(outputJson.contains("/cont/cont1/lf12")); - - assertTrue(outputJson.contains("lf12 value")); - - assertTrue(outputJson.contains("")); - } - - private NormalizedNodeContext preparNNC() { - final QName cont = QName.create("instance:identifier:module", "2014-01-17", - "cont"); - final QName cont1 = QName.create("instance:identifier:module", "2014-01-17", - "cont1"); - final QName lst11 = QName.create("augment:module", "2014-01-17", "lst11"); - final QName lf11 = QName.create("augment:augment:module", "2014-01-17", - "lf111"); - final QName lf12 = QName.create("augment:augment:module", "2014-01-17", - "lf112"); - final QName keyvalue111 = QName.create("augment:module", "2014-01-17", - "keyvalue111"); - final QName keyvalue112 = QName.create("augment:module", "2014-01-17", - "keyvalue112"); - - final DataSchemaNode schemaCont = schemaContext.getDataChildByName(cont); - - final DataContainerNodeAttrBuilder dataCont = Builders - .containerBuilder((ContainerSchemaNode) schemaCont); - - final DataSchemaNode schemaCont1 = ((ContainerSchemaNode) schemaCont) - .getDataChildByName(cont1); - - final DataContainerNodeAttrBuilder dataCont1 = Builders - .containerBuilder((ContainerSchemaNode) schemaCont1); - - final List instanceLst11 = ControllerContext - .findInstanceDataChildrenByName( - (DataNodeContainer) schemaCont1, lst11.getLocalName()); - final DataSchemaNode lst11Schema = Iterables.getFirst(instanceLst11, null); - - final CollectionNodeBuilder dataLst11 = Builders - .mapBuilder((ListSchemaNode) lst11Schema); - - final DataContainerNodeAttrBuilder dataLst11Vaule = Builders - .mapEntryBuilder((ListSchemaNode) lst11Schema); - - dataLst11Vaule.withChild(buildLeaf(lst11Schema, keyvalue111, dataLst11, - "keyvalue111")); - - dataLst11Vaule.withChild(buildLeaf(lst11Schema, keyvalue112, dataLst11, - "keyvalue112")); - - dataLst11Vaule.withChild(buildLeaf(lst11Schema, lf11, dataLst11, - "/cont/cont1/lf12")); - - dataLst11Vaule.withChild(buildLeaf(lst11Schema, lf12, dataLst11, - "lf12 value")); - - dataLst11.withChild(dataLst11Vaule.build()); - - dataCont1.withChild(dataLst11.build()); - dataCont.withChild(dataCont1.build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, schemaCont, - null, schemaContext), dataCont.build()); - - return testNormalizedNodeContext; - } - - private DataContainerChild buildLeaf(final DataSchemaNode lst11Schema, - final QName qname, - final CollectionNodeBuilder dataLst11, final Object value) { - - final List instanceLf = ControllerContext - .findInstanceDataChildrenByName( - (DataNodeContainer) lst11Schema, qname.getLocalName()); - final DataSchemaNode schemaLf = Iterables.getFirst(instanceLf, null); - - return Builders.leafBuilder((LeafSchemaNode) schemaLf).withValue(value) - .build(); - } - - @Override - protected MediaType getMediaType() { - return null; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlNotExistingLeafTypeTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlNotExistingLeafTypeTest.java deleted file mode 100644 index 50ca667f00..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlNotExistingLeafTypeTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.nn.to.xml.test; - -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import javax.ws.rs.core.MediaType; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.test.DummyType; -import org.opendaylight.controller.sal.restconf.impl.test.TestUtils; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder; -import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder; - -public class NnToXmlNotExistingLeafTypeTest extends AbstractBodyReaderTest { - - public NnToXmlNotExistingLeafTypeTest() throws NoSuchFieldException, - SecurityException { - super(); - } - - @Test(expected = NullPointerException.class) - public void incorrectTopLevelElementTest() throws Exception { - final NormalizedNodeXmlBodyWriter xmlBodyWriter = new NormalizedNodeXmlBodyWriter(); - final OutputStream output = new ByteArrayOutputStream(); - - final NormalizedNodeContext normalizedNodeContext = prepareNNC(prepareDataSchemaNode()); - xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null, - mediaType, null, output); - - } - - private NormalizedNodeContext prepareNNC(final DataSchemaNode dataSchemaNode) { - final QName cont = QName.create("simple:uri", "2012-12-17", "cont"); - final QName lf = QName.create("simple:uri", "2012-12-17", "lf1"); - - final DataSchemaNode contSchema = ((ContainerSchemaNode) dataSchemaNode) - .getDataChildByName(cont); - final DataContainerNodeAttrBuilder dataCont = Builders - .containerBuilder((ContainerSchemaNode) contSchema); - - final DataSchemaNode lfSchema = ((ContainerSchemaNode) dataSchemaNode) - .getDataChildByName(lf); - - dataCont.withChild(Builders.leafBuilder((LeafSchemaNode) lfSchema) - .withValue("any value").build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, contSchema, - null, (SchemaContext) dataSchemaNode), dataCont.build()); - - return testNormalizedNodeContext; - } - - private DataSchemaNode prepareDataSchemaNode() { - final ContainerSchemaNodeBuilder contBuild = new ContainerSchemaNodeBuilder( - "module", 1, TestUtils.buildQName("cont", "simple:uri", - "2012-12-17"), null); - final LeafSchemaNodeBuilder leafBuild = new LeafSchemaNodeBuilder("module", - 2, TestUtils.buildQName("lf1", "simple:uri", "2012-12-17"), - null); - leafBuild.setType(new DummyType()); - leafBuild.setConfiguration(true); - - contBuild.addChildNode(leafBuild); - return contBuild.build(); - } - - @Override - protected MediaType getMediaType() { - return null; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlTest.java deleted file mode 100644 index 941562ea8d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlTest.java +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.nn.to.xml.test; - -import static org.junit.Assert.assertTrue; - -import com.google.common.base.Optional; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.util.List; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair; -import org.opendaylight.yangtools.yang.model.util.BinaryType; -import org.opendaylight.yangtools.yang.model.util.BitsType; -import org.opendaylight.yangtools.yang.model.util.BooleanType; -import org.opendaylight.yangtools.yang.model.util.EmptyType; -import org.opendaylight.yangtools.yang.model.util.EnumerationType; -import org.opendaylight.yangtools.yang.model.util.Int16; -import org.opendaylight.yangtools.yang.model.util.Int32; -import org.opendaylight.yangtools.yang.model.util.Int64; -import org.opendaylight.yangtools.yang.model.util.Int8; -import org.opendaylight.yangtools.yang.model.util.StringType; -import org.opendaylight.yangtools.yang.model.util.Uint16; -import org.opendaylight.yangtools.yang.model.util.Uint32; -import org.opendaylight.yangtools.yang.model.util.Uint64; -import org.opendaylight.yangtools.yang.model.util.Uint8; -import org.opendaylight.yangtools.yang.model.util.UnionType; - -public class NnToXmlTest extends AbstractBodyReaderTest { - - private final NormalizedNodeXmlBodyWriter xmlBodyWriter; - private static SchemaContext schemaContext; - - public NnToXmlTest() throws NoSuchFieldException, SecurityException { - super(); - xmlBodyWriter = new NormalizedNodeXmlBodyWriter(); - } - - @BeforeClass - public static void initialization() { - schemaContext = schemaContextLoader("/nn-to-xml/yang", schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void nnAsYangIdentityrefToXMLTest() throws Exception { - final NormalizedNodeContext normalizedNodeContext = prepareIdrefData(null, - true); - nnToXml(normalizedNodeContext, - "x:iden"); - } - - @Test - public void nnAsYangIdentityrefWithQNamePrefixToXMLTest() throws Exception { - final NormalizedNodeContext normalizedNodeContext = prepareIdrefData( - "prefix", true); - nnToXml(normalizedNodeContext, "", ":iden"); - } - - @Test - public void nnAsYangIdentityrefWithPrefixToXMLTest() throws Exception { - final NormalizedNodeContext normalizedNodeContext = prepareIdrefData( - "prefix", false); - nnToXml(normalizedNodeContext, "no qname value"); - } - - @Test - public void nnAsYangLeafrefWithPrefixToXMLTest() throws Exception { - final NormalizedNodeContext normalizedNodeContext = prepareLeafrefData(); - nnToXml(normalizedNodeContext, "true", - "true"); - } - - @Test - public void nnAsYangStringToXmlTest() throws Exception { - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(StringType.getInstance()) - .deserialize("lfStr value"), "lfStr"); - nnToXml(normalizedNodeContext, "lfStr value"); - } - - @Test - public void nnAsYangInt8ToXmlTest() throws Exception { - final String elName = "lfInt8"; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(Int8.getInstance()).deserialize( - "14"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">14"); - } - - @Test - public void nnAsYangInt16ToXmlTest() throws Exception { - final String elName = "lfInt16"; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(Int16.getInstance()).deserialize( - "3000"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">3000"); - } - - @Test - public void nnAsYangInt32ToXmlTest() throws Exception { - final String elName = "lfInt32"; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(Int32.getInstance()).deserialize( - "201234"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">201234"); - } - - @Test - public void nnAsYangInt64ToXmlTest() throws Exception { - final String elName = "lfInt64"; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(Int64.getInstance()).deserialize( - "5123456789"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">5123456789"); - } - - @Test - public void nnAsYangUint8ToXmlTest() throws Exception { - final String elName = "lfUint8"; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(Uint8.getInstance()).deserialize( - "200"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">200"); - } - - @Test - public void snAsYangUint16ToXmlTest() throws Exception { - final String elName = "lfUint16"; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(Uint16.getInstance()) - .deserialize("4000"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">4000"); - } - - @Test - public void nnAsYangUint32ToXmlTest() throws Exception { - final String elName = "lfUint32"; - - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(Uint32.getInstance()) - .deserialize("4123456789"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">4123456789"); - } - - @Test - public void snAsYangUint64ToXmlTest() throws Exception { - final String elName = "lfUint64"; - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(Uint64.getInstance()) - .deserialize("5123456789"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">5123456789"); - } - - @Test - public void nnAsYangBinaryToXmlTest() throws Exception { - final String elName = "lfBinary"; - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec - .from(BinaryType.getInstance()) - .deserialize( - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567"), - elName); - nnToXml( - normalizedNodeContext, - "<" - + elName - + ">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567"); - } - - @Test - public void nnAsYangBitsToXmlTest() throws Exception { - final BitsTypeDefinition.Bit mockBit1 = Mockito - .mock(BitsTypeDefinition.Bit.class); - Mockito.when(mockBit1.getName()).thenReturn("one"); - final BitsTypeDefinition.Bit mockBit2 = Mockito - .mock(BitsTypeDefinition.Bit.class); - Mockito.when(mockBit2.getName()).thenReturn("two"); - final List bitList = Lists.newArrayList( - mockBit1, mockBit2); - - final String elName = "lfBits"; - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec - .from(BitsType.create(Mockito.mock(SchemaPath.class), - bitList)).deserialize("one two"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">one two"); - } - - @Test - public void nnAsYangEnumerationToXmlTest() throws Exception { - final EnumTypeDefinition.EnumPair mockEnum = Mockito - .mock(EnumTypeDefinition.EnumPair.class); - Mockito.when(mockEnum.getName()).thenReturn("enum2"); - final List enumList = Lists.newArrayList(mockEnum); - - final String elName = "lfEnumeration"; - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec - .from(EnumerationType.create( - Mockito.mock(SchemaPath.class), enumList, - Optional. absent())) - .deserialize("enum2"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">enum2"); - } - - @Test - public void nnAsYangEmptyToXmlTest() throws Exception { - final String elName = "lfEmpty"; - final NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(EmptyType.getInstance()) - .deserialize(null), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">"); - } - - @Test - public void nnAsYangBooleanToXmlTest() throws Exception { - final String elName = "lfBoolean"; - NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(BooleanType.getInstance()) -.deserialize("false"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">false"); - - normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(BooleanType.getInstance()) - .deserialize("true"), elName); - nnToXml(normalizedNodeContext, "<" + elName + ">true"); - } - - @Test - public void nnAsYangUnionToXmlTest() throws Exception { - - final BitsTypeDefinition.Bit mockBit1 = Mockito - .mock(BitsTypeDefinition.Bit.class); - Mockito.when(mockBit1.getName()).thenReturn("first"); - final BitsTypeDefinition.Bit mockBit2 = Mockito - .mock(BitsTypeDefinition.Bit.class); - Mockito.when(mockBit2.getName()).thenReturn("second"); - final List bitList = Lists.newArrayList( - mockBit1, mockBit2); - - final List> types = Lists - .> newArrayList(Int8.getInstance(), BitsType - .create(Mockito.mock(SchemaPath.class), bitList), - BooleanType.getInstance()); - final UnionType unionType = UnionType.create(types); - - final String elName = "lfUnion"; - final String int8 = "15"; - - NormalizedNodeContext normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(unionType).deserialize(int8), - elName); - nnToXml(normalizedNodeContext, "<" + elName + ">15"); - - final String bits = "first second"; - normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(unionType).deserialize(bits), - elName); - nnToXml(normalizedNodeContext, "<" + elName + ">first second"); - - final String bool = "true"; - normalizedNodeContext = prepareNNC( - TypeDefinitionAwareCodec.from(unionType).deserialize(bool), - elName); - nnToXml(normalizedNodeContext, "<" + elName + ">true"); - } - - private NormalizedNodeContext prepareNNC(final Object object, final String name) { - final QName cont = QName.create("basic:module", "2013-12-2", "cont"); - final QName lf = QName.create("basic:module", "2013-12-2", name); - - final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont); - - final DataContainerNodeAttrBuilder contData = Builders - .containerBuilder((ContainerSchemaNode) contSchema); - - final List instanceLf = ControllerContext - .findInstanceDataChildrenByName((DataNodeContainer) contSchema, - lf.getLocalName()); - final DataSchemaNode schemaLf = Iterables.getFirst(instanceLf, null); - - contData.withChild(Builders.leafBuilder((LeafSchemaNode) schemaLf) - .withValue(object).build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, contSchema, - null, schemaContext), contData.build()); - - return testNormalizedNodeContext; - } - - private void nnToXml( - final NormalizedNodeContext normalizedNodeContext, - final String... xmlRepresentation) - throws Exception { - final OutputStream output = new ByteArrayOutputStream(); - xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null, - mediaType, null, output); - - for (int i = 0; i < xmlRepresentation.length; i++) { - assertTrue(output.toString().contains(xmlRepresentation[i])); - } - } - - private NormalizedNodeContext prepareLeafrefData() { - final QName cont = QName.create("basic:module", "2013-12-2", "cont"); - final QName lfBoolean = QName - .create("basic:module", "2013-12-2", "lfBoolean"); - final QName lfLfref = QName.create("basic:module", "2013-12-2", "lfLfref"); - - final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont); - - final DataContainerNodeAttrBuilder contData = Builders - .containerBuilder((ContainerSchemaNode) contSchema); - - List instanceLf = ControllerContext - .findInstanceDataChildrenByName((DataNodeContainer) contSchema, - lfBoolean.getLocalName()); - DataSchemaNode schemaLf = Iterables.getFirst(instanceLf, null); - - contData.withChild(Builders.leafBuilder((LeafSchemaNode) schemaLf) - .withValue(Boolean.TRUE).build()); - - instanceLf = ControllerContext.findInstanceDataChildrenByName( - (DataNodeContainer) contSchema, lfLfref.getLocalName()); - schemaLf = Iterables.getFirst(instanceLf, null); - - contData.withChild(Builders.leafBuilder((LeafSchemaNode) schemaLf) - .withValue("true").build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, contSchema, - null, schemaContext), contData.build()); - - return testNormalizedNodeContext; - } - - private NormalizedNodeContext prepareIdrefData(final String prefix, - final boolean valueAsQName) { - final QName cont = QName.create("basic:module", "2013-12-2", "cont"); - final QName cont1 = QName.create("basic:module", "2013-12-2", "cont1"); - final QName lf11 = QName.create("basic:module", "2013-12-2", "lf11"); - - final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont); - - final DataContainerNodeAttrBuilder contData = Builders - .containerBuilder((ContainerSchemaNode) contSchema); - - final DataSchemaNode cont1Schema = ((ContainerSchemaNode) contSchema) - .getDataChildByName(cont1); - - final DataContainerNodeAttrBuilder cont1Data = Builders - .containerBuilder((ContainerSchemaNode) cont1Schema); - - Object value = null; - if (valueAsQName) { - value = QName.create("referenced:module", "2013-12-2", "iden"); - } else { - value = "no qname value"; - } - - final List instanceLf = ControllerContext - .findInstanceDataChildrenByName( - (DataNodeContainer) cont1Schema, lf11.getLocalName()); - final DataSchemaNode schemaLf = Iterables.getFirst(instanceLf, null); - - cont1Data.withChild(Builders.leafBuilder((LeafSchemaNode) schemaLf) - .withValue(value).build()); - - contData.withChild(cont1Data.build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, contSchema, - null, schemaContext), contData.build()); - return testNormalizedNodeContext; - } - - @Override - protected MediaType getMediaType() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithChoiceTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithChoiceTest.java deleted file mode 100644 index 943a05cfdb..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithChoiceTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.nn.to.xml.test; - -import static org.junit.Assert.assertTrue; -import com.google.common.collect.Iterables; -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.util.List; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class NnToXmlWithChoiceTest extends AbstractBodyReaderTest { - - private final NormalizedNodeXmlBodyWriter xmlBodyWriter; - private static SchemaContext schemaContext; - - public NnToXmlWithChoiceTest() throws NoSuchFieldException, - SecurityException { - super(); - xmlBodyWriter = new NormalizedNodeXmlBodyWriter(); - } - - @BeforeClass - public static void initialization() { - schemaContext = schemaContextLoader("/nn-to-xml/choice", schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void cnSnToXmlWithYangChoice() throws Exception { - NormalizedNodeContext normalizedNodeContext = prepareNNC("lf1", - "String data1"); - OutputStream output = new ByteArrayOutputStream(); - xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null, - mediaType, null, output); - assertTrue(output.toString().contains("String data1")); - - normalizedNodeContext = prepareNNC("lf2", "String data2"); - output = new ByteArrayOutputStream(); - - xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null, - mediaType, null, output); - assertTrue(output.toString().contains("String data2")); - } - - private NormalizedNodeContext prepareNNC(final String name, - final Object value) { - - final QName contQname = QName.create("module:with:choice", "2013-12-18", - "cont"); - final QName lf = QName.create("module:with:choice", "2013-12-18", name); - final QName choA = QName.create("module:with:choice", "2013-12-18", "choA"); - - final DataSchemaNode contSchemaNode = schemaContext - .getDataChildByName(contQname); - final DataContainerNodeAttrBuilder dataContainerNodeAttrBuilder = Builders - .containerBuilder((ContainerSchemaNode) contSchemaNode); - - final DataSchemaNode choiceSchemaNode = ((ContainerSchemaNode) contSchemaNode) - .getDataChildByName(choA); - assertTrue(choiceSchemaNode instanceof ChoiceSchemaNode); - - final DataContainerNodeBuilder dataChoice = Builders - .choiceBuilder((ChoiceSchemaNode) choiceSchemaNode); - - final List instanceLf = ControllerContext - .findInstanceDataChildrenByName( - (DataNodeContainer) contSchemaNode, lf.getLocalName()); - final DataSchemaNode schemaLf = Iterables.getFirst(instanceLf, null); - - dataChoice.withChild(Builders.leafBuilder((LeafSchemaNode) schemaLf) - .withValue(value).build()); - - dataContainerNodeAttrBuilder.withChild(dataChoice.build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, - contSchemaNode, null, schemaContext), - dataContainerNodeAttrBuilder.build()); - - return testNormalizedNodeContext; - } - - @Override - protected MediaType getMediaType() { - return null; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java deleted file mode 100644 index 05d3a55bb9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.nn.to.xml.test; - -import static org.junit.Assert.assertTrue; -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.URISyntaxException; -import java.util.List; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class NnToXmlWithDataFromSeveralModulesTest extends - AbstractBodyReaderTest { - - private final NormalizedNodeXmlBodyWriter xmlBodyWriter; - private static SchemaContext schemaContext; - - public NnToXmlWithDataFromSeveralModulesTest() throws NoSuchFieldException, - SecurityException { - super(); - xmlBodyWriter = new NormalizedNodeXmlBodyWriter(); - } - - @BeforeClass - public static void initialize() { - schemaContext = schemaContextLoader( - "/nn-to-xml/data-of-several-modules/yang", schemaContext); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void dataFromSeveralModulesToXmlTest() - throws WebApplicationException, IOException, URISyntaxException { - final NormalizedNodeContext normalizedNodeContext = prepareNormalizedNodeContext(); - final OutputStream output = new ByteArrayOutputStream(); - xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null, - mediaType, null, output); - - final String outputString = output.toString(); - // data - assertTrue(outputString - .contains( - "')); - // cont m2 - assertTrue(outputString.contains( - "')); - assertTrue(outputString.contains("lf1 m2 value")); - assertTrue(outputString.contains("")); - assertTrue(outputString.contains("")); - - // cont m1 - assertTrue(outputString.contains( - "')); - assertTrue(outputString.contains("")); - assertTrue(outputString.contains("lf1 m1 value")); - assertTrue(outputString.contains("")); - - // end - assertTrue(output.toString().contains("")); - } - - @Override - protected MediaType getMediaType() { - // TODO Auto-generated method stub - return null; - } - - private NormalizedNodeContext prepareNormalizedNodeContext() { - final String rev = "2014-01-17"; - - final DataSchemaNode schemaContNode = schemaContext; - - assertTrue(schemaContNode instanceof ContainerSchemaNode); - - final DataContainerNodeAttrBuilder dataContSchemaContNode = Builders - .containerBuilder((ContainerSchemaNode) schemaContNode); - - final DataContainerNodeAttrBuilder modul1 = buildContBuilderMod1( - "module:one", rev, "cont_m1", "contB_m1", "lf1_m1", - "lf1 m1 value"); - dataContSchemaContNode.withChild(modul1.build()); - - final DataContainerNodeAttrBuilder modul2 = buildContBuilderMod1( - "module:two", rev, "cont_m2", "contB_m2", "lf1_m2", - "lf1 m2 value"); - dataContSchemaContNode.withChild(modul2.build()); - - final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext(null, - schemaContNode, null, schemaContext), - dataContSchemaContNode.build()); - - return testNormalizedNodeContext; - } - - private DataContainerNodeAttrBuilder buildContBuilderMod1( - final String uri, final String rev, final String cont, final String contB, final String lf1, - final String lf1_value) { - final QName contQname = QName.create(uri, rev, cont); - final QName contBQname = QName.create(uri, rev, contB); - final QName lf1Qname = QName.create(contQname, lf1); - - final DataSchemaNode contSchemaNode = schemaContext - .getDataChildByName(contQname); - final DataContainerNodeAttrBuilder dataContainerNodeAttrBuilder = Builders - .containerBuilder((ContainerSchemaNode) contSchemaNode); - - Preconditions.checkState(contSchemaNode instanceof ContainerSchemaNode); - final List instanceLf1_m1 = ControllerContext - .findInstanceDataChildrenByName( - (DataNodeContainer) contSchemaNode, - lf1Qname.getLocalName()); - final DataSchemaNode schemaLf1_m1 = Iterables.getFirst(instanceLf1_m1, null); - - dataContainerNodeAttrBuilder.withChild(Builders - .leafBuilder((LeafSchemaNode) schemaLf1_m1) - .withValue(lf1_value).build()); - - final DataSchemaNode contBSchemaNode = ((ContainerSchemaNode) contSchemaNode) - .getDataChildByName(contBQname); - - final DataContainerNodeAttrBuilder dataContainerB = Builders - .containerBuilder((ContainerSchemaNode) contBSchemaNode); - - return dataContainerNodeAttrBuilder.withChild(dataContainerB.build()); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java deleted file mode 100644 index ff3fca11b4..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import java.util.concurrent.Future; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError; -import org.opendaylight.controller.sal.streams.listeners.ListenerAdapter; -import org.opendaylight.controller.sal.streams.listeners.Notificator; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -/** - * Unit tests for BrokerFacade. - * - * @author Thomas Pantelis - */ -public class BrokerFacadeTest { - - @Mock - DOMDataBroker domDataBroker; - - @Mock - ConsumerSession context; - - @Mock - DOMRpcService mockRpcService; - - @Mock - DOMMountPoint mockMountInstance; - - BrokerFacade brokerFacade = BrokerFacade.getInstance(); - - NormalizedNode dummyNode = createDummyNode("test:module", "2014-01-09", "interfaces"); - CheckedFuture>,ReadFailedException> dummyNodeInFuture = wrapDummyNode(dummyNode); - - QName qname = TestUtils.buildQName("interfaces","test:module", "2014-01-09"); - - SchemaPath type = SchemaPath.create(true, qname); - - YangInstanceIdentifier instanceID = YangInstanceIdentifier.builder().node(qname).build(); - - @Mock - DOMDataReadOnlyTransaction rTransaction; - - @Mock - DOMDataWriteTransaction wTransaction; - - @Mock - DOMDataReadWriteTransaction rwTransaction; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - // TODO it is started before every test method - brokerFacade.setDomDataBroker(domDataBroker); - brokerFacade.setRpcService(mockRpcService); - brokerFacade.setContext(context); - when(domDataBroker.newReadOnlyTransaction()).thenReturn(rTransaction); - when(domDataBroker.newWriteOnlyTransaction()).thenReturn(wTransaction); - when(domDataBroker.newReadWriteTransaction()).thenReturn(rwTransaction); - - ControllerContext.getInstance().setSchemas(TestUtils.loadSchemaContext("/full-versions/test-module")); - - } - - private CheckedFuture>,ReadFailedException> wrapDummyNode(final NormalizedNode dummyNode) { - return Futures.immediateCheckedFuture(Optional.> of(dummyNode)); - } - - private CheckedFuture wrapExistence(final Boolean exists) { - return Futures.immediateCheckedFuture(exists); - } - - - /** - * Value of this node shouldn't be important for testing purposes - */ - private NormalizedNode createDummyNode(final String namespace, final String date, final String localName) { - return Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(QName.create(namespace, date, localName))).build(); - } - - @Test - public void testReadConfigurationData() { - when(rTransaction.read(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class))).thenReturn( - dummyNodeInFuture); - - final NormalizedNode actualNode = brokerFacade.readConfigurationData(instanceID); - - assertSame("readConfigurationData", dummyNode, actualNode); - } - - @Test - public void testReadOperationalData() { - when(rTransaction.read(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class))).thenReturn( - dummyNodeInFuture); - - final NormalizedNode actualNode = brokerFacade.readOperationalData(instanceID); - - assertSame("readOperationalData", dummyNode, actualNode); - } - - @Test(expected = RestconfDocumentedException.class) - public void testReadOperationalDataWithNoDataBroker() { - brokerFacade.setDomDataBroker(null); - - brokerFacade.readOperationalData(instanceID); - } - - @Test - public void testInvokeRpc() throws Exception { - final DOMRpcResult expResult = mock(DOMRpcResult.class); - final CheckedFuture future = Futures.immediateCheckedFuture(expResult); - when(mockRpcService.invokeRpc(type, dummyNode)).thenReturn(future); - - final CheckedFuture actualFuture = brokerFacade.invokeRpc(type, dummyNode); - assertNotNull("Future is null", actualFuture); - final DOMRpcResult actualResult = actualFuture.get(); - assertSame("invokeRpc", expResult, actualResult); - } - - @Test(expected = RestconfDocumentedException.class) - public void testInvokeRpcWithNoConsumerSession() { - brokerFacade.setContext(null); - brokerFacade.invokeRpc(type, dummyNode); - } - - @Ignore - @Test - public void testCommitConfigurationDataPut() { - @SuppressWarnings("unchecked") - final CheckedFuture expFuture = mock(CheckedFuture.class); - - when(wTransaction.submit()).thenReturn(expFuture); - - final Future actualFuture = brokerFacade.commitConfigurationDataPut((SchemaContext)null, instanceID, dummyNode); - - assertSame("commitConfigurationDataPut", expFuture, actualFuture); - - final InOrder inOrder = inOrder(domDataBroker, wTransaction); - inOrder.verify(domDataBroker).newWriteOnlyTransaction(); - inOrder.verify(wTransaction).put(LogicalDatastoreType.CONFIGURATION, instanceID, dummyNode); - inOrder.verify(wTransaction).submit(); - } - - @Test - public void testCommitConfigurationDataPost() { - @SuppressWarnings("unchecked") - final CheckedFuture expFuture = mock(CheckedFuture.class); - - when(rwTransaction.exists(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn( - wrapExistence(false)); - - - when(rwTransaction.submit()).thenReturn(expFuture); - - final CheckedFuture actualFuture = brokerFacade.commitConfigurationDataPost( - (SchemaContext)null, instanceID, dummyNode); - - assertSame("commitConfigurationDataPost", expFuture, actualFuture); - - final InOrder inOrder = inOrder(domDataBroker, rwTransaction); - inOrder.verify(domDataBroker).newReadWriteTransaction(); - inOrder.verify(rwTransaction).exists(LogicalDatastoreType.CONFIGURATION, instanceID); - inOrder.verify(rwTransaction).put(LogicalDatastoreType.CONFIGURATION, instanceID, dummyNode); - inOrder.verify(rwTransaction).submit(); - } - - @Test(expected = RestconfDocumentedException.class) - public void testCommitConfigurationDataPostAlreadyExists() { - final CheckedFuture successFuture = Futures.immediateCheckedFuture(Boolean.TRUE); - when(rwTransaction.exists(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn( - successFuture); - try { - // Schema context is only necessary for ensuring parent structure - brokerFacade.commitConfigurationDataPost((SchemaContext)null, instanceID, dummyNode); - } catch (final RestconfDocumentedException e) { - assertEquals("getErrorTag", RestconfError.ErrorTag.DATA_EXISTS, e.getErrors().get(0).getErrorTag()); - throw e; - } - } - - @Test - public void testCommitConfigurationDataDelete() { - @SuppressWarnings("unchecked") - final CheckedFuture expFuture = mock(CheckedFuture.class); - - when(wTransaction.submit()).thenReturn(expFuture); - - final CheckedFuture actualFuture = brokerFacade - .commitConfigurationDataDelete(instanceID); - - assertSame("commitConfigurationDataDelete", expFuture, actualFuture); - - final InOrder inOrder = inOrder(domDataBroker, wTransaction); - inOrder.verify(domDataBroker).newWriteOnlyTransaction(); - inOrder.verify(wTransaction).delete(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class)); - inOrder.verify(wTransaction).submit(); - } - - @SuppressWarnings("unchecked") - @Test - public void testRegisterToListenDataChanges() { - final ListenerAdapter listener = Notificator.createListener(instanceID, "stream"); - - final ListenerRegistration mockRegistration = mock(ListenerRegistration.class); - - when( - domDataBroker.registerDataChangeListener(any(LogicalDatastoreType.class), eq(instanceID), eq(listener), - eq(DataChangeScope.BASE))).thenReturn(mockRegistration); - - brokerFacade.registerToListenDataChanges(LogicalDatastoreType.CONFIGURATION, DataChangeScope.BASE, listener); - - verify(domDataBroker).registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, instanceID, listener, - DataChangeScope.BASE); - - assertEquals("isListening", true, listener.isListening()); - - brokerFacade.registerToListenDataChanges(LogicalDatastoreType.CONFIGURATION, DataChangeScope.BASE, listener); - verifyNoMoreInteractions(domDataBroker); - - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug3595Test.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug3595Test.java deleted file mode 100644 index 6ab6b85e0e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug3595Test.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import java.io.FileNotFoundException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class Bug3595Test { - - private static final QName CONT_QNAME = QName.create("leafref:module", "2014-04-17", "cont"); - private static final QName LST_WITH_LFREF_KEY_QNAME = QName.create(CONT_QNAME, "lst-with-lfref-key"); - private static final QName LFREF_KEY_QNAME = QName.create(CONT_QNAME, "lfref-key"); - - - private static ControllerContext controllerContext = ControllerContext.getInstance(); - - @BeforeClass - public static void initialize() throws FileNotFoundException { - SchemaContext schemaContext = TestUtils.loadSchemaContext("/leafref/yang"); - Module module = TestUtils.findModule(schemaContext.getModules(), "leafref-module"); - assertNotNull(module); - module = TestUtils.findModule(schemaContext.getModules(), "referenced-module"); - assertNotNull(module); - - controllerContext.setGlobalSchema(schemaContext); - } - - @Test - public void testLeafrefListKeyDeserializtion() { - final YangInstanceIdentifier node1IIexpected = YangInstanceIdentifier.of(CONT_QNAME) - .node(LST_WITH_LFREF_KEY_QNAME).node(new YangInstanceIdentifier.NodeIdentifierWithPredicates( - LST_WITH_LFREF_KEY_QNAME, LFREF_KEY_QNAME, "node1")); - final InstanceIdentifierContext iiContext = - controllerContext.toInstanceIdentifier("leafref-module:cont/lst-with-lfref-key/node1"); - iiContext.getInstanceIdentifier(); - assertEquals(node1IIexpected, iiContext.getInstanceIdentifier()); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java deleted file mode 100644 index df2b01070a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; -import org.junit.BeforeClass; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; - -public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSchemaLoader { - - @BeforeClass - public static void initialize() { - dataLoad("/instanceidentifier/yang", 4, "instance-identifier-module", "cont"); - } - - - private void validateXmlOutput(final String xml) throws XMLStreamException { - final XMLInputFactory xmlInFactory = XMLInputFactory.newInstance(); - XMLEventReader eventReader; - - eventReader = xmlInFactory.createXMLEventReader(new ByteArrayInputStream(xml.getBytes())); - String aaModulePrefix = null; - String aModulePrefix = null; - String iiModulePrefix = null; - while (eventReader.hasNext()) { - final XMLEvent nextEvent = eventReader.nextEvent(); - if (nextEvent.isStartElement()) { - final StartElement startElement = (StartElement) nextEvent; - if (startElement.getName().getLocalPart().equals("lf111")) { - final Iterator prefixes = startElement.getNamespaceContext().getPrefixes("augment:augment:module"); - - while (prefixes.hasNext() && aaModulePrefix == null) { - final String prefix = (String) prefixes.next(); - if (!prefix.isEmpty()) { - aaModulePrefix = prefix; - } - } - - aModulePrefix = startElement.getNamespaceContext().getPrefix("augment:module"); - iiModulePrefix = startElement.getNamespaceContext().getPrefix("instance:identifier:module"); - break; - } - } - } - - assertNotNull(aaModulePrefix); - assertNotNull(aModulePrefix); - assertNotNull(iiModulePrefix); - - final String instanceIdentifierValue = "/" + iiModulePrefix + ":cont/" + iiModulePrefix + ":cont1/" + aModulePrefix - + ":lst11[" + aModulePrefix + ":keyvalue111='value1'][" + aModulePrefix + ":keyvalue112='value2']/" - + aaModulePrefix + ":lf112"; - - assertTrue(xml.contains(instanceIdentifierValue)); - - } - - private void validateXmlOutputWithLeafList(final String xml) throws XMLStreamException { - final XMLInputFactory xmlInFactory = XMLInputFactory.newInstance(); - XMLEventReader eventReader; - - eventReader = xmlInFactory.createXMLEventReader(new ByteArrayInputStream(xml.getBytes())); - String aModuleLfLstPrefix = null; - String iiModulePrefix = null; - while (eventReader.hasNext()) { - final XMLEvent nextEvent = eventReader.nextEvent(); - if (nextEvent.isStartElement()) { - final StartElement startElement = (StartElement) nextEvent; - if (startElement.getName().getLocalPart().equals("lf111")) { - final Iterator prefixes = startElement.getNamespaceContext().getPrefixes("augment:module:leaf:list"); - - while (prefixes.hasNext() && aModuleLfLstPrefix == null) { - final String prefix = (String) prefixes.next(); - if (!prefix.isEmpty()) { - aModuleLfLstPrefix = prefix; - } - } - iiModulePrefix = startElement.getNamespaceContext().getPrefix("instance:identifier:module"); - break; - } - } - } - - assertNotNull(aModuleLfLstPrefix); - assertNotNull(iiModulePrefix); - - final String instanceIdentifierValue = "/" + iiModulePrefix + ":cont/" + iiModulePrefix + ":cont1/" - + aModuleLfLstPrefix + ":lflst11[.='lflst11_1']"; - - assertTrue(xml.contains(instanceIdentifierValue)); - - } - - private YangInstanceIdentifier createInstanceIdentifier() throws URISyntaxException { - final List pathArguments = new ArrayList<>(); - pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont"))); - pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1"))); - - final QName qName = new QName(new URI("augment:module"), "lst11"); - final Map keyValues = new HashMap<>(); - keyValues.put(new QName(new URI("augment:module"), "keyvalue111"), "value1"); - keyValues.put(new QName(new URI("augment:module"), "keyvalue112"), "value2"); - final NodeIdentifierWithPredicates nodeIdentifierWithPredicates = new NodeIdentifierWithPredicates(qName, keyValues); - pathArguments.add(nodeIdentifierWithPredicates); - - pathArguments.add(new NodeIdentifier(new QName(new URI("augment:augment:module"), "lf112"))); - - return YangInstanceIdentifier.create(pathArguments); - } - - private YangInstanceIdentifier createInstanceIdentifierWithLeafList() throws URISyntaxException { - final List pathArguments = new ArrayList<>(); - pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont"))); - pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1"))); - pathArguments.add(new NodeWithValue(new QName(new URI("augment:module:leaf:list"), "lflst11"), "lflst11_1")); - - return YangInstanceIdentifier.create(pathArguments); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CodecsExceptionsCatchingTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CodecsExceptionsCatchingTest.java deleted file mode 100644 index 188eda0e53..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CodecsExceptionsCatchingTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Brocade Communication Systems, Inc., Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertTrue; -import java.io.FileNotFoundException; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class CodecsExceptionsCatchingTest extends JerseyTest { - - private static RestconfImpl restConf; - private static ControllerContext controllerContext = ControllerContext.getInstance(); - - @BeforeClass - public static void init() throws FileNotFoundException { - restConf = RestconfImpl.getInstance(); - controllerContext = ControllerContext.getInstance(); - final SchemaContext schemaContext = TestUtils.loadSchemaContext("/decoding-exception/yang"); - controllerContext.setGlobalSchema(schemaContext); - restConf.setControllerContext(controllerContext); - } - - @Override - protected Application configure() { - /* enable/disable Jersey logs to console */ - // enable(TestProperties.LOG_TRAFFIC); - // enable(TestProperties.DUMP_ENTITY); - // enable(TestProperties.RECORD_LOG_LEVEL); - // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue()); - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(restConf, new NormalizedNodeJsonBodyWriter(), - new NormalizedNodeXmlBodyWriter(), new XmlNormalizedNodeBodyReader(), new JsonNormalizedNodeBodyReader()); - resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); - return resourceConfig; - } - - @Test - @Ignore // TODO RestconfDocumentedExceptionMapper needs be fixed before - public void StringToNumberConversionError() { - final Response response = target("/config/number:cont").request(MediaType.APPLICATION_XML).put( - Entity.entity("3f", MediaType.APPLICATION_XML)); - final String exceptionMessage = response.readEntity(String.class); - assertTrue(exceptionMessage.contains("invalid-value")); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CutDataToCorrectDepthTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CutDataToCorrectDepthTest.java deleted file mode 100644 index 6684bec334..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CutDataToCorrectDepthTest.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import javax.ws.rs.Consumes; -import javax.ws.rs.Encoded; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.QueryParametersParser; -import org.opendaylight.controller.sal.restconf.impl.WriterParameters; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class CutDataToCorrectDepthTest extends JerseyTest { - - private static NormalizedNode depth1Cont; - private static NormalizedNode depth2Cont1; - private NormalizedNode globalPayload; - private static SchemaContext schemaContextModules; - - @Path("/") - public class RestImpl { - - @GET - @Path("/config/{identifier:.+}") - @Produces({ "application/json", "application/xml" }) - public NormalizedNodeContext getData(@Encoded @PathParam("identifier") String identifier, - @Context UriInfo uriInfo) { - - final InstanceIdentifierContext iiWithData = ControllerContext.getInstance().toInstanceIdentifier( - identifier); - - NormalizedNode data = null; - if (identifier.equals("nested-module:depth1-cont/depth2-cont1")) { - data = depth2Cont1; - } else if (identifier.equals("nested-module:depth1-cont")) { - data = depth1Cont; - } - - final WriterParameters writerParameters = QueryParametersParser.parseWriterParameters(uriInfo); - return new NormalizedNodeContext(iiWithData, data, writerParameters); - } - - @GET - @Path("/operational/{identifier:.+}") - @Produces({ "application/json", "application/xml" }) - public NormalizedNodeContext getDataOperational(@Encoded @PathParam("identifier") String identifier, - @Context UriInfo uriInfo) { - return getData(identifier, uriInfo); - } - - @PUT - @Path("/config/{identifier:.+}") - @Consumes({ "application/json", "application/xml" }) - public void normalizedData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload) throws InterruptedException { - System.out.println(payload); - System.out.println(payload.getInstanceIdentifierContext().getInstanceIdentifier()); - System.out.println(payload.getData()); - globalPayload = payload.getData(); - } - - @PUT - @Path("/operational/{identifier:.+}") - @Consumes({ "application/json", "application/xml" }) - public void normalizedDataOperational(@Encoded @PathParam("identifier") String identifier, - NormalizedNodeContext payload) throws InterruptedException { - normalizedData(identifier, payload); - } - } - - @BeforeClass - public static void initialize() throws FileNotFoundException { - schemaContextModules = TestUtils.loadSchemaContext("/modules"); - Module module = TestUtils.findModule(schemaContextModules.getModules(), "nested-module"); - assertNotNull(module); - - UnkeyedListNode listAsUnkeyedList = unkeyedList( - "depth2-cont1", - unkeyedEntry("depth2-cont1", - container("depth3-cont1", - container("depth4-cont1", leaf("depth5-leaf1", "depth5-leaf1-value")), - leaf("depth4-leaf1", "depth4-leaf1-value")), leaf("depth3-leaf1", "depth3-leaf1-value"))); - - MapNode listAsMap = mapNode( - "depth2-list2", - mapEntryNode("depth2-list2", 2, leaf("depth3-lf1-key", "depth3-lf1-key-value"), - leaf("depth3-lf2-key", "depth3-lf2-key-value"), leaf("depth3-lf3", "depth3-lf3-value"))); - - depth1Cont = container( - "depth1-cont", - listAsUnkeyedList, - listAsMap, - leafList("depth2-lfLst1", "depth2-lflst1-value1", "depth2-lflst1-value2", "depth2-lflst1-value3"), - container( - "depth2-cont2", - container("depth3-cont2", - container("depth4-cont2", leaf("depth5-leaf2", "depth5-leaf2-value")), - leaf("depth4-leaf2", "depth4-leaf2-value")), leaf("depth3-leaf2", "depth3-leaf2-value")), - leaf("depth2-leaf1", "depth2-leaf1-value")); - - depth2Cont1 = listAsUnkeyedList; - } - - // TODO: These tests should be fixed/rewriten because they fail randomly due to data not being de-serialized - // properly in readers - //@Test - public void getDataWithUriDepthParameterTest() throws WebApplicationException, IOException { - getDataWithUriDepthParameter("application/json"); - getDataWithUriDepthParameter("application/xml"); - } - - public void getDataWithUriDepthParameter(final String mediaType) throws WebApplicationException, IOException { - ControllerContext.getInstance().setGlobalSchema(schemaContextModules); - Response response; - - // Test config with depth 1 - response = target("/config/nested-module:depth1-cont").queryParam("depth", "1").request(mediaType) - .get(); - txtDataToNormalizedNode(response, mediaType, "/config/nested-module:depth1-cont"); - verifyResponse(nodeDataDepth1()); - - // Test config with depth 2 - response = target("/config/nested-module:depth1-cont").queryParam("depth", "2").request(mediaType) - .get(); - txtDataToNormalizedNode(response, mediaType, "/config/nested-module:depth1-cont"); - verifyResponse(nodeDataDepth2()); - - // Test config with depth 3 - response = target("/config/nested-module:depth1-cont").queryParam("depth", "3").request(mediaType) - .get(); - txtDataToNormalizedNode(response, mediaType, "/config/nested-module:depth1-cont"); - verifyResponse(nodeDataDepth3()); - - // Test config with depth 4 - response = target("/config/nested-module:depth1-cont").queryParam("depth", "4").request(mediaType) - .get(); - txtDataToNormalizedNode(response, mediaType, "/config/nested-module:depth1-cont"); - verifyResponse(nodeDataDepth4()); - - // Test config with depth 5 - response = target("/config/nested-module:depth1-cont").queryParam("depth", "5").request(mediaType) - .get(); - txtDataToNormalizedNode(response, mediaType, "/config/nested-module:depth1-cont"); - verifyResponse(nodeDataDepth5()); - - // Test config with depth unbounded - - response = target("/config/nested-module:depth1-cont").queryParam("depth", "unbounded") - .request(mediaType).get(); - txtDataToNormalizedNode(response, mediaType, "/config/nested-module:depth1-cont"); - verifyResponse(nodeDataDepth5()); - } - - private void txtDataToNormalizedNode(final Response response, final String mediaType, final String uri) { - String responseStr = response.readEntity(String.class); - System.out.println(responseStr); - target(uri).request(mediaType).put(Entity.entity(responseStr, mediaType)); - } - - private void verifyResponse(final NormalizedNode nodeData) throws WebApplicationException, IOException { - assertNotNull(globalPayload); - assertEquals(globalPayload, nodeData); - globalPayload = null; - } - - @Override - protected Application configure() { - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(new RestImpl()); - resourceConfig.registerClasses(XmlNormalizedNodeBodyReader.class, NormalizedNodeXmlBodyWriter.class, - JsonNormalizedNodeBodyReader.class, NormalizedNodeJsonBodyWriter.class, - RestconfDocumentedExceptionMapper.class); - return resourceConfig; - } - - private static LeafNode leaf(final String localName, final Object value) { - return Builders.leafBuilder().withNodeIdentifier(toIdentifier(localName)).withValue(value).build(); - } - - private static ContainerNode container(final String localName, final DataContainerChild... children) { - DataContainerNodeAttrBuilder containerBuilder = Builders.containerBuilder(); - for (DataContainerChild child : children) { - containerBuilder.withChild(child); - } - containerBuilder.withNodeIdentifier(toIdentifier(localName)); - return containerBuilder.build(); - } - - private static UnkeyedListNode unkeyedList( - final String localName, - final UnkeyedListEntryNode... entryNodes) { - CollectionNodeBuilder builder = Builders.unkeyedListBuilder(); - final NodeIdentifier identifier = toIdentifier(localName); - builder.withNodeIdentifier(identifier); - for (UnkeyedListEntryNode unkeyedListEntryNode : entryNodes) { - builder.withChild(unkeyedListEntryNode); - } - return builder.build(); - } - - private static UnkeyedListEntryNode unkeyedEntry(final String localName, - final DataContainerChild... children) { - DataContainerNodeAttrBuilder builder = Builders.unkeyedListEntryBuilder(); - builder.withNodeIdentifier(toIdentifier(localName)); - for (DataContainerChild child : children) { - builder.withChild(child); - } - return builder.build(); - } - - private static MapNode mapNode(final String localName, final MapEntryNode... entryNodes) { - CollectionNodeBuilder builder = Builders.mapBuilder(); - builder.withNodeIdentifier(toIdentifier(localName)); - for (MapEntryNode mapEntryNode : entryNodes) { - builder.withChild(mapEntryNode); - } - return builder.build(); - } - - private static MapEntryNode mapEntryNode(final String localName, final int keysNumber, - final DataContainerChild... children) { - DataContainerNodeAttrBuilder builder = Builders.mapEntryBuilder(); - Map keys = new HashMap<>(); - for (int i = 0; i < keysNumber; i++) { - keys.put(children[i].getNodeType(), children[i].getValue()); - } - builder.withNodeIdentifier(toIdentifier(localName, keys)); - - for (DataContainerChild child : children) { - builder.withChild(child); - } - return builder.build(); - } - - private static LeafSetNode leafList(final String localName, final String... children) { - ListNodeBuilder> builder = Builders.leafSetBuilder(); - builder.withNodeIdentifier(toIdentifier(localName)); - for (String child : children) { - builder.withChild(Builders.leafSetEntryBuilder().withNodeIdentifier(toIdentifier(localName, child)) - .withValue(child).build()); - } - return builder.build(); - } - - private static NodeIdentifier toIdentifier(String localName) { - return new NodeIdentifier(QName.create("urn:nested:module", "2014-06-3", localName)); - } - - private static NodeIdentifierWithPredicates toIdentifier(String localName, Map keys) { - return new NodeIdentifierWithPredicates(QName.create("urn:nested:module", "2014-06-3", localName), - keys); - } - - private static NodeWithValue toIdentifier(final String localName, final Object value) { - return new NodeWithValue(QName.create("urn:nested:module", "2014-06-3", localName), value); - } - - - - private UnkeyedListEntryNode nodeDataDepth3Operational() { - return unkeyedEntry("depth2-cont1", - container("depth3-cont1", container("depth4-cont1"), leaf("depth4-leaf1", "depth4-leaf1-value")), - leaf("depth3-leaf1", "depth3-leaf1-value")); - } - - private ContainerNode nodeDataDepth5() { - return container( - "depth1-cont", - unkeyedList( - "depth2-cont1", - unkeyedEntry("depth2-cont1", - container("depth3-cont1", - container("depth4-cont1", leaf("depth5-leaf1", "depth5-leaf1-value")), - leaf("depth4-leaf1", "depth4-leaf1-value")), - leaf("depth3-leaf1", "depth3-leaf1-value"))), - mapNode("depth2-list2", - mapEntryNode("depth2-list2", 2, leaf("depth3-lf1-key", "depth3-lf1-key-value"), - leaf("depth3-lf2-key", "depth3-lf2-key-value"), leaf("depth3-lf3", "depth3-lf3-value"))), - leafList("depth2-lfLst1", "depth2-lflst1-value1", "depth2-lflst1-value2", "depth2-lflst1-value3"), - container( - "depth2-cont2", - container("depth3-cont2", - container("depth4-cont2", leaf("depth5-leaf2", "depth5-leaf2-value")), - leaf("depth4-leaf2", "depth4-leaf2-value")), leaf("depth3-leaf2", "depth3-leaf2-value")), - leaf("depth2-leaf1", "depth2-leaf1-value")); - } - - private ContainerNode nodeDataDepth4() { - return container( - "depth1-cont", - unkeyedList("depth2-cont1", nodeDataDepth3Operational()), - mapNode("depth2-list2", - mapEntryNode("depth2-list2", 2, leaf("depth3-lf1-key", "depth3-lf1-key-value"), - leaf("depth3-lf2-key", "depth3-lf2-key-value"), leaf("depth3-lf3", "depth3-lf3-value"))), - leafList("depth2-lfLst1", "depth2-lflst1-value1", "depth2-lflst1-value2", "depth2-lflst1-value3"), - container( - "depth2-cont2", - container("depth3-cont2", container("depth4-cont2"), leaf("depth4-leaf2", "depth4-leaf2-value")), - leaf("depth3-leaf2", "depth3-leaf2-value")), leaf("depth2-leaf1", "depth2-leaf1-value")); - } - - private ContainerNode nodeDataDepth3() { - return container( - "depth1-cont", - unkeyedList("depth2-cont1", - unkeyedEntry("depth2-cont1", container("depth3-cont1"), leaf("depth3-leaf1", "depth3-leaf1-value"))), - mapNode("depth2-list2", - mapEntryNode("depth2-list2", 2, leaf("depth3-lf1-key", "depth3-lf1-key-value"), - leaf("depth3-lf2-key", "depth3-lf2-key-value"), leaf("depth3-lf3", "depth3-lf3-value"))), - leafList("depth2-lfLst1", "depth2-lflst1-value1", "depth2-lflst1-value2", "depth2-lflst1-value3"), - container("depth2-cont2", container("depth3-cont2"), leaf("depth3-leaf2", "depth3-leaf2-value")), - leaf("depth2-leaf1", "depth2-leaf1-value")); - } - - private ContainerNode nodeDataDepth2() { - return container( - "depth1-cont", - unkeyedList("depth2-cont1", unkeyedEntry("depth2-cont1")), - mapNode("depth2-list2", - mapEntryNode("depth2-list2", 2, leaf("depth3-lf1-key", "depth3-lf1-key-value"), - leaf("depth3-lf2-key", "depth3-lf2-key-value"))), container("depth2-cont2"), -// leafList("depth2-lfLst1"), - leaf("depth2-leaf1", "depth2-leaf1-value")); - } - - private ContainerNode nodeDataDepth1() { - return container("depth1-cont"); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java deleted file mode 100644 index 8ae8d0bdac..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.opendaylight.yangtools.yang.common.RpcResult; - -public class DummyFuture implements Future> { - - private final boolean cancel; - private final boolean isCancelled; - private final boolean isDone; - private final RpcResult result; - - public DummyFuture() { - cancel = false; - isCancelled = false; - isDone = false; - result = null; - } - - private DummyFuture(final Builder builder) { - cancel = builder.cancel; - isCancelled = builder.isCancelled; - isDone = builder.isDone; - result = builder.result; - } - - @Override - public boolean cancel(final boolean mayInterruptIfRunning) { - return cancel; - } - - @Override - public boolean isCancelled() { - return isCancelled; - } - - @Override - public boolean isDone() { - return isDone; - } - - @Override - public RpcResult get() throws InterruptedException, ExecutionException { - return result; - } - - @Override - public RpcResult get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, - TimeoutException { - return result; - } - - public static class Builder { - - private boolean cancel; - private boolean isCancelled; - private boolean isDone; - private RpcResult result; - - public Builder cancel(final boolean cancel) { - this.cancel = cancel; - return this; - } - - public Builder isCancelled(final boolean isCancelled) { - this.isCancelled = isCancelled; - return this; - } - - public Builder isDone(final boolean isDone) { - this.isDone = isDone; - return this; - } - - public Builder rpcResult(final RpcResult result) { - this.result = result; - return this; - } - - public Future> build() { - return new DummyFuture(this); - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyRpcResult.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyRpcResult.java deleted file mode 100644 index 3c545c06e9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyRpcResult.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import java.util.Collection; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; - -public class DummyRpcResult implements RpcResult { - - private final boolean isSuccessful; - private final T result; - private final Collection errors; - - public DummyRpcResult() { - isSuccessful = false; - result = null; - errors = null; - } - - private DummyRpcResult(final Builder builder) { - isSuccessful = builder.isSuccessful; - result = builder.result; - errors = builder.errors; - } - - @Override - public boolean isSuccessful() { - return isSuccessful; - } - - @Override - public T getResult() { - return result; - } - - @Override - public Collection getErrors() { - return errors; - } - - public static class Builder { - private boolean isSuccessful; - private T result; - private Collection errors; - - public Builder isSuccessful(final boolean isSuccessful) { - this.isSuccessful = isSuccessful; - return this; - } - - public Builder result(final T result) { - this.result = result; - return this; - } - - public Builder errors(final Collection errors) { - this.errors = errors; - return this; - } - - public RpcResult build() { - return new DummyRpcResult(this); - } - - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyType.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyType.java deleted file mode 100644 index 008fda4e09..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyType.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import java.util.List; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.Status; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; - -public class DummyType implements TypeDefinition { - QName dummyQName = TestUtils.buildQName("dummy type", "simple:uri", "2012-12-17"); - - @Override - public QName getQName() { - return dummyQName; - } - - @Override - public SchemaPath getPath() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getDescription() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getReference() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Status getStatus() { - // TODO Auto-generated method stub - return null; - } - - @Override - public List getUnknownSchemaNodes() { - // TODO Auto-generated method stub - return null; - } - - @Override - public DummyType getBaseType() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUnits() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object getDefaultValue() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java deleted file mode 100644 index ded3397242..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java +++ /dev/null @@ -1,398 +0,0 @@ -/* - * Copyright (c) 2013, 2015 Brocade Communication Systems, Inc., Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import java.io.FileNotFoundException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils; - -public class InvokeRpcMethodTest { - - private RestconfImpl restconfImpl = null; - private static ControllerContext controllerContext = null; - private static UriInfo uriInfo; - - - @BeforeClass - public static void init() throws FileNotFoundException { - final Set allModules = new HashSet(TestUtils.loadModulesFrom("/full-versions/yangs")); - allModules.addAll(TestUtils.loadModulesFrom("/invoke-rpc")); - assertNotNull(allModules); - final Module module = TestUtils.resolveModule("invoke-rpc-module", allModules); - assertNotNull(module); - final SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules); - controllerContext = spy(ControllerContext.getInstance()); - controllerContext.setSchemas(schemaContext); - uriInfo = mock(UriInfo.class); - final MultivaluedMap map = new MultivaluedHashMap<>(); - map.put("prettyPrint", Collections.singletonList("true")); - when(uriInfo.getQueryParameters(any(Boolean.class))).thenReturn(map); - } - - @Before - public void initMethod() { - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setControllerContext(controllerContext); - } - - /** - * Test method invokeRpc in RestconfImpl class tests if composite node as input parameter of method invokeRpc - * (second argument) is wrapped to parent composite node which has QName equals to QName of rpc (resolved from - * string - first argument). - */ - @Test - @Ignore - public void invokeRpcMethodTest() { - final ControllerContext contContext = controllerContext; - try { - contContext.findModuleNameByNamespace(new URI("invoke:rpc:module")); - } catch (final URISyntaxException e) { - assertTrue("Uri wasn't created sucessfuly", false); - } - - final BrokerFacade mockedBrokerFacade = mock(BrokerFacade.class); - - final RestconfImpl restconf = RestconfImpl.getInstance(); - restconf.setBroker(mockedBrokerFacade); - restconf.setControllerContext(contContext); - - final NormalizedNodeContext payload = prepareDomPayload(); - - final NormalizedNodeContext rpcResponse = restconf.invokeRpc("invoke-rpc-module:rpc-test", payload, uriInfo); - assertTrue(rpcResponse != null); - assertTrue(rpcResponse.getData() == null); - - } - - private NormalizedNodeContext prepareDomPayload() { - final SchemaContext schema = controllerContext.getGlobalSchema(); - final Module rpcModule = schema.findModuleByName("invoke-rpc-module", null); - assertNotNull(rpcModule); - final QName rpcQName = QName.create(rpcModule.getQNameModule(), "rpc-test"); - final QName rpcInputQName = QName.create(rpcModule.getQNameModule(),"input"); - final Set setRpcs = rpcModule.getRpcs(); - ContainerSchemaNode rpcInputSchemaNode = null; - for (final RpcDefinition rpc : setRpcs) { - if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { - rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName); - break; - } - } - assertNotNull(rpcInputSchemaNode); - - final DataContainerNodeAttrBuilder container = Builders.containerBuilder(rpcInputSchemaNode); - - final QName contQName = QName.create(rpcModule.getQNameModule(), "cont"); - final DataSchemaNode contSchemaNode = rpcInputSchemaNode.getDataChildByName(contQName); - assertTrue(contSchemaNode instanceof ContainerSchemaNode); - final DataContainerNodeAttrBuilder contNode = Builders.containerBuilder((ContainerSchemaNode) contSchemaNode); - - final QName lfQName = QName.create(rpcModule.getQNameModule(), "lf"); - final DataSchemaNode lfSchemaNode = ((ContainerSchemaNode) contSchemaNode).getDataChildByName(lfQName); - assertTrue(lfSchemaNode instanceof LeafSchemaNode); - final LeafNode lfNode = (Builders.leafBuilder((LeafSchemaNode) lfSchemaNode).withValue("any value")).build(); - contNode.withChild(lfNode); - container.withChild(contNode.build()); - - return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpcInputSchemaNode, null, schema), container.build()); - } - - @Test - public void testInvokeRpcWithNoPayloadRpc_FailNoErrors() { - final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption"); - final CheckedFuture future = Futures.immediateFailedCheckedFuture(exception); - - final BrokerFacade brokerFacade = mock(BrokerFacade.class); - - final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"); - final SchemaPath type = SchemaPath.create(true, qname); - - when(brokerFacade.invokeRpc(eq(type), any(NormalizedNode.class))).thenReturn(future); - - restconfImpl.setBroker(brokerFacade); - - try { - restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo); - fail("Expected an exception to be thrown."); - } catch (final RestconfDocumentedException e) { - verifyRestconfDocumentedException(e, 0, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, - Optional. absent(), Optional. absent()); - } - } - - void verifyRestconfDocumentedException(final RestconfDocumentedException e, final int index, - final ErrorType expErrorType, final ErrorTag expErrorTag, final Optional expErrorMsg, - final Optional expAppTag) { - RestconfError actual = null; - try { - actual = e.getErrors().get(index); - } catch (final ArrayIndexOutOfBoundsException ex) { - fail("RestconfError not found at index " + index); - } - - assertEquals("getErrorType", expErrorType, actual.getErrorType()); - assertEquals("getErrorTag", expErrorTag, actual.getErrorTag()); - assertNotNull("getErrorMessage is null", actual.getErrorMessage()); - - if (expErrorMsg.isPresent()) { - assertEquals("getErrorMessage", expErrorMsg.get(), actual.getErrorMessage()); - } - - if (expAppTag.isPresent()) { - assertEquals("getErrorAppTag", expAppTag.get(), actual.getErrorAppTag()); - } - } - - @Test - public void testInvokeRpcWithNoPayloadRpc_FailWithRpcError() { - final List rpcErrors = Arrays.asList( - RpcResultBuilder.newError( RpcError.ErrorType.TRANSPORT, "bogusTag", "foo" ), - RpcResultBuilder.newWarning( RpcError.ErrorType.RPC, "in-use", "bar", - "app-tag", null, null ) ); - - final DOMRpcResult resutl = new DefaultDOMRpcResult(rpcErrors); - final CheckedFuture future = Futures.immediateCheckedFuture(resutl); - - final SchemaPath path = SchemaPath.create(true, - QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast")); - - final BrokerFacade brokerFacade = mock(BrokerFacade.class); - when(brokerFacade.invokeRpc(eq(path), any(NormalizedNode.class))).thenReturn(future); - - restconfImpl.setBroker(brokerFacade); - - try { - restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo); - fail("Expected an exception to be thrown."); - } catch (final RestconfDocumentedException e) { - verifyRestconfDocumentedException(e, 0, ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED, Optional.of("foo"), - Optional. absent()); - verifyRestconfDocumentedException(e, 1, ErrorType.RPC, ErrorTag.IN_USE, Optional.of("bar"), - Optional.of("app-tag")); - } - } - - @Test - public void testInvokeRpcWithNoPayload_Success() { - final NormalizedNode resultObj = null; - final DOMRpcResult expResult = new DefaultDOMRpcResult(resultObj); - final CheckedFuture future = Futures.immediateCheckedFuture(expResult); - - final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"); - final SchemaPath path = SchemaPath.create(true, qname); - - final BrokerFacade brokerFacade = mock(BrokerFacade.class); - when(brokerFacade.invokeRpc(eq(path), any (NormalizedNode.class))).thenReturn(future); - - restconfImpl.setBroker(brokerFacade); - - final NormalizedNodeContext output = restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo); - assertNotNull(output); - assertEquals(null, output.getData()); - // additional validation in the fact that the restconfImpl does not - // throw an exception. - } - - @Test - public void testInvokeRpcMethodExpectingNoPayloadButProvidePayload() { - try { - restconfImpl.invokeRpc("toaster:cancel-toast", " a payload ", uriInfo); - fail("Expected an exception"); - } catch (final RestconfDocumentedException e) { - verifyRestconfDocumentedException(e, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, - Optional. absent(), Optional. absent()); - } - } - - @Test - public void testInvokeRpcMethodWithBadMethodName() { - try { - restconfImpl.invokeRpc("toaster:bad-method", "", uriInfo); - fail("Expected an exception"); - } catch (final RestconfDocumentedException e) { - verifyRestconfDocumentedException(e, 0, ErrorType.RPC, ErrorTag.UNKNOWN_ELEMENT, - Optional. absent(), Optional. absent()); - } - } - - @Test - @Ignore - public void testInvokeRpcMethodWithInput() { - final DOMRpcResult expResult = mock(DOMRpcResult.class); - final CheckedFuture future = Futures.immediateCheckedFuture(expResult); - final SchemaPath path = SchemaPath.create(true, - QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)make-toast")); - - final SchemaContext schemaContext = controllerContext.getGlobalSchema(); - final Module rpcModule = schemaContext.findModuleByName("toaster", null); - assertNotNull(rpcModule); - final QName rpcQName = QName.create(rpcModule.getQNameModule(), "make-toast"); - final QName rpcInputQName = QName.create(rpcModule.getQNameModule(),"input"); - - final Set setRpcs = rpcModule.getRpcs(); - RpcDefinition rpcDef = null; - ContainerSchemaNode rpcInputSchemaNode = null; - - for (final RpcDefinition rpc : setRpcs) { - if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { - rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName); - rpcDef = rpc; - break; - } - } - - assertNotNull(rpcDef); - assertNotNull(rpcInputSchemaNode); - assertTrue(rpcInputSchemaNode instanceof ContainerSchemaNode); - final DataContainerNodeAttrBuilder containerBuilder = - Builders.containerBuilder(rpcInputSchemaNode); - - final NormalizedNodeContext payload = new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpcInputSchemaNode, - null, schemaContext), containerBuilder.build()); - - final BrokerFacade brokerFacade = mock(BrokerFacade.class); - when(brokerFacade.invokeRpc(eq(path), any(NormalizedNode.class))).thenReturn(future); - restconfImpl.setBroker(brokerFacade); - - final NormalizedNodeContext output = restconfImpl.invokeRpc("toaster:make-toast", payload, uriInfo); - assertNotNull(output); - assertEquals(null, output.getData()); - // additional validation in the fact that the restconfImpl does not - // throw an exception. - } - - @Test - public void testThrowExceptionWhenSlashInModuleName() { - try { - restconfImpl.invokeRpc("toaster/slash", "", uriInfo); - fail("Expected an exception."); - } catch (final RestconfDocumentedException e) { - verifyRestconfDocumentedException(e, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, - Optional. absent(), Optional. absent()); - } - } - - @Test - public void testInvokeRpcWithNoPayloadWithOutput_Success() { - final SchemaContext schema = controllerContext.getGlobalSchema(); - final Module rpcModule = schema.findModuleByName("toaster", null); - assertNotNull(rpcModule); - final QName rpcQName = QName.create(rpcModule.getQNameModule(), "testOutput"); - final QName rpcOutputQName = QName.create(rpcModule.getQNameModule(),"output"); - - final Set setRpcs = rpcModule.getRpcs(); - RpcDefinition rpcDef = null; - ContainerSchemaNode rpcOutputSchemaNode = null; - for (final RpcDefinition rpc : setRpcs) { - if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { - rpcOutputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcOutputQName); - rpcDef = rpc; - break; - } - } - assertNotNull(rpcDef); - assertNotNull(rpcOutputSchemaNode); - assertTrue(rpcOutputSchemaNode instanceof ContainerSchemaNode); - final DataContainerNodeAttrBuilder containerBuilder = - Builders.containerBuilder(rpcOutputSchemaNode); - final DataSchemaNode leafSchema = rpcOutputSchemaNode - .getDataChildByName(QName.create(rpcModule.getQNameModule(), "textOut")); - assertTrue(leafSchema instanceof LeafSchemaNode); - final NormalizedNodeAttrBuilder> leafBuilder = - Builders.leafBuilder((LeafSchemaNode) leafSchema); - leafBuilder.withValue("brm"); - containerBuilder.withChild(leafBuilder.build()); - final ContainerNode container = containerBuilder.build(); - - final DOMRpcResult result = new DefaultDOMRpcResult(container); - final CheckedFuture future = Futures.immediateCheckedFuture(result); - - final BrokerFacade brokerFacade = mock(BrokerFacade.class); - when(brokerFacade.invokeRpc(eq(rpcDef.getPath()), any(NormalizedNode.class))).thenReturn(future); - - restconfImpl.setBroker(brokerFacade); - - final NormalizedNodeContext output = restconfImpl.invokeRpc("toaster:testOutput", "", uriInfo); - assertNotNull(output); - assertNotNull(output.getData()); - assertSame(container, output.getData()); - assertNotNull(output.getInstanceIdentifierContext()); - assertNotNull(output.getInstanceIdentifierContext().getSchemaContext()); - } - - /** - * - * Tests calling of RestConfImpl method invokeRpc. In the method there is searched rpc in remote schema context. - * This rpc is then executed. - * - * I wasn't able to simulate calling of rpc on remote device therefore this testing method raise method when rpc is - * invoked. - */ - @Test - @Ignore // FIXME find how to use mockito for it - public void testMountedRpcCallNoPayload_Success() throws Exception { - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MediaTypesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MediaTypesTest.java deleted file mode 100644 index a00b0d1fc6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MediaTypesTest.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.JSON; -import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.XML; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.api.RestconfService; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; - -public class MediaTypesTest extends JerseyTest { - - private static RestconfService restconfService; - private static String jsonData; - private static String xmlData; - - @BeforeClass - public static void init() throws IOException { - restconfService = mock(RestconfService.class); - final String jsonPath = RestconfImplTest.class.getResource("/parts/ietf-interfaces_interfaces.json").getPath(); - jsonData = TestUtils.loadTextFile(jsonPath); - final InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml"); - xmlData = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream)); - } - - @Override - protected Application configure() { - /* enable/disable Jersey logs to console */ - // enable(TestProperties.LOG_TRAFFIC); - // enable(TestProperties.DUMP_ENTITY); - // enable(TestProperties.RECORD_LOG_LEVEL); - // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue()); - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(restconfService, new NormalizedNodeJsonBodyWriter(), - new NormalizedNodeXmlBodyWriter(), new XmlNormalizedNodeBodyReader(), new JsonNormalizedNodeBodyReader()); - resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); - return resourceConfig; - } - - @Test - @Ignore - public void testPostOperationsWithInputDataMediaTypes() throws UnsupportedEncodingException { - final String uriPrefix = "/operations/"; - final String uriPath = "ietf-interfaces:interfaces"; - final String uri = uriPrefix + uriPath; - when(restconfService.invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class))).thenReturn(null); - post(uri, Draft02.MediaTypes.OPERATION + JSON, Draft02.MediaTypes.OPERATION + JSON, jsonData); - verify(restconfService, times(1)).invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, Draft02.MediaTypes.OPERATION + XML, Draft02.MediaTypes.OPERATION + XML, xmlData); - verify(restconfService, times(2)).invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON, jsonData); - verify(restconfService, times(3)).invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, MediaType.APPLICATION_XML, MediaType.APPLICATION_XML, xmlData); - verify(restconfService, times(4)).invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, MediaType.TEXT_XML, MediaType.TEXT_XML, xmlData); - verify(restconfService, times(5)).invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, MediaType.TEXT_XML, xmlData); - verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class)); - - // negative tests - post(uri, MediaType.TEXT_PLAIN, MediaType.TEXT_XML, xmlData); - verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, MediaType.TEXT_XML, MediaType.TEXT_PLAIN, xmlData); - verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(NormalizedNodeContext.class), any(UriInfo.class)); - } - - @Test - public void testGetConfigMediaTypes() throws UnsupportedEncodingException { - final String uriPrefix = "/config/"; - final String uriPath = "ietf-interfaces:interfaces"; - final String uri = uriPrefix + uriPath; - when(restconfService.readConfigurationData(eq(uriPath), any(UriInfo.class))).thenReturn(null); - get(uri, Draft02.MediaTypes.DATA + JSON); - verify(restconfService, times(1)).readConfigurationData(eq(uriPath), any(UriInfo.class)); - get(uri, Draft02.MediaTypes.DATA + XML); - verify(restconfService, times(2)).readConfigurationData(eq(uriPath), any(UriInfo.class)); - get(uri, MediaType.APPLICATION_JSON); - verify(restconfService, times(3)).readConfigurationData(eq(uriPath), any(UriInfo.class)); - get(uri, MediaType.APPLICATION_XML); - verify(restconfService, times(4)).readConfigurationData(eq(uriPath), any(UriInfo.class)); - get(uri, MediaType.TEXT_XML); - verify(restconfService, times(5)).readConfigurationData(eq(uriPath), any(UriInfo.class)); - - // negative tests - get(uri, MediaType.TEXT_PLAIN); - verify(restconfService, times(5)).readConfigurationData(eq(uriPath), any(UriInfo.class)); - } - - @Test - public void testGetOperationalMediaTypes() throws UnsupportedEncodingException { - final String uriPrefix = "/operational/"; - final String uriPath = "ietf-interfaces:interfaces"; - final String uri = uriPrefix + uriPath; - when(restconfService.readOperationalData(eq(uriPath), any(UriInfo.class))).thenReturn(null); - get(uri, Draft02.MediaTypes.DATA + JSON); - verify(restconfService, times(1)).readOperationalData(eq(uriPath), any(UriInfo.class)); - get(uri, Draft02.MediaTypes.DATA + XML); - verify(restconfService, times(2)).readOperationalData(eq(uriPath), any(UriInfo.class)); - get(uri, MediaType.APPLICATION_JSON); - verify(restconfService, times(3)).readOperationalData(eq(uriPath), any(UriInfo.class)); - get(uri, MediaType.APPLICATION_XML); - verify(restconfService, times(4)).readOperationalData(eq(uriPath), any(UriInfo.class)); - get(uri, MediaType.TEXT_XML); - verify(restconfService, times(5)).readOperationalData(eq(uriPath), any(UriInfo.class)); - - // negative tests - get(uri, MediaType.TEXT_PLAIN); - verify(restconfService, times(5)).readOperationalData(eq(uriPath), any(UriInfo.class)); - } - - @Test - @Ignore - public void testPutConfigMediaTypes() throws UnsupportedEncodingException { - final String uriPrefix = "/config/"; - final String uriPath = "ietf-interfaces:interfaces"; - final String uri = uriPrefix + uriPath; - when(restconfService.updateConfigurationData(eq(uriPath), any(NormalizedNodeContext.class))).thenReturn(null); - put(uri, null, Draft02.MediaTypes.DATA + JSON, jsonData); - verify(restconfService, times(1)).updateConfigurationData(eq(uriPath), any(NormalizedNodeContext.class)); - put(uri, null, Draft02.MediaTypes.DATA + XML, xmlData); - verify(restconfService, times(2)).updateConfigurationData(eq(uriPath), any(NormalizedNodeContext.class)); - put(uri, null, MediaType.APPLICATION_JSON, jsonData); - verify(restconfService, times(3)).updateConfigurationData(eq(uriPath), any(NormalizedNodeContext.class)); - put(uri, null, MediaType.APPLICATION_XML, xmlData); - verify(restconfService, times(4)).updateConfigurationData(eq(uriPath), any(NormalizedNodeContext.class)); - put(uri, null, MediaType.TEXT_XML, xmlData); - verify(restconfService, times(5)).updateConfigurationData(eq(uriPath), any(NormalizedNodeContext.class)); - put(uri, "fooMediaType", MediaType.TEXT_XML, xmlData); - verify(restconfService, times(6)).updateConfigurationData(eq(uriPath), any(NormalizedNodeContext.class)); - } - - @Test - @Ignore - public void testPostConfigWithPathMediaTypes() throws UnsupportedEncodingException { - final String uriPrefix = "/config/"; - final String uriPath = "ietf-interfaces:interfaces"; - final String uri = uriPrefix + uriPath; - when(restconfService.createConfigurationData(eq(uriPath), any(NormalizedNodeContext.class), - any(UriInfo.class))).thenReturn(null); - post(uri, null, Draft02.MediaTypes.DATA + JSON, jsonData); - verify(restconfService, times(1)).createConfigurationData(eq(uriPath), - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, Draft02.MediaTypes.DATA + XML, xmlData); - verify(restconfService, times(2)).createConfigurationData(eq(uriPath), - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, MediaType.APPLICATION_JSON, jsonData); - verify(restconfService, times(3)).createConfigurationData(eq(uriPath), - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, MediaType.APPLICATION_XML, xmlData); - verify(restconfService, times(4)).createConfigurationData(eq(uriPath), - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, MediaType.TEXT_XML, xmlData); - verify(restconfService, times(5)).createConfigurationData(eq(uriPath), - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, "fooMediaType", MediaType.TEXT_XML, xmlData); - verify(restconfService, times(6)).createConfigurationData(eq(uriPath), - any(NormalizedNodeContext.class), any(UriInfo.class)); - } - - @Test - @Ignore - public void testPostConfigMediaTypes() throws UnsupportedEncodingException { - final String uriPrefix = "/config/"; - final String uri = uriPrefix; - when(restconfService.createConfigurationData(any(NormalizedNodeContext.class), - any(UriInfo.class))).thenReturn(null); - post(uri, null, Draft02.MediaTypes.DATA + JSON, jsonData); - verify(restconfService, times(1)).createConfigurationData( - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, Draft02.MediaTypes.DATA + XML, xmlData); - verify(restconfService, times(2)).createConfigurationData( - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, MediaType.APPLICATION_JSON, jsonData); - verify(restconfService, times(3)).createConfigurationData( - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, MediaType.APPLICATION_XML, xmlData); - verify(restconfService, times(4)).createConfigurationData( - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, null, MediaType.TEXT_XML, xmlData); - verify(restconfService, times(5)).createConfigurationData( - any(NormalizedNodeContext.class), any(UriInfo.class)); - post(uri, "fooMediaType", MediaType.TEXT_XML, xmlData); - verify(restconfService, times(6)).createConfigurationData( - any(NormalizedNodeContext.class), any(UriInfo.class)); - } - - @Test - public void testDeleteConfigMediaTypes() throws UnsupportedEncodingException { - final String uriPrefix = "/config/"; - final String uriPath = "ietf-interfaces:interfaces"; - final String uri = uriPrefix + uriPath; - when(restconfService.deleteConfigurationData(eq(uriPath))).thenReturn(null); - target(uri).request("fooMediaType").delete(); - verify(restconfService, times(1)).deleteConfigurationData(uriPath); - } - - private int get(final String uri, final String acceptMediaType) { - return target(uri).request(acceptMediaType).get().getStatus(); - } - - private int put(final String uri, final String acceptMediaType, final String contentTypeMediaType, final String data) { - if (acceptMediaType == null) { - return target(uri).request().put(Entity.entity(data, contentTypeMediaType)).getStatus(); - } - return target(uri).request(acceptMediaType).put(Entity.entity(data, contentTypeMediaType)).getStatus(); - } - - private int post(final String uri, final String acceptMediaType, final String contentTypeMediaType, final String data) { - if (acceptMediaType == null) { - if (contentTypeMediaType == null || data == null) { - return target(uri).request().post(null).getStatus(); - } - return target(uri).request().post(Entity.entity(data, contentTypeMediaType)).getStatus(); - } - if (contentTypeMediaType == null || data == null) { - return target(uri).request(acceptMediaType).post(null).getStatus(); - } - return target(uri).request(acceptMediaType).post(Entity.entity(data, contentTypeMediaType)).getStatus(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MultipleEqualNamesForDataNodesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MultipleEqualNamesForDataNodesTest.java deleted file mode 100644 index 8c017341e9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MultipleEqualNamesForDataNodesTest.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - - -/** - * If more then one data element with equal name exists where container or leaf schema node should be present the - * RestconfDocumentedException has to be raised - * - * Tests for BUG 1204 - */ -public class MultipleEqualNamesForDataNodesTest { - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/NormalizeNodeTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/NormalizeNodeTest.java deleted file mode 100644 index a2aff72d1f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/NormalizeNodeTest.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import org.junit.BeforeClass; - -public class NormalizeNodeTest extends YangAndXmlAndDataSchemaLoader { - - @BeforeClass - public static void initialization() { - dataLoad("/normalize-node/yang/"); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestCodecExceptionsTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestCodecExceptionsTest.java deleted file mode 100644 index 4000c7cc80..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestCodecExceptionsTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.mock; - -import java.util.Collections; -import org.junit.Test; -import org.opendaylight.controller.sal.restconf.impl.RestCodec; -import org.opendaylight.yangtools.concepts.Codec; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit; -import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; -import org.opendaylight.yangtools.yang.model.util.BitsType; - -public class RestCodecExceptionsTest { - - private static final SchemaPath PATH = SchemaPath.create(true, QName.create("test", "2014-05-30", "test")); - - @Test - public void serializeExceptionTest() { - Codec codec = RestCodec.from(BitsType.create(PATH, Collections. emptyList()), null); - String serializedValue = (String) codec.serialize("incorrect value"); // set - // expected - assertEquals("incorrect value", serializedValue); - } - - @Test - public void deserializeExceptionTest() { - IdentityrefTypeDefinition mockedIidentityrefType = mock(IdentityrefTypeDefinition.class); - - Codec codec = RestCodec.from(mockedIidentityrefType, null); - assertNull(codec.deserialize("incorrect value")); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java deleted file mode 100644 index 519680ba3c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.common.util.concurrent.CheckedFuture; -import java.io.FileNotFoundException; -import java.io.UnsupportedEncodingException; -import java.util.Set; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class RestDeleteOperationTest extends JerseyTest { - - private static ControllerContext controllerContext; - private static BrokerFacade brokerFacade; - private static RestconfImpl restconfImpl; - - @BeforeClass - public static void init() throws FileNotFoundException { - final Set allModules = TestUtils.loadModulesFrom("/test-config-data/yang1"); - assertNotNull(allModules); - final SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules); - controllerContext = ControllerContext.getInstance(); - controllerContext.setSchemas(schemaContext); - brokerFacade = mock(BrokerFacade.class); - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setBroker(brokerFacade); - restconfImpl.setControllerContext(controllerContext); - } - - @Override - protected Application configure() { - /* enable/disable Jersey logs to console */ - // enable(TestProperties.LOG_TRAFFIC); - // enable(TestProperties.DUMP_ENTITY); - // enable(TestProperties.RECORD_LOG_LEVEL); - // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue()); - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(restconfImpl, new NormalizedNodeJsonBodyWriter(), - new NormalizedNodeXmlBodyWriter(), new XmlNormalizedNodeBodyReader(), new JsonNormalizedNodeBodyReader()); - resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); - return resourceConfig; - } - - @SuppressWarnings("unchecked") - @Test - public void deleteConfigStatusCodes() throws UnsupportedEncodingException { - final String uri = "/config/test-interface:interfaces"; - when(brokerFacade.commitConfigurationDataDelete(any(YangInstanceIdentifier.class))).thenReturn( - mock(CheckedFuture.class)); - Response response = target(uri).request(MediaType.APPLICATION_XML).delete(); - assertEquals(200, response.getStatus()); - - doThrow(RestconfDocumentedException.class).when(brokerFacade).commitConfigurationDataDelete( - any(YangInstanceIdentifier.class)); - response = target(uri).request(MediaType.APPLICATION_XML).delete(); - assertEquals(500, response.getStatus()); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetAugmentedElementWhenEqualNamesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetAugmentedElementWhenEqualNamesTest.java deleted file mode 100644 index 746ae50483..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetAugmentedElementWhenEqualNamesTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.FileNotFoundException; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class RestGetAugmentedElementWhenEqualNamesTest { - - private static ControllerContext controllerContext = ControllerContext.getInstance(); - - @Rule - public ExpectedException exception = ExpectedException.none(); - - @BeforeClass - public static void init() throws FileNotFoundException { - final SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/common/augment/yang"); - controllerContext.setSchemas(schemaContextTestModule); - } - - @Test - public void augmentedNodesInUri() { - InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-a:cont1"); - assertEquals("ns:augment:main:a", iiWithData.getSchemaNode().getQName().getNamespace().toString()); - iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-b:cont1"); - assertEquals("ns:augment:main:b", iiWithData.getSchemaNode().getQName().getNamespace().toString()); - } - - @Test - public void nodeWithoutNamespaceHasMoreAugments() { - try { - controllerContext.toInstanceIdentifier("main:cont/cont1"); - fail("Expected exception"); - } catch (final RestconfDocumentedException e) { - assertTrue(e.getErrors().get(0).getErrorMessage().contains("is added as augment from more than one module")); - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java deleted file mode 100644 index cbc8e27d15..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java +++ /dev/null @@ -1,813 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import java.io.FileNotFoundException; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfApplication; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class RestGetOperationTest extends JerseyTest { - - static class NodeData { - Object key; - Object data; // List for a CompositeNode, value Object for a SimpleNode - - NodeData(final Object key, final Object data) { - this.key = key; - this.data = data; - } - } - - private static BrokerFacade brokerFacade; - private static RestconfImpl restconfImpl; - private static SchemaContext schemaContextYangsIetf; - private static SchemaContext schemaContextTestModule; - @SuppressWarnings("rawtypes") - private static NormalizedNode answerFromGet; - - private static SchemaContext schemaContextModules; - private static SchemaContext schemaContextBehindMountPoint; - - private static final String RESTCONF_NS = "urn:ietf:params:xml:ns:yang:ietf-restconf"; - - @BeforeClass - public static void init() throws FileNotFoundException, ParseException { - schemaContextYangsIetf = TestUtils.loadSchemaContext("/full-versions/yangs"); - schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module"); - brokerFacade = mock(BrokerFacade.class); - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setBroker(brokerFacade); - answerFromGet = TestUtils.prepareNormalizedNodeWithIetfInterfacesInterfacesData(); - - schemaContextModules = TestUtils.loadSchemaContext("/modules"); - schemaContextBehindMountPoint = TestUtils.loadSchemaContext("/modules/modules-behind-mount-point"); - } - - @Override - protected Application configure() { - /* enable/disable Jersey logs to console */ - // enable(TestProperties.LOG_TRAFFIC); - // enable(TestProperties.DUMP_ENTITY); - // enable(TestProperties.RECORD_LOG_LEVEL); - // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue()); - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(restconfImpl, new NormalizedNodeJsonBodyWriter(), - new NormalizedNodeXmlBodyWriter(), new XmlNormalizedNodeBodyReader(), new JsonNormalizedNodeBodyReader()); - resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); - resourceConfig.registerClasses(new RestconfApplication().getClasses()); - return resourceConfig; - } - - private void setControllerContext(final SchemaContext schemaContext) { - final ControllerContext controllerContext = ControllerContext.getInstance(); - controllerContext.setSchemas(schemaContext); - restconfImpl.setControllerContext(controllerContext); - } - - /** - * Tests of status codes for "/operational/{identifier}". - */ - @Test - public void getOperationalStatusCodes() throws UnsupportedEncodingException { - setControllerContext(schemaContextYangsIetf); - mockReadOperationalDataMethod(); - String uri = "/operational/ietf-interfaces:interfaces/interface/eth0"; - assertEquals(200, get(uri, MediaType.APPLICATION_XML)); - - uri = "/operational/wrong-module:interfaces/interface/eth0"; - assertEquals(400, get(uri, MediaType.APPLICATION_XML)); - } - - /** - * Tests of status codes for "/config/{identifier}". - */ - @Test - public void getConfigStatusCodes() throws UnsupportedEncodingException { - setControllerContext(schemaContextYangsIetf); - mockReadConfigurationDataMethod(); - String uri = "/config/ietf-interfaces:interfaces/interface/eth0"; - assertEquals(200, get(uri, MediaType.APPLICATION_XML)); - - uri = "/config/wrong-module:interfaces/interface/eth0"; - assertEquals(400, get(uri, MediaType.APPLICATION_XML)); - } - - /** - * MountPoint test. URI represents mount point. - */ - @SuppressWarnings("unchecked") - @Test - public void getDataWithUrlMountPoint() throws UnsupportedEncodingException, URISyntaxException, ParseException { - when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), any(YangInstanceIdentifier.class))).thenReturn( - prepareCnDataForMountPointTest(false)); - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/cont1"; - assertEquals(200, get(uri, MediaType.APPLICATION_XML)); - - uri = "/config/ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1"; - assertEquals(200, get(uri, MediaType.APPLICATION_XML)); - } - - /** - * MountPoint test. URI represents mount point. - * - * Slashes in URI behind mount point. lst1 element with key GigabitEthernet0%2F0%2F0%2F0 (GigabitEthernet0/0/0/0) is - * requested via GET HTTP operation. It is tested whether %2F character is replaced with simple / in - * InstanceIdentifier parameter in method - * {@link BrokerFacade#readConfigurationData(DOMMountPoint, YangInstanceIdentifier)} which is called in - * method {@link RestconfImpl#readConfigurationData} - * - * @throws ParseException - */ - @Test - public void getDataWithSlashesBehindMountPoint() throws Exception { - final YangInstanceIdentifier awaitedInstanceIdentifier = prepareInstanceIdentifierForList(); - when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), eq(awaitedInstanceIdentifier))).thenReturn( - prepareCnDataForSlashesBehindMountPointTest()); - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - final String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/lst1/GigabitEthernet0%2F0%2F0%2F0"; - assertEquals(200, get(uri, MediaType.APPLICATION_XML)); - } - - private YangInstanceIdentifier prepareInstanceIdentifierForList() throws Exception { - final List parameters = new ArrayList<>(); - - final QName qNameCont = newTestModuleQName("cont"); - final QName qNameList = newTestModuleQName("lst1"); - final QName qNameKeyList = newTestModuleQName("lf11"); - - parameters.add(new YangInstanceIdentifier.NodeIdentifier(qNameCont)); - parameters.add(new YangInstanceIdentifier.NodeIdentifier(qNameList)); - parameters.add(new YangInstanceIdentifier.NodeIdentifierWithPredicates(qNameList, qNameKeyList, - "GigabitEthernet0/0/0/0")); - return YangInstanceIdentifier.create(parameters); - } - - private QName newTestModuleQName(String localPart) throws Exception { - final Date revision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-01-09"); - final URI uri = new URI("test:module"); - return QName.create(uri, revision, localPart); - } - - @Test - public void getDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException, - ParseException { - when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), any(YangInstanceIdentifier.class))).thenReturn( - prepareCnDataForMountPointTest(true)); - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - final String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont"; - assertEquals(200, get(uri, MediaType.APPLICATION_XML)); - } - - @SuppressWarnings("unchecked") - @Test - public void getDataWithIdentityrefInURL() throws Exception { - setControllerContext(schemaContextTestModule); - - QName moduleQN = newTestModuleQName("module"); - ImmutableMap keyMap = ImmutableMap.builder() - .put(newTestModuleQName("type"), newTestModuleQName("test-identity")) - .put(newTestModuleQName("name"), "foo").build(); - YangInstanceIdentifier iid = YangInstanceIdentifier.builder().node(newTestModuleQName("modules")) - .node(moduleQN).nodeWithKey(moduleQN, keyMap).build(); - @SuppressWarnings("rawtypes") - NormalizedNode data = ImmutableMapNodeBuilder.create().withNodeIdentifier( - new NodeIdentifier(moduleQN)).withChild(ImmutableNodes.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(moduleQN, keyMap)) - .withChild(ImmutableNodes.leafNode(newTestModuleQName("type"), newTestModuleQName("test-identity"))) - .withChild(ImmutableNodes.leafNode(newTestModuleQName("name"), "foo")) - .withChild(ImmutableNodes.leafNode(newTestModuleQName("data"), "bar")).build()).build(); - when(brokerFacade.readConfigurationData(iid)).thenReturn(data); - - String uri = "/config/test-module:modules/module/test-module:test-identity/foo"; - assertEquals(200, get(uri, MediaType.APPLICATION_XML)); - } - - // /modules - @Test - public void getModulesTest() throws UnsupportedEncodingException, FileNotFoundException { - final ControllerContext controllerContext = ControllerContext.getInstance(); - controllerContext.setGlobalSchema(schemaContextModules); - restconfImpl.setControllerContext(controllerContext); - - final String uri = "/modules"; - - Response response = target(uri).request("application/yang.api+json").get(); - validateModulesResponseJson(response); - - response = target(uri).request("application/yang.api+xml").get(); - validateModulesResponseXml(response,schemaContextModules); - } - - // /streams/ - @Test - @Ignore // FIXME : find why it is fail by in gerrit build - public void getStreamsTest() throws UnsupportedEncodingException, FileNotFoundException { - setControllerContext(schemaContextModules); - - final String uri = "/streams"; - - Response response = target(uri).request("application/yang.api+json").get(); - final String responseBody = response.readEntity(String.class); - assertEquals(200, response.getStatus()); - assertNotNull(responseBody); - assertTrue(responseBody.contains("streams")); - - response = target(uri).request("application/yang.api+xml").get(); - assertEquals(200, response.getStatus()); - final Document responseXmlBody = response.readEntity(Document.class); - assertNotNull(responseXmlBody); - final Element rootNode = responseXmlBody.getDocumentElement(); - - assertEquals("streams", rootNode.getLocalName()); - assertEquals(RESTCONF_NS, rootNode.getNamespaceURI()); - } - - // /modules/module - @Test - public void getModuleTest() throws FileNotFoundException, UnsupportedEncodingException { - setControllerContext(schemaContextModules); - - final String uri = "/modules/module/module2/2014-01-02"; - - Response response = target(uri).request("application/yang.api+xml").get(); - assertEquals(200, response.getStatus()); - final Document responseXml = response.readEntity(Document.class); - - final QName qname = assertedModuleXmlToModuleQName(responseXml.getDocumentElement()); - assertNotNull(qname); - - assertEquals("module2", qname.getLocalName()); - assertEquals("module:2", qname.getNamespace().toString()); - assertEquals("2014-01-02", qname.getFormattedRevision()); - - response = target(uri).request("application/yang.api+json").get(); - assertEquals(200, response.getStatus()); - final String responseBody = response.readEntity(String.class); - assertTrue("Module2 in json wasn't found", prepareJsonRegex("module2", "2014-01-02", "module:2", responseBody) - .find()); - final String[] split = responseBody.split("\"module\""); - assertEquals("\"module\" element is returned more then once", 2, split.length); - - } - - // /operations - @Test - public void getOperationsTest() throws FileNotFoundException, UnsupportedEncodingException { - setControllerContext(schemaContextModules); - - final String uri = "/operations"; - - Response response = target(uri).request("application/yang.api+xml").get(); - assertEquals(200, response.getStatus()); - final Document responseDoc = response.readEntity(Document.class); - validateOperationsResponseXml(responseDoc, schemaContextModules); - - response = target(uri).request("application/yang.api+json").get(); - assertEquals(200, response.getStatus()); - final String responseBody = response.readEntity(String.class); - assertTrue("Json response for /operations dummy-rpc1-module1 is incorrect", - validateOperationsResponseJson(responseBody, "dummy-rpc1-module1", "module1").find()); - assertTrue("Json response for /operations dummy-rpc2-module1 is incorrect", - validateOperationsResponseJson(responseBody, "dummy-rpc2-module1", "module1").find()); - assertTrue("Json response for /operations dummy-rpc1-module2 is incorrect", - validateOperationsResponseJson(responseBody, "dummy-rpc1-module2", "module2").find()); - assertTrue("Json response for /operations dummy-rpc2-module2 is incorrect", - validateOperationsResponseJson(responseBody, "dummy-rpc2-module2", "module2").find()); - - } - - private void validateOperationsResponseXml(final Document responseDoc, final SchemaContext schemaContext) { - - final Element operationsElem = responseDoc.getDocumentElement(); - assertEquals(RESTCONF_NS, operationsElem.getNamespaceURI()); - assertEquals("operations", operationsElem.getLocalName()); - - final NodeList operationsList = operationsElem.getChildNodes(); - final HashSet foundOperations = new HashSet<>(); - - for (int i = 0; i < operationsList.getLength(); i++) { - final org.w3c.dom.Node operation = operationsList.item(i); - foundOperations.add(operation.getLocalName()); - } - - for (final RpcDefinition schemaOp : schemaContext.getOperations()) { - assertTrue(foundOperations.contains(schemaOp.getQName().getLocalName())); - } - } - - // /operations/pathToMountPoint/yang-ext:mount - @Test - public void getOperationsBehindMountPointTest() throws FileNotFoundException, UnsupportedEncodingException { - setControllerContext(schemaContextModules); - - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - final String uri = "/operations/ietf-interfaces:interfaces/interface/0/yang-ext:mount/"; - - Response response = target(uri).request("application/yang.api+xml").get(); - assertEquals(200, response.getStatus()); - - final Document responseDoc = response.readEntity(Document.class); - validateOperationsResponseXml(responseDoc, schemaContextBehindMountPoint); - - response = target(uri).request("application/yang.api+json").get(); - assertEquals(200, response.getStatus()); - final String responseBody = response.readEntity(String.class); - assertTrue("Json response for /operations/mount_point rpc-behind-module1 is incorrect", - validateOperationsResponseJson(responseBody, "rpc-behind-module1", "module1-behind-mount-point").find()); - assertTrue("Json response for /operations/mount_point rpc-behind-module2 is incorrect", - validateOperationsResponseJson(responseBody, "rpc-behind-module2", "module2-behind-mount-point").find()); - - } - - private Matcher validateOperationsResponseJson(final String searchIn, final String rpcName, final String moduleName) { - final StringBuilder regex = new StringBuilder(); - regex.append(".*\"" + rpcName + "\""); - final Pattern ptrn = Pattern.compile(regex.toString(), Pattern.DOTALL); - return ptrn.matcher(searchIn); - - } - - private Matcher validateOperationsResponseXml(final String searchIn, final String rpcName, final String namespace) { - final StringBuilder regex = new StringBuilder(); - - regex.append("^"); - - regex.append(".*"); - - regex.append(".*<"); - regex.append(".*" + rpcName); - regex.append(".*" + namespace); - regex.append(".*/"); - regex.append(".*>"); - - regex.append(".*"); - - regex.append(".*"); - regex.append("$"); - final Pattern ptrn = Pattern.compile(regex.toString(), Pattern.DOTALL); - return ptrn.matcher(searchIn); - } - - // /restconf/modules/pathToMountPoint/yang-ext:mount - @Test - public void getModulesBehindMountPoint() throws FileNotFoundException, UnsupportedEncodingException { - setControllerContext(schemaContextModules); - - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - final String uri = "/modules/ietf-interfaces:interfaces/interface/0/yang-ext:mount/"; - - Response response = target(uri).request("application/yang.api+json").get(); - assertEquals(200, response.getStatus()); - final String responseBody = response.readEntity(String.class); - - assertTrue( - "module1-behind-mount-point in json wasn't found", - prepareJsonRegex("module1-behind-mount-point", "2014-02-03", "module:1:behind:mount:point", - responseBody).find()); - assertTrue( - "module2-behind-mount-point in json wasn't found", - prepareJsonRegex("module2-behind-mount-point", "2014-02-04", "module:2:behind:mount:point", - responseBody).find()); - - response = target(uri).request("application/yang.api+xml").get(); - assertEquals(200, response.getStatus()); - validateModulesResponseXml(response, schemaContextBehindMountPoint); - - } - - // /restconf/modules/module/pathToMountPoint/yang-ext:mount/moduleName/revision - @Test - public void getModuleBehindMountPoint() throws FileNotFoundException, UnsupportedEncodingException { - setControllerContext(schemaContextModules); - - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - final String uri = "/modules/module/ietf-interfaces:interfaces/interface/0/yang-ext:mount/module1-behind-mount-point/2014-02-03"; - - Response response = target(uri).request("application/yang.api+json").get(); - assertEquals(200, response.getStatus()); - final String responseBody = response.readEntity(String.class); - - assertTrue( - "module1-behind-mount-point in json wasn't found", - prepareJsonRegex("module1-behind-mount-point", "2014-02-03", "module:1:behind:mount:point", - responseBody).find()); - final String[] split = responseBody.split("\"module\""); - assertEquals("\"module\" element is returned more then once", 2, split.length); - - response = target(uri).request("application/yang.api+xml").get(); - assertEquals(200, response.getStatus()); - final Document responseXml = response.readEntity(Document.class); - - final QName module = assertedModuleXmlToModuleQName(responseXml.getDocumentElement()); - - assertEquals("module1-behind-mount-point", module.getLocalName()); - assertEquals("2014-02-03", module.getFormattedRevision()); - assertEquals("module:1:behind:mount:point", module.getNamespace().toString()); - - - } - - private void validateModulesResponseXml(final Response response, final SchemaContext schemaContext) { - assertEquals(200, response.getStatus()); - final Document responseBody = response.readEntity(Document.class); - final NodeList moduleNodes = responseBody.getDocumentElement().getElementsByTagNameNS(RESTCONF_NS, "module"); - - assertTrue(moduleNodes.getLength() > 0); - - final HashSet foundModules = new HashSet<>(); - - for(int i=0;i < moduleNodes.getLength();i++) { - final org.w3c.dom.Node module = moduleNodes.item(i); - - final QName name = assertedModuleXmlToModuleQName(module); - foundModules.add(name); - } - - assertAllModules(foundModules,schemaContext); - } - - private void assertAllModules(final Set foundModules, final SchemaContext schemaContext) { - for(final Module module : schemaContext.getModules()) { - final QName current = QName.create(module.getQNameModule(),module.getName()); - assertTrue("Module not found in response.",foundModules.contains(current)); - } - - } - - private QName assertedModuleXmlToModuleQName(final org.w3c.dom.Node module) { - assertEquals("module", module.getLocalName()); - assertEquals(RESTCONF_NS, module.getNamespaceURI()); - String revision = null; - String namespace = null; - String name = null; - - - final NodeList childNodes = module.getChildNodes(); - - for(int i =0;i < childNodes.getLength(); i++) { - final org.w3c.dom.Node child = childNodes.item(i); - assertEquals(RESTCONF_NS, child.getNamespaceURI()); - - switch(child.getLocalName()) { - case "name": - assertNull("Name element appeared multiple times",name); - name = child.getTextContent().trim(); - break; - case "revision": - assertNull("Revision element appeared multiple times",revision); - revision = child.getTextContent().trim(); - break; - - case "namespace": - assertNull("Namespace element appeared multiple times",namespace); - namespace = child.getTextContent().trim(); - break; - } - } - - assertNotNull("Revision was not part of xml",revision); - assertNotNull("Module namespace was not part of xml",namespace); - assertNotNull("Module identiffier was not part of xml",name); - - - // TODO Auto-generated method stub - - return QName.create(namespace,revision,name); - } - - private void validateModulesResponseJson(final Response response) { - assertEquals(200, response.getStatus()); - final String responseBody = response.readEntity(String.class); - - assertTrue("Module1 in json wasn't found", prepareJsonRegex("module1", "2014-01-01", "module:1", responseBody) - .find()); - assertTrue("Module2 in json wasn't found", prepareJsonRegex("module2", "2014-01-02", "module:2", responseBody) - .find()); - assertTrue("Module3 in json wasn't found", prepareJsonRegex("module3", "2014-01-03", "module:3", responseBody) - .find()); - } - - private Matcher prepareJsonRegex(final String module, final String revision, final String namespace, - final String searchIn) { - final StringBuilder regex = new StringBuilder(); - regex.append("^"); - - regex.append(".*\\{"); - regex.append(".*\"name\""); - regex.append(".*:"); - regex.append(".*\"" + module + "\","); - - regex.append(".*\"revision\""); - regex.append(".*:"); - regex.append(".*\"" + revision + "\","); - - regex.append(".*\"namespace\""); - regex.append(".*:"); - regex.append(".*\"" + namespace + "\""); - - regex.append(".*\\}"); - - regex.append(".*"); - regex.append("$"); - final Pattern ptrn = Pattern.compile(regex.toString(), Pattern.DOTALL); - return ptrn.matcher(searchIn); - - } - - - private int get(final String uri, final String mediaType) { - return target(uri).request(mediaType).get().getStatus(); - } - - /** - container cont { - container cont1 { - leaf lf11 { - type string; - } - */ - @SuppressWarnings("rawtypes") - private NormalizedNode prepareCnDataForMountPointTest(final boolean wrapToCont) throws URISyntaxException, ParseException { - final String testModuleDate = "2014-01-09"; - final ContainerNode contChild = Builders - .containerBuilder() - .withNodeIdentifier(TestUtils.getNodeIdentifier("cont1", "test:module", testModuleDate)) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(TestUtils.getNodeIdentifier("lf11", "test:module", testModuleDate)) - .withValue("lf11 value").build()).build(); - - if (wrapToCont) { - return Builders.containerBuilder() - .withNodeIdentifier(TestUtils.getNodeIdentifier("cont", "test:module", testModuleDate)) - .withChild(contChild).build(); - } - return contChild; - - } - - @SuppressWarnings("unchecked") - private void mockReadOperationalDataMethod() { - when(brokerFacade.readOperationalData(any(YangInstanceIdentifier.class))).thenReturn(answerFromGet); - } - - @SuppressWarnings("unchecked") - private void mockReadConfigurationDataMethod() { - when(brokerFacade.readConfigurationData(any(YangInstanceIdentifier.class))).thenReturn(answerFromGet); - } - - @SuppressWarnings("rawtypes") - private NormalizedNode prepareCnDataForSlashesBehindMountPointTest() throws ParseException { - return ImmutableMapEntryNodeBuilder - .create() - .withNodeIdentifier( - TestUtils.getNodeIdentifierPredicate("lst1", "test:module", "2014-01-09", "lf11", - "GigabitEthernet0/0/0/0")) - .withChild( - ImmutableLeafNodeBuilder.create() - .withNodeIdentifier(TestUtils.getNodeIdentifier("lf11", "test:module", "2014-01-09")) - .withValue("GigabitEthernet0/0/0/0").build()).build(); - - } - - /** - * If includeWhiteChars URI parameter is set to false then no white characters can be included in returned output - * - * @throws UnsupportedEncodingException - */ - @Test - public void getDataWithUriIncludeWhiteCharsParameterTest() throws UnsupportedEncodingException { - getDataWithUriIncludeWhiteCharsParameter("config"); - getDataWithUriIncludeWhiteCharsParameter("operational"); - } - - private void getDataWithUriIncludeWhiteCharsParameter(final String target) throws UnsupportedEncodingException { - mockReadConfigurationDataMethod(); - mockReadOperationalDataMethod(); - final String uri = "/" + target + "/ietf-interfaces:interfaces/interface/eth0"; - Response response = target(uri).queryParam("prettyPrint", "false").request("application/xml").get(); - final String xmlData = response.readEntity(String.class); - - Pattern pattern = Pattern.compile(".*(>\\s+|\\s+<).*", Pattern.DOTALL); - Matcher matcher = pattern.matcher(xmlData); - // XML element can't surrounded with white character (e.g "> " or - // " <") - assertFalse(matcher.matches()); - - response = target(uri).queryParam("prettyPrint", "false").request("application/json").get(); - final String jsonData = response.readEntity(String.class); - pattern = Pattern.compile(".*(\\}\\s+|\\s+\\{|\\]\\s+|\\s+\\[|\\s+:|:\\s+).*", Pattern.DOTALL); - matcher = pattern.matcher(jsonData); - // JSON element can't surrounded with white character (e.g "} ", " {", - // "] ", " [", " :" or ": ") - assertFalse(matcher.matches()); - } - - /** - * Tests behavior when invalid value of depth URI parameter - */ - @Test - @Ignore - public void getDataWithInvalidDepthParameterTest() { - setControllerContext(schemaContextModules); - - final MultivaluedMap paramMap = new MultivaluedHashMap<>(); - paramMap.putSingle("depth", "1o"); - final UriInfo mockInfo = mock(UriInfo.class); - when(mockInfo.getQueryParameters(false)).thenAnswer(new Answer>() { - @Override - public MultivaluedMap answer(final InvocationOnMock invocation) { - return paramMap; - } - }); - - getDataWithInvalidDepthParameterTest(mockInfo); - - paramMap.putSingle("depth", "0"); - getDataWithInvalidDepthParameterTest(mockInfo); - - paramMap.putSingle("depth", "-1"); - getDataWithInvalidDepthParameterTest(mockInfo); - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - private void getDataWithInvalidDepthParameterTest(final UriInfo uriInfo) { - try { - final QName qNameDepth1Cont = QName.create("urn:nested:module", "2014-06-3", "depth1-cont"); - final YangInstanceIdentifier ii = YangInstanceIdentifier.builder().node(qNameDepth1Cont).build(); - final NormalizedNode value = (Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(qNameDepth1Cont)).build()); - when(brokerFacade.readConfigurationData(eq(ii))).thenReturn(value); - restconfImpl.readConfigurationData("nested-module:depth1-cont", uriInfo); - fail("Expected RestconfDocumentedException"); - } catch (final RestconfDocumentedException e) { - assertTrue("Unexpected error message: " + e.getErrors().get(0).getErrorMessage(), e.getErrors().get(0) - .getErrorMessage().contains("depth")); - } - } - - @SuppressWarnings("unused") - private void verifyXMLResponse(final Response response, final NodeData nodeData) { - final Document doc = response.readEntity(Document.class); -// Document doc = TestUtils.loadDocumentFrom((InputStream) response.getEntity()); -// System.out.println(); - assertNotNull("Could not parse XML document", doc); - - // System.out.println(TestUtils.getDocumentInPrintableForm( doc )); - - verifyContainerElement(doc.getDocumentElement(), nodeData); - } - - @SuppressWarnings("unchecked") - private void verifyContainerElement(final Element element, final NodeData nodeData) { - - assertEquals("Element local name", nodeData.key, element.getLocalName()); - - final NodeList childNodes = element.getChildNodes(); - if (nodeData.data == null) { // empty container - assertTrue("Expected no child elements for \"" + element.getLocalName() + "\"", childNodes.getLength() == 0); - return; - } - - final Map expChildMap = Maps.newHashMap(); - for (final NodeData expChild : (List) nodeData.data) { - expChildMap.put(expChild.key.toString(), expChild); - } - - for (int i = 0; i < childNodes.getLength(); i++) { - final org.w3c.dom.Node actualChild = childNodes.item(i); - if (!(actualChild instanceof Element)) { - continue; - } - - final Element actualElement = (Element) actualChild; - final NodeData expChild = expChildMap.remove(actualElement.getLocalName()); - assertNotNull( - "Unexpected child element for parent \"" + element.getLocalName() + "\": " - + actualElement.getLocalName(), expChild); - - if (expChild.data == null || expChild.data instanceof List) { - verifyContainerElement(actualElement, expChild); - } else { - assertEquals("Text content for element: " + actualElement.getLocalName(), expChild.data, - actualElement.getTextContent()); - } - } - - if (!expChildMap.isEmpty()) { - fail("Missing elements for parent \"" + element.getLocalName() + "\": " + expChildMap.keySet()); - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestOperationUtils.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestOperationUtils.java deleted file mode 100644 index 7bf4782790..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestOperationUtils.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -public class RestOperationUtils { - - public static final String JSON = "+json"; - public static final String XML = "+xml"; - - private RestOperationUtils() { - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java deleted file mode 100644 index bb731a32d0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.XML; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.util.Set; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class RestPostOperationTest extends JerseyTest { - - private static String xmlDataAbsolutePath; - private static String xmlDataInterfaceAbsolutePath; - private static String xmlDataRpcInput; - private static String xmlBlockData; - private static String xmlTestInterface; - private static String xmlData3; - private static String xmlData4; - - private static BrokerFacade brokerFacade; - private static RestconfImpl restconfImpl; - private static SchemaContext schemaContextYangsIetf; - private static SchemaContext schemaContextTestModule; - private static SchemaContext schemaContext; - - private static DOMMountPointService mountService; - - @BeforeClass - public static void init() throws URISyntaxException, IOException { - schemaContextYangsIetf = TestUtils.loadSchemaContext("/full-versions/yangs"); - schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module"); - brokerFacade = mock(BrokerFacade.class); - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setBroker(brokerFacade); - - final Set modules = TestUtils.loadModulesFrom("/test-config-data/yang1"); - schemaContext = TestUtils.loadSchemaContext(modules); - - loadData(); - } - - @Override - protected Application configure() { - /* enable/disable Jersey logs to console */ - // enable(TestProperties.LOG_TRAFFIC); - // enable(TestProperties.DUMP_ENTITY); - // enable(TestProperties.RECORD_LOG_LEVEL); - // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue()); - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(restconfImpl, new XmlNormalizedNodeBodyReader(), - new NormalizedNodeXmlBodyWriter(), new JsonNormalizedNodeBodyReader(), new NormalizedNodeJsonBodyWriter()); - resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); - return resourceConfig; - } - - private void setSchemaControllerContext(final SchemaContext schema) { - final ControllerContext context = ControllerContext.getInstance(); - context.setSchemas(schema); - restconfImpl.setControllerContext(context); - } - - @SuppressWarnings("unchecked") - @Test - @Ignore /// xmlData* need netconf-yang - public void postDataViaUrlMountPoint() throws UnsupportedEncodingException { - setSchemaControllerContext(schemaContextYangsIetf); - when( - brokerFacade.commitConfigurationDataPost(any(DOMMountPoint.class), any(YangInstanceIdentifier.class), - any(NormalizedNode.class))).thenReturn(mock(CheckedFuture.class)); - - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - String uri = "/config/ietf-interfaces:interfaces/interface/0/"; - assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData4)); - uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont"; - assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData3)); - - assertEquals(400, post(uri, MediaType.APPLICATION_JSON, "")); - } - - @SuppressWarnings("unchecked") - @Test - @Ignore //jenkins has problem with JerseyTest - we expecting problems with singletons ControllerContext as schemaContext holder - public void createConfigurationDataTest() throws UnsupportedEncodingException, ParseException { - initMocking(); - final RpcResult rpcResult = new DummyRpcResult.Builder().result( - TransactionStatus.COMMITED).build(); - - when(brokerFacade.commitConfigurationDataPost((SchemaContext)null, any(YangInstanceIdentifier.class), any(NormalizedNode.class))) - .thenReturn(mock(CheckedFuture.class)); - - final ArgumentCaptor instanceIdCaptor = ArgumentCaptor.forClass(YangInstanceIdentifier.class); - @SuppressWarnings("rawtypes") - final ArgumentCaptor compNodeCaptor = ArgumentCaptor.forClass(NormalizedNode.class); - - - // FIXME : identify who is set the schemaContext -// final String URI_1 = "/config"; -// assertEquals(204, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface)); -// verify(brokerFacade).commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture()); - final String identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces]"; -// assertEquals(identifier, ImmutableList.copyOf(instanceIdCaptor.getValue().getPathArguments()).toString()); - - final String URI_2 = "/config/test-interface:interfaces"; - assertEquals(204, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData)); - // FIXME : NEVER test a nr. of call some service in complex test suite -// verify(brokerFacade, times(2)) - verify(brokerFacade, times(1)) - .commitConfigurationDataPost((SchemaContext)null, instanceIdCaptor.capture(), compNodeCaptor.capture()); -// identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces, (urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)block]"; - assertEquals(identifier, ImmutableList.copyOf(instanceIdCaptor.getValue().getPathArguments()).toString()); - } - - @Test - public void createConfigurationDataNullTest() throws UnsupportedEncodingException { - initMocking(); - - when(brokerFacade.commitConfigurationDataPost(any(SchemaContext.class), any(YangInstanceIdentifier.class),any(NormalizedNode.class))) - .thenReturn(Futures.immediateCheckedFuture(null)); - - //FIXME : find who is set schemaContext -// final String URI_1 = "/config"; -// assertEquals(204, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface)); - - final String URI_2 = "/config/test-interface:interfaces"; - assertEquals(204, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData)); - } - - private static void initMocking() { - final ControllerContext controllerContext = ControllerContext.getInstance(); - controllerContext.setSchemas(schemaContext); - mountService = mock(DOMMountPointService.class); - controllerContext.setMountService(mountService); - brokerFacade = mock(BrokerFacade.class); - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setBroker(brokerFacade); - restconfImpl.setControllerContext(controllerContext); - } - - private int post(final String uri, final String mediaType, final String data) { - return target(uri).request(mediaType).post(Entity.entity(data, mediaType)).getStatus(); - } - - private static void loadData() throws IOException, URISyntaxException { - InputStream xmlStream = RestconfImplTest.class - .getResourceAsStream("/parts/ietf-interfaces_interfaces_absolute_path.xml"); - xmlDataAbsolutePath = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream)); - xmlStream = RestconfImplTest.class - .getResourceAsStream("/parts/ietf-interfaces_interfaces_interface_absolute_path.xml"); - xmlDataInterfaceAbsolutePath = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream)); - final String xmlPathRpcInput = RestconfImplTest.class.getResource("/full-versions/test-data2/data-rpc-input.xml") - .getPath(); - xmlDataRpcInput = TestUtils.loadTextFile(xmlPathRpcInput); - final String xmlPathBlockData = RestconfImplTest.class.getResource("/test-config-data/xml/block-data.xml").getPath(); - xmlBlockData = TestUtils.loadTextFile(xmlPathBlockData); - final String xmlPathTestInterface = RestconfImplTest.class.getResource("/test-config-data/xml/test-interface.xml") - .getPath(); - xmlTestInterface = TestUtils.loadTextFile(xmlPathTestInterface); -// cnSnDataOutput = prepareCnSnRpcOutput(); - final String data3Input = RestconfImplTest.class.getResource("/full-versions/test-data2/data3.xml").getPath(); - xmlData3 = TestUtils.loadTextFile(data3Input); - final String data4Input = RestconfImplTest.class.getResource("/full-versions/test-data2/data7.xml").getPath(); - xmlData4 = TestUtils.loadTextFile(data4Input); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutConfigTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutConfigTest.java deleted file mode 100644 index 634b63c8fe..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutConfigTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl.test; - -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * sal-rest-connector - * org.opendaylight.controller.sal.restconf.impl.test - * - * - * - * @author Vaclav Demcak - * - * Created: May 14, 2015 - */ -@RunWith(MockitoJUnitRunner.class) -public class RestPutConfigTest { - - private RestconfImpl restconfService; - private ControllerContext controllerCx; - private SchemaContext schemaCx; - - @Mock - private BrokerFacade brokerFacade; - - @Before - public void init() { - restconfService = RestconfImpl.getInstance(); - controllerCx = ControllerContext.getInstance(); - schemaCx = TestRestconfUtils.loadSchemaContext("/test-config-data/yang1/", null); - controllerCx.setSchemas(schemaCx); - restconfService.setControllerContext(controllerCx); - } - - @Test - public void testPutConfigData() { - final String identifier = "test-interface:interfaces/interface/key"; - final InstanceIdentifierContext iiCx = controllerCx.toInstanceIdentifier(identifier); - final MapEntryNode data = Mockito.mock(MapEntryNode.class); - final QName qName = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "interface"); - final QName qNameKey = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "name"); - final NodeIdentifierWithPredicates identWithPredicates = new NodeIdentifierWithPredicates(qName, qNameKey, "key"); - Mockito.when(data.getNodeType()).thenReturn(qName); - Mockito.when(data.getIdentifier()).thenReturn(identWithPredicates); - final NormalizedNodeContext payload = new NormalizedNodeContext(iiCx, data); - - mockingBrokerPut(iiCx.getInstanceIdentifier(), data); - - restconfService.updateConfigurationData(identifier, payload); - } - - @Test - public void testPutConfigDataCheckOnlyLastElement() { - final String identifier = "test-interface:interfaces/interface/key/sub-interface/subkey"; - final InstanceIdentifierContext iiCx = controllerCx.toInstanceIdentifier(identifier); - final MapEntryNode data = Mockito.mock(MapEntryNode.class); - final QName qName = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "sub-interface"); - final QName qNameSubKey = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "sub-name"); - final NodeIdentifierWithPredicates identWithPredicates = new NodeIdentifierWithPredicates(qName, qNameSubKey, "subkey"); - Mockito.when(data.getNodeType()).thenReturn(qName); - Mockito.when(data.getIdentifier()).thenReturn(identWithPredicates); - final NormalizedNodeContext payload = new NormalizedNodeContext(iiCx, data); - - mockingBrokerPut(iiCx.getInstanceIdentifier(), data); - - restconfService.updateConfigurationData(identifier, payload); - } - - @Test(expected=RestconfDocumentedException.class) - public void testPutConfigDataMissingUriKey() { - final String identifier = "test-interface:interfaces/interface"; - controllerCx.toInstanceIdentifier(identifier); - } - - @Test(expected=RestconfDocumentedException.class) - public void testPutConfigDataDiferentKey() { - final String identifier = "test-interface:interfaces/interface/key"; - final InstanceIdentifierContext iiCx = controllerCx.toInstanceIdentifier(identifier); - final MapEntryNode data = Mockito.mock(MapEntryNode.class); - final QName qName = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "interface"); - final QName qNameKey = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "name"); - final NodeIdentifierWithPredicates identWithPredicates = new NodeIdentifierWithPredicates(qName, qNameKey, "notSameKey"); - Mockito.when(data.getNodeType()).thenReturn(qName); - Mockito.when(data.getIdentifier()).thenReturn(identWithPredicates); - final NormalizedNodeContext payload = new NormalizedNodeContext(iiCx, data); - - mockingBrokerPut(iiCx.getInstanceIdentifier(), data); - - restconfService.updateConfigurationData(identifier, payload); - } - - private void mockingBrokerPut(final YangInstanceIdentifier yii, final NormalizedNode data) { - final CheckedFuture checkedFuture = Futures.immediateCheckedFuture(null); - Mockito.when(brokerFacade.commitConfigurationDataPut(schemaCx, yii, data)).thenReturn(checkedFuture); - restconfService.setBroker(brokerFacade); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java deleted file mode 100644 index f70af4e4f6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Ignore -public class RestPutOperationTest extends JerseyTest { - - private static String xmlData; - private static String xmlData2; - private static String xmlData3; - - private static BrokerFacade brokerFacade; - private static RestconfImpl restconfImpl; - private static SchemaContext schemaContextYangsIetf; - private static SchemaContext schemaContextTestModule; - - @BeforeClass - public static void init() throws IOException { - schemaContextYangsIetf = TestUtils.loadSchemaContext("/full-versions/yangs"); - schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module"); - final ControllerContext controllerContext = ControllerContext.getInstance(); - controllerContext.setSchemas(schemaContextYangsIetf); - brokerFacade = mock(BrokerFacade.class); - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setBroker(brokerFacade); - restconfImpl.setControllerContext(controllerContext); - loadData(); - } - - private static void loadData() throws IOException { - final InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml"); - xmlData = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream)); - final InputStream xmlStream2 = RestconfImplTest.class.getResourceAsStream("/full-versions/test-data2/data2.xml"); - xmlData2 = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream2)); - final InputStream xmlStream3 = RestconfImplTest.class.getResourceAsStream("/full-versions/test-data2/data7.xml"); - xmlData3 = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream3)); - } - - @Override - protected Application configure() { - /* enable/disable Jersey logs to console */ - // enable(TestProperties.LOG_TRAFFIC); - // enable(TestProperties.DUMP_ENTITY); - // enable(TestProperties.RECORD_LOG_LEVEL); - // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue()); - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(restconfImpl,new XmlNormalizedNodeBodyReader(), - new NormalizedNodeXmlBodyWriter(), new JsonNormalizedNodeBodyReader(), new NormalizedNodeJsonBodyWriter()); - resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); - return resourceConfig; - } - - /** - * Tests of status codes for "/config/{identifier}". - */ - @Test - public void putConfigStatusCodes() throws UnsupportedEncodingException { - final String uri = "/config/ietf-interfaces:interfaces/interface/eth0"; - mockCommitConfigurationDataPutMethod(true); - assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData)); - - mockCommitConfigurationDataPutMethod(false); - assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); - - assertEquals(400, put(uri, MediaType.APPLICATION_JSON, "")); - } - - @Test - public void putConfigStatusCodesEmptyBody() throws UnsupportedEncodingException { - final String uri = "/config/ietf-interfaces:interfaces/interface/eth0"; - @SuppressWarnings("unused") - final Response resp = target(uri).request(MediaType.APPLICATION_JSON).put( - Entity.entity("", MediaType.APPLICATION_JSON)); - assertEquals(400, put(uri, MediaType.APPLICATION_JSON, "")); - } - - @Test - @Ignore // jenkins has problem with JerseyTest - we expecting problems with singletons ControllerContext as schemaContext holder - public void testRpcResultCommitedToStatusCodesWithMountPoint() throws UnsupportedEncodingException, - FileNotFoundException, URISyntaxException { - - @SuppressWarnings("unchecked") - final CheckedFuture dummyFuture = mock(CheckedFuture.class); - - when( - brokerFacade.commitConfigurationDataPut(any(DOMMountPoint.class), any(YangInstanceIdentifier.class), - any(NormalizedNode.class))).thenReturn(dummyFuture); - - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont"; - assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2)); - - uri = "/config/ietf-interfaces:interfaces/yang-ext:mount/test-module:cont"; - assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2)); - } - - @Test - public void putDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException { - @SuppressWarnings("unchecked") - final CheckedFuture dummyFuture = mock(CheckedFuture.class); - when( - brokerFacade.commitConfigurationDataPut(any(DOMMountPoint.class), any(YangInstanceIdentifier.class), - any(NormalizedNode.class))).thenReturn(dummyFuture); - - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); - final DOMMountPointService mockMountService = mock(DOMMountPointService.class); - when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - - ControllerContext.getInstance().setMountService(mockMountService); - - final String uri = "/config/ietf-interfaces:interfaces/yang-ext:mount"; - assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData3)); - } - - @Test - public void putWithOptimisticLockFailedException() throws UnsupportedEncodingException { - - final String uri = "/config/ietf-interfaces:interfaces/interface/eth0"; - - doThrow(OptimisticLockFailedException.class). - when(brokerFacade).commitConfigurationDataPut( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class)); - - assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); - - doThrow(OptimisticLockFailedException.class).doReturn(mock(CheckedFuture.class)). - when(brokerFacade).commitConfigurationDataPut( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class)); - - assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData)); - } - - @Test - @Ignore // jenkins has problem with JerseyTest - we expecting problems with singletons ControllerContext as schemaContext holder - public void putWithTransactionCommitFailedException() throws UnsupportedEncodingException { - - final String uri = "/config/ietf-interfaces:interfaces/interface/eth0"; - - doThrow(TransactionCommitFailedException.class). - when(brokerFacade).commitConfigurationDataPut( - (SchemaContext)null, any(YangInstanceIdentifier.class), any(NormalizedNode.class)); - - assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); - } - - private int put(final String uri, final String mediaType, final String data) throws UnsupportedEncodingException { - return target(uri).request(mediaType).put(Entity.entity(data, mediaType)).getStatus(); - } - - private void mockCommitConfigurationDataPutMethod(final boolean noErrors) { - if (noErrors) { - doReturn(mock(CheckedFuture.class)).when(brokerFacade).commitConfigurationDataPut( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class)); - } else { - doThrow(RestconfDocumentedException.class).when(brokerFacade).commitConfigurationDataPut( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class)); - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java deleted file mode 100644 index 9edd9525a3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java +++ /dev/null @@ -1,830 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.when; -import com.google.common.collect.Maps; -import com.google.common.io.ByteStreams; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriInfo; -import javax.xml.namespace.NamespaceContext; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathFactory; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.api.Draft02; -import org.opendaylight.controller.sal.rest.api.RestconfService; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfError; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * Unit tests for RestconfDocumentedExceptionMapper. - * - * @author Thomas Pantelis - */ -public class RestconfDocumentedExceptionMapperTest extends JerseyTest { - - interface ErrorInfoVerifier { - void verifyXML(Node errorInfoNode); - - void verifyJson(JsonElement errorInfoElement); - } - - static class SimpleErrorInfoVerifier implements ErrorInfoVerifier { - - String expTextContent; - - public SimpleErrorInfoVerifier(final String expErrorInfo) { - expTextContent = expErrorInfo; - } - - void verifyContent(final String actualContent) { - assertNotNull("Actual \"error-info\" text content is null", actualContent); - assertTrue("", actualContent.contains(expTextContent)); - } - - @Override - public void verifyXML(final Node errorInfoNode) { - verifyContent(errorInfoNode.getTextContent()); - } - - @Override - public void verifyJson(final JsonElement errorInfoElement) { - verifyContent(errorInfoElement.getAsString()); - } - } - - static RestconfService mockRestConf = mock(RestconfService.class); - - static XPath XPATH = XPathFactory.newInstance().newXPath(); - static XPathExpression ERROR_LIST; - static XPathExpression ERROR_TYPE; - static XPathExpression ERROR_TAG; - static XPathExpression ERROR_MESSAGE; - static XPathExpression ERROR_APP_TAG; - static XPathExpression ERROR_INFO; - - @BeforeClass - public static void init() throws Exception { - ControllerContext.getInstance().setGlobalSchema(TestUtils.loadSchemaContext("/modules")); - - final NamespaceContext nsContext = new NamespaceContext() { - @Override - public Iterator getPrefixes(final String namespaceURI) { - return null; - } - - @Override - public String getPrefix(final String namespaceURI) { - return null; - } - - @Override - public String getNamespaceURI(final String prefix) { - return "ietf-restconf".equals(prefix) ? Draft02.RestConfModule.NAMESPACE : null; - } - }; - - XPATH.setNamespaceContext(nsContext); - ERROR_LIST = XPATH.compile("ietf-restconf:errors/ietf-restconf:error"); - ERROR_TYPE = XPATH.compile("ietf-restconf:error-type"); - ERROR_TAG = XPATH.compile("ietf-restconf:error-tag"); - ERROR_MESSAGE = XPATH.compile("ietf-restconf:error-message"); - ERROR_APP_TAG = XPATH.compile("ietf-restconf:error-app-tag"); - ERROR_INFO = XPATH.compile("ietf-restconf:error-info"); - } - - @Override - @Before - public void setUp() throws Exception { - reset(mockRestConf); - super.setUp(); - } - - @Override - protected Application configure() { - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(mockRestConf, new XmlNormalizedNodeBodyReader(), - new JsonNormalizedNodeBodyReader(), new NormalizedNodeJsonBodyWriter(), new NormalizedNodeXmlBodyWriter()); - resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); - return resourceConfig; - } - - void stageMockEx(final RestconfDocumentedException ex) { - reset(mockRestConf); - when(mockRestConf.readOperationalData(any(String.class), any(UriInfo.class))).thenThrow(ex); - } - - void testJsonResponse(final RestconfDocumentedException ex, final Status expStatus, final ErrorType expErrorType, - final ErrorTag expErrorTag, final String expErrorMessage, final String expErrorAppTag, - final ErrorInfoVerifier errorInfoVerifier) throws Exception { - - stageMockEx(ex); - - final Response resp = target("/operational/foo").request(MediaType.APPLICATION_JSON).get(); - - final InputStream stream = verifyResponse(resp, MediaType.APPLICATION_JSON, expStatus); - - verifyJsonResponseBody(stream, expErrorType, expErrorTag, expErrorMessage, expErrorAppTag, errorInfoVerifier); - } - - @Test - public void testToJsonResponseWithMessageOnly() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error"), Status.INTERNAL_SERVER_ERROR, - ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, "mock error", null, null); - - - // To test verification code - // String json = - // "{ errors: {" + - // " error: [{" + - // " error-tag : \"operation-failed\"" + - // " ,error-type : \"application\"" + - // " ,error-message : \"An error occurred\"" + - // " ,error-info : {" + - // " session-id: \"123\"" + - // " ,address: \"1.2.3.4\"" + - // " }" + - // " }]" + - // " }" + - // "}"; - // - // verifyJsonResponseBody( new java.io.StringBufferInputStream(json ), - // ErrorType.APPLICATION, - // ErrorTag.OPERATION_FAILED, "An error occurred", null, - // com.google.common.collect.ImmutableMap.of( "session-id", "123", - // "address", "1.2.3.4" ) ); - } - - @Test - public void testToJsonResponseWithInUseErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.IN_USE), - Status.CONFLICT, ErrorType.PROTOCOL, ErrorTag.IN_USE, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithInvalidValueErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.RPC, ErrorTag.INVALID_VALUE), - Status.BAD_REQUEST, ErrorType.RPC, ErrorTag.INVALID_VALUE, "mock error", null, null); - - } - - @Test - public void testToJsonResponseWithTooBigErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.TRANSPORT, ErrorTag.TOO_BIG), - Status.REQUEST_ENTITY_TOO_LARGE, ErrorType.TRANSPORT, ErrorTag.TOO_BIG, "mock error", null, null); - - } - - @Test - public void testToJsonResponseWithMissingAttributeErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithBadAttributeErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithUnknownAttributeErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ATTRIBUTE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ATTRIBUTE, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithBadElementErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithUnknownElementErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithUnknownNamespaceErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_NAMESPACE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_NAMESPACE, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithMalformedMessageErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithAccessDeniedErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.ACCESS_DENIED), - Status.FORBIDDEN, ErrorType.PROTOCOL, ErrorTag.ACCESS_DENIED, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithLockDeniedErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.LOCK_DENIED), - Status.CONFLICT, ErrorType.PROTOCOL, ErrorTag.LOCK_DENIED, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithResourceDeniedErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.RESOURCE_DENIED), - Status.CONFLICT, ErrorType.PROTOCOL, ErrorTag.RESOURCE_DENIED, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithRollbackFailedErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.ROLLBACK_FAILED), - Status.INTERNAL_SERVER_ERROR, ErrorType.PROTOCOL, ErrorTag.ROLLBACK_FAILED, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithDataExistsErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS), - Status.CONFLICT, ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithDataMissingErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING), - Status.NOT_FOUND, ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithOperationNotSupportedErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, - ErrorTag.OPERATION_NOT_SUPPORTED), Status.NOT_IMPLEMENTED, ErrorType.PROTOCOL, - ErrorTag.OPERATION_NOT_SUPPORTED, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithOperationFailedErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.OPERATION_FAILED), - Status.INTERNAL_SERVER_ERROR, ErrorType.PROTOCOL, ErrorTag.OPERATION_FAILED, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithPartialOperationErrorTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.PARTIAL_OPERATION), - Status.INTERNAL_SERVER_ERROR, ErrorType.PROTOCOL, ErrorTag.PARTIAL_OPERATION, "mock error", null, null); - } - - @Test - public void testToJsonResponseWithErrorAppTag() throws Exception { - - testJsonResponse(new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, - ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag")), Status.BAD_REQUEST, ErrorType.APPLICATION, - ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", null); - } - - @Test - @Ignore // FIXME : find why it return "error-type" RPC no expected APPLICATION - public void testToJsonResponseWithMultipleErrors() throws Exception { - - final List errorList = Arrays.asList(new RestconfError(ErrorType.APPLICATION, ErrorTag.LOCK_DENIED, - "mock error1"), new RestconfError(ErrorType.RPC, ErrorTag.ROLLBACK_FAILED, "mock error2")); - stageMockEx(new RestconfDocumentedException("mock", null, errorList)); - - final Response resp = target("/operational/foo").request(MediaType.APPLICATION_JSON).get(); - - final InputStream stream = verifyResponse(resp, MediaType.APPLICATION_JSON, Status.CONFLICT); - - final JsonArray arrayElement = parseJsonErrorArrayElement(stream); - - assertEquals("\"error\" Json array element length", 2, arrayElement.size()); - - verifyJsonErrorNode(arrayElement.get(0), ErrorType.APPLICATION, ErrorTag.LOCK_DENIED, "mock error1", null, null); - - verifyJsonErrorNode(arrayElement.get(1), ErrorType.RPC, ErrorTag.ROLLBACK_FAILED, "mock error2", null, null); - } - - @Test - public void testToJsonResponseWithErrorInfo() throws Exception { - - final String errorInfo = "
1.2.3.4
123"; - testJsonResponse(new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, - ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", errorInfo)), Status.BAD_REQUEST, - ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", - new SimpleErrorInfoVerifier(errorInfo)); - } - - @Test - public void testToJsonResponseWithExceptionCause() throws Exception { - - final Exception cause = new Exception("mock exception cause"); - testJsonResponse(new RestconfDocumentedException("mock error", cause), Status.INTERNAL_SERVER_ERROR, - ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, "mock error", null, - new SimpleErrorInfoVerifier(cause.getMessage())); - } - - void testXMLResponse(final RestconfDocumentedException ex, final Status expStatus, final ErrorType expErrorType, - final ErrorTag expErrorTag, final String expErrorMessage, final String expErrorAppTag, - final ErrorInfoVerifier errorInfoVerifier) throws Exception { - stageMockEx(ex); - - final Response resp = target("/operational/foo").request(MediaType.APPLICATION_XML).get(); - - final InputStream stream = verifyResponse(resp, MediaType.APPLICATION_XML, expStatus); - - verifyXMLResponseBody(stream, expErrorType, expErrorTag, expErrorMessage, expErrorAppTag, errorInfoVerifier); - } - - @Test - public void testToXMLResponseWithMessageOnly() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error"), Status.INTERNAL_SERVER_ERROR, - ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, "mock error", null, null); - - // To test verification code - // String xml = - // ""+ - // " " + - // " application"+ - // " operation-failed"+ - // " An error occurred"+ - // " " + - // " 123" + - // "
1.2.3.4
" + - // "
" + - // "
" + - // "
"; - // - // verifyXMLResponseBody( new java.io.StringBufferInputStream(xml), - // ErrorType.APPLICATION, - // ErrorTag.OPERATION_FAILED, "An error occurred", null, - // com.google.common.collect.ImmutableMap.of( "session-id", "123", - // "address", "1.2.3.4" ) ); - } - - @Test - public void testToXMLResponseWithInUseErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.IN_USE), - Status.CONFLICT, ErrorType.PROTOCOL, ErrorTag.IN_USE, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithInvalidValueErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.RPC, ErrorTag.INVALID_VALUE), - Status.BAD_REQUEST, ErrorType.RPC, ErrorTag.INVALID_VALUE, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithTooBigErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.TRANSPORT, ErrorTag.TOO_BIG), - Status.REQUEST_ENTITY_TOO_LARGE, ErrorType.TRANSPORT, ErrorTag.TOO_BIG, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithMissingAttributeErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithBadAttributeErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithUnknownAttributeErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ATTRIBUTE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ATTRIBUTE, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithBadElementErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithUnknownElementErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithUnknownNamespaceErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_NAMESPACE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_NAMESPACE, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithMalformedMessageErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE), - Status.BAD_REQUEST, ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithAccessDeniedErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.ACCESS_DENIED), - Status.FORBIDDEN, ErrorType.PROTOCOL, ErrorTag.ACCESS_DENIED, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithLockDeniedErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.LOCK_DENIED), - Status.CONFLICT, ErrorType.PROTOCOL, ErrorTag.LOCK_DENIED, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithResourceDeniedErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.RESOURCE_DENIED), - Status.CONFLICT, ErrorType.PROTOCOL, ErrorTag.RESOURCE_DENIED, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithRollbackFailedErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.ROLLBACK_FAILED), - Status.INTERNAL_SERVER_ERROR, ErrorType.PROTOCOL, ErrorTag.ROLLBACK_FAILED, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithDataExistsErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS), - Status.CONFLICT, ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithDataMissingErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING), - Status.NOT_FOUND, ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithOperationNotSupportedErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, - ErrorTag.OPERATION_NOT_SUPPORTED), Status.NOT_IMPLEMENTED, ErrorType.PROTOCOL, - ErrorTag.OPERATION_NOT_SUPPORTED, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithOperationFailedErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.OPERATION_FAILED), - Status.INTERNAL_SERVER_ERROR, ErrorType.PROTOCOL, ErrorTag.OPERATION_FAILED, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithPartialOperationErrorTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException("mock error", ErrorType.PROTOCOL, ErrorTag.PARTIAL_OPERATION), - Status.INTERNAL_SERVER_ERROR, ErrorType.PROTOCOL, ErrorTag.PARTIAL_OPERATION, "mock error", null, null); - } - - @Test - public void testToXMLResponseWithErrorAppTag() throws Exception { - - testXMLResponse(new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, - ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag")), Status.BAD_REQUEST, ErrorType.APPLICATION, - ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", null); - } - - @Test - public void testToXMLResponseWithErrorInfo() throws Exception { - - final String errorInfo = "
1.2.3.4
123"; - testXMLResponse(new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, - ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", errorInfo)), Status.BAD_REQUEST, - ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", - new SimpleErrorInfoVerifier(errorInfo)); - } - - @Test - public void testToXMLResponseWithExceptionCause() throws Exception { - - final Exception cause = new Exception("mock exception cause"); - testXMLResponse(new RestconfDocumentedException("mock error", cause), Status.INTERNAL_SERVER_ERROR, - ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, "mock error", null, - new SimpleErrorInfoVerifier(cause.getMessage())); - } - - @Test - @Ignore // FIXME : find why it return error-type as RPC no APPLICATION - public void testToXMLResponseWithMultipleErrors() throws Exception { - - final List errorList = Arrays.asList(new RestconfError(ErrorType.APPLICATION, ErrorTag.LOCK_DENIED, - "mock error1"), new RestconfError(ErrorType.RPC, ErrorTag.ROLLBACK_FAILED, "mock error2")); - stageMockEx(new RestconfDocumentedException("mock", null, errorList)); - - final Response resp = target("/operational/foo").request(MediaType.APPLICATION_XML).get(); - - final InputStream stream = verifyResponse(resp, MediaType.APPLICATION_XML, Status.CONFLICT); - - final Document doc = parseXMLDocument(stream); - - final NodeList children = getXMLErrorList(doc, 2); - - verifyXMLErrorNode(children.item(0), ErrorType.APPLICATION, ErrorTag.LOCK_DENIED, "mock error1", null, null); - - verifyXMLErrorNode(children.item(1), ErrorType.RPC, ErrorTag.ROLLBACK_FAILED, "mock error2", null, null); - } - - @Test - public void testToResponseWithAcceptHeader() throws Exception { - - stageMockEx(new RestconfDocumentedException("mock error")); - - final Response resp = target("/operational/foo").request().header("Accept", MediaType.APPLICATION_JSON).get(); - - final InputStream stream = verifyResponse(resp, MediaType.APPLICATION_JSON, Status.INTERNAL_SERVER_ERROR); - - verifyJsonResponseBody(stream, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, "mock error", null, null); - } - - @Test - @Ignore - public void testToResponseWithStatusOnly() throws Exception { - - // The StructuredDataToJsonProvider should throw a - // RestconfDocumentedException with no data - - when(mockRestConf.readOperationalData(any(String.class), any(UriInfo.class))).thenReturn( - new NormalizedNodeContext(null, null)); - - final Response resp = target("/operational/foo").request(MediaType.APPLICATION_JSON).get(); - - verifyResponse(resp, MediaType.TEXT_PLAIN, Status.NOT_FOUND); - } - - InputStream verifyResponse(final Response resp, final String expMediaType, final Status expStatus) { - assertEquals("getMediaType", MediaType.valueOf(expMediaType), resp.getMediaType()); - assertEquals("getStatus", expStatus.getStatusCode(), resp.getStatus()); - - final Object entity = resp.getEntity(); - assertEquals("Response entity", true, entity instanceof InputStream); - final InputStream stream = (InputStream) entity; - return stream; - } - - void verifyJsonResponseBody(final InputStream stream, final ErrorType expErrorType, final ErrorTag expErrorTag, - final String expErrorMessage, final String expErrorAppTag, final ErrorInfoVerifier errorInfoVerifier) - throws Exception { - - final JsonArray arrayElement = parseJsonErrorArrayElement(stream); - - assertEquals("\"error\" Json array element length", 1, arrayElement.size()); - - verifyJsonErrorNode(arrayElement.get(0), expErrorType, expErrorTag, expErrorMessage, expErrorAppTag, - errorInfoVerifier); - } - - private JsonArray parseJsonErrorArrayElement(final InputStream stream) throws IOException { - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ByteStreams.copy(stream, bos); - - System.out.println("JSON: " + bos.toString()); - - final JsonParser parser = new JsonParser(); - JsonElement rootElement; - - try { - rootElement = parser.parse(new InputStreamReader(new ByteArrayInputStream(bos.toByteArray()))); - } catch (final Exception e) { - throw new IllegalArgumentException("Invalid JSON response:\n" + bos.toString(), e); - } - - assertTrue("Root element of Json is not an Object", rootElement.isJsonObject()); - - final Set> errorsEntrySet = rootElement.getAsJsonObject().entrySet(); - assertEquals("Json Object element set count", 1, errorsEntrySet.size()); - - final Entry errorsEntry = errorsEntrySet.iterator().next(); - final JsonElement errorsElement = errorsEntry.getValue(); - assertEquals("First Json element name", "errors", errorsEntry.getKey()); - assertTrue("\"errors\" Json element is not an Object", errorsElement.isJsonObject()); - - final Set> errorListEntrySet = errorsElement.getAsJsonObject().entrySet(); - assertEquals("Root \"errors\" element child count", 1, errorListEntrySet.size()); - - final JsonElement errorListElement = errorListEntrySet.iterator().next().getValue(); - assertEquals("\"errors\" child Json element name", "error", errorListEntrySet.iterator().next().getKey()); - assertTrue("\"error\" Json element is not an Array", errorListElement.isJsonArray()); - - // As a final check, make sure there aren't multiple "error" array - // elements. Unfortunately, - // the call above to getAsJsonObject().entrySet() will out duplicate - // "error" elements. So - // we'll use regex on the json string to verify this. - - final Matcher matcher = Pattern.compile("\"error\"[ ]*:[ ]*\\[", Pattern.DOTALL).matcher(bos.toString()); - assertTrue("Expected 1 \"error\" element", matcher.find()); - assertFalse("Found multiple \"error\" elements", matcher.find()); - - return errorListElement.getAsJsonArray(); - } - - void verifyJsonErrorNode(final JsonElement errorEntryElement, final ErrorType expErrorType, - final ErrorTag expErrorTag, final String expErrorMessage, final String expErrorAppTag, - final ErrorInfoVerifier errorInfoVerifier) { - - JsonElement errorInfoElement = null; - final Map leafMap = Maps.newHashMap(); - for (final Entry entry : errorEntryElement.getAsJsonObject().entrySet()) { - final String leafName = entry.getKey(); - final JsonElement leafElement = entry.getValue(); - - if ("error-info".equals(leafName)) { - assertNotNull("Found unexpected \"error-info\" element", errorInfoVerifier); - errorInfoElement = leafElement; - } else { - assertTrue("\"error\" leaf Json element " + leafName + " is not a Primitive", - leafElement.isJsonPrimitive()); - - leafMap.put(leafName, leafElement.getAsString()); - } - } - - assertEquals("error-type", expErrorType.getErrorTypeTag(), leafMap.remove("error-type")); - assertEquals("error-tag", expErrorTag.getTagValue(), leafMap.remove("error-tag")); - - verifyOptionalJsonLeaf(leafMap.remove("error-message"), expErrorMessage, "error-message"); - verifyOptionalJsonLeaf(leafMap.remove("error-app-tag"), expErrorAppTag, "error-app-tag"); - - if (!leafMap.isEmpty()) { - fail("Found unexpected Json leaf elements for \"error\" element: " + leafMap); - } - - if (errorInfoVerifier != null) { - assertNotNull("Missing \"error-info\" element", errorInfoElement); - errorInfoVerifier.verifyJson(errorInfoElement); - } - } - - void verifyOptionalJsonLeaf(final String actualValue, final String expValue, final String tagName) { - if (expValue != null) { - assertEquals(tagName, expValue, actualValue); - } else { - assertNull("Found unexpected \"error\" leaf entry for: " + tagName, actualValue); - } - } - - void verifyXMLResponseBody(final InputStream stream, final ErrorType expErrorType, final ErrorTag expErrorTag, - final String expErrorMessage, final String expErrorAppTag, final ErrorInfoVerifier errorInfoVerifier) - throws Exception { - - final Document doc = parseXMLDocument(stream); - - final NodeList children = getXMLErrorList(doc, 1); - - verifyXMLErrorNode(children.item(0), expErrorType, expErrorTag, expErrorMessage, expErrorAppTag, - errorInfoVerifier); - } - - private Document parseXMLDocument(final InputStream stream) throws IOException { - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - factory.setCoalescing(true); - factory.setIgnoringElementContentWhitespace(true); - factory.setIgnoringComments(true); - - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ByteStreams.copy(stream, bos); - - System.out.println("XML: " + bos.toString()); - - Document doc = null; - try { - doc = factory.newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray())); - } catch (final Exception e) { - throw new IllegalArgumentException("Invalid XML response:\n" + bos.toString(), e); - } - return doc; - } - - void verifyXMLErrorNode(final Node errorNode, final ErrorType expErrorType, final ErrorTag expErrorTag, - final String expErrorMessage, final String expErrorAppTag, final ErrorInfoVerifier errorInfoVerifier) - throws Exception { - - final String errorType = (String) ERROR_TYPE.evaluate(errorNode, XPathConstants.STRING); - assertEquals("error-type", expErrorType.getErrorTypeTag(), errorType); - - final String errorTag = (String) ERROR_TAG.evaluate(errorNode, XPathConstants.STRING); - assertEquals("error-tag", expErrorTag.getTagValue(), errorTag); - - verifyOptionalXMLLeaf(errorNode, ERROR_MESSAGE, expErrorMessage, "error-message"); - verifyOptionalXMLLeaf(errorNode, ERROR_APP_TAG, expErrorAppTag, "error-app-tag"); - - final Node errorInfoNode = (Node) ERROR_INFO.evaluate(errorNode, XPathConstants.NODE); - if (errorInfoVerifier != null) { - assertNotNull("Missing \"error-info\" node", errorInfoNode); - - errorInfoVerifier.verifyXML(errorInfoNode); - } else { - assertNull("Found unexpected \"error-info\" node", errorInfoNode); - } - } - - void verifyOptionalXMLLeaf(final Node fromNode, final XPathExpression xpath, final String expValue, - final String tagName) throws Exception { - if (expValue != null) { - final String actual = (String) xpath.evaluate(fromNode, XPathConstants.STRING); - assertEquals(tagName, expValue, actual); - } else { - assertNull("Found unexpected \"error\" leaf entry for: " + tagName, - xpath.evaluate(fromNode, XPathConstants.NODE)); - } - } - - NodeList getXMLErrorList(final Node fromNode, final int count) throws Exception { - final NodeList errorList = (NodeList) ERROR_LIST.evaluate(fromNode, XPathConstants.NODESET); - assertNotNull("Root errors node is empty", errorList); - assertEquals("Root errors node child count", count, errorList.getLength()); - return errorList; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfErrorTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfErrorTest.java deleted file mode 100644 index 010572de96..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfErrorTest.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -import java.util.HashMap; -import java.util.Map; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.junit.Test; -import org.opendaylight.controller.sal.restconf.impl.RestconfError; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag; -import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - -/** - * Unit tests for RestconfError. - * - * @author Devin Avery - * @author Thomas Pantelis - * - */ -public class RestconfErrorTest { - - static class Contains extends BaseMatcher { - - private final String text; - - public Contains(String text) { - this.text = text; - } - - @Override - public void describeTo(Description desc) { - desc.appendText("contains ").appendValue(text); - } - - @Override - public boolean matches(Object arg) { - return arg != null && arg.toString().contains(text); - } - } - - @Test - public void testErrorTagValueOf() { - assertEquals(ErrorTag.IN_USE, ErrorTag.valueOfCaseInsensitive(ErrorTag.IN_USE.getTagValue())); - } - - @Test - public void testErrorTagValueOfIsLowercase() { - assertEquals("in-use", ErrorTag.IN_USE.getTagValue()); - } - - @Test - public void testErrorTypeGetErrorTypeTagIsLowerCase() { - assertEquals(ErrorType.APPLICATION.name().toLowerCase(), ErrorType.APPLICATION.getErrorTypeTag()); - } - - @Test - public void testErrorTypeValueOf() { - assertEquals(ErrorType.APPLICATION, ErrorType.valueOfCaseInsensitive(ErrorType.APPLICATION.getErrorTypeTag())); - } - - @Test - public void testErrorTagStatusCodes() { - Map lookUpMap = new HashMap(); - - lookUpMap.put("in-use", 409); - lookUpMap.put("invalid-value", 400); - lookUpMap.put("too-big", 413); - lookUpMap.put("missing-attribute", 400); - lookUpMap.put("bad-attribute", 400); - lookUpMap.put("unknown-attribute", 400); - lookUpMap.put("bad-element", 400); - lookUpMap.put("unknown-element", 400); - lookUpMap.put("unknown-namespace", 400); - lookUpMap.put("access-denied", 403); - lookUpMap.put("lock-denied", 409); - lookUpMap.put("resource-denied", 409); - lookUpMap.put("rollback-failed", 500); - lookUpMap.put("data-exists", 409); - lookUpMap.put("data-missing", 404); - lookUpMap.put("operation-not-supported", 501); - lookUpMap.put("operation-failed", 500); - lookUpMap.put("partial-operation", 500); - lookUpMap.put("malformed-message", 400); - - for (ErrorTag tag : ErrorTag.values()) { - Integer expectedStatusCode = lookUpMap.get(tag.getTagValue()); - assertNotNull("Failed to find " + tag.getTagValue(), expectedStatusCode); - assertEquals("Status Code does not match", expectedStatusCode, Integer.valueOf(tag.getStatusCode())); - } - } - - @Test - public void testRestConfDocumentedException_NoCause() { - String expectedMessage = "Message"; - ErrorType expectedErrorType = ErrorType.RPC; - ErrorTag expectedErrorTag = ErrorTag.IN_USE; - RestconfError e = new RestconfError(expectedErrorType, expectedErrorTag, expectedMessage); - - validateRestConfError(expectedMessage, expectedErrorType, expectedErrorTag, null, (String) null, e); - } - - @Test - public void testRestConfDocumentedException_WithAppTag() { - String expectedMessage = "Message"; - ErrorType expectedErrorType = ErrorType.RPC; - ErrorTag expectedErrorTag = ErrorTag.IN_USE; - String expectedErrorAppTag = "application.tag"; - - RestconfError e = new RestconfError(expectedErrorType, expectedErrorTag, expectedMessage, expectedErrorAppTag); - - validateRestConfError(expectedMessage, expectedErrorType, expectedErrorTag, expectedErrorAppTag, (String) null, - e); - } - - @Test - public void testRestConfDocumentedException_WithAppTagErrorInfo() { - String expectedMessage = "Message"; - ErrorType expectedErrorType = ErrorType.RPC; - ErrorTag expectedErrorTag = ErrorTag.IN_USE; - String expectedErrorAppTag = "application.tag"; - String errorInfo = "session.id"; - - RestconfError e = new RestconfError(expectedErrorType, expectedErrorTag, expectedMessage, expectedErrorAppTag, - errorInfo); - - validateRestConfError(expectedMessage, expectedErrorType, expectedErrorTag, expectedErrorAppTag, errorInfo, e); - } - - @Test - public void testRestConfErrorWithRpcError() { - - // All fields set - RpcError rpcError = RpcResultBuilder.newError( - RpcError.ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE.getTagValue(), "mock error-message", - "mock app-tag", "mock error-info", new Exception( "mock cause" ) ); - - validateRestConfError("mock error-message", ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE, "mock app-tag", - "mock error-info", new RestconfError(rpcError)); - - // All fields set except 'info' - expect error-info set to 'cause' - rpcError = RpcResultBuilder.newError( - RpcError.ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE.getTagValue(), "mock error-message", - "mock app-tag", null, new Exception( "mock cause" ) ); - - validateRestConfError("mock error-message", ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE, "mock app-tag", - new Contains("mock cause"), new RestconfError(rpcError)); - - // Some fields set - expect error-info set to ErrorSeverity - rpcError = RpcResultBuilder.newError( - RpcError.ErrorType.RPC, ErrorTag.ACCESS_DENIED.getTagValue(), null, null, null, null ); - - validateRestConfError(null, ErrorType.RPC, ErrorTag.ACCESS_DENIED, null, "error", - new RestconfError(rpcError)); - - // 'tag' field not mapped to ErrorTag - expect error-tag set to - // OPERATION_FAILED - rpcError = RpcResultBuilder.newWarning( - RpcError.ErrorType.TRANSPORT, "not mapped", null, null, null, null ); - - validateRestConfError(null, ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED, null, - "warning", new RestconfError(rpcError)); - - // No fields set - edge case - rpcError = RpcResultBuilder.newError( null, null, null, null, null, null ); - - validateRestConfError( null, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, - null, "error", new RestconfError( rpcError ) ); - } - - private void validateRestConfError(String expectedMessage, ErrorType expectedErrorType, ErrorTag expectedErrorTag, - String expectedErrorAppTag, String errorInfo, RestconfError e) { - - validateRestConfError(expectedMessage, expectedErrorType, expectedErrorTag, expectedErrorAppTag, - equalTo(errorInfo), e); - } - - private void validateRestConfError(String expectedMessage, ErrorType expectedErrorType, ErrorTag expectedErrorTag, - String expectedErrorAppTag, Matcher errorInfoMatcher, RestconfError e) { - - assertEquals("getErrorMessage", expectedMessage, e.getErrorMessage()); - assertEquals("getErrorType", expectedErrorType, e.getErrorType()); - assertEquals("getErrorTag", expectedErrorTag, e.getErrorTag()); - assertEquals("getErrorAppTag", expectedErrorAppTag, e.getErrorAppTag()); - assertThat("getErrorInfo", e.getErrorInfo(), errorInfoMatcher); - e.toString(); // really just checking for NPE etc. Don't care about - // contents. - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java deleted file mode 100644 index fa878b68e5..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.io.FileNotFoundException; -import java.text.ParseException; -import java.util.Set; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * @See {@link InvokeRpcMethodTest} - * - */ -public class RestconfImplTest { - - private RestconfImpl restconfImpl = null; - private static ControllerContext controllerContext = null; - - @BeforeClass - public static void init() throws FileNotFoundException { - final Set allModules = TestUtils.loadModulesFrom("/full-versions/yangs"); - assertNotNull(allModules); - final SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules); - controllerContext = spy(ControllerContext.getInstance()); - controllerContext.setSchemas(schemaContext); - - } - - @Before - public void initMethod() { - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setControllerContext(controllerContext); - } - - @SuppressWarnings("unchecked") - @Test - public void testExample() throws FileNotFoundException, ParseException { - @SuppressWarnings("rawtypes") - final - NormalizedNode normalizedNodeData = TestUtils.prepareNormalizedNodeWithIetfInterfacesInterfacesData(); - final BrokerFacade brokerFacade = mock(BrokerFacade.class); - when(brokerFacade.readOperationalData(any(YangInstanceIdentifier.class))).thenReturn(normalizedNodeData); - assertEquals(normalizedNodeData, - brokerFacade.readOperationalData(null)); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java deleted file mode 100644 index 75cce14d09..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertNotNull; - -import com.google.common.base.Preconditions; -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.net.URI; -import java.net.URISyntaxException; -import java.sql.Date; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -public final class TestUtils { - - private static final Logger LOG = LoggerFactory.getLogger(TestUtils.class); - - private final static YangContextParser PARSER = new YangParserImpl(); - - private static Set loadModules(final String resourceDirectory) throws FileNotFoundException { - final File testDir = new File(resourceDirectory); - final String[] fileList = testDir.list(); - final List testFiles = new ArrayList(); - if (fileList == null) { - throw new FileNotFoundException(resourceDirectory); - } - for (int i = 0; i < fileList.length; i++) { - final String fileName = fileList[i]; - if (new File(testDir, fileName).isDirectory() == false) { - testFiles.add(new File(testDir, fileName)); - } - } - return PARSER.parseYangModels(testFiles); - } - - public static Set loadModulesFrom(final String yangPath) { - try { - return TestUtils.loadModules(TestUtils.class.getResource(yangPath).getPath()); - } catch (final FileNotFoundException e) { - LOG.error("Yang files at path: " + yangPath + " weren't loaded."); - } - - return null; - } - - public static SchemaContext loadSchemaContext(final Set modules) { - return PARSER.resolveSchemaContext(modules); - } - - public static SchemaContext loadSchemaContext(final String resourceDirectory) throws FileNotFoundException { - return PARSER.resolveSchemaContext(loadModulesFrom(resourceDirectory)); - } - - public static Module findModule(final Set modules, final String moduleName) { - for (final Module module : modules) { - if (module.getName().equals(moduleName)) { - return module; - } - } - return null; - } - - public static Document loadDocumentFrom(final InputStream inputStream) { - try { - final DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); - final DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); - return docBuilder.parse(inputStream); - } catch (SAXException | IOException | ParserConfigurationException e) { - LOG.error("Error during loading Document from XML", e); - return null; - } - } - - public static String getDocumentInPrintableForm(final Document doc) { - Preconditions.checkNotNull(doc); - try { - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - final TransformerFactory tf = TransformerFactory.newInstance(); - final Transformer transformer = tf.newTransformer(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - - transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, "UTF-8"))); - final byte[] charData = out.toByteArray(); - return new String(charData, "UTF-8"); - } catch (IOException | TransformerException e) { - final String msg = "Error during transformation of Document into String"; - LOG.error(msg, e); - return msg; - } - - } - - /** - * Searches module with name {@code searchedModuleName} in {@code modules}. If module name isn't specified and - * module set has only one element then this element is returned. - * - */ - public static Module resolveModule(final String searchedModuleName, final Set modules) { - assertNotNull("Modules can't be null.", modules); - if (searchedModuleName != null) { - for (final Module m : modules) { - if (m.getName().equals(searchedModuleName)) { - return m; - } - } - } else if (modules.size() == 1) { - return modules.iterator().next(); - } - return null; - } - - public static DataSchemaNode resolveDataSchemaNode(final String searchedDataSchemaName, final Module module) { - assertNotNull("Module can't be null", module); - - if (searchedDataSchemaName != null) { - for (final DataSchemaNode dsn : module.getChildNodes()) { - if (dsn.getQName().getLocalName().equals(searchedDataSchemaName)) { - return dsn; - } - } - } else if (module.getChildNodes().size() == 1) { - return module.getChildNodes().iterator().next(); - } - return null; - } - - public static QName buildQName(final String name, final String uri, final String date, final String prefix) { - try { - final URI u = new URI(uri); - Date dt = null; - if (date != null) { - dt = Date.valueOf(date); - } - return QName.create(u, dt, name); - } catch (final URISyntaxException e) { - return null; - } - } - - public static QName buildQName(final String name, final String uri, final String date) { - return buildQName(name, uri, date, null); - } - - public static QName buildQName(final String name) { - return buildQName(name, "", null); - } - - public static String loadTextFile(final String filePath) throws IOException { - final FileReader fileReader = new FileReader(filePath); - final BufferedReader bufReader = new BufferedReader(fileReader); - - String line = null; - final StringBuilder result = new StringBuilder(); - while ((line = bufReader.readLine()) != null) { - result.append(line); - } - bufReader.close(); - return result.toString(); - } - - private static Pattern patternForStringsSeparatedByWhiteChars(final String... substrings) { - final StringBuilder pattern = new StringBuilder(); - pattern.append(".*"); - for (final String substring : substrings) { - pattern.append(substring); - pattern.append("\\s*"); - } - pattern.append(".*"); - return Pattern.compile(pattern.toString(), Pattern.DOTALL); - } - - public static boolean containsStringData(final String jsonOutput, final String... substrings) { - final Pattern pattern = patternForStringsSeparatedByWhiteChars(substrings); - final Matcher matcher = pattern.matcher(jsonOutput); - return matcher.matches(); - } - - public static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier(final String localName, final String namespace, - final String revision) throws ParseException { - return new YangInstanceIdentifier.NodeIdentifier(QName.create(namespace, revision, localName)); - } - - public static YangInstanceIdentifier.NodeIdentifierWithPredicates getNodeIdentifierPredicate(final String localName, - final String namespace, final String revision, final Map keys) throws ParseException { - final Map predicate = new HashMap<>(); - for (final String key : keys.keySet()) { - predicate.put(QName.create(namespace, revision, key), keys.get(key)); - } - - return new YangInstanceIdentifier.NodeIdentifierWithPredicates( - - QName.create(namespace, revision, localName), predicate); - } - - public static YangInstanceIdentifier.NodeIdentifierWithPredicates getNodeIdentifierPredicate(final String localName, - final String namespace, final String revision, final String... keysAndValues) throws ParseException { - if (keysAndValues.length % 2 != 0) { - new IllegalArgumentException("number of keys argument have to be divisible by 2 (map)"); - } - final Map predicate = new HashMap<>(); - - int i = 0; - while (i < keysAndValues.length) { - predicate.put(QName.create(namespace, revision, keysAndValues[i++]), keysAndValues[i++]); - } - - return new YangInstanceIdentifier.NodeIdentifierWithPredicates(QName.create(namespace, revision, localName), - predicate); - } - - static NormalizedNode prepareNormalizedNodeWithIetfInterfacesInterfacesData() throws ParseException { - final String ietfInterfacesDate = "2013-07-04"; - final String namespace = "urn:ietf:params:xml:ns:yang:ietf-interfaces"; - final DataContainerNodeAttrBuilder mapEntryNode = ImmutableMapEntryNodeBuilder.create(); - - final Map predicates = new HashMap<>(); - predicates.put("name", "eth0"); - - mapEntryNode.withNodeIdentifier(getNodeIdentifierPredicate("interface", namespace, ietfInterfacesDate, - predicates)); - mapEntryNode - .withChild(new ImmutableLeafNodeBuilder() - .withNodeIdentifier(getNodeIdentifier("name", namespace, ietfInterfacesDate)).withValue("eth0") - .build()); - mapEntryNode.withChild(new ImmutableLeafNodeBuilder() - .withNodeIdentifier(getNodeIdentifier("type", namespace, ietfInterfacesDate)) - .withValue("ethernetCsmacd").build()); - mapEntryNode.withChild(new ImmutableLeafNodeBuilder() - .withNodeIdentifier(getNodeIdentifier("enabled", namespace, ietfInterfacesDate)) - .withValue(Boolean.FALSE).build()); - mapEntryNode.withChild(new ImmutableLeafNodeBuilder() - .withNodeIdentifier(getNodeIdentifier("description", namespace, ietfInterfacesDate)) - .withValue("some interface").build()); - - return mapEntryNode.build(); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java deleted file mode 100644 index 0514e03ac7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat; - -import java.io.FileNotFoundException; -import java.text.ParseException; -import java.util.Date; -import java.util.Set; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriInfo; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.controller.sal.streams.listeners.ListenerAdapter; -import org.opendaylight.controller.sal.streams.listeners.Notificator; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils; - -public class URIParametersParsing { - - private RestconfImpl restconf; - private BrokerFacade mockedBrokerFacade; - private ControllerContext controllerContext; - - @Before - public void init() throws FileNotFoundException { - restconf = RestconfImpl.getInstance(); - mockedBrokerFacade = mock(BrokerFacade.class); - controllerContext = ControllerContext.getInstance(); - controllerContext.setSchemas(TestUtils.loadSchemaContext("/datastore-and-scope-specification")); - restconf.setControllerContext(controllerContext); - restconf.setBroker(mockedBrokerFacade); - } - - @Test - @Ignore // URI parsing test - not able to catch a motivation + bad mocking response now - it needs to change Controller RPC table holder approach - public void resolveURIParametersConcreteValues() { - resolveURIParameters("OPERATIONAL", "SUBTREE", LogicalDatastoreType.OPERATIONAL, DataChangeScope.SUBTREE); - } - - @Test - @Ignore // URI parsing test - not able to catch a motivation + bad mocking response now - it needs to change Controller RPC table holder approach - public void resolveURIParametersDefaultValues() { - resolveURIParameters(null, null, LogicalDatastoreType.CONFIGURATION, DataChangeScope.BASE); - } - - private void resolveURIParameters(final String datastore, final String scope, - final LogicalDatastoreType datastoreExpected, final DataChangeScope scopeExpected) { - - final InstanceIdentifierBuilder iiBuilder = YangInstanceIdentifier.builder(); - iiBuilder.node(QName.create("dummyStreamName")); - - final String datastoreValue = datastore == null ? "CONFIGURATION" : datastore; - final String scopeValue = scope == null ? "BASE" : scope + ""; - Notificator.createListener(iiBuilder.build(), "dummyStreamName/datastore=" + datastoreValue + "/scope=" - + scopeValue); - - final UriInfo mockedUriInfo = mock(UriInfo.class); - @SuppressWarnings("unchecked") - final MultivaluedMap mockedMultivaluedMap = mock(MultivaluedMap.class); - when(mockedMultivaluedMap.getFirst(eq("datastore"))).thenReturn(datastoreValue); - when(mockedMultivaluedMap.getFirst(eq("scope"))).thenReturn(scopeValue); - - when(mockedUriInfo.getQueryParameters(eq(false))).thenReturn(mockedMultivaluedMap); - - final UriBuilder uriBuilder = UriBuilder.fromUri("www.whatever.com"); - when(mockedUriInfo.getAbsolutePathBuilder()).thenReturn(uriBuilder); - -// when(mockedBrokerFacade.invokeRpc(any(SchemaPath.class), any(NormalizedNode.class))) -// .thenReturn(Futures. immediateCheckedFuture(new DefaultDOMRpcResult(Builders.containerBuilder().build()))); - - restconf.invokeRpc("sal-remote:create-data-change-event-subscription", prepareDomRpcNode(datastore, scope), - mockedUriInfo); - - final ListenerAdapter listener = Notificator.getListenerFor("opendaylight-inventory:nodes/datastore=" - + datastoreValue + "/scope=" + scopeValue); - assertNotNull(listener); - - } - - private NormalizedNodeContext prepareDomRpcNode(final String datastore, final String scope) { - final SchemaContext schema = controllerContext.getGlobalSchema(); - final Date revDate; - try { - revDate = getRevisionFormat().parse("2014-01-14"); - } - catch (final ParseException e) { - throw new IllegalStateException(e); - } - final Module rpcSalRemoteModule = schema.findModuleByName("sal-remote", revDate); - final Set setRpcs = rpcSalRemoteModule.getRpcs(); - final QName rpcQName = QName.create(rpcSalRemoteModule.getQNameModule(), "create-data-change-event-subscription"); - final QName rpcInputQName = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote","2014-01-14","input"); - ContainerSchemaNode rpcInputSchemaNode = null; - for (final RpcDefinition rpc : setRpcs) { - if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { - rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName); - break; - } - } - assertNotNull("RPC ContainerSchemaNode was not found!", rpcInputSchemaNode); - - final DataContainerNodeAttrBuilder container = Builders.containerBuilder(rpcInputSchemaNode); - - final QName pathQName = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "2014-01-14", "path"); - final DataSchemaNode pathSchemaNode = rpcInputSchemaNode.getDataChildByName(pathQName); - assertTrue(pathSchemaNode instanceof LeafSchemaNode); - final LeafNode pathNode = (Builders.leafBuilder((LeafSchemaNode) pathSchemaNode) - .withValue(YangInstanceIdentifier.builder().node(QName.create("urn:opendaylight:inventory", "2013-08-19", "nodes")).build())).build(); - container.withChild(pathNode); - - final QName dataStoreQName = QName.create("urn:sal:restconf:event:subscription", "2014-7-8", "datastore"); - final DataSchemaNode dsSchemaNode = rpcInputSchemaNode.getDataChildByName(dataStoreQName); - assertTrue(dsSchemaNode instanceof LeafSchemaNode); - final LeafNode dsNode = (Builders.leafBuilder((LeafSchemaNode) dsSchemaNode) - .withValue(datastore)).build(); - container.withChild(dsNode); - - final QName scopeQName = QName.create("urn:sal:restconf:event:subscription", "2014-7-8", "scope"); - final DataSchemaNode scopeSchemaNode = rpcInputSchemaNode.getDataChildByName(scopeQName); - assertTrue(scopeSchemaNode instanceof LeafSchemaNode); - final LeafNode scopeNode = (Builders.leafBuilder((LeafSchemaNode) scopeSchemaNode) - .withValue(scope)).build(); - container.withChild(scopeNode); - - return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpcInputSchemaNode, null, schema), container.build()); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java deleted file mode 100644 index 3121fc0685..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import java.io.FileNotFoundException; -import java.util.Set; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class URITest { - - private static final ControllerContext controllerContext = ControllerContext.getInstance(); - - @Rule - public ExpectedException exception = ExpectedException.none(); - - @BeforeClass - public static void init() throws FileNotFoundException { - final Set allModules = TestUtils.loadModulesFrom("/full-versions/yangs"); - assertNotNull(allModules); - final SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules); - controllerContext.setSchemas(schemaContext); - } - - @Test - public void testToInstanceIdentifierList() throws FileNotFoundException { - InstanceIdentifierContext instanceIdentifier = controllerContext - .toInstanceIdentifier("simple-nodes:userWithoutClass/foo"); - assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "userWithoutClass"); - - instanceIdentifier = controllerContext.toInstanceIdentifier("simple-nodes:userWithoutClass/foo"); - assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "userWithoutClass"); - - instanceIdentifier = controllerContext.toInstanceIdentifier("simple-nodes:user/foo/boo"); - assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "user"); - - instanceIdentifier = controllerContext.toInstanceIdentifier("simple-nodes:user//boo"); - assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "user"); - - } - - @Test - public void testToInstanceIdentifierListWithNullKey() { - exception.expect(RestconfDocumentedException.class); - controllerContext.toInstanceIdentifier("simple-nodes:user/null/boo"); - } - - @Test - public void testToInstanceIdentifierListWithMissingKey() { - exception.expect(RestconfDocumentedException.class); - controllerContext.toInstanceIdentifier("simple-nodes:user/foo"); - } - - @Test - public void testToInstanceIdentifierContainer() throws FileNotFoundException { - final InstanceIdentifierContext instanceIdentifier = controllerContext.toInstanceIdentifier("simple-nodes:users"); - assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "users"); - assertTrue(instanceIdentifier.getSchemaNode() instanceof ContainerSchemaNode); - assertEquals(2, ((ContainerSchemaNode) instanceIdentifier.getSchemaNode()).getChildNodes().size()); - } - - @Test - @Ignore //jenkins has problem with JerseyTest - we expecting problems with singletons ControllerContext as schemaContext holder - public void testToInstanceIdentifierChoice() throws FileNotFoundException { - final InstanceIdentifierContext instanceIdentifier = controllerContext - .toInstanceIdentifier("simple-nodes:food/nonalcoholic"); - assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "nonalcoholic"); - } - - @Test - public void testToInstanceIdentifierChoiceException() { - exception.expect(RestconfDocumentedException.class); - controllerContext.toInstanceIdentifier("simple-nodes:food/snack"); - } - - @Test - public void testToInstanceIdentifierCaseException() { - exception.expect(RestconfDocumentedException.class); - controllerContext.toInstanceIdentifier("simple-nodes:food/sports-arena"); - } - - @Test - public void testToInstanceIdentifierChoiceCaseException() { - exception.expect(RestconfDocumentedException.class); - controllerContext.toInstanceIdentifier("simple-nodes:food/snack/sports-arena"); - } - - @Test - public void testToInstanceIdentifierWithoutNode() { - exception.expect(RestconfDocumentedException.class); - controllerContext.toInstanceIdentifier("simple-nodes"); - } - - @Test - public void testMountPointWithExternModul() throws FileNotFoundException { - initMountService(true); - final InstanceIdentifierContext instanceIdentifier = controllerContext - .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name"); - assertEquals( - "[(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)student, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)student[{(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)name=name}]]", - ImmutableList.copyOf(instanceIdentifier.getInstanceIdentifier().getPathArguments()).toString()); - } - - @Test - public void testMountPointWithoutExternModul() throws FileNotFoundException { - initMountService(true); - final InstanceIdentifierContext instanceIdentifier = controllerContext - .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/"); - assertTrue(Iterables.isEmpty(instanceIdentifier.getInstanceIdentifier().getPathArguments())); - } - - @Test - public void testMountPointWithoutMountService() throws FileNotFoundException { - exception.expect(RestconfDocumentedException.class); - - controllerContext.setMountService(null); - controllerContext.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name"); - } - - @Test - public void testMountPointWithoutMountPointSchema() { - initMountService(false); - exception.expect(RestconfDocumentedException.class); - - controllerContext.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class"); - } - - public void initMountService(final boolean withSchema) { - final DOMMountPointService mountService = mock(DOMMountPointService.class); - controllerContext.setMountService(mountService); - final BrokerFacade brokerFacade = mock(BrokerFacade.class); - final RestconfImpl restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setBroker(brokerFacade); - restconfImpl.setControllerContext(controllerContext); - - final Set modules2 = TestUtils.loadModulesFrom("/test-config-data/yang2"); - final SchemaContext schemaContext2 = TestUtils.loadSchemaContext(modules2); - final DOMMountPoint mountInstance = mock(DOMMountPoint.class); - if (withSchema) { - when(mountInstance.getSchemaContext()).thenReturn(schemaContext2); - } else { - when(mountInstance.getSchemaContext()).thenReturn(null); - } - when(mountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance)); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnInstanceIdentifierTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnInstanceIdentifierTest.java deleted file mode 100644 index aa37c7572d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnInstanceIdentifierTest.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import org.junit.BeforeClass; - -public class XmlAndJsonToCnSnInstanceIdentifierTest extends YangAndXmlAndDataSchemaLoader { - - @BeforeClass - public static void initialize() { - dataLoad("/instanceidentifier/yang", 4, "instance-identifier-module", "cont"); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnLeafRefTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnLeafRefTest.java deleted file mode 100644 index e2e19c25de..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnLeafRefTest.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import org.junit.BeforeClass; -import org.opendaylight.yangtools.yang.common.QName; - -public class XmlAndJsonToCnSnLeafRefTest extends YangAndXmlAndDataSchemaLoader { - - final QName refContQName = QName.create("referenced:module", "2014-04-17", "cont"); - final QName refLf1QName = QName.create(refContQName, "lf1"); - final QName contQName = QName.create("leafref:module", "2014-04-17", "cont"); - final QName lf1QName = QName.create(contQName, "lf1"); - final QName lf2QName = QName.create(contQName, "lf2"); - final QName lf3QName = QName.create(contQName, "lf3"); - - @BeforeClass - public static void initialize() { - dataLoad("/leafref/yang", 2, "leafref-module", "cont"); - } - - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java deleted file mode 100644 index efcc3743c6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Set; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; - -public abstract class YangAndXmlAndDataSchemaLoader { - - protected static Set modules; - protected static DataSchemaNode dataSchemaNode; - protected static String searchedModuleName; - protected static String searchedDataSchemaName; - protected static String schemaNodePath; - - protected static void dataLoad(String yangPath) { - dataLoad(yangPath, 1, null, null); - } - - protected static void dataLoad(String yangPath, int modulesNumber, String moduleName, String dataSchemaName) { - modules = TestUtils.loadModulesFrom(yangPath); - assertEquals(modulesNumber, modules.size()); - Module module = TestUtils.resolveModule(moduleName, modules); - searchedModuleName = module == null ? "" : module.getName(); - assertNotNull(module); - dataSchemaNode = TestUtils.resolveDataSchemaNode(dataSchemaName, module); - searchedDataSchemaName = dataSchemaNode == null ? "" : dataSchemaNode.getQName().getLocalName(); - assertNotNull(dataSchemaNode); - schemaNodePath = searchedModuleName + ":" + searchedDataSchemaName; - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/IClientMessageCallback.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/IClientMessageCallback.java deleted file mode 100644 index 5b658a6cdf..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/IClientMessageCallback.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.sal.restconf.impl.websockets.client; - -/** - * Created by mbobak on 1/22/14. - */ -public interface IClientMessageCallback { - - public void onMessageReceived(Object message); -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/WebSocketClient.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/WebSocketClient.java deleted file mode 100644 index bc915d0c86..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/WebSocketClient.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.websockets.client; - -import io.netty.bootstrap.Bootstrap; -import io.netty.buffer.Unpooled; -import io.netty.channel.Channel; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.handler.codec.http.HttpClientCodec; -import io.netty.handler.codec.http.HttpObjectAggregator; -import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; -import io.netty.handler.codec.http.websocketx.PingWebSocketFrame; -import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; -import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory; -import io.netty.handler.codec.http.websocketx.WebSocketVersion; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URI; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WebSocketClient { - - private final URI uri; - private Bootstrap bootstrap = new Bootstrap();; - private final WebSocketClientHandler clientHandler; - private static final Logger logger = LoggerFactory.getLogger(WebSocketClient.class); - private Channel clientChannel; - private final EventLoopGroup group = new NioEventLoopGroup(); - - public WebSocketClient(URI uri, IClientMessageCallback clientMessageCallback) { - this.uri = uri; - clientHandler = new WebSocketClientHandler(WebSocketClientHandshakerFactory.newHandshaker(uri, - WebSocketVersion.V13, null, false, null), clientMessageCallback); // last - // null - // could - // be - // replaced - // with - // DefaultHttpHeaders - initialize(); - } - - private void initialize() { - - String protocol = uri.getScheme(); - if (!"ws".equals(protocol)) { - throw new IllegalArgumentException("Unsupported protocol: " + protocol); - } - - bootstrap.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) throws Exception { - ChannelPipeline pipeline = ch.pipeline(); - pipeline.addLast("http-codec", new HttpClientCodec()); - pipeline.addLast("aggregator", new HttpObjectAggregator(8192)); - pipeline.addLast("ws-handler", clientHandler); - } - }); - } - - public void connect() throws InterruptedException { - System.out.println("WebSocket Client connecting"); - clientChannel = bootstrap.connect(uri.getHost(), uri.getPort()).sync().channel(); - clientHandler.handshakeFuture().sync(); - } - - public void writeAndFlush(String message) { - clientChannel.writeAndFlush(new TextWebSocketFrame(message)); - } - - public void writeAndFlush(Object message) { - clientChannel.writeAndFlush(message); - } - - public void ping() { - clientChannel.writeAndFlush(new PingWebSocketFrame(Unpooled.copiedBuffer(new byte[] { 1, 2, 3, 4, 5, 6 }))); - } - - public void close(String reasonText) throws InterruptedException { - CloseWebSocketFrame closeWebSocketFrame = new CloseWebSocketFrame(1000, reasonText); - clientChannel.writeAndFlush(closeWebSocketFrame); - - // WebSocketClientHandler will close the connection when the server - // responds to the CloseWebSocketFrame. - clientChannel.closeFuture().sync(); - group.shutdownGracefully(); - } - - public static void main(String[] args) throws Exception { - URI uri; - if (args.length > 0) { - uri = new URI(args[0]); - } else { - uri = new URI("http://192.168.1.101:8181/opendaylight-inventory:nodes"); - } - IClientMessageCallback messageCallback = new ClientMessageCallback(); - WebSocketClient webSocketClient = new WebSocketClient(uri, messageCallback); - webSocketClient.connect(); - - while (true) { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - String input = br.readLine(); - if (input.equals("q")) { - System.out.print("Would you like to close stream? (Y = yes, empty = yes)\n"); - input = br.readLine(); - if (input.equals("yes") || input.isEmpty()) { - webSocketClient.close("opendaylight-inventory:nodes"); - break; - } - } - } - } - - private static class ClientMessageCallback implements IClientMessageCallback { - @Override - public void onMessageReceived(Object message) { - if (message instanceof TextWebSocketFrame) { - logger.info("received message {}" + ((TextWebSocketFrame) message).text()); - } - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/WebSocketClientHandler.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/WebSocketClientHandler.java deleted file mode 100644 index e07d8c48f0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/client/WebSocketClientHandler.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.websockets.client; - -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelPromise; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.http.FullHttpResponse; -import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; -import io.netty.handler.codec.http.websocketx.PongWebSocketFrame; -import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; -import io.netty.handler.codec.http.websocketx.WebSocketFrame; -import io.netty.util.CharsetUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WebSocketClientHandler extends SimpleChannelInboundHandler { - - private static final Logger logger = LoggerFactory.getLogger(WebSocketClientHandler.class.toString()); - private final WebSocketClientHandshaker handshaker; - private ChannelPromise handshakeFuture; - private final IClientMessageCallback messageListener; - - public WebSocketClientHandler(WebSocketClientHandshaker handshaker, IClientMessageCallback listener) { - this.handshaker = handshaker; - this.messageListener = listener; - } - - public ChannelFuture handshakeFuture() { - return handshakeFuture; - } - - @Override - public void handlerAdded(ChannelHandlerContext ctx) throws Exception { - handshakeFuture = ctx.newPromise(); - } - - @Override - public void channelActive(ChannelHandlerContext ctx) throws Exception { - handshaker.handshake(ctx.channel()); - } - - @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception { - logger.info("WebSocket Client disconnected!"); - } - - @Override - public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { - Channel ch = ctx.channel(); - if (!handshaker.isHandshakeComplete()) { - handshaker.finishHandshake(ch, (FullHttpResponse) msg); - logger.info("WebSocket Client connected!"); - handshakeFuture.setSuccess(); - return; - } - - if (msg instanceof FullHttpResponse) { - FullHttpResponse response = (FullHttpResponse) msg; - throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.getStatus() + ", content=" - + response.content().toString(CharsetUtil.UTF_8) + ')'); - } - - messageListener.onMessageReceived(msg); - WebSocketFrame frame = (WebSocketFrame) msg; - - if (frame instanceof PongWebSocketFrame) { - logger.info("WebSocket Client received pong"); - } else if (frame instanceof CloseWebSocketFrame) { - logger.info("WebSocket Client received closing"); - ch.close(); - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - cause.printStackTrace(); - - if (!handshakeFuture.isDone()) { - handshakeFuture.setFailure(cause); - } - - ctx.close(); - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/test/RestStream.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/test/RestStream.java deleted file mode 100644 index 754d829d94..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/websockets/test/RestStream.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.websockets.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import java.io.FileNotFoundException; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeJsonBodyWriter; -import org.opendaylight.controller.sal.rest.impl.NormalizedNodeXmlBodyWriter; -import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper; -import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader; -import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; -import org.opendaylight.controller.sal.restconf.impl.ControllerContext; -import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; -import org.opendaylight.controller.sal.restconf.impl.test.TestUtils; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class RestStream extends JerseyTest { - - private static BrokerFacade brokerFacade; - private static RestconfImpl restconfImpl; - private static SchemaContext schemaContextYangsIetf; - - @BeforeClass - public static void init() throws FileNotFoundException { - schemaContextYangsIetf = TestUtils.loadSchemaContext("/full-versions/yangs"); - final ControllerContext controllerContext = ControllerContext.getInstance(); - controllerContext.setSchemas(schemaContextYangsIetf); - brokerFacade = mock(BrokerFacade.class); - restconfImpl = RestconfImpl.getInstance(); - restconfImpl.setBroker(brokerFacade); - restconfImpl.setControllerContext(controllerContext); - } - - @Override - protected Application configure() { - /* enable/disable Jersey logs to console */ - // enable(TestProperties.LOG_TRAFFIC); - // enable(TestProperties.DUMP_ENTITY); - // enable(TestProperties.RECORD_LOG_LEVEL); - // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue()); - ResourceConfig resourceConfig = new ResourceConfig(); - resourceConfig = resourceConfig.registerInstances(restconfImpl, new NormalizedNodeJsonBodyWriter(), - new NormalizedNodeXmlBodyWriter(), new XmlNormalizedNodeBodyReader(), new JsonNormalizedNodeBodyReader()); - resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); - return resourceConfig; - } - - @Test - @Ignore // FIXME : find problem with codec - public void testCallRpcCallGet() throws UnsupportedEncodingException, InterruptedException { - String uri = "/operations/sal-remote:create-data-change-event-subscription"; - final Response responseWithStreamName = post(uri, MediaType.APPLICATION_XML, getRpcInput()); - final Document xmlResponse = responseWithStreamName.readEntity(Document.class); - assertNotNull(xmlResponse); - final Element outputElement = xmlResponse.getDocumentElement(); - assertEquals("output",outputElement.getLocalName()); - - final Node streamNameElement = outputElement.getFirstChild(); - assertEquals("stream-name",streamNameElement.getLocalName()); - assertEquals("ietf-interfaces:interfaces/ietf-interfaces:interface/eth0/datastore=CONFIGURATION/scope=BASE",streamNameElement.getTextContent()); - - uri = "/streams/stream/ietf-interfaces:interfaces/ietf-interfaces:interface/eth0/datastore=CONFIGURATION/scope=BASE"; - final Response responseWithRedirectionUri = get(uri, MediaType.APPLICATION_XML); - final URI websocketServerUri = responseWithRedirectionUri.getLocation(); - assertNotNull(websocketServerUri); - assertTrue(websocketServerUri.toString().matches(".*http://localhost:[\\d]+/ietf-interfaces:interfaces/ietf-interfaces:interface/eth0.*")); - } - - private Response post(final String uri, final String mediaType, final String data) { - return target(uri).request(mediaType).post(Entity.entity(data, mediaType)); - } - - private Response get(final String uri, final String mediaType) { - return target(uri).request(mediaType).get(); - } - - private String getRpcInput() { - final StringBuilder sb = new StringBuilder(); - sb.append(""); - sb.append("/int:interfaces/int:interface[int:name='eth0']"); - sb.append(""); - return sb.toString(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlAugmentedElementToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlAugmentedElementToCnSnTest.java deleted file mode 100644 index 2a6f7dead4..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlAugmentedElementToCnSnTest.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.xml.to.cnsn.test; - - -public class XmlAugmentedElementToCnSnTest { - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java deleted file mode 100644 index 9745c955c2..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.restconf.impl.xml.to.cnsn.test; - -import org.junit.BeforeClass; -import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader; - -public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader { - - @BeforeClass - public static void initialize() { - dataLoad("/xml-to-cnsn/leafref"); - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/json/dataa.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/json/dataa.json deleted file mode 100644 index 6097bd11b1..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/json/dataa.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "main:cont":{ - "augment-main-a:cont1":{ - "lf11":"lf11 value from a" - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/json/datab.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/json/datab.json deleted file mode 100644 index 297584a905..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/json/datab.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "main:cont":{ - "augment-main-b:cont1":{ - "lf11":"lf11 value from b" - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/xml/dataa.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/xml/dataa.xml deleted file mode 100644 index 97c5ae5246..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/xml/dataa.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - lf11 value for a - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/xml/datab.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/xml/datab.xml deleted file mode 100644 index b7696ca2a0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/xml/datab.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - lf11 value for b - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/augment-main-a.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/augment-main-a.yang deleted file mode 100644 index aa3bf3f253..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/augment-main-a.yang +++ /dev/null @@ -1,20 +0,0 @@ -module augment-main-a { - namespace "ns:augment:main:a"; - prefix "aumaa"; - - - import main {prefix mn; revision-date 2014-01-21;} - - - revision "2014-01-21" { - } - - augment "/mn:cont" { - container cont1 { - leaf lf11 { - type string; - } - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/augment-main-b.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/augment-main-b.yang deleted file mode 100644 index dcf493df08..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/augment-main-b.yang +++ /dev/null @@ -1,20 +0,0 @@ -module augment-main-b { - namespace "ns:augment:main:b"; - prefix "aumab"; - - - import main {prefix mn; revision-date 2014-01-21;} - - - revision "2014-01-21" { - } - - augment "/mn:cont" { - container cont1 { - leaf lf11 { - type string; - } - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/main.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/main.yang deleted file mode 100644 index e2917223a4..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/common/augment/yang/main.yang +++ /dev/null @@ -1,10 +0,0 @@ -module main { - namespace "ns:main"; - prefix "ma"; - - revision "2014-01-21" { - } - - container cont { - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/opendaylight-inventory.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/opendaylight-inventory.yang deleted file mode 100644 index e4247bee1e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/opendaylight-inventory.yang +++ /dev/null @@ -1,19 +0,0 @@ -module opendaylight-inventory { - namespace "urn:opendaylight:inventory"; - prefix inv; - - revision "2013-08-19" { - description "Initial revision of Inventory model"; - } - - - container nodes { - list node { - key "id"; - leaf id { - type string; - } - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/sal-remote-augment.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/sal-remote-augment.yang deleted file mode 100644 index 83934568cc..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/sal-remote-augment.yang +++ /dev/null @@ -1,31 +0,0 @@ -module sal-remote-augment { - - yang-version 1; - namespace "urn:sal:restconf:event:subscription"; - prefix "salrmt-aug-ev-subscr"; - - import sal-remote {prefix salrmt; revision-date "2014-01-14";} - - description - "Added input parameters to rpc create-data-change-event-subscription"; - - revision "2014-7-8" { - } - - augment "/salrmt:create-data-change-event-subscription/salrmt:input" { - leaf datastore { - type enumeration { - enum OPERATIONAL; - enum CONFIGURATION; - } - } - leaf scope { - type enumeration { - enum BASE; - enum ONE; - enum SUBTREE; - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/sal-remote@2014-01-14.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/sal-remote@2014-01-14.yang deleted file mode 100644 index d12e252711..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/datastore-and-scope-specification/sal-remote@2014-01-14.yang +++ /dev/null @@ -1,98 +0,0 @@ -module sal-remote { - - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote"; - prefix "sal-remote"; - - - organization "Cisco Systems, Inc."; - contact "Martin Bobak "; - - description - "This module contains the definition of methods related to - sal remote model. - - Copyright (c)2013 Cisco Systems, Inc. All rights reserved. - - This program and the accompanying materials are made available - under the terms of the Eclipse Public License v1.0 which - accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html"; - - revision "2014-01-14" { - description - "Initial revision"; - } - - - typedef q-name { - type string; - reference - "http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#QName"; - } - - rpc create-data-change-event-subscription { - input { - leaf path { - type instance-identifier; - description "Subtree path. "; - } - } - output { - leaf stream-name { - type string; - description "Notification stream name."; - } - } - } - - notification data-changed-notification { - description "Data change notification."; - list data-change-event { - key path; - leaf path { - type instance-identifier; - } - leaf store { - type enumeration { - enum config; - enum operation; - } - } - leaf operation { - type enumeration { - enum created; - enum updated; - enum deleted; - } - } - anyxml data{ - description "DataObject "; - } - } - } - - rpc create-notification-stream { - input { - leaf-list notifications { - type q-name; - description "Notification QNames"; - } - } - output { - leaf notification-stream-identifier { - type string; - description "Unique notification stream identifier, in which notifications will be propagated"; - } - } - } - - rpc begin-transaction{ - output{ - anyxml data-modification-transaction{ - description "DataModificationTransaction xml"; - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/decoding-exception/yang/number.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/decoding-exception/yang/number.yang deleted file mode 100644 index c4638827ef..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/decoding-exception/yang/number.yang +++ /dev/null @@ -1,17 +0,0 @@ - module number { - - namespace "number"; - prefix "number"; - - revision 2014-04-24 { - } - - - - container cont { - leaf lf { - type uint8; - } - - } - } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-container.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-container.json deleted file mode 100644 index 78b097d8e8..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-container.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "cont":{ - "cont1":[ - { - "lst11":{ - "lf111":"value1" - } - }, - { - "lst11":{ - "lf111":"value2" - } - } - ] - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-container.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-container.xml deleted file mode 100644 index 26a1f5f21d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-container.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - value1 - - - - - value1 - - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-leaf.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-leaf.json deleted file mode 100644 index d0a9fd4d3a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-leaf.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "cont":{ - "cont1":{ - "lst11":[ - { - "lf111":"value1", - "lf111":"value2" - }, - { - "lf111":"value3" - } - ] - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-leaf.xml deleted file mode 100644 index 4221c2d5a7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/equal-name-data-for-leaf.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - value1, - value2, - - - value3, - - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/yang/equal-data-node-names.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/yang/equal-data-node-names.yang deleted file mode 100644 index 3a3653a12b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/equal-data-node-names/yang/equal-data-node-names.yang +++ /dev/null @@ -1,18 +0,0 @@ -/* bug 1204 */ -module equal-data-node-names { - namespace "ns:equal:data:node:names"; - - prefix "eqdanona"; - revision 2014-06-26 { - } - - container cont { - container cont1 { - list lst11 { - leaf lf111 { - type string; - } - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.json deleted file mode 100644 index 0eae37ac21..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "test-module:input":{ - "cont":{ - "cont1":{ - "lf11":"lf1 data", - "lf12":"lf2 data" - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.xml deleted file mode 100644 index fb9726d5b1..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - lf1 data - lf2 data - - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data2.xml deleted file mode 100644 index db2f4e9cf9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data2.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - lf1 data - lf2 data - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data3.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data3.xml deleted file mode 100644 index b7b05d1ea2..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data3.xml +++ /dev/null @@ -1,4 +0,0 @@ - - lf1 data - lf2 data - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data4.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data4.xml deleted file mode 100644 index 3ce6741261..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data4.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - lf1 data - lf2 data - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data5.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data5.xml deleted file mode 100644 index 89aa782b01..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data5.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - John -
F.C.I 43
- j@j -
-
- diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data6.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data6.xml deleted file mode 100644 index 7feb6bf12b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data6.xml +++ /dev/null @@ -1,6 +0,0 @@ - - John -
F.C.I 43
- j@j -
- diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data7.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data7.xml deleted file mode 100644 index 43742770ae..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data7.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - lf1 data - lf2 data - - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module.yang deleted file mode 100644 index 2cc78b38fa..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module.yang +++ /dev/null @@ -1,101 +0,0 @@ -module test-module { - namespace "test:module"; - prefix tstmod; - - revision 2014-01-09 { - } - - identity module-type { - } - - identity test-identity { - } - - container interfaces { - container class { - leaf name { - type string; - } - leaf address { - type string; - } - leaf email { - type string; - } - } - } - - container cont { - container cont1 { - leaf lf11 { - type string; - } - leaf lf12 { - type string; - } - } - list lst1 { - key "lf11"; - leaf lf11 { - type string; - } - } - } - - container modules { - list module { - key "type name"; - leaf name { - type string; - mandatory true; - } - - leaf type { - type identityref { - base module-type; - } - mandatory true; - } - - leaf data { - type string; - } - } - } - - list lst-with-composite-key { - key "key1 key2"; - leaf key1 { - type string; - } - leaf key2 { - type uint8; - } - } - - rpc no-payload-rpc-test { - output { - container cont-output { - } - } - } - - rpc rpc-test { - input { - container cont { - container cont1 { - leaf lf11 { - type string; - } - leaf lf12 { - type string; - } - } - } - } - output { - container cont-output { - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/testData.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/testData.json deleted file mode 100644 index a736067f0b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/testData.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "interfaces": { - "interface": [ - { - "name": "eth0", - "type": "ethernetCsmacd", - "enabled": false - }, - { - "name": "eth1", - "type": "ethernetCsmacd", - "enabled": true, - "vlan-tagging": true - }, - { - "name": "eth1.10", - "type": "l2vlan", - "enabled": true, - "base-interface": "eth1", - "vlan-id": 10 - }, - { - "name": "lo1", - "type": "softwareLoopback", - "enabled": true - } - ] - }, - "interfaces-state": { - "interface": [ - { - "name": "eth0", - "type": "ethernetCsmacd", - "admin-status": "down", - "oper-status": "down", - "if-index": 2, - "phys-address": "00:01:02:03:04:05", - "statistics": { - "discontinuity-time": "2013-04-01T03:00:00+00:00" - } - }, - { - "name": "eth1", - "type": "ethernetCsmacd", - "admin-status": "up", - "oper-status": "up", - "if-index": 7, - "phys-address": "00:01:02:03:04:06", - "higher-layer-if": [ - "eth1.10" - ], - "statistics": { - "discontinuity-time": "2013-04-01T03:00:00+00:00" - } - }, - { - "name": "eth1.10", - "type": "l2vlan", - "admin-status": "up", - "oper-status": "up", - "if-index": 9, - "lower-layer-if": [ - "eth1" - ], - "statistics": { - "discontinuity-time": "2013-04-01T03:00:00+00:00" - } - }, - { - "name": "eth2", - "type": "ethernetCsmacd", - "admin-status": "down", - "oper-status": "down", - "if-index": 8, - "phys-address": "00:01:02:03:04:07", - "statistics": { - "discontinuity-time": "2013-04-01T03:00:00+00:00" - } - }, - { - "name": "lo1", - "type": "softwareLoopback", - "admin-status": "up", - "oper-status": "up", - "if-index": 1, - "statistics": { - "discontinuity-time": "2013-04-01T03:00:00+00:00" - } - } - ] - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/testData.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/testData.xml deleted file mode 100644 index bdd9c101ac..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/testData.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - eth0 - ethernetCsmacd - false - - - - eth1 - ethernetCsmacd - true - true - - - - eth1.10 - l2vlan - true - eth1 - 10 - - - - lo1 - softwareLoopback - true - - - - - - - - eth0 - ethernetCsmacd - down - down - 2 - 00:01:02:03:04:05 - - - 2013-04-01T03:00:00+00:00 - - - - - - - eth1 - ethernetCsmacd - up - up - 7 - 00:01:02:03:04:06 - eth1.10 - - - 2013-04-01T03:00:00+00:00 - - - - - - - eth1.10 - l2vlan - up - up - 9 - eth1 - - - 2013-04-01T03:00:00+00:00 - - - - - - - - eth2 - ethernetCsmacd - down - down - 8 - 00:01:02:03:04:07 - - - 2013-04-01T03:00:00+00:00 - - - - - - - lo1 - softwareLoopback - up - up - 1 - - - 2013-04-01T03:00:00+00:00 - - - - - - - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ex-vlan.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ex-vlan.yang deleted file mode 100644 index 59369add3e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ex-vlan.yang +++ /dev/null @@ -1,47 +0,0 @@ -module ex-vlan { - namespace "http://example.com/vlan"; - prefix "vlan"; - - import ietf-interfaces { - prefix if; - } - - revision 2013-10-22 { - description - "Initial revision."; - reference - "RFC A YANG Data Model for Interface Management draft-ietf-netmod-interfaces-cfg-12 - Appendix C"; - } - - augment "/if:interfaces/if:interface" { - when "if:type = 'ethernetCsmacd' or - if:type = 'ieee8023adLag'"; - leaf vlan-tagging { - type boolean; - default false; - } - } - - augment "/if:interfaces/if:interface" { - when "if:type = 'l2vlan'"; - - leaf base-interface { - type if:interface-ref; - must "/if:interfaces/if:interface[if:name = current()]" - + "/vlan:vlan-tagging = 'true'" { - description - "The base interface must have vlan tagging enabled."; - } - } - leaf vlan-id { - type uint16 { - range "1..4094"; - } - must "../base-interface" { - description - "If a vlan-id is defined, a base-interface must - be specified."; - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/iana-if-type.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/iana-if-type.yang deleted file mode 100644 index 7bd0003b5d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/iana-if-type.yang +++ /dev/null @@ -1,1517 +0,0 @@ -module iana-if-type { - namespace "urn:ietf:params:xml:ns:yang:iana-if-type"; - prefix ianaift; - - organization "IANA"; - contact - " Internet Assigned Numbers Authority - - Postal: ICANN - 4676 Admiralty Way, Suite 330 - Marina del Rey, CA 90292 - - Tel: +1 310 823 9358 - E-Mail: iana&iana.org"; - description - "This YANG module defines the iana-if-type typedef, which - contains YANG definitions for IANA-registered interface types. - - This YANG module is maintained by IANA, and reflects the - 'ifType definitions' registry. - - The latest revision of this YANG module can be obtained from - the IANA web site. - - Copyright (c) 2011 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - revision 2013-07-04 { - description - "Initial revision."; - reference - "RFC XXXX: IANA Interface Type YANG Module"; - } - - typedef iana-if-type { - type enumeration { - enum "other" { - value 1; - description - "None of the following"; - } - enum "regular1822" { - value 2; - } - enum "hdh1822" { - value 3; - } - enum "ddnX25" { - value 4; - } - enum "rfc877x25" { - value 5; - reference - "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer"; - } - enum "ethernetCsmacd" { - value 6; - description - "For all ethernet-like interfaces, regardless of speed, - as per RFC3635."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "iso88023Csmacd" { - value 7; - status deprecated; - description - "Deprecated via RFC3635. - Use ethernetCsmacd(6) instead."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "iso88024TokenBus" { - value 8; - } - enum "iso88025TokenRing" { - value 9; - } - enum "iso88026Man" { - value 10; - } - enum "starLan" { - value 11; - status deprecated; - description - "Deprecated via RFC3635. - Use ethernetCsmacd(6) instead."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "proteon10Mbit" { - value 12; - } - enum "proteon80Mbit" { - value 13; - } - enum "hyperchannel" { - value 14; - } - enum "fddi" { - value 15; - reference - "RFC 1512 - FDDI Management Information Base"; - } - enum "lapb" { - value 16; - reference - "RFC 1381 - SNMP MIB Extension for X.25 LAPB"; - } - enum "sdlc" { - value 17; - } - enum "ds1" { - value 18; - description - "DS1-MIB"; - reference - "RFC 4805 - Definitions of Managed Objects for the - DS1, J1, E1, DS2, and E2 Interface Types"; - } - enum "e1" { - value 19; - status obsolete; - description - "Obsolete see DS1-MIB"; - reference - "RFC 4805 - Definitions of Managed Objects for the - DS1, J1, E1, DS2, and E2 Interface Types"; - } - enum "basicISDN" { - value 20; - description - "see also RFC2127"; - } - enum "primaryISDN" { - value 21; - } - enum "propPointToPointSerial" { - value 22; - description - "proprietary serial"; - } - enum "ppp" { - value 23; - } - enum "softwareLoopback" { - value 24; - } - enum "eon" { - value 25; - description - "CLNP over IP"; - } - enum "ethernet3Mbit" { - value 26; - } - enum "nsip" { - value 27; - description - "XNS over IP"; - } - enum "slip" { - value 28; - description - "generic SLIP"; - } - enum "ultra" { - value 29; - description - "ULTRA technologies"; - } - enum "ds3" { - value 30; - description - "DS3-MIB"; - reference - "RFC 3896 - Definitions of Managed Objects for the - DS3/E3 Interface Type"; - } - enum "sip" { - value 31; - description - "SMDS, coffee"; - reference - "RFC 1694 - Definitions of Managed Objects for SMDS - Interfaces using SMIv2"; - } - enum "frameRelay" { - value 32; - description - "DTE only."; - reference - "RFC 2115 - Management Information Base for Frame Relay - DTEs Using SMIv2"; - } - enum "rs232" { - value 33; - reference - "RFC 1659 - Definitions of Managed Objects for RS-232-like - Hardware Devices using SMIv2"; - } - enum "para" { - value 34; - description - "parallel-port"; - reference - "RFC 1660 - Definitions of Managed Objects for - Parallel-printer-like Hardware Devices using - SMIv2"; - } - enum "arcnet" { - value 35; - description - "arcnet"; - } - enum "arcnetPlus" { - value 36; - description - "arcnet plus"; - } - enum "atm" { - value 37; - description - "ATM cells"; - } - enum "miox25" { - value 38; - reference - "RFC 1461 - SNMP MIB extension for Multiprotocol - Interconnect over X.25"; - } - enum "sonet" { - value 39; - description - "SONET or SDH"; - } - enum "x25ple" { - value 40; - reference - "RFC 2127 - ISDN Management Information Base using SMIv2"; - } - enum "iso88022llc" { - value 41; - } - enum "localTalk" { - value 42; - } - enum "smdsDxi" { - value 43; - } - enum "frameRelayService" { - value 44; - description - "FRNETSERV-MIB"; - reference - "RFC 2954 - Definitions of Managed Objects for Frame - Relay Service"; - } - enum "v35" { - value 45; - } - enum "hssi" { - value 46; - } - enum "hippi" { - value 47; - } - enum "modem" { - value 48; - description - "Generic modem"; - } - enum "aal5" { - value 49; - description - "AAL5 over ATM"; - } - enum "sonetPath" { - value 50; - } - enum "sonetVT" { - value 51; - } - enum "smdsIcip" { - value 52; - description - "SMDS InterCarrier Interface"; - } - enum "propVirtual" { - value 53; - description - "proprietary virtual/internal"; - reference - "RFC 2863 - The Interfaces Group MIB"; - } - enum "propMultiplexor" { - value 54; - description - "proprietary multiplexing"; - reference - "RFC 2863 - The Interfaces Group MIB"; - } - enum "ieee80212" { - value 55; - description - "100BaseVG"; - } - enum "fibreChannel" { - value 56; - description - "Fibre Channel"; - } - enum "hippiInterface" { - value 57; - description - "HIPPI interfaces"; - } - enum "frameRelayInterconnect" { - value 58; - status obsolete; - description - "Obsolete use either - frameRelay(32) or frameRelayService(44)."; - } - enum "aflane8023" { - value 59; - description - "ATM Emulated LAN for 802.3"; - } - enum "aflane8025" { - value 60; - description - "ATM Emulated LAN for 802.5"; - } - enum "cctEmul" { - value 61; - description - "ATM Emulated circuit"; - } - enum "fastEther" { - value 62; - status deprecated; - description - "Obsoleted via RFC3635. - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "isdn" { - value 63; - description - "ISDN and X.25"; - reference - "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN - in the Packet Mode"; - } - enum "v11" { - value 64; - description - "CCITT V.11/X.21"; - } - enum "v36" { - value 65; - description - "CCITT V.36"; - } - enum "g703at64k" { - value 66; - description - "CCITT G703 at 64Kbps"; - } - enum "g703at2mb" { - value 67; - status obsolete; - description - "Obsolete see DS1-MIB"; - } - enum "qllc" { - value 68; - description - "SNA QLLC"; - } - enum "fastEtherFX" { - value 69; - status deprecated; - description - "Obsoleted via RFC3635 - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "channel" { - value 70; - description - "channel"; - } - enum "ieee80211" { - value 71; - description - "radio spread spectrum"; - } - enum "ibm370parChan" { - value 72; - description - "IBM System 360/370 OEMI Channel"; - } - enum "escon" { - value 73; - description - "IBM Enterprise Systems Connection"; - } - enum "dlsw" { - value 74; - description - "Data Link Switching"; - } - enum "isdns" { - value 75; - description - "ISDN S/T interface"; - } - enum "isdnu" { - value 76; - description - "ISDN U interface"; - } - enum "lapd" { - value 77; - description - "Link Access Protocol D"; - } - enum "ipSwitch" { - value 78; - description - "IP Switching Objects"; - } - enum "rsrb" { - value 79; - description - "Remote Source Route Bridging"; - } - enum "atmLogical" { - value 80; - description - "ATM Logical Port"; - reference - "RFC 3606 - Definitions of Supplemental Managed Objects - for ATM Interface"; - } - enum "ds0" { - value 81; - description - "Digital Signal Level 0"; - reference - "RFC 2494 - Definitions of Managed Objects for the DS0 - and DS0 Bundle Interface Type"; - } - enum "ds0Bundle" { - value 82; - description - "group of ds0s on the same ds1"; - reference - "RFC 2494 - Definitions of Managed Objects for the DS0 - and DS0 Bundle Interface Type"; - } - enum "bsc" { - value 83; - description - "Bisynchronous Protocol"; - } - enum "async" { - value 84; - description - "Asynchronous Protocol"; - } - enum "cnr" { - value 85; - description - "Combat Net Radio"; - } - enum "iso88025Dtr" { - value 86; - description - "ISO 802.5r DTR"; - } - enum "eplrs" { - value 87; - description - "Ext Pos Loc Report Sys"; - } - enum "arap" { - value 88; - description - "Appletalk Remote Access Protocol"; - } - enum "propCnls" { - value 89; - description - "Proprietary Connectionless Protocol"; - } - enum "hostPad" { - value 90; - description - "CCITT-ITU X.29 PAD Protocol"; - } - enum "termPad" { - value 91; - description - "CCITT-ITU X.3 PAD Facility"; - } - enum "frameRelayMPI" { - value 92; - description - "Multiproto Interconnect over FR"; - } - enum "x213" { - value 93; - description - "CCITT-ITU X213"; - } - enum "adsl" { - value 94; - description - "Asymmetric Digital Subscriber Loop"; - } - enum "radsl" { - value 95; - description - "Rate-Adapt. Digital Subscriber Loop"; - } - enum "sdsl" { - value 96; - description - "Symmetric Digital Subscriber Loop"; - } - enum "vdsl" { - value 97; - description - "Very H-Speed Digital Subscrib. Loop"; - } - enum "iso88025CRFPInt" { - value 98; - description - "ISO 802.5 CRFP"; - } - enum "myrinet" { - value 99; - description - "Myricom Myrinet"; - } - enum "voiceEM" { - value 100; - description - "voice recEive and transMit"; - } - enum "voiceFXO" { - value 101; - description - "voice Foreign Exchange Office"; - } - enum "voiceFXS" { - value 102; - description - "voice Foreign Exchange Station"; - } - enum "voiceEncap" { - value 103; - description - "voice encapsulation"; - } - enum "voiceOverIp" { - value 104; - description - "voice over IP encapsulation"; - } - enum "atmDxi" { - value 105; - description - "ATM DXI"; - } - enum "atmFuni" { - value 106; - description - "ATM FUNI"; - } - enum "atmIma" { - value 107; - description - "ATM IMA"; - } - enum "pppMultilinkBundle" { - value 108; - description - "PPP Multilink Bundle"; - } - enum "ipOverCdlc" { - value 109; - description - "IBM ipOverCdlc"; - } - enum "ipOverClaw" { - value 110; - description - "IBM Common Link Access to Workstn"; - } - enum "stackToStack" { - value 111; - description - "IBM stackToStack"; - } - enum "virtualIpAddress" { - value 112; - description - "IBM VIPA"; - } - enum "mpc" { - value 113; - description - "IBM multi-protocol channel support"; - } - enum "ipOverAtm" { - value 114; - description - "IBM ipOverAtm"; - reference - "RFC 2320 - Definitions of Managed Objects for Classical IP - and ARP Over ATM Using SMIv2 (IPOA-MIB)"; - } - enum "iso88025Fiber" { - value 115; - description - "ISO 802.5j Fiber Token Ring"; - } - enum "tdlc" { - value 116; - description - "IBM twinaxial data link control"; - } - enum "gigabitEthernet" { - value 117; - status deprecated; - description - "Obsoleted via RFC3635 - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "hdlc" { - value 118; - description - "HDLC"; - } - enum "lapf" { - value 119; - description - "LAP F"; - } - enum "v37" { - value 120; - description - "V.37"; - } - enum "x25mlp" { - value 121; - description - "Multi-Link Protocol"; - } - enum "x25huntGroup" { - value 122; - description - "X25 Hunt Group"; - } - enum "transpHdlc" { - value 123; - description - "Transp HDLC"; - } - enum "interleave" { - value 124; - description - "Interleave channel"; - } - enum "fast" { - value 125; - description - "Fast channel"; - } - enum "ip" { - value 126; - description - "IP (for APPN HPR in IP networks)"; - } - enum "docsCableMaclayer" { - value 127; - description - "CATV Mac Layer"; - } - enum "docsCableDownstream" { - value 128; - description - "CATV Downstream interface"; - } - enum "docsCableUpstream" { - value 129; - description - "CATV Upstream interface"; - } - enum "a12MppSwitch" { - value 130; - description - "Avalon Parallel Processor"; - } - enum "tunnel" { - value 131; - description - "Encapsulation interface"; - } - enum "coffee" { - value 132; - description - "coffee pot"; - reference - "RFC 2325 - Coffee MIB"; - } - enum "ces" { - value 133; - description - "Circuit Emulation Service"; - } - enum "atmSubInterface" { - value 134; - description - "ATM Sub Interface"; - } - enum "l2vlan" { - value 135; - description - "Layer 2 Virtual LAN using 802.1Q"; - } - enum "l3ipvlan" { - value 136; - description - "Layer 3 Virtual LAN using IP"; - } - enum "l3ipxvlan" { - value 137; - description - "Layer 3 Virtual LAN using IPX"; - } - enum "digitalPowerline" { - value 138; - description - "IP over Power Lines"; - } - enum "mediaMailOverIp" { - value 139; - description - "Multimedia Mail over IP"; - } - enum "dtm" { - value 140; - description - "Dynamic syncronous Transfer Mode"; - } - enum "dcn" { - value 141; - description - "Data Communications Network"; - } - enum "ipForward" { - value 142; - description - "IP Forwarding Interface"; - } - enum "msdsl" { - value 143; - description - "Multi-rate Symmetric DSL"; - } - enum "ieee1394" { - value 144; - description - "IEEE1394 High Performance Serial Bus"; - } - enum "if-gsn" { - value 145; - description - "HIPPI-6400"; - } - enum "dvbRccMacLayer" { - value 146; - description - "DVB-RCC MAC Layer"; - } - enum "dvbRccDownstream" { - value 147; - description - "DVB-RCC Downstream Channel"; - } - enum "dvbRccUpstream" { - value 148; - description - "DVB-RCC Upstream Channel"; - } - enum "atmVirtual" { - value 149; - description - "ATM Virtual Interface"; - } - enum "mplsTunnel" { - value 150; - description - "MPLS Tunnel Virtual Interface"; - } - enum "srp" { - value 151; - description - "Spatial Reuse Protocol"; - } - enum "voiceOverAtm" { - value 152; - description - "Voice Over ATM"; - } - enum "voiceOverFrameRelay" { - value 153; - description - "Voice Over Frame Relay"; - } - enum "idsl" { - value 154; - description - "Digital Subscriber Loop over ISDN"; - } - enum "compositeLink" { - value 155; - description - "Avici Composite Link Interface"; - } - enum "ss7SigLink" { - value 156; - description - "SS7 Signaling Link"; - } - enum "propWirelessP2P" { - value 157; - description - "Prop. P2P wireless interface"; - } - enum "frForward" { - value 158; - description - "Frame Forward Interface"; - } - enum "rfc1483" { - value 159; - description - "Multiprotocol over ATM AAL5"; - reference - "RFC 1483 - Multiprotocol Encapsulation over ATM - Adaptation Layer 5"; - } - enum "usb" { - value 160; - description - "USB Interface"; - } - enum "ieee8023adLag" { - value 161; - description - "IEEE 802.3ad Link Aggregate"; - } - enum "bgppolicyaccounting" { - value 162; - description - "BGP Policy Accounting"; - } - enum "frf16MfrBundle" { - value 163; - description - "FRF .16 Multilink Frame Relay"; - } - enum "h323Gatekeeper" { - value 164; - description - "H323 Gatekeeper"; - } - enum "h323Proxy" { - value 165; - description - "H323 Voice and Video Proxy"; - } - enum "mpls" { - value 166; - description - "MPLS"; - } - enum "mfSigLink" { - value 167; - description - "Multi-frequency signaling link"; - } - enum "hdsl2" { - value 168; - description - "High Bit-Rate DSL - 2nd generation"; - } - enum "shdsl" { - value 169; - description - "Multirate HDSL2"; - } - enum "ds1FDL" { - value 170; - description - "Facility Data Link 4Kbps on a DS1"; - } - enum "pos" { - value 171; - description - "Packet over SONET/SDH Interface"; - } - enum "dvbAsiIn" { - value 172; - description - "DVB-ASI Input"; - } - enum "dvbAsiOut" { - value 173; - description - "DVB-ASI Output"; - } - enum "plc" { - value 174; - description - "Power Line Communtications"; - } - enum "nfas" { - value 175; - description - "Non Facility Associated Signaling"; - } - enum "tr008" { - value 176; - description - "TR008"; - } - enum "gr303RDT" { - value 177; - description - "Remote Digital Terminal"; - } - enum "gr303IDT" { - value 178; - description - "Integrated Digital Terminal"; - } - enum "isup" { - value 179; - description - "ISUP"; - } - enum "propDocsWirelessMaclayer" { - value 180; - description - "Cisco proprietary Maclayer"; - } - enum "propDocsWirelessDownstream" { - value 181; - description - "Cisco proprietary Downstream"; - } - enum "propDocsWirelessUpstream" { - value 182; - description - "Cisco proprietary Upstream"; - } - enum "hiperlan2" { - value 183; - description - "HIPERLAN Type 2 Radio Interface"; - } - enum "propBWAp2Mp" { - value 184; - description - "PropBroadbandWirelessAccesspt2multipt use of this value - for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f - is deprecated and ieee80216WMAN(237) should be used - instead."; - } - enum "sonetOverheadChannel" { - value 185; - description - "SONET Overhead Channel"; - } - enum "digitalWrapperOverheadChannel" { - value 186; - description - "Digital Wrapper"; - } - enum "aal2" { - value 187; - description - "ATM adaptation layer 2"; - } - enum "radioMAC" { - value 188; - description - "MAC layer over radio links"; - } - enum "atmRadio" { - value 189; - description - "ATM over radio links"; - } - enum "imt" { - value 190; - description - "Inter Machine Trunks"; - } - enum "mvl" { - value 191; - description - "Multiple Virtual Lines DSL"; - } - enum "reachDSL" { - value 192; - description - "Long Reach DSL"; - } - enum "frDlciEndPt" { - value 193; - description - "Frame Relay DLCI End Point"; - } - enum "atmVciEndPt" { - value 194; - description - "ATM VCI End Point"; - } - enum "opticalChannel" { - value 195; - description - "Optical Channel"; - } - enum "opticalTransport" { - value 196; - description - "Optical Transport"; - } - enum "propAtm" { - value 197; - description - "Proprietary ATM"; - } - enum "voiceOverCable" { - value 198; - description - "Voice Over Cable Interface"; - } - enum "infiniband" { - value 199; - description - "Infiniband"; - } - enum "teLink" { - value 200; - description - "TE Link"; - } - enum "q2931" { - value 201; - description - "Q.2931"; - } - enum "virtualTg" { - value 202; - description - "Virtual Trunk Group"; - } - enum "sipTg" { - value 203; - description - "SIP Trunk Group"; - } - enum "sipSig" { - value 204; - description - "SIP Signaling"; - } - enum "docsCableUpstreamChannel" { - value 205; - description - "CATV Upstream Channel"; - } - enum "econet" { - value 206; - description - "Acorn Econet"; - } - enum "pon155" { - value 207; - description - "FSAN 155Mb Symetrical PON interface"; - } - enum "pon622" { - value 208; - description - "FSAN622Mb Symetrical PON interface"; - } - enum "bridge" { - value 209; - description - "Transparent bridge interface"; - } - enum "linegroup" { - value 210; - description - "Interface common to multiple lines"; - } - enum "voiceEMFGD" { - value 211; - description - "voice E&M Feature Group D"; - } - enum "voiceFGDEANA" { - value 212; - description - "voice FGD Exchange Access North American"; - } - enum "voiceDID" { - value 213; - description - "voice Direct Inward Dialing"; - } - enum "mpegTransport" { - value 214; - description - "MPEG transport interface"; - } - enum "sixToFour" { - value 215; - status deprecated; - description - "6to4 interface (DEPRECATED)"; - reference - "RFC 4087 - IP Tunnel MIB"; - } - enum "gtp" { - value 216; - description - "GTP (GPRS Tunneling Protocol)"; - } - enum "pdnEtherLoop1" { - value 217; - description - "Paradyne EtherLoop 1"; - } - enum "pdnEtherLoop2" { - value 218; - description - "Paradyne EtherLoop 2"; - } - enum "opticalChannelGroup" { - value 219; - description - "Optical Channel Group"; - } - enum "homepna" { - value 220; - description - "HomePNA ITU-T G.989"; - } - enum "gfp" { - value 221; - description - "Generic Framing Procedure (GFP)"; - } - enum "ciscoISLvlan" { - value 222; - description - "Layer 2 Virtual LAN using Cisco ISL"; - } - enum "actelisMetaLOOP" { - value 223; - description - "Acteleis proprietary MetaLOOP High Speed Link"; - } - enum "fcipLink" { - value 224; - description - "FCIP Link"; - } - enum "rpr" { - value 225; - description - "Resilient Packet Ring Interface Type"; - } - enum "qam" { - value 226; - description - "RF Qam Interface"; - } - enum "lmp" { - value 227; - description - "Link Management Protocol"; - reference - "RFC 4327 - Link Management Protocol (LMP) Management - Information Base (MIB)"; - } - enum "cblVectaStar" { - value 228; - description - "Cambridge Broadband Networks Limited VectaStar"; - } - enum "docsCableMCmtsDownstream" { - value 229; - description - "CATV Modular CMTS Downstream Interface"; - } - enum "adsl2" { - value 230; - status deprecated; - description - "Asymmetric Digital Subscriber Loop Version 2 - (DEPRECATED/OBSOLETED - please use adsl2plus(238) - instead)"; - reference - "RFC 4706 - Definitions of Managed Objects for Asymmetric - Digital Subscriber Line 2 (ADSL2)"; - } - enum "macSecControlledIF" { - value 231; - description - "MACSecControlled"; - } - enum "macSecUncontrolledIF" { - value 232; - description - "MACSecUncontrolled"; - } - enum "aviciOpticalEther" { - value 233; - description - "Avici Optical Ethernet Aggregate"; - } - enum "atmbond" { - value 234; - description - "atmbond"; - } - enum "voiceFGDOS" { - value 235; - description - "voice FGD Operator Services"; - } - enum "mocaVersion1" { - value 236; - description - "MultiMedia over Coax Alliance (MoCA) Interface - as documented in information provided privately to IANA"; - } - enum "ieee80216WMAN" { - value 237; - description - "IEEE 802.16 WMAN interface"; - } - enum "adsl2plus" { - value 238; - description - "Asymmetric Digital Subscriber Loop Version 2, - Version 2 Plus and all variants"; - } - enum "dvbRcsMacLayer" { - value 239; - description - "DVB-RCS MAC Layer"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "dvbTdm" { - value 240; - description - "DVB Satellite TDM"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "dvbRcsTdma" { - value 241; - description - "DVB-RCS TDMA"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "x86Laps" { - value 242; - description - "LAPS based on ITU-T X.86/Y.1323"; - } - enum "wwanPP" { - value 243; - description - "3GPP WWAN"; - } - enum "wwanPP2" { - value 244; - description - "3GPP2 WWAN"; - } - enum "voiceEBS" { - value 245; - description - "voice P-phone EBS physical interface"; - } - enum "ifPwType" { - value 246; - description - "Pseudowire interface type"; - reference - "RFC 5601 - Pseudowire (PW) Management Information Base"; - } - enum "ilan" { - value 247; - description - "Internal LAN on a bridge per IEEE 802.1ap"; - } - enum "pip" { - value 248; - description - "Provider Instance Port on a bridge per IEEE 802.1ah PBB"; - } - enum "aluELP" { - value 249; - description - "Alcatel-Lucent Ethernet Link Protection"; - } - enum "gpon" { - value 250; - description - "Gigabit-capable passive optical networks (G-PON) as per - ITU-T G.948"; - } - enum "vdsl2" { - value 251; - description - "Very high speed digital subscriber line Version 2 - (as per ITU-T Recommendation G.993.2)"; - reference - "RFC 5650 - Definitions of Managed Objects for Very High - Speed Digital Subscriber Line 2 (VDSL2)"; - } - enum "capwapDot11Profile" { - value 252; - description - "WLAN Profile Interface"; - reference - "RFC 5834 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Binding MIB for - IEEE 802.11"; - } - enum "capwapDot11Bss" { - value 253; - description - "WLAN BSS Interface"; - reference - "RFC 5834 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Binding MIB for - IEEE 802.11"; - } - enum "capwapWtpVirtualRadio" { - value 254; - description - "WTP Virtual Radio Interface"; - reference - "RFC 5833 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Base MIB"; - } - enum "bits" { - value 255; - description - "bitsport"; - } - enum "docsCableUpstreamRfPort" { - value 256; - description - "DOCSIS CATV Upstream RF Port"; - } - enum "cableDownstreamRfPort" { - value 257; - description - "CATV downstream RF port"; - } - enum "vmwareVirtualNic" { - value 258; - description - "VMware Virtual Network Interface"; - } - enum "ieee802154" { - value 259; - description - "IEEE 802.15.4 WPAN interface"; - reference - "IEEE 802.15.4-2006"; - } - enum "otnOdu" { - value 260; - description - "OTN Optical Data Unit"; - } - enum "otnOtu" { - value 261; - description - "OTN Optical channel Transport Unit"; - } - enum "ifVfiType" { - value 262; - description - "VPLS Forwarding Instance Interface Type"; - } - enum "g9981" { - value 263; - description - "G.998.1 bonded interface"; - } - enum "g9982" { - value 264; - description - "G.998.2 bonded interface"; - } - enum "g9983" { - value 265; - description - "G.998.3 bonded interface"; - } - enum "aluEpon" { - value 266; - description - "Ethernet Passive Optical Networks (E-PON)"; - } - enum "aluEponOnu" { - value 267; - description - "EPON Optical Network Unit"; - } - enum "aluEponPhysicalUni" { - value 268; - description - "EPON physical User to Network interface"; - } - enum "aluEponLogicalLink" { - value 269; - description - "The emulation of a point-to-point link over the EPON - layer"; - } - enum "aluGponOnu" { - value 270; - description - "GPON Optical Network Unit"; - reference - "ITU-T G.984.2"; - } - enum "aluGponPhysicalUni" { - value 271; - description - "GPON physical User to Network interface"; - reference - "ITU-T G.984.2"; - } - enum "vmwareNicTeam" { - value 272; - description - "VMware NIC Team"; - } - // value 273 reserved by IANA - } - description - "This data type is used as the syntax of the 'type' - leaf in the 'interface' list in the YANG module - ietf-interface. - - The definition of this typedef with the - addition of newly assigned values is published - periodically by the IANA, in either the Assigned - Numbers RFC, or some derivative of it specific to - Internet Network Management number assignments. (The - latest arrangements can be obtained by contacting the - IANA.) - - Requests for new values should be made to IANA via - email (iana&iana.org)."; - reference - "IANA ifType definitions registry. - "; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ietf-interfaces@2013-07-04.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ietf-interfaces@2013-07-04.yang deleted file mode 100644 index 9db753c440..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ietf-interfaces@2013-07-04.yang +++ /dev/null @@ -1,673 +0,0 @@ -module ietf-interfaces { - - namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces"; - prefix if; - - import ietf-yang-types { - prefix yang; - } - import iana-if-type { - prefix ianaift; - } - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Kessens - - - WG Chair: Juergen Schoenwaelder - - - Editor: Martin Bjorklund - "; - - description - "This module contains a collection of YANG definitions for - managing network interfaces. - - Copyright (c) 2013 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - revision 2013-07-04 { - description - "Initial revision."; - reference - "RFC XXXX: A YANG Data Model for Interface Management"; - } - - /* Typedefs */ - - typedef interface-ref { - type leafref { - path "/if:interfaces/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - configured interfaces."; - } - - typedef interface-state-ref { - type leafref { - path "/if:interfaces-state/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - the operationally present interfaces."; - } - - /* Features */ - - feature arbitrary-names { - description - "This feature indicates that the device allows user-controlled - interfaces to be named arbitrarily."; - } - - feature pre-provisioning { - description - "This feature indicates that the device supports - pre-provisioning of interface configuration, i.e., it is - possible to configure an interface whose physical interface - hardware is not present on the device."; - } - - feature if-mib { - description - "This feature indicates that the device implements IF-MIB."; - reference - "RFC 2863: The Interfaces Group MIB"; - } - - /* Data nodes */ - - container interfaces { - description - "Interface configuration parameters."; - - list interface { - key "name"; - - description - "The list of configured interfaces on the device. - - The operational state of an interface is available in the - /interfaces-state/interface list. If the configuration of a - system-controlled interface cannot be used by the system - (e.g., the interface hardware present does not match the - interface type), then the configuration is not applied to - the system-controlled interface shown in the - /interfaces-state/interface list. If the the configuration - of a user-controlled interface cannot be used by the system, - the configured interface is not instantiated in the - /interfaces-state/interface list."; - - leaf name { - type string; - description - "The name of the interface. - - A device MAY restrict the allowed values for this leaf, - possibly depending on the type of the interface. - - For system-controlled interfaces, this leaf is the - device-specific name of the interface. The 'config false' - list /interfaces-state/interface contains the currently - existing interfaces on the device. - - If a client tries to create configuration for a - system-controlled interface that is not present in the - /interfaces-state/interface list, the server MAY reject - the request, if the implementation does not support - pre-provisioning of interfaces, or if the name refers to - an interface that can never exist in the system. A - NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case. - - If the device supports pre-provisioning of interface - configuration, the feature 'pre-provisioning' is - advertised. - - If the device allows arbitrarily named user-controlled - interfaces, the feature 'arbitrary-names' is advertised. - - When a configured user-controlled interface is created by - the system, it is instantiated with the same name in the - /interface-state/interface list. Since the name in that - list MAY be mapped to ifName by an implementation, such an - implementation MUST restrict the allowed values for this - leaf so that it matches the restrictions of ifName. - - If a NETCONF server that implements this restriction is - sent a value that doesn't match the restriction, it MUST - reply with an rpc-error with the error-tag - 'invalid-value'."; - } - - leaf description { - type string; - description - "A textual description of the interface. - - This leaf MAY be mapped to ifAlias by an implementation. - Such an implementation MUST restrict the allowed values - for this leaf so that it matches the restrictions of - ifAlias. - - If a NETCONF server that implements this restriction is - sent a value that doesn't match the restriction, it MUST - reply with an rpc-error with the error-tag - 'invalid-value'. - - Since ifAlias is defined to be stored in non-volatile - storage, the MIB implementation MUST map ifAlias to the - value of 'description' in the persistently stored - datastore. - - Specifically, if the device supports ':startup', when - ifAlias is read the device MUST return the value of - 'description' in the 'startup' datastore, and when it is - written, it MUST be written to the 'running' and 'startup' - datastores. Note that it is up to the implementation if - it modifies this single leaf in 'startup', or if it - performs an implicit copy-config from 'running' to - 'startup'. - - If the device does not support ':startup', ifAlias MUST - be mapped to the 'description' leaf in the 'running' - datastore."; - reference - "RFC 2863: The Interfaces Group MIB - ifAlias"; - } - - leaf type { - type ianaift:iana-if-type; - mandatory true; - description - "The type of the interface. - - When an interface entry is created, a server MAY - initialize the type leaf with a valid value, e.g., if it - is possible to derive the type from the name of the - interface. - - If a client tries to set the type of an interface to a - value that can never be used by the system, e.g., if the - type is not supported or if the type does not match the - name of the interface, the server MUST reject the request. - A NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf enabled { - type boolean; - default "true"; - description - "This leaf contains the configured, desired state of the - interface. - - Systems that implement the IF-MIB use the value of this - leaf in the 'running' datastore to set - IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry - has been initialized, as described in RFC 2863. - - Changes in this leaf in the 'running' datastore are - reflected in ifAdminStatus, but if ifAdminStatus is - changed over SNMP, this leaf is not affected."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf link-up-down-trap-enable { - if-feature if-mib; - type enumeration { - enum enabled { - value 1; - } - enum disabled { - value 2; - } - } - description - "Controls whether linkUp/linkDown SNMP notifications - should be generated for this interface. - - If this node is not configured, the value 'enabled' is - operationally used by the server for interfaces which do - not operate on top of any other interface (i.e., there are - no 'lower-layer-if' entries), and 'disabled' otherwise."; - reference - "RFC 2863: The Interfaces Group MIB - - ifLinkUpDownTrapEnable"; - } - } - } - - container interfaces-state { - config false; - description - "Data nodes for the operational state of interfaces."; - - list interface { - key "name"; - - description - "The list of interfaces on the device. - - System-controlled interfaces created by the system are - always present in this list, whether they are configured or - not."; - - leaf name { - type string; - description - "The name of the interface. - - This leaf MAY be mapped to ifName by an implementation."; - reference - "RFC 2863: The Interfaces Group MIB - ifName"; - } - - leaf type { - type ianaift:iana-if-type; - mandatory true; - description - "The type of the interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf admin-status { - if-feature if-mib; - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "Not ready to pass packets and not in some test mode."; - } - enum testing { - value 3; - description - "In some test mode."; - } - } - mandatory true; - description - "The desired state of the interface. - - This leaf has the same read semantics as ifAdminStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf oper-status { - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "The interface does not pass any packets."; - } - enum testing { - value 3; - description - "In some test mode. No operational packets can - be passed."; - } - enum unknown { - value 4; - description - "Status cannot be determined for some reason."; - } - enum dormant { - value 5; - description - "Waiting for some external event."; - } - enum not-present { - value 6; - description - "Some component (typically hardware) is missing."; - } - enum lower-layer-down { - value 7; - description - "Down due to state of lower-layer interface(s)."; - } - } - mandatory true; - description - "The current operational state of the interface. - - This leaf has the same semantics as ifOperStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifOperStatus"; - } - - leaf last-change { - type yang:date-and-time; - description - "The time the interface entered its current operational - state. If the current state was entered prior to the - last re-initialization of the local network management - subsystem, then this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifLastChange"; - } - - leaf if-index { - if-feature if-mib; - type int32 { - range "1..2147483647"; - } - mandatory true; - description - "The ifIndex value for the ifEntry represented by this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifIndex"; - } - - leaf phys-address { - type yang:phys-address; - description - "The interface's address at its protocol sub-layer. For - example, for an 802.x interface, this object normally - contains a MAC address. The interface's media-specific - modules must define the bit and byte ordering and the - format of the value of this object. For interfaces that do - not have such an address (e.g., a serial line), this node - is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifPhysAddress"; - } - - leaf-list higher-layer-if { - type interface-state-ref; - description - "A list of references to interfaces layered on top of this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf-list lower-layer-if { - type interface-state-ref; - description - "A list of references to interfaces layered underneath this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf speed { - type yang:gauge64; - units "bits / second"; - description - "An estimate of the interface's current bandwidth in bits - per second. For interfaces that do not vary in - bandwidth or for those where no accurate estimation can - be made, this node should contain the nominal bandwidth. - For interfaces that have no concept of bandwidth, this - node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - - ifSpeed, ifHighSpeed"; - } - - container statistics { - description - "A collection of interface-related statistics objects."; - - leaf discontinuity-time { - type yang:date-and-time; - mandatory true; - description - "The time on the most recent occasion at which any one or - more of this interface's counters suffered a - discontinuity. If no such discontinuities have occurred - since the last re-initialization of the local management - subsystem, then this node contains the time the local - management subsystem re-initialized itself."; - } - - leaf in-octets { - type yang:counter64; - description - "The total number of octets received on the interface, - including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; - } - leaf in-unicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were not addressed to a - multicast or broadcast address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; - } - leaf in-broadcast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were addressed to a broadcast - address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInBroadcastPkts"; - } - leaf in-multicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were addressed to a multicast - address at this sub-layer. For a MAC layer protocol, - this includes both Group and Functional addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInMulticastPkts"; - } - leaf in-discards { - type yang:counter32; - description - "The number of inbound packets which were chosen to be - discarded even though no errors had been detected to - prevent their being deliverable to a higher-layer - protocol. One possible reason for discarding such a - packet could be to free up buffer space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInDiscards"; - } - leaf in-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of inbound - packets that contained errors preventing them from being - deliverable to a higher-layer protocol. For character- - oriented or fixed-length interfaces, the number of - inbound transmission units that contained errors - preventing them from being deliverable to a higher-layer - protocol. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInErrors"; - } - leaf in-unknown-protos { - type yang:counter32; - description - "For packet-oriented interfaces, the number of packets - received via the interface which were discarded because - of an unknown or unsupported protocol. For - character-oriented or fixed-length interfaces that - support protocol multiplexing the number of transmission - units received via the interface which were discarded - because of an unknown or unsupported protocol. For any - interface that does not support protocol multiplexing, - this counter is not present. - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; - } - - leaf out-octets { - type yang:counter64; - description - "The total number of octets transmitted out of the - interface, including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; - } - leaf out-unicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were not addressed - to a multicast or broadcast address at this sub-layer, - including those that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; - } - leaf out-broadcast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were addressed to a - broadcast address at this sub-layer, including those - that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutBroadcastPkts"; - } - leaf out-multicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were addressed to a - multicast address at this sub-layer, including those - that were discarded or not sent. For a MAC layer - protocol, this includes both Group and Functional - addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutMulticastPkts"; - } - leaf out-discards { - type yang:counter32; - description - "The number of outbound packets which were chosen to be - discarded even though no errors had been detected to - prevent their being transmitted. One possible reason - for discarding such a packet could be to free up buffer - space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; - } - leaf out-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of outbound - packets that could not be transmitted because of errors. - For character-oriented or fixed-length interfaces, the - number of outbound transmission units that could not be - transmitted because of errors. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutErrors"; - } - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ietf-yang-types@2013-05-16.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ietf-yang-types@2013-05-16.yang deleted file mode 100644 index 6c82d9dea6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/ietf-yang-types@2013-05-16.yang +++ /dev/null @@ -1,471 +0,0 @@ -module ietf-yang-types { - - namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types"; - prefix "yang"; - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Kessens - - - WG Chair: Juergen Schoenwaelder - - - Editor: Juergen Schoenwaelder - "; - - description - "This module contains a collection of generally useful derived - YANG data types. - - Copyright (c) 2013 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - - revision 2013-05-16 { - description - "This revision adds the following new data types: - - yang-identifier - - hex-string - - uuid - - dotted-quad"; - reference - "RFC XXXX: Common YANG Data Types"; - } - - revision 2010-09-24 { - description - "Initial revision."; - reference - "RFC 6021: Common YANG Data Types"; - } - - /*** collection of counter and gauge types ***/ - - typedef counter32 { - type uint32; - description - "The counter32 type represents a non-negative integer - that monotonically increases until it reaches a - maximum value of 2^32-1 (4294967295 decimal), when it - wraps around and starts increasing again from zero. - - Counters have no defined 'initial' value, and thus, a - single value of a counter has (in general) no information - content. Discontinuities in the monotonically increasing - value normally occur at re-initialization of the - management system, and at other times as specified in the - description of a schema node using this type. If such - other times can occur, for example, the creation of - a schema node of type counter32 at times other than - re-initialization, then a corresponding schema node - should be defined, with an appropriate type, to indicate - the last discontinuity. - - The counter32 type should not be used for configuration - schema nodes. A default statement SHOULD NOT be used in - combination with the type counter32. - - In the value set and its semantics, this type is equivalent - to the Counter32 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 - (SMIv2)"; - } - - typedef zero-based-counter32 { - type yang:counter32; - default "0"; - description - "The zero-based-counter32 type represents a counter32 - that has the defined 'initial' value zero. - - A schema node of this type will be set to zero (0) on creation - and will thereafter increase monotonically until it reaches - a maximum value of 2^32-1 (4294967295 decimal), when it - wraps around and starts increasing again from zero. - - Provided that an application discovers a new schema node - of this type within the minimum time to wrap, it can use the - 'initial' value as a delta. It is important for a management - station to be aware of this minimum time and the actual time - between polls, and to discard data if the actual time is too - long or there is no defined minimum time. - - In the value set and its semantics, this type is equivalent - to the ZeroBasedCounter32 textual convention of the SMIv2."; - reference - "RFC 4502: Remote Network Monitoring Management Information - Base Version 2"; - } - - typedef counter64 { - type uint64; - description - "The counter64 type represents a non-negative integer - that monotonically increases until it reaches a - maximum value of 2^64-1 (18446744073709551615 decimal), - when it wraps around and starts increasing again from zero. - - Counters have no defined 'initial' value, and thus, a - single value of a counter has (in general) no information - content. Discontinuities in the monotonically increasing - value normally occur at re-initialization of the - management system, and at other times as specified in the - description of a schema node using this type. If such - other times can occur, for example, the creation of - a schema node of type counter64 at times other than - re-initialization, then a corresponding schema node - should be defined, with an appropriate type, to indicate - the last discontinuity. - - The counter64 type should not be used for configuration - schema nodes. A default statement SHOULD NOT be used in - combination with the type counter64. - - In the value set and its semantics, this type is equivalent - to the Counter64 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 - (SMIv2)"; - } - - typedef zero-based-counter64 { - type yang:counter64; - default "0"; - description - "The zero-based-counter64 type represents a counter64 that - has the defined 'initial' value zero. - - A schema node of this type will be set to zero (0) on creation - and will thereafter increase monotonically until it reaches - a maximum value of 2^64-1 (18446744073709551615 decimal), - when it wraps around and starts increasing again from zero. - - Provided that an application discovers a new schema node - of this type within the minimum time to wrap, it can use the - 'initial' value as a delta. It is important for a management - station to be aware of this minimum time and the actual time - between polls, and to discard data if the actual time is too - long or there is no defined minimum time. - - In the value set and its semantics, this type is equivalent - to the ZeroBasedCounter64 textual convention of the SMIv2."; - reference - "RFC 2856: Textual Conventions for Additional High Capacity - Data Types"; - } - - typedef gauge32 { - type uint32; - description - "The gauge32 type represents a non-negative integer, which - may increase or decrease, but shall never exceed a maximum - value, nor fall below a minimum value. The maximum value - cannot be greater than 2^32-1 (4294967295 decimal), and - the minimum value cannot be smaller than 0. The value of - a gauge32 has its maximum value whenever the information - being modeled is greater than or equal to its maximum - value, and has its minimum value whenever the information - being modeled is smaller than or equal to its minimum value. - If the information being modeled subsequently decreases - below (increases above) the maximum (minimum) value, the - gauge32 also decreases (increases). - - In the value set and its semantics, this type is equivalent - to the Gauge32 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 - (SMIv2)"; - } - - typedef gauge64 { - type uint64; - description - "The gauge64 type represents a non-negative integer, which - may increase or decrease, but shall never exceed a maximum - value, nor fall below a minimum value. The maximum value - cannot be greater than 2^64-1 (18446744073709551615), and - the minimum value cannot be smaller than 0. The value of - a gauge64 has its maximum value whenever the information - being modeled is greater than or equal to its maximum - value, and has its minimum value whenever the information - being modeled is smaller than or equal to its minimum value. - If the information being modeled subsequently decreases - below (increases above) the maximum (minimum) value, the - gauge64 also decreases (increases). - - In the value set and its semantics, this type is equivalent - to the CounterBasedGauge64 SMIv2 textual convention defined - in RFC 2856"; - reference - "RFC 2856: Textual Conventions for Additional High Capacity - Data Types"; - } - - /*** collection of identifier related types ***/ - - typedef object-identifier { - type string { - pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))' - + '(\.(0|([1-9]\d*)))*'; - } - description - "The object-identifier type represents administratively - assigned names in a registration-hierarchical-name tree. - - Values of this type are denoted as a sequence of numerical - non-negative sub-identifier values. Each sub-identifier - value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers - are separated by single dots and without any intermediate - whitespace. - - The ASN.1 standard restricts the value space of the first - sub-identifier to 0, 1, or 2. Furthermore, the value space - of the second sub-identifier is restricted to the range - 0 to 39 if the first sub-identifier is 0 or 1. Finally, - the ASN.1 standard requires that an object identifier - has always at least two sub-identifier. The pattern - captures these restrictions. - - Although the number of sub-identifiers is not limited, - module designers should realize that there may be - implementations that stick with the SMIv2 limit of 128 - sub-identifiers. - - This type is a superset of the SMIv2 OBJECT IDENTIFIER type - since it is not restricted to 128 sub-identifiers. Hence, - this type SHOULD NOT be used to represent the SMIv2 OBJECT - IDENTIFIER type, the object-identifier-128 type SHOULD be - used instead."; - reference - "ISO9834-1: Information technology -- Open Systems - Interconnection -- Procedures for the operation of OSI - Registration Authorities: General procedures and top - arcs of the ASN.1 Object Identifier tree"; - } - - typedef object-identifier-128 { - type object-identifier { - pattern '\d*(\.\d*){1,127}'; - } - description - "This type represents object-identifiers restricted to 128 - sub-identifiers. - - In the value set and its semantics, this type is equivalent - to the OBJECT IDENTIFIER type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 - (SMIv2)"; - } - - typedef yang-identifier { - type string { - length "1..max"; - pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*'; - pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*'; - } - description - "A YANG identifier string as defined in RFC 6020, page 163. - An identifier must start with an alphabetic character or - an underscore followed by an arbitrary sequence of - alphabetic or numeric characters, underscores, hyphens - or dots. - - A YANG identifier MUST NOT start with any possible - combination of the lower-case or upper-case character - sequence 'xml'."; - reference - "RFC 6020: YANG - A Data Modeling Language for the Network - Configuration Protocol (NETCONF)"; - } - - /*** collection of date and time related types ***/ - - typedef date-and-time { - type string { - pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?' - + '(Z|[\+\-]\d{2}:\d{2})'; - } - description - "The date-and-time type is a profile of the ISO 8601 - standard for representation of dates and times using the - Gregorian calendar. The profile is defined by the - date-time production in Section 5.6 of RFC 3339. - - The date-and-time type is compatible with the dateTime XML - schema type with the following notable exceptions: - - (a) The date-and-time type does not allow negative years. - - (b) The date-and-time time-offset -00:00 indicates an unknown - time zone (see RFC 3339) while -00:00 and +00:00 and Z all - represent the same time zone in dateTime. - - (c) The canonical format (see below) of data-and-time values - differs from the canonical format used by the dateTime XML - schema type, which requires all times to be in UTC using - the time-offset 'Z'. - - This type is not equivalent to the DateAndTime textual - convention of the SMIv2 since RFC 3339 uses a different - separator between full-date and full-time and provides - higher resolution of time-secfrac. - The canonical format for date-and-time values with a known time - zone uses a numeric time zone offset that is calculated using - the device's configured known offset to UTC time. A change of - the device's offset to UTC time will cause date-and-time values - to change accordingly. Such changes might happen periodically - in case a server follows automatically daylight saving time - (DST) time zone offset changes. The canonical format for - date-and-time values with an unknown time zone (usually - referring to the notion of local time) uses the time-offset - -00:00."; - reference - "RFC 3339: Date and Time on the Internet: Timestamps - RFC 2579: Textual Conventions for SMIv2 - XSD-TYPES: XML Schema Part 2: Datatypes Second Edition"; - } - - typedef timeticks { - type uint32; - description - "The timeticks type represents a non-negative integer that - represents the time, modulo 2^32 (4294967296 decimal), in - hundredths of a second between two epochs. When a schema - node is defined that uses this type, the description of - the schema node identifies both of the reference epochs. - - In the value set and its semantics, this type is equivalent - to the TimeTicks type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 - (SMIv2)"; - } - - typedef timestamp { - type yang:timeticks; - description - "The timestamp type represents the value of an associated - timeticks schema node at which a specific occurrence - happened. The specific occurrence must be defined in the - description of any schema node defined using this type. When - the specific occurrence occurred prior to the last time the - associated timeticks attribute was zero, then the timestamp - value is zero. Note that this requires all timestamp values - to be reset to zero when the value of the associated timeticks - attribute reaches 497+ days and wraps around to zero. - - The associated timeticks schema node must be specified - in the description of any schema node using this type. - In the value set and its semantics, this type is equivalent - to the TimeStamp textual convention of the SMIv2."; - reference - "RFC 2579: Textual Conventions for SMIv2"; - } - - /*** collection of generic address types ***/ - - typedef phys-address { - type string { - pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?'; - } - description - "Represents media- or physical-level addresses represented - as a sequence octets, each octet represented by two hexadecimal - numbers. Octets are separated by colons. The canonical - representation uses lowercase characters. - - In the value set and its semantics, this type is equivalent - to the PhysAddress textual convention of the SMIv2."; - reference - "RFC 2579: Textual Conventions for SMIv2"; - } - - typedef mac-address { - type string { - pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'; - } - description - "The mac-address type represents an IEEE 802 MAC address. - The canonical representation uses lowercase characters. - - In the value set and its semantics, this type is equivalent - to the MacAddress textual convention of the SMIv2."; - reference - "IEEE 802: IEEE Standard for Local and Metropolitan Area - Networks: Overview and Architecture - RFC 2579: Textual Conventions for SMIv2"; - } - - /*** collection of XML specific types ***/ - - typedef xpath1.0 { - type string; - description - "This type represents an XPATH 1.0 expression. - - When a schema node is defined that uses this type, the - description of the schema node MUST specify the XPath - context in which the XPath expression is evaluated."; - reference - "XPATH: XML Path Language (XPath) Version 1.0"; - } - - /*** collection of string types ***/ - - typedef hex-string { - type string { - pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?'; - } - description - "A hexadecimal string with octets represented as hex digits - separated by colons. The canonical representation uses - lowercase characters."; - } - - typedef uuid { - type string { - pattern '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-' - + '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'; - } - description - "A Universally Unique IDentifier in the string representation - defined in RFC 4122. The canonical representation uses - lowercase characters. - - The following is an example of a UUID in string representation: - f81d4fae-7dec-11d0-a765-00a0c91e6bf6 - "; - reference - "RFC 4122: A Universally Unique IDentifier (UUID) URN - Namespace"; - } - - typedef dotted-quad { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; - } - description - "An unsigned 32-bit number expressed in the dotted-quad - notation, i.e., four octets written as decimal numbers - and separated with the '.' (full stop) character."; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/sal-remote@2014-01-14.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/sal-remote@2014-01-14.yang deleted file mode 100644 index d12e252711..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/sal-remote@2014-01-14.yang +++ /dev/null @@ -1,98 +0,0 @@ -module sal-remote { - - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote"; - prefix "sal-remote"; - - - organization "Cisco Systems, Inc."; - contact "Martin Bobak "; - - description - "This module contains the definition of methods related to - sal remote model. - - Copyright (c)2013 Cisco Systems, Inc. All rights reserved. - - This program and the accompanying materials are made available - under the terms of the Eclipse Public License v1.0 which - accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html"; - - revision "2014-01-14" { - description - "Initial revision"; - } - - - typedef q-name { - type string; - reference - "http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#QName"; - } - - rpc create-data-change-event-subscription { - input { - leaf path { - type instance-identifier; - description "Subtree path. "; - } - } - output { - leaf stream-name { - type string; - description "Notification stream name."; - } - } - } - - notification data-changed-notification { - description "Data change notification."; - list data-change-event { - key path; - leaf path { - type instance-identifier; - } - leaf store { - type enumeration { - enum config; - enum operation; - } - } - leaf operation { - type enumeration { - enum created; - enum updated; - enum deleted; - } - } - anyxml data{ - description "DataObject "; - } - } - } - - rpc create-notification-stream { - input { - leaf-list notifications { - type q-name; - description "Notification QNames"; - } - } - output { - leaf notification-stream-identifier { - type string; - description "Unique notification stream identifier, in which notifications will be propagated"; - } - } - } - - rpc begin-transaction{ - output{ - anyxml data-modification-transaction{ - description "DataModificationTransaction xml"; - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/simple-nodes.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/simple-nodes.yang deleted file mode 100644 index 0dec051ac7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/simple-nodes.yang +++ /dev/null @@ -1,75 +0,0 @@ -module simple-nodes { - yang-version 1; - namespace "urn:opendaylight:simple-nodes"; - prefix "sn"; - - description - "test file containing yang data nodes"; - - revision "2013-07-30" { - description - "Initial revision."; - reference "will be defined"; - } - - container users { - leaf user { - type string; - } - - leaf group { - type string; - } - } - - list user { - key "name class"; - leaf name { - type string; - } - leaf full-name { - type string; - } - leaf class { - type string; - } - } - - list userWithoutClass { - key "name"; - leaf name { - type string; - } - leaf full-name { - type string; - } - } - - container food { - choice snack { - case sports-arena { - leaf pretzel { - type string; - } - leaf beer { - type string; - } - container nonalcoholic { - leaf beer { - type string; - } - } - } - case late-night { - leaf chocolate { - type enumeration { - enum dark; - enum milk; - enum first-available; - } - } - } - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/toaster.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/toaster.yang deleted file mode 100644 index 571ed0c86e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/yangs/toaster.yang +++ /dev/null @@ -1,197 +0,0 @@ - module toaster { - - yang-version 1; - - namespace - "http://netconfcentral.org/ns/toaster"; - - prefix toast; - - organization "Netconf Central"; - - contact - "Andy Bierman "; - - description - "YANG version of the TOASTER-MIB."; - - revision "2009-11-20" { - description - "Toaster module in progress."; - } - - - identity toast-type { - description - "Base for all bread types supported by the toaster. - New bread types not listed here nay be added in the - future."; - } - - identity white-bread { - base toast:toast-type; - description "White bread."; - } - - identity wheat-bread { - base toast-type; - description "Wheat bread."; - } - - identity wonder-bread { - base toast-type; - description "Wonder bread."; - } - - identity frozen-waffle { - base toast-type; - description "Frozen waffle."; - } - - identity frozen-bagel { - base toast-type; - description "Frozen bagel."; - } - - identity hash-brown { - base toast-type; - description "Hash browned potatos."; - } - - typedef DisplayString { - type string { - length "0 .. 255"; - } - description - "YANG version of the SMIv2 DisplayString TEXTUAL-CONVENTION."; - reference - "RFC 2579, section 2."; - - } - - container toaster { - presence - "Indicates the toaster service is available"; - description - "Top-level container for all toaster database objects."; - leaf toasterManufacturer { - type DisplayString; - config false; - mandatory true; - description - "The name of the toaster's manufacturer. For instance, - Microsoft Toaster."; - } - - leaf toasterModelNumber { - type DisplayString; - config false; - mandatory true; - description - "The name of the toaster's model. For instance, - Radiant Automatic."; - } - - leaf toasterStatus { - type enumeration { - enum "up" { - value 1; - description - "The toaster knob position is up. - No toast is being made now."; - } - enum "down" { - value 2; - description - "The toaster knob position is down. - Toast is being made now."; - } - } - config false; - mandatory true; - description - "This variable indicates the current state of - the toaster."; - } - } // container toaster - - rpc make-toast { - description - "Make some toast. - The toastDone notification will be sent when - the toast is finished. - An 'in-use' error will be returned if toast - is already being made. - A 'resource-denied' error will be returned - if the toaster service is disabled."; - input { - leaf toasterDoneness { - type uint32 { - range "1 .. 10"; - } - default '5'; - description - "This variable controls how well-done is the - ensuing toast. It should be on a scale of 1 to 10. - Toast made at 10 generally is considered unfit - for human consumption; toast made at 1 is warmed - lightly."; - } - - leaf toasterToastType { - type identityref { - base toast:toast-type; - } - default 'wheat-bread'; - description - "This variable informs the toaster of the type of - material that is being toasted. The toaster - uses this information, combined with - toasterDoneness, to compute for how - long the material must be toasted to achieve - the required doneness."; - } - } - } // rpc make-toast - - rpc testOutput { - output { - leaf textOut { - type string; - } - } - } - - rpc cancel-toast { - description - "Stop making toast, if any is being made. - A 'resource-denied' error will be returned - if the toaster service is disabled."; - } // rpc cancel-toast - - notification toastDone { - description - "Indicates that the toast in progress has completed."; - leaf toastStatus { - type enumeration { - enum "done" { - value 0; - description "The toast is done."; - } - enum "cancelled" { - value 1; - description - "The toast was cancelled."; - } - enum "error" { - value 2; - description - "The toaster service was disabled or - the toaster is broken."; - } - } - description - "Indicates the final toast status"; - } - } // notification toastDone - } // module toaster diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_augment_choice_container.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_augment_choice_container.json deleted file mode 100644 index e64e00ed32..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_augment_choice_container.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "augment-module:case-choice-case-container1": { - "augment-module:case-choice-case-leaf1": "stryng" - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_augment_container.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_augment_container.json deleted file mode 100644 index e2532f2876..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_augment_container.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "augment-module:cont-augment": { - "augment-module:leaf1": "stryng" - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_sub_container.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_sub_container.json deleted file mode 100644 index 22a1d15e5a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/json_sub_container.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "instance-identifier-module:cont1": { - "augment-module-leaf-list:lf11" : "/instance-identifier-module:cont/instance-identifier-module:cont1/augment-module-leaf-list:lflst11[.=\"lflst11_1\"]" - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/jsondata.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/jsondata.json deleted file mode 100644 index f616a8a95b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/jsondata.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "instance-identifier-module:cont": { - "cont1": { - "augment-module:lst11": [ - { - "keyvalue111":"value1", - "keyvalue112":"value2", - "augment-augment-module:lf111":"/instance-identifier-module:cont/instance-identifier-module:cont1/augment-module:lst11[augment-module:keyvalue111=\"value1\"][augment-module:keyvalue112=\"value2\"]/augment-augment-module:lf112", - "augment-augment-module:lf112":"lf112 value" - } - ] - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/jsondata_leaf_list.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/jsondata_leaf_list.json deleted file mode 100644 index 63be4b9d5d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/json/jsondata_leaf_list.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "instance-identifier-module:cont": { - "cont1": { - "augment-module-leaf-list:lf11" : "/instance-identifier-module:cont/instance-identifier-module:cont1/augment-module-leaf-list:lflst11[.=\"lflst11_1\"]" - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_augment_choice_container.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_augment_choice_container.xml deleted file mode 100644 index d73b3008b6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_augment_choice_container.xml +++ /dev/null @@ -1,3 +0,0 @@ - - stryng - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_augment_container.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_augment_container.xml deleted file mode 100644 index 6b35e9e967..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_augment_container.xml +++ /dev/null @@ -1,3 +0,0 @@ - - stryng - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_sub_container.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_sub_container.xml deleted file mode 100644 index f76e08dda0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xml_sub_container.xml +++ /dev/null @@ -1,6 +0,0 @@ - - lflst11_1 - lflst11_2 - lflst11_3 - /a:cont/a:cont1/b:lflst11[.="lflst11_1"] - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata.xml deleted file mode 100644 index bd558fb6b9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - value1 - value2 - /a:cont/a:cont1/b:lst11[b:keyvalue111="value1"][b:keyvalue112="value2"]/c:lf112 - lf112 value - - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata_leaf_list.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata_leaf_list.xml deleted file mode 100644 index 00d58c2cb7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata_leaf_list.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - lflst11_1 - lflst11_2 - lflst11_3 - /a:cont/a:cont1/b:lflst11[.="lflst11_1"] - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-augment-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-augment-module.yang deleted file mode 100644 index 546111c3d8..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-augment-module.yang +++ /dev/null @@ -1,21 +0,0 @@ -module augment-augment-module { - namespace "augment:augment:module"; - - prefix "aamodule"; - - import augment-module {prefix amodule; revision-date 2014-01-17;} - import instance-identifier-module {prefix imodule; revision-date 2014-01-17;} - - revision 2014-01-17 { - } - - augment "/imodule:cont/imodule:cont1/amodule:lst11" { - leaf lf111 { - type instance-identifier; - } - leaf lf112 { - type string; - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-module-leaf-list.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-module-leaf-list.yang deleted file mode 100644 index 54c305b208..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-module-leaf-list.yang +++ /dev/null @@ -1,20 +0,0 @@ -module augment-module-leaf-list { - namespace "augment:module:leaf:list"; - - prefix "amodulelflst"; - - import instance-identifier-module {prefix imodule; revision-date 2014-01-17;} - - revision 2014-01-27 { - } - - augment "/imodule:cont/imodule:cont1" { - leaf-list lflst11 { - type string; - } - leaf lf11 { - type instance-identifier; - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-module.yang deleted file mode 100644 index c918ef98ad..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/augment-module.yang +++ /dev/null @@ -1,63 +0,0 @@ -module augment-module { - namespace "augment:module"; - - prefix "amodule"; - - import instance-identifier-module {prefix imodule; revision-date 2014-01-17;} - - revision 2014-01-17 { - } - - augment "/imodule:cont/imodule:cont1" { - list lst11 { - key "keyvalue111 keyvalue112"; - leaf keyvalue111 { - type string; - } - leaf keyvalue112 { - type string; - } - } - } - - augment "/imodule:cont" { - container cont-augment { - leaf leaf1 { - type string; - } - } - } - - augment "/imodule:cont" { - choice augment-choice1 { - case case1 { - container case-container1 { - leaf case-leaf1 { - type string; - } - } - } - - case case2 { - container case-container2 { - leaf case-leaf2 { - type string; - } - } - } - } - } - - augment "/imodule:cont/augment-choice1/case1" { - choice augment-choice2 { - case case11 { - container case-choice-case-container1 { - leaf case-choice-case-leaf1 { - type string; - } - } - } - } - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/instance-identifier-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/instance-identifier-module.yang deleted file mode 100644 index 7a95a5ff0f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/yang/instance-identifier-module.yang +++ /dev/null @@ -1,13 +0,0 @@ -module instance-identifier-module { - namespace "instance:identifier:module"; - - prefix "iimodule"; - revision 2014-01-17 { - } - - container cont { - container cont1 { - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/invoke-rpc-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/invoke-rpc-module.yang deleted file mode 100644 index ad4883c064..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/invoke-rpc-module.yang +++ /dev/null @@ -1,30 +0,0 @@ -module invoke-rpc-module { - namespace "invoke:rpc:module"; - - prefix "inrpcmod"; - - revision 2013-12-3 { - - } - - rpc rpc-test { - input { - container cont { - leaf lf { - type string; - } - } - } - output { - container cont-out { - leaf lf-out { - type string; - } - } - } - } - - rpc rpc-noop { - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/json/rpc-input.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/json/rpc-input.json deleted file mode 100644 index 2ba5f27a4c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/json/rpc-input.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "invoke-rpc-module:input" : { - "cont" : { - "lf" : "lf-test" - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/json/rpc-output.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/json/rpc-output.json deleted file mode 100644 index 107f4c796f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/json/rpc-output.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "invoke-rpc-module:output" : { - "cont-out" : { - "lf-out" : "lf-test" - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-input.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-input.xml deleted file mode 100644 index 48fb557070..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-input.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - lf-test - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-output.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-output.xml deleted file mode 100644 index 3b11eb87a5..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/invoke-rpc/xml/rpc-output.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - lf-test - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/array-with-null.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/array-with-null.json deleted file mode 100644 index 995b3c6189..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/array-with-null.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "array-with-null-yang:cont": { - "lf":null - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/empty-data.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/empty-data.json deleted file mode 100644 index a6ad7f6272..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/empty-data.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cont": { - "lflst1":[], - "lflst2":[45] - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/empty-data1.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/empty-data1.json deleted file mode 100644 index b886fc9da9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/empty-data1.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "cont": { - "lf": - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/identity-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/identity-module.yang deleted file mode 100644 index 30890bf9c3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/identity-module.yang +++ /dev/null @@ -1,10 +0,0 @@ -module identity-module { - namespace "identity:module"; - - prefix "idemod"; - revision 2013-12-2 { - } - - identity iden { - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/identityref-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/identityref-module.yang deleted file mode 100644 index b90b533ce5..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/identityref-module.yang +++ /dev/null @@ -1,39 +0,0 @@ -module identityref-module { - namespace "identityref:module"; - - prefix "iderefmod"; - - import identity-module {prefix idemo; revision-date 2013-12-2;} - - revision 2013-12-2 { - } - - identity iden_local { - } - - container cont { - container cont1 { - leaf lf11 { - type identityref { - base "idemo:iden"; - } - } - leaf lf12 { - type identityref { - base "iden_local"; - } - } - leaf lf13 { - type identityref { - base "iden_local"; - } - } - leaf lf14 { - type identityref { - base "iden_local"; - } - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/json/data.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/json/data.json deleted file mode 100644 index 88cd6b43c3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/identityref/json/data.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "identityref:cont":{ - "cont1":{ - "lf11":"identity-module:iden", - "lf12":"identityref-module:iden_local", - "identityref-module:lf13":"identityref-module:iden_local", - "identityref-module:lf14":"identity-module:iden" - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/invalid-uri-character-in-value.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/invalid-uri-character-in-value.json deleted file mode 100644 index 8281546836..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/invalid-uri-character-in-value.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cont":{ - "lf1":"moduleName:value lf2" - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/augment-leafref-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/augment-leafref-module.yang deleted file mode 100644 index 766cc8153e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/augment-leafref-module.yang +++ /dev/null @@ -1,21 +0,0 @@ -module augment-leafref-module { - namespace "augment:leafref:module"; - - prefix "auglfrfmo"; - revision 2014-12-16 { - } - - - typedef leafreftype { - type leafref { - path "/cont/lf3"; - - } - } - - container cont { - leaf lf3 { - type string; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/json/data.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/json/data.json deleted file mode 100644 index df5bcefc8d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/json/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "leafref-module:cont":{ - "lf1":121, - "lf2":121, - "lf4":"pcc://39.39.39.39" - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/leafref-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/leafref-module.yang deleted file mode 100644 index 9b124a0fe6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/leafref/leafref-module.yang +++ /dev/null @@ -1,24 +0,0 @@ -module leafref-module { - namespace "leafref:module"; - - prefix "lfrfmo"; - - import augment-leafref-module {prefix augleafref; revision-date 2014-12-16;} - revision 2013-11-18 { - } - - container cont { - leaf lf1 { - type int32; - } - leaf lf2 { - type leafref { - path "/cont/lf1"; - } - } - leaf lf4 { - type augleafref:leafreftype; - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/multiple-items-in-list.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/multiple-items-in-list.json deleted file mode 100644 index 7702b8860f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/multiple-items-in-list.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "multiple-items:lst":[ - { - "lst1": [ - { - "lf11":"lf11_1" - }, - { - "lflst11":[ - 45 - ] - }, - { - "cont11":{ - } - }, - { - "lst11":[ - { - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/multiple-leaflist-items.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/multiple-leaflist-items.json deleted file mode 100644 index d8f0ce6654..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/multiple-leaflist-items.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "multiple-leaflist:lst": { - "lflst1":[45,55,66] - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-container-yang/simple-container.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-container-yang/simple-container.yang deleted file mode 100644 index 493101ced1..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-container-yang/simple-container.yang +++ /dev/null @@ -1,20 +0,0 @@ -module simple-container-yang { - namespace "simple:container:yang"; - - prefix "smpdtp"; - revision 2013-11-12 { - } - - container cont { - container cont1 { - } - list lst1 { - } - leaf-list lflst1 { - type string; - } - leaf lf1 { - type string; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-container.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-container.json deleted file mode 100644 index 1be414991e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-container.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "cont":{ - "cont1":{ - }, - "lst1": [ - { - } - ], - "lflst1":[ - "lflst1_1", - "lflst1_2" - ], - "lf1":"lf1" - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/1/simple-list1.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/1/simple-list1.yang deleted file mode 100644 index 0ce8ea428c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/1/simple-list1.yang +++ /dev/null @@ -1,20 +0,0 @@ -module simple-list-yang1 { - namespace "simple:list:yang1"; - - prefix "smplstyg"; - revision 2013-11-12 { - } - - list lst { - container cont1 { - } - list lst1 { - } - leaf-list lflst1 { - type string; - } - leaf lf1 { - type string; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/2/simple-list2.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/2/simple-list2.yang deleted file mode 100644 index 0872a4754d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/2/simple-list2.yang +++ /dev/null @@ -1,20 +0,0 @@ -module simple-list-yang2 { - namespace "simple:list:yang2"; - - prefix "smplstyg"; - revision 2013-11-12 { - } - - list lst { - container cont1 { - } - list lst1 { - } - leaf-list lflst1 { - type string; - } - leaf lf1 { - type string; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/3/multiple-items.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/3/multiple-items.yang deleted file mode 100644 index dcc17d53aa..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/3/multiple-items.yang +++ /dev/null @@ -1,24 +0,0 @@ -module multiple-items-yang { - namespace "multiple:items:yang"; - - prefix "mltitmsyg"; - revision 2013-11-12 { - } - - list lst { - list lst1 { - leaf lf11{ - type string; - } - leaf-list lflst11{ - type string; - } - container cont11{ - - } - list lst11{ - - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/4/array-with-null.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/4/array-with-null.yang deleted file mode 100644 index 869e406555..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list-yang/4/array-with-null.yang +++ /dev/null @@ -1,26 +0,0 @@ -module array-with-null-yang { - namespace "array:with:null:yang"; - - prefix "arwnlyn"; - revision 2013-11-12 { - } - - container cont{ - leaf lf{ - type empty; - } - leaf lf1{ - type string; - } - leaf lf2{ - type string; - } - leaf-list lflst1{ - type empty; - } - - leaf-list lflst2{ - type string; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list.json deleted file mode 100644 index d18ecc007e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/simple-list.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "simple-list:lst":[ - { - "cont1":{ - }, - "lst1": [ - { - } - ], - "lflst1":[ - "lflst1_1", - "lflst1_2" - ], - "lf1":"lf1" - } - ] -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/unsupported-json-format.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/unsupported-json-format.json deleted file mode 100644 index abc626739e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/unsupported-json-format.json +++ /dev/null @@ -1 +0,0 @@ -fffff \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level1.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level1.json deleted file mode 100644 index 594a802c0e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level1.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - - "cont":[ - { - }, - { - } - ] -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level2.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level2.json deleted file mode 100644 index af75a47e8b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - - "lst": { - }, - "lst1":[ - { - } - ] -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level3.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level3.json deleted file mode 100644 index 7288969971..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/json-to-nn/wrong-top-level3.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "lf":"hello" -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/json/jsondata.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/json/jsondata.json deleted file mode 100644 index f4a435e3bf..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/json/jsondata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "leafref-module:cont" : { - "lf4" : "/referenced-module:cont/referenced-module:lf1", - "lf2" : "/leafref-module:cont/leafref-module:lf1", - "lf3" : "/leafref-module:cont/leafref-module:lf2", - "lf5" : "/leafref-module:cont/leafref-module:lf3" - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/xml/xmldata.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/xml/xmldata.xml deleted file mode 100644 index 1b5ce835fc..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/xml/xmldata.xml +++ /dev/null @@ -1,6 +0,0 @@ - - /nsa:cont/nsa:lf1 - /nsa:cont/nsa:lf1 - /ns:cont/ns:lf2 - /nsa:cont/nsa:lf3 - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/yang/leafref-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/yang/leafref-module.yang deleted file mode 100644 index 9675b79ac9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/yang/leafref-module.yang +++ /dev/null @@ -1,54 +0,0 @@ -module leafref-module { - namespace "leafref:module"; - - - prefix "lfrfmodule"; - - import referenced-module { prefix refmod; revision-date 2014-04-17;} - - - revision 2014-04-17 { - } - - - container cont { - leaf lf1 { - type instance-identifier; - } - - leaf lf2 { - type leafref { - path "../lf1"; - } - } - - leaf lf3 { - type leafref { - path "/refmod:cont/refmod:lf1"; - } - } - - leaf lf4 { - type leafref { - path "/cont/lf1"; - } - } - - leaf lf5 { - type leafref { - path "../lf1"; - } - } - - list lst-with-lfref-key { - key "lfref-key"; - - leaf lfref-key { - type leafref { - path "/refmod:cont/refmod:id-ref"; - } - } - } - - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/yang/referenced-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/yang/referenced-module.yang deleted file mode 100644 index 05dd123eeb..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/yang/referenced-module.yang +++ /dev/null @@ -1,23 +0,0 @@ -module referenced-module { - namespace "referenced:module"; - - prefix "refmodule"; - revision 2014-04-17 { - } - - container cont { - leaf lf1 { - type instance-identifier; - } - - leaf id-ref { - type leafref { - path "../../id"; - } - } - } - - leaf id { - type string; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/iana-if-type.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/iana-if-type.yang deleted file mode 100644 index 7bd0003b5d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/iana-if-type.yang +++ /dev/null @@ -1,1517 +0,0 @@ -module iana-if-type { - namespace "urn:ietf:params:xml:ns:yang:iana-if-type"; - prefix ianaift; - - organization "IANA"; - contact - " Internet Assigned Numbers Authority - - Postal: ICANN - 4676 Admiralty Way, Suite 330 - Marina del Rey, CA 90292 - - Tel: +1 310 823 9358 - E-Mail: iana&iana.org"; - description - "This YANG module defines the iana-if-type typedef, which - contains YANG definitions for IANA-registered interface types. - - This YANG module is maintained by IANA, and reflects the - 'ifType definitions' registry. - - The latest revision of this YANG module can be obtained from - the IANA web site. - - Copyright (c) 2011 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - revision 2013-07-04 { - description - "Initial revision."; - reference - "RFC XXXX: IANA Interface Type YANG Module"; - } - - typedef iana-if-type { - type enumeration { - enum "other" { - value 1; - description - "None of the following"; - } - enum "regular1822" { - value 2; - } - enum "hdh1822" { - value 3; - } - enum "ddnX25" { - value 4; - } - enum "rfc877x25" { - value 5; - reference - "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer"; - } - enum "ethernetCsmacd" { - value 6; - description - "For all ethernet-like interfaces, regardless of speed, - as per RFC3635."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "iso88023Csmacd" { - value 7; - status deprecated; - description - "Deprecated via RFC3635. - Use ethernetCsmacd(6) instead."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "iso88024TokenBus" { - value 8; - } - enum "iso88025TokenRing" { - value 9; - } - enum "iso88026Man" { - value 10; - } - enum "starLan" { - value 11; - status deprecated; - description - "Deprecated via RFC3635. - Use ethernetCsmacd(6) instead."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "proteon10Mbit" { - value 12; - } - enum "proteon80Mbit" { - value 13; - } - enum "hyperchannel" { - value 14; - } - enum "fddi" { - value 15; - reference - "RFC 1512 - FDDI Management Information Base"; - } - enum "lapb" { - value 16; - reference - "RFC 1381 - SNMP MIB Extension for X.25 LAPB"; - } - enum "sdlc" { - value 17; - } - enum "ds1" { - value 18; - description - "DS1-MIB"; - reference - "RFC 4805 - Definitions of Managed Objects for the - DS1, J1, E1, DS2, and E2 Interface Types"; - } - enum "e1" { - value 19; - status obsolete; - description - "Obsolete see DS1-MIB"; - reference - "RFC 4805 - Definitions of Managed Objects for the - DS1, J1, E1, DS2, and E2 Interface Types"; - } - enum "basicISDN" { - value 20; - description - "see also RFC2127"; - } - enum "primaryISDN" { - value 21; - } - enum "propPointToPointSerial" { - value 22; - description - "proprietary serial"; - } - enum "ppp" { - value 23; - } - enum "softwareLoopback" { - value 24; - } - enum "eon" { - value 25; - description - "CLNP over IP"; - } - enum "ethernet3Mbit" { - value 26; - } - enum "nsip" { - value 27; - description - "XNS over IP"; - } - enum "slip" { - value 28; - description - "generic SLIP"; - } - enum "ultra" { - value 29; - description - "ULTRA technologies"; - } - enum "ds3" { - value 30; - description - "DS3-MIB"; - reference - "RFC 3896 - Definitions of Managed Objects for the - DS3/E3 Interface Type"; - } - enum "sip" { - value 31; - description - "SMDS, coffee"; - reference - "RFC 1694 - Definitions of Managed Objects for SMDS - Interfaces using SMIv2"; - } - enum "frameRelay" { - value 32; - description - "DTE only."; - reference - "RFC 2115 - Management Information Base for Frame Relay - DTEs Using SMIv2"; - } - enum "rs232" { - value 33; - reference - "RFC 1659 - Definitions of Managed Objects for RS-232-like - Hardware Devices using SMIv2"; - } - enum "para" { - value 34; - description - "parallel-port"; - reference - "RFC 1660 - Definitions of Managed Objects for - Parallel-printer-like Hardware Devices using - SMIv2"; - } - enum "arcnet" { - value 35; - description - "arcnet"; - } - enum "arcnetPlus" { - value 36; - description - "arcnet plus"; - } - enum "atm" { - value 37; - description - "ATM cells"; - } - enum "miox25" { - value 38; - reference - "RFC 1461 - SNMP MIB extension for Multiprotocol - Interconnect over X.25"; - } - enum "sonet" { - value 39; - description - "SONET or SDH"; - } - enum "x25ple" { - value 40; - reference - "RFC 2127 - ISDN Management Information Base using SMIv2"; - } - enum "iso88022llc" { - value 41; - } - enum "localTalk" { - value 42; - } - enum "smdsDxi" { - value 43; - } - enum "frameRelayService" { - value 44; - description - "FRNETSERV-MIB"; - reference - "RFC 2954 - Definitions of Managed Objects for Frame - Relay Service"; - } - enum "v35" { - value 45; - } - enum "hssi" { - value 46; - } - enum "hippi" { - value 47; - } - enum "modem" { - value 48; - description - "Generic modem"; - } - enum "aal5" { - value 49; - description - "AAL5 over ATM"; - } - enum "sonetPath" { - value 50; - } - enum "sonetVT" { - value 51; - } - enum "smdsIcip" { - value 52; - description - "SMDS InterCarrier Interface"; - } - enum "propVirtual" { - value 53; - description - "proprietary virtual/internal"; - reference - "RFC 2863 - The Interfaces Group MIB"; - } - enum "propMultiplexor" { - value 54; - description - "proprietary multiplexing"; - reference - "RFC 2863 - The Interfaces Group MIB"; - } - enum "ieee80212" { - value 55; - description - "100BaseVG"; - } - enum "fibreChannel" { - value 56; - description - "Fibre Channel"; - } - enum "hippiInterface" { - value 57; - description - "HIPPI interfaces"; - } - enum "frameRelayInterconnect" { - value 58; - status obsolete; - description - "Obsolete use either - frameRelay(32) or frameRelayService(44)."; - } - enum "aflane8023" { - value 59; - description - "ATM Emulated LAN for 802.3"; - } - enum "aflane8025" { - value 60; - description - "ATM Emulated LAN for 802.5"; - } - enum "cctEmul" { - value 61; - description - "ATM Emulated circuit"; - } - enum "fastEther" { - value 62; - status deprecated; - description - "Obsoleted via RFC3635. - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "isdn" { - value 63; - description - "ISDN and X.25"; - reference - "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN - in the Packet Mode"; - } - enum "v11" { - value 64; - description - "CCITT V.11/X.21"; - } - enum "v36" { - value 65; - description - "CCITT V.36"; - } - enum "g703at64k" { - value 66; - description - "CCITT G703 at 64Kbps"; - } - enum "g703at2mb" { - value 67; - status obsolete; - description - "Obsolete see DS1-MIB"; - } - enum "qllc" { - value 68; - description - "SNA QLLC"; - } - enum "fastEtherFX" { - value 69; - status deprecated; - description - "Obsoleted via RFC3635 - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "channel" { - value 70; - description - "channel"; - } - enum "ieee80211" { - value 71; - description - "radio spread spectrum"; - } - enum "ibm370parChan" { - value 72; - description - "IBM System 360/370 OEMI Channel"; - } - enum "escon" { - value 73; - description - "IBM Enterprise Systems Connection"; - } - enum "dlsw" { - value 74; - description - "Data Link Switching"; - } - enum "isdns" { - value 75; - description - "ISDN S/T interface"; - } - enum "isdnu" { - value 76; - description - "ISDN U interface"; - } - enum "lapd" { - value 77; - description - "Link Access Protocol D"; - } - enum "ipSwitch" { - value 78; - description - "IP Switching Objects"; - } - enum "rsrb" { - value 79; - description - "Remote Source Route Bridging"; - } - enum "atmLogical" { - value 80; - description - "ATM Logical Port"; - reference - "RFC 3606 - Definitions of Supplemental Managed Objects - for ATM Interface"; - } - enum "ds0" { - value 81; - description - "Digital Signal Level 0"; - reference - "RFC 2494 - Definitions of Managed Objects for the DS0 - and DS0 Bundle Interface Type"; - } - enum "ds0Bundle" { - value 82; - description - "group of ds0s on the same ds1"; - reference - "RFC 2494 - Definitions of Managed Objects for the DS0 - and DS0 Bundle Interface Type"; - } - enum "bsc" { - value 83; - description - "Bisynchronous Protocol"; - } - enum "async" { - value 84; - description - "Asynchronous Protocol"; - } - enum "cnr" { - value 85; - description - "Combat Net Radio"; - } - enum "iso88025Dtr" { - value 86; - description - "ISO 802.5r DTR"; - } - enum "eplrs" { - value 87; - description - "Ext Pos Loc Report Sys"; - } - enum "arap" { - value 88; - description - "Appletalk Remote Access Protocol"; - } - enum "propCnls" { - value 89; - description - "Proprietary Connectionless Protocol"; - } - enum "hostPad" { - value 90; - description - "CCITT-ITU X.29 PAD Protocol"; - } - enum "termPad" { - value 91; - description - "CCITT-ITU X.3 PAD Facility"; - } - enum "frameRelayMPI" { - value 92; - description - "Multiproto Interconnect over FR"; - } - enum "x213" { - value 93; - description - "CCITT-ITU X213"; - } - enum "adsl" { - value 94; - description - "Asymmetric Digital Subscriber Loop"; - } - enum "radsl" { - value 95; - description - "Rate-Adapt. Digital Subscriber Loop"; - } - enum "sdsl" { - value 96; - description - "Symmetric Digital Subscriber Loop"; - } - enum "vdsl" { - value 97; - description - "Very H-Speed Digital Subscrib. Loop"; - } - enum "iso88025CRFPInt" { - value 98; - description - "ISO 802.5 CRFP"; - } - enum "myrinet" { - value 99; - description - "Myricom Myrinet"; - } - enum "voiceEM" { - value 100; - description - "voice recEive and transMit"; - } - enum "voiceFXO" { - value 101; - description - "voice Foreign Exchange Office"; - } - enum "voiceFXS" { - value 102; - description - "voice Foreign Exchange Station"; - } - enum "voiceEncap" { - value 103; - description - "voice encapsulation"; - } - enum "voiceOverIp" { - value 104; - description - "voice over IP encapsulation"; - } - enum "atmDxi" { - value 105; - description - "ATM DXI"; - } - enum "atmFuni" { - value 106; - description - "ATM FUNI"; - } - enum "atmIma" { - value 107; - description - "ATM IMA"; - } - enum "pppMultilinkBundle" { - value 108; - description - "PPP Multilink Bundle"; - } - enum "ipOverCdlc" { - value 109; - description - "IBM ipOverCdlc"; - } - enum "ipOverClaw" { - value 110; - description - "IBM Common Link Access to Workstn"; - } - enum "stackToStack" { - value 111; - description - "IBM stackToStack"; - } - enum "virtualIpAddress" { - value 112; - description - "IBM VIPA"; - } - enum "mpc" { - value 113; - description - "IBM multi-protocol channel support"; - } - enum "ipOverAtm" { - value 114; - description - "IBM ipOverAtm"; - reference - "RFC 2320 - Definitions of Managed Objects for Classical IP - and ARP Over ATM Using SMIv2 (IPOA-MIB)"; - } - enum "iso88025Fiber" { - value 115; - description - "ISO 802.5j Fiber Token Ring"; - } - enum "tdlc" { - value 116; - description - "IBM twinaxial data link control"; - } - enum "gigabitEthernet" { - value 117; - status deprecated; - description - "Obsoleted via RFC3635 - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "hdlc" { - value 118; - description - "HDLC"; - } - enum "lapf" { - value 119; - description - "LAP F"; - } - enum "v37" { - value 120; - description - "V.37"; - } - enum "x25mlp" { - value 121; - description - "Multi-Link Protocol"; - } - enum "x25huntGroup" { - value 122; - description - "X25 Hunt Group"; - } - enum "transpHdlc" { - value 123; - description - "Transp HDLC"; - } - enum "interleave" { - value 124; - description - "Interleave channel"; - } - enum "fast" { - value 125; - description - "Fast channel"; - } - enum "ip" { - value 126; - description - "IP (for APPN HPR in IP networks)"; - } - enum "docsCableMaclayer" { - value 127; - description - "CATV Mac Layer"; - } - enum "docsCableDownstream" { - value 128; - description - "CATV Downstream interface"; - } - enum "docsCableUpstream" { - value 129; - description - "CATV Upstream interface"; - } - enum "a12MppSwitch" { - value 130; - description - "Avalon Parallel Processor"; - } - enum "tunnel" { - value 131; - description - "Encapsulation interface"; - } - enum "coffee" { - value 132; - description - "coffee pot"; - reference - "RFC 2325 - Coffee MIB"; - } - enum "ces" { - value 133; - description - "Circuit Emulation Service"; - } - enum "atmSubInterface" { - value 134; - description - "ATM Sub Interface"; - } - enum "l2vlan" { - value 135; - description - "Layer 2 Virtual LAN using 802.1Q"; - } - enum "l3ipvlan" { - value 136; - description - "Layer 3 Virtual LAN using IP"; - } - enum "l3ipxvlan" { - value 137; - description - "Layer 3 Virtual LAN using IPX"; - } - enum "digitalPowerline" { - value 138; - description - "IP over Power Lines"; - } - enum "mediaMailOverIp" { - value 139; - description - "Multimedia Mail over IP"; - } - enum "dtm" { - value 140; - description - "Dynamic syncronous Transfer Mode"; - } - enum "dcn" { - value 141; - description - "Data Communications Network"; - } - enum "ipForward" { - value 142; - description - "IP Forwarding Interface"; - } - enum "msdsl" { - value 143; - description - "Multi-rate Symmetric DSL"; - } - enum "ieee1394" { - value 144; - description - "IEEE1394 High Performance Serial Bus"; - } - enum "if-gsn" { - value 145; - description - "HIPPI-6400"; - } - enum "dvbRccMacLayer" { - value 146; - description - "DVB-RCC MAC Layer"; - } - enum "dvbRccDownstream" { - value 147; - description - "DVB-RCC Downstream Channel"; - } - enum "dvbRccUpstream" { - value 148; - description - "DVB-RCC Upstream Channel"; - } - enum "atmVirtual" { - value 149; - description - "ATM Virtual Interface"; - } - enum "mplsTunnel" { - value 150; - description - "MPLS Tunnel Virtual Interface"; - } - enum "srp" { - value 151; - description - "Spatial Reuse Protocol"; - } - enum "voiceOverAtm" { - value 152; - description - "Voice Over ATM"; - } - enum "voiceOverFrameRelay" { - value 153; - description - "Voice Over Frame Relay"; - } - enum "idsl" { - value 154; - description - "Digital Subscriber Loop over ISDN"; - } - enum "compositeLink" { - value 155; - description - "Avici Composite Link Interface"; - } - enum "ss7SigLink" { - value 156; - description - "SS7 Signaling Link"; - } - enum "propWirelessP2P" { - value 157; - description - "Prop. P2P wireless interface"; - } - enum "frForward" { - value 158; - description - "Frame Forward Interface"; - } - enum "rfc1483" { - value 159; - description - "Multiprotocol over ATM AAL5"; - reference - "RFC 1483 - Multiprotocol Encapsulation over ATM - Adaptation Layer 5"; - } - enum "usb" { - value 160; - description - "USB Interface"; - } - enum "ieee8023adLag" { - value 161; - description - "IEEE 802.3ad Link Aggregate"; - } - enum "bgppolicyaccounting" { - value 162; - description - "BGP Policy Accounting"; - } - enum "frf16MfrBundle" { - value 163; - description - "FRF .16 Multilink Frame Relay"; - } - enum "h323Gatekeeper" { - value 164; - description - "H323 Gatekeeper"; - } - enum "h323Proxy" { - value 165; - description - "H323 Voice and Video Proxy"; - } - enum "mpls" { - value 166; - description - "MPLS"; - } - enum "mfSigLink" { - value 167; - description - "Multi-frequency signaling link"; - } - enum "hdsl2" { - value 168; - description - "High Bit-Rate DSL - 2nd generation"; - } - enum "shdsl" { - value 169; - description - "Multirate HDSL2"; - } - enum "ds1FDL" { - value 170; - description - "Facility Data Link 4Kbps on a DS1"; - } - enum "pos" { - value 171; - description - "Packet over SONET/SDH Interface"; - } - enum "dvbAsiIn" { - value 172; - description - "DVB-ASI Input"; - } - enum "dvbAsiOut" { - value 173; - description - "DVB-ASI Output"; - } - enum "plc" { - value 174; - description - "Power Line Communtications"; - } - enum "nfas" { - value 175; - description - "Non Facility Associated Signaling"; - } - enum "tr008" { - value 176; - description - "TR008"; - } - enum "gr303RDT" { - value 177; - description - "Remote Digital Terminal"; - } - enum "gr303IDT" { - value 178; - description - "Integrated Digital Terminal"; - } - enum "isup" { - value 179; - description - "ISUP"; - } - enum "propDocsWirelessMaclayer" { - value 180; - description - "Cisco proprietary Maclayer"; - } - enum "propDocsWirelessDownstream" { - value 181; - description - "Cisco proprietary Downstream"; - } - enum "propDocsWirelessUpstream" { - value 182; - description - "Cisco proprietary Upstream"; - } - enum "hiperlan2" { - value 183; - description - "HIPERLAN Type 2 Radio Interface"; - } - enum "propBWAp2Mp" { - value 184; - description - "PropBroadbandWirelessAccesspt2multipt use of this value - for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f - is deprecated and ieee80216WMAN(237) should be used - instead."; - } - enum "sonetOverheadChannel" { - value 185; - description - "SONET Overhead Channel"; - } - enum "digitalWrapperOverheadChannel" { - value 186; - description - "Digital Wrapper"; - } - enum "aal2" { - value 187; - description - "ATM adaptation layer 2"; - } - enum "radioMAC" { - value 188; - description - "MAC layer over radio links"; - } - enum "atmRadio" { - value 189; - description - "ATM over radio links"; - } - enum "imt" { - value 190; - description - "Inter Machine Trunks"; - } - enum "mvl" { - value 191; - description - "Multiple Virtual Lines DSL"; - } - enum "reachDSL" { - value 192; - description - "Long Reach DSL"; - } - enum "frDlciEndPt" { - value 193; - description - "Frame Relay DLCI End Point"; - } - enum "atmVciEndPt" { - value 194; - description - "ATM VCI End Point"; - } - enum "opticalChannel" { - value 195; - description - "Optical Channel"; - } - enum "opticalTransport" { - value 196; - description - "Optical Transport"; - } - enum "propAtm" { - value 197; - description - "Proprietary ATM"; - } - enum "voiceOverCable" { - value 198; - description - "Voice Over Cable Interface"; - } - enum "infiniband" { - value 199; - description - "Infiniband"; - } - enum "teLink" { - value 200; - description - "TE Link"; - } - enum "q2931" { - value 201; - description - "Q.2931"; - } - enum "virtualTg" { - value 202; - description - "Virtual Trunk Group"; - } - enum "sipTg" { - value 203; - description - "SIP Trunk Group"; - } - enum "sipSig" { - value 204; - description - "SIP Signaling"; - } - enum "docsCableUpstreamChannel" { - value 205; - description - "CATV Upstream Channel"; - } - enum "econet" { - value 206; - description - "Acorn Econet"; - } - enum "pon155" { - value 207; - description - "FSAN 155Mb Symetrical PON interface"; - } - enum "pon622" { - value 208; - description - "FSAN622Mb Symetrical PON interface"; - } - enum "bridge" { - value 209; - description - "Transparent bridge interface"; - } - enum "linegroup" { - value 210; - description - "Interface common to multiple lines"; - } - enum "voiceEMFGD" { - value 211; - description - "voice E&M Feature Group D"; - } - enum "voiceFGDEANA" { - value 212; - description - "voice FGD Exchange Access North American"; - } - enum "voiceDID" { - value 213; - description - "voice Direct Inward Dialing"; - } - enum "mpegTransport" { - value 214; - description - "MPEG transport interface"; - } - enum "sixToFour" { - value 215; - status deprecated; - description - "6to4 interface (DEPRECATED)"; - reference - "RFC 4087 - IP Tunnel MIB"; - } - enum "gtp" { - value 216; - description - "GTP (GPRS Tunneling Protocol)"; - } - enum "pdnEtherLoop1" { - value 217; - description - "Paradyne EtherLoop 1"; - } - enum "pdnEtherLoop2" { - value 218; - description - "Paradyne EtherLoop 2"; - } - enum "opticalChannelGroup" { - value 219; - description - "Optical Channel Group"; - } - enum "homepna" { - value 220; - description - "HomePNA ITU-T G.989"; - } - enum "gfp" { - value 221; - description - "Generic Framing Procedure (GFP)"; - } - enum "ciscoISLvlan" { - value 222; - description - "Layer 2 Virtual LAN using Cisco ISL"; - } - enum "actelisMetaLOOP" { - value 223; - description - "Acteleis proprietary MetaLOOP High Speed Link"; - } - enum "fcipLink" { - value 224; - description - "FCIP Link"; - } - enum "rpr" { - value 225; - description - "Resilient Packet Ring Interface Type"; - } - enum "qam" { - value 226; - description - "RF Qam Interface"; - } - enum "lmp" { - value 227; - description - "Link Management Protocol"; - reference - "RFC 4327 - Link Management Protocol (LMP) Management - Information Base (MIB)"; - } - enum "cblVectaStar" { - value 228; - description - "Cambridge Broadband Networks Limited VectaStar"; - } - enum "docsCableMCmtsDownstream" { - value 229; - description - "CATV Modular CMTS Downstream Interface"; - } - enum "adsl2" { - value 230; - status deprecated; - description - "Asymmetric Digital Subscriber Loop Version 2 - (DEPRECATED/OBSOLETED - please use adsl2plus(238) - instead)"; - reference - "RFC 4706 - Definitions of Managed Objects for Asymmetric - Digital Subscriber Line 2 (ADSL2)"; - } - enum "macSecControlledIF" { - value 231; - description - "MACSecControlled"; - } - enum "macSecUncontrolledIF" { - value 232; - description - "MACSecUncontrolled"; - } - enum "aviciOpticalEther" { - value 233; - description - "Avici Optical Ethernet Aggregate"; - } - enum "atmbond" { - value 234; - description - "atmbond"; - } - enum "voiceFGDOS" { - value 235; - description - "voice FGD Operator Services"; - } - enum "mocaVersion1" { - value 236; - description - "MultiMedia over Coax Alliance (MoCA) Interface - as documented in information provided privately to IANA"; - } - enum "ieee80216WMAN" { - value 237; - description - "IEEE 802.16 WMAN interface"; - } - enum "adsl2plus" { - value 238; - description - "Asymmetric Digital Subscriber Loop Version 2, - Version 2 Plus and all variants"; - } - enum "dvbRcsMacLayer" { - value 239; - description - "DVB-RCS MAC Layer"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "dvbTdm" { - value 240; - description - "DVB Satellite TDM"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "dvbRcsTdma" { - value 241; - description - "DVB-RCS TDMA"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "x86Laps" { - value 242; - description - "LAPS based on ITU-T X.86/Y.1323"; - } - enum "wwanPP" { - value 243; - description - "3GPP WWAN"; - } - enum "wwanPP2" { - value 244; - description - "3GPP2 WWAN"; - } - enum "voiceEBS" { - value 245; - description - "voice P-phone EBS physical interface"; - } - enum "ifPwType" { - value 246; - description - "Pseudowire interface type"; - reference - "RFC 5601 - Pseudowire (PW) Management Information Base"; - } - enum "ilan" { - value 247; - description - "Internal LAN on a bridge per IEEE 802.1ap"; - } - enum "pip" { - value 248; - description - "Provider Instance Port on a bridge per IEEE 802.1ah PBB"; - } - enum "aluELP" { - value 249; - description - "Alcatel-Lucent Ethernet Link Protection"; - } - enum "gpon" { - value 250; - description - "Gigabit-capable passive optical networks (G-PON) as per - ITU-T G.948"; - } - enum "vdsl2" { - value 251; - description - "Very high speed digital subscriber line Version 2 - (as per ITU-T Recommendation G.993.2)"; - reference - "RFC 5650 - Definitions of Managed Objects for Very High - Speed Digital Subscriber Line 2 (VDSL2)"; - } - enum "capwapDot11Profile" { - value 252; - description - "WLAN Profile Interface"; - reference - "RFC 5834 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Binding MIB for - IEEE 802.11"; - } - enum "capwapDot11Bss" { - value 253; - description - "WLAN BSS Interface"; - reference - "RFC 5834 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Binding MIB for - IEEE 802.11"; - } - enum "capwapWtpVirtualRadio" { - value 254; - description - "WTP Virtual Radio Interface"; - reference - "RFC 5833 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Base MIB"; - } - enum "bits" { - value 255; - description - "bitsport"; - } - enum "docsCableUpstreamRfPort" { - value 256; - description - "DOCSIS CATV Upstream RF Port"; - } - enum "cableDownstreamRfPort" { - value 257; - description - "CATV downstream RF port"; - } - enum "vmwareVirtualNic" { - value 258; - description - "VMware Virtual Network Interface"; - } - enum "ieee802154" { - value 259; - description - "IEEE 802.15.4 WPAN interface"; - reference - "IEEE 802.15.4-2006"; - } - enum "otnOdu" { - value 260; - description - "OTN Optical Data Unit"; - } - enum "otnOtu" { - value 261; - description - "OTN Optical channel Transport Unit"; - } - enum "ifVfiType" { - value 262; - description - "VPLS Forwarding Instance Interface Type"; - } - enum "g9981" { - value 263; - description - "G.998.1 bonded interface"; - } - enum "g9982" { - value 264; - description - "G.998.2 bonded interface"; - } - enum "g9983" { - value 265; - description - "G.998.3 bonded interface"; - } - enum "aluEpon" { - value 266; - description - "Ethernet Passive Optical Networks (E-PON)"; - } - enum "aluEponOnu" { - value 267; - description - "EPON Optical Network Unit"; - } - enum "aluEponPhysicalUni" { - value 268; - description - "EPON physical User to Network interface"; - } - enum "aluEponLogicalLink" { - value 269; - description - "The emulation of a point-to-point link over the EPON - layer"; - } - enum "aluGponOnu" { - value 270; - description - "GPON Optical Network Unit"; - reference - "ITU-T G.984.2"; - } - enum "aluGponPhysicalUni" { - value 271; - description - "GPON physical User to Network interface"; - reference - "ITU-T G.984.2"; - } - enum "vmwareNicTeam" { - value 272; - description - "VMware NIC Team"; - } - // value 273 reserved by IANA - } - description - "This data type is used as the syntax of the 'type' - leaf in the 'interface' list in the YANG module - ietf-interface. - - The definition of this typedef with the - addition of newly assigned values is published - periodically by the IANA, in either the Assigned - Numbers RFC, or some derivative of it specific to - Internet Network Management number assignments. (The - latest arrangements can be obtained by contacting the - IANA.) - - Requests for new values should be made to IANA via - email (iana&iana.org)."; - reference - "IANA ifType definitions registry. - "; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-inet-types.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-inet-types.yang deleted file mode 100644 index de20febbb7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-inet-types.yang +++ /dev/null @@ -1,418 +0,0 @@ - module ietf-inet-types { - - namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types"; - prefix "inet"; - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Partain - - - WG Chair: David Kessens - - - Editor: Juergen Schoenwaelder - "; - - description - "This module contains a collection of generally useful derived - YANG data types for Internet addresses and related things. - - Copyright (c) 2010 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, is permitted pursuant to, and subject to the license - terms contained in, the Simplified BSD License set forth in Section - 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC 6021; see - the RFC itself for full legal notices."; - - revision 2010-09-24 { - description - "Initial revision."; - reference - "RFC 6021: Common YANG Data Types"; - } - - /*** collection of protocol field related types ***/ - - typedef ip-version { - type enumeration { - enum unknown { - value "0"; - description - "An unknown or unspecified version of the Internet protocol."; - } - enum ipv4 { - value "1"; - description - "The IPv4 protocol as defined in RFC 791."; - } - enum ipv6 { - value "2"; - description - "The IPv6 protocol as defined in RFC 2460."; - } - } - description - "This value represents the version of the IP protocol. - - In the value set and its semantics, this type is equivalent - to the InetVersion textual convention of the SMIv2."; - reference - "RFC 791: Internet Protocol - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - typedef dscp { - type uint8 { - range "0..63"; - } - description - "The dscp type represents a Differentiated Services Code-Point - that may be used for marking packets in a traffic stream. - - In the value set and its semantics, this type is equivalent - to the Dscp textual convention of the SMIv2."; - reference - "RFC 3289: Management Information Base for the Differentiated - Services Architecture - RFC 2474: Definition of the Differentiated Services Field - (DS Field) in the IPv4 and IPv6 Headers - RFC 2780: IANA Allocation Guidelines For Values In - the Internet Protocol and Related Headers"; - } - - typedef ipv6-flow-label { - type uint32 { - range "0..1048575"; - } - description - "The flow-label type represents flow identifier or Flow Label - in an IPv6 packet header that may be used to discriminate - traffic flows. - - In the value set and its semantics, this type is equivalent - to the IPv6FlowLabel textual convention of the SMIv2."; - reference - "RFC 3595: Textual Conventions for IPv6 Flow Label - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"; - } - - typedef port-number { - type uint16 { - range "0..65535"; - } - description - "The port-number type represents a 16-bit port number of an - Internet transport layer protocol such as UDP, TCP, DCCP, or - SCTP. Port numbers are assigned by IANA. A current list of - all assignments is available from . - - Note that the port number value zero is reserved by IANA. In - situations where the value zero does not make sense, it can - be excluded by subtyping the port-number type. - - In the value set and its semantics, this type is equivalent - to the InetPortNumber textual convention of the SMIv2."; - reference - "RFC 768: User Datagram Protocol - RFC 793: Transmission Control Protocol - RFC 4960: Stream Control Transmission Protocol - RFC 4340: Datagram Congestion Control Protocol (DCCP) - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - /*** collection of autonomous system related types ***/ - - typedef as-number { - type uint32; - description - "The as-number type represents autonomous system numbers - which identify an Autonomous System (AS). An AS is a set - of routers under a single technical administration, using - an interior gateway protocol and common metrics to route - packets within the AS, and using an exterior gateway - protocol to route packets to other ASs'. IANA maintains - the AS number space and has delegated large parts to the - regional registries. - - Autonomous system numbers were originally limited to 16 - bits. BGP extensions have enlarged the autonomous system - number space to 32 bits. This type therefore uses an uint32 - base type without a range restriction in order to support - a larger autonomous system number space. - - In the value set and its semantics, this type is equivalent - to the InetAutonomousSystemNumber textual convention of - the SMIv2."; - reference - "RFC 1930: Guidelines for creation, selection, and registration - of an Autonomous System (AS) - RFC 4271: A Border Gateway Protocol 4 (BGP-4) - RFC 4893: BGP Support for Four-octet AS Number Space - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - /*** collection of IP address and hostname related types ***/ - - typedef ip-address { - type union { - type inet:ipv4-address; - type inet:ipv6-address; - } - description - "The ip-address type represents an IP address and is IP - version neutral. The format of the textual representations - implies the IP version."; - } - - typedef ipv4-address { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' - + '(%[\p{N}\p{L}]+)?'; - } - description - "The ipv4-address type represents an IPv4 address in - dotted-quad notation. The IPv4 address may include a zone - index, separated by a % sign. - - The zone index is used to disambiguate identical address - values. For link-local addresses, the zone index will - typically be the interface index number or the name of an - interface. If the zone index is not present, the default - zone of the device will be used. - - The canonical format for the zone index is the numerical - format"; - } - - typedef ipv6-address { - type string { - pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' - + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' - + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' - + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' - + '(%[\p{N}\p{L}]+)?'; - pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' - + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' - + '(%.+)?'; - } - description - "The ipv6-address type represents an IPv6 address in full, - mixed, shortened, and shortened-mixed notation. The IPv6 - address may include a zone index, separated by a % sign. - - The zone index is used to disambiguate identical address - values. For link-local addresses, the zone index will - typically be the interface index number or the name of an - interface. If the zone index is not present, the default - zone of the device will be used. - - The canonical format of IPv6 addresses uses the compressed - format described in RFC 4291, Section 2.2, item 2 with the - following additional rules: the :: substitution must be - applied to the longest sequence of all-zero 16-bit chunks - in an IPv6 address. If there is a tie, the first sequence - of all-zero 16-bit chunks is replaced by ::. Single - all-zero 16-bit chunks are not compressed. The canonical - format uses lowercase characters and leading zeros are - not allowed. The canonical format for the zone index is - the numerical format as described in RFC 4007, Section - 11.2."; - reference - "RFC 4291: IP Version 6 Addressing Architecture - RFC 4007: IPv6 Scoped Address Architecture - RFC 5952: A Recommendation for IPv6 Address Text Representation"; - } - - typedef ip-prefix { - type union { - type inet:ipv4-prefix; - type inet:ipv6-prefix; - } - description - "The ip-prefix type represents an IP prefix and is IP - version neutral. The format of the textual representations - implies the IP version."; - } - - typedef ipv4-prefix { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' - + '/(([0-9])|([1-2][0-9])|(3[0-2]))'; - } - description - "The ipv4-prefix type represents an IPv4 address prefix. - The prefix length is given by the number following the - slash character and must be less than or equal to 32. - - A prefix length value of n corresponds to an IP address - mask that has n contiguous 1-bits from the most - significant bit (MSB) and all other bits set to 0. - - The canonical format of an IPv4 prefix has all bits of - the IPv4 address set to zero that are not part of the - IPv4 prefix."; - } - - typedef ipv6-prefix { - type string { - pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' - + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' - + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' - + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' - + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'; - pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' - + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' - + '(/.+)'; - } - description - "The ipv6-prefix type represents an IPv6 address prefix. - The prefix length is given by the number following the - slash character and must be less than or equal 128. - - A prefix length value of n corresponds to an IP address - mask that has n contiguous 1-bits from the most - significant bit (MSB) and all other bits set to 0. - - The IPv6 address should have all bits that do not belong - to the prefix set to zero. - - The canonical format of an IPv6 prefix has all bits of - the IPv6 address set to zero that are not part of the - IPv6 prefix. Furthermore, IPv6 address is represented - in the compressed format described in RFC 4291, Section - 2.2, item 2 with the following additional rules: the :: - substitution must be applied to the longest sequence of - all-zero 16-bit chunks in an IPv6 address. If there is - a tie, the first sequence of all-zero 16-bit chunks is - replaced by ::. Single all-zero 16-bit chunks are not - compressed. The canonical format uses lowercase - characters and leading zeros are not allowed."; - reference - "RFC 4291: IP Version 6 Addressing Architecture"; - } - - /*** collection of domain name and URI types ***/ - - typedef domain-name { - type string { - pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' - + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' - + '|\.'; - length "1..253"; - } - description - "The domain-name type represents a DNS domain name. The - name SHOULD be fully qualified whenever possible. - - Internet domain names are only loosely specified. Section - 3.5 of RFC 1034 recommends a syntax (modified in Section - 2.1 of RFC 1123). The pattern above is intended to allow - for current practice in domain name use, and some possible - future expansion. It is designed to hold various types of - domain names, including names used for A or AAAA records - (host names) and other records, such as SRV records. Note - that Internet host names have a stricter syntax (described - in RFC 952) than the DNS recommendations in RFCs 1034 and - 1123, and that systems that want to store host names in - schema nodes using the domain-name type are recommended to - adhere to this stricter standard to ensure interoperability. - - The encoding of DNS names in the DNS protocol is limited - to 255 characters. Since the encoding consists of labels - prefixed by a length bytes and there is a trailing NULL - byte, only 253 characters can appear in the textual dotted - notation. - - The description clause of schema nodes using the domain-name - type MUST describe when and how these names are resolved to - IP addresses. Note that the resolution of a domain-name value - may require to query multiple DNS records (e.g., A for IPv4 - and AAAA for IPv6). The order of the resolution process and - which DNS record takes precedence can either be defined - explicitely or it may depend on the configuration of the - resolver. - - Domain-name values use the US-ASCII encoding. Their canonical - format uses lowercase US-ASCII characters. Internationalized - domain names MUST be encoded in punycode as described in RFC - 3492"; - reference - "RFC 952: DoD Internet Host Table Specification - RFC 1034: Domain Names - Concepts and Facilities - RFC 1123: Requirements for Internet Hosts -- Application - and Support - RFC 2782: A DNS RR for specifying the location of services - (DNS SRV) - RFC 3492: Punycode: A Bootstring encoding of Unicode for - Internationalized Domain Names in Applications - (IDNA) - RFC 5891: Internationalizing Domain Names in Applications - (IDNA): Protocol"; - } - - typedef host { - type union { - type inet:ip-address; - type inet:domain-name; - } - description - "The host type represents either an IP address or a DNS - domain name."; - } - - typedef uri { - type string; - description - "The uri type represents a Uniform Resource Identifier - (URI) as defined by STD 66. - - Objects using the uri type MUST be in US-ASCII encoding, - and MUST be normalized as described by RFC 3986 Sections - 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary - percent-encoding is removed, and all case-insensitive - characters are set to lowercase except for hexadecimal - digits, which are normalized to uppercase as described in - Section 6.2.2.1. - - The purpose of this normalization is to help provide - unique URIs. Note that this normalization is not - sufficient to provide uniqueness. Two URIs that are - textually distinct after this normalization may still be - equivalent. - - Objects using the uri type may restrict the schemes that - they permit. For example, 'data:' and 'urn:' schemes - might not be appropriate. - - A zero-length URI is not a valid URI. This can be used to - express 'URI absent' where required. - - In the value set and its semantics, this type is equivalent - to the Uri SMIv2 textual convention defined in RFC 5017."; - reference - "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax - RFC 3305: Report from the Joint W3C/IETF URI Planning Interest - Group: Uniform Resource Identifiers (URIs), URLs, - and Uniform Resource Names (URNs): Clarifications - and Recommendations - RFC 5017: MIB Textual Conventions for Uniform Resource - Identifiers (URIs)"; - } - - } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-interfaces@2013-07-04.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-interfaces@2013-07-04.yang deleted file mode 100644 index 9db753c440..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-interfaces@2013-07-04.yang +++ /dev/null @@ -1,673 +0,0 @@ -module ietf-interfaces { - - namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces"; - prefix if; - - import ietf-yang-types { - prefix yang; - } - import iana-if-type { - prefix ianaift; - } - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Kessens - - - WG Chair: Juergen Schoenwaelder - - - Editor: Martin Bjorklund - "; - - description - "This module contains a collection of YANG definitions for - managing network interfaces. - - Copyright (c) 2013 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - revision 2013-07-04 { - description - "Initial revision."; - reference - "RFC XXXX: A YANG Data Model for Interface Management"; - } - - /* Typedefs */ - - typedef interface-ref { - type leafref { - path "/if:interfaces/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - configured interfaces."; - } - - typedef interface-state-ref { - type leafref { - path "/if:interfaces-state/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - the operationally present interfaces."; - } - - /* Features */ - - feature arbitrary-names { - description - "This feature indicates that the device allows user-controlled - interfaces to be named arbitrarily."; - } - - feature pre-provisioning { - description - "This feature indicates that the device supports - pre-provisioning of interface configuration, i.e., it is - possible to configure an interface whose physical interface - hardware is not present on the device."; - } - - feature if-mib { - description - "This feature indicates that the device implements IF-MIB."; - reference - "RFC 2863: The Interfaces Group MIB"; - } - - /* Data nodes */ - - container interfaces { - description - "Interface configuration parameters."; - - list interface { - key "name"; - - description - "The list of configured interfaces on the device. - - The operational state of an interface is available in the - /interfaces-state/interface list. If the configuration of a - system-controlled interface cannot be used by the system - (e.g., the interface hardware present does not match the - interface type), then the configuration is not applied to - the system-controlled interface shown in the - /interfaces-state/interface list. If the the configuration - of a user-controlled interface cannot be used by the system, - the configured interface is not instantiated in the - /interfaces-state/interface list."; - - leaf name { - type string; - description - "The name of the interface. - - A device MAY restrict the allowed values for this leaf, - possibly depending on the type of the interface. - - For system-controlled interfaces, this leaf is the - device-specific name of the interface. The 'config false' - list /interfaces-state/interface contains the currently - existing interfaces on the device. - - If a client tries to create configuration for a - system-controlled interface that is not present in the - /interfaces-state/interface list, the server MAY reject - the request, if the implementation does not support - pre-provisioning of interfaces, or if the name refers to - an interface that can never exist in the system. A - NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case. - - If the device supports pre-provisioning of interface - configuration, the feature 'pre-provisioning' is - advertised. - - If the device allows arbitrarily named user-controlled - interfaces, the feature 'arbitrary-names' is advertised. - - When a configured user-controlled interface is created by - the system, it is instantiated with the same name in the - /interface-state/interface list. Since the name in that - list MAY be mapped to ifName by an implementation, such an - implementation MUST restrict the allowed values for this - leaf so that it matches the restrictions of ifName. - - If a NETCONF server that implements this restriction is - sent a value that doesn't match the restriction, it MUST - reply with an rpc-error with the error-tag - 'invalid-value'."; - } - - leaf description { - type string; - description - "A textual description of the interface. - - This leaf MAY be mapped to ifAlias by an implementation. - Such an implementation MUST restrict the allowed values - for this leaf so that it matches the restrictions of - ifAlias. - - If a NETCONF server that implements this restriction is - sent a value that doesn't match the restriction, it MUST - reply with an rpc-error with the error-tag - 'invalid-value'. - - Since ifAlias is defined to be stored in non-volatile - storage, the MIB implementation MUST map ifAlias to the - value of 'description' in the persistently stored - datastore. - - Specifically, if the device supports ':startup', when - ifAlias is read the device MUST return the value of - 'description' in the 'startup' datastore, and when it is - written, it MUST be written to the 'running' and 'startup' - datastores. Note that it is up to the implementation if - it modifies this single leaf in 'startup', or if it - performs an implicit copy-config from 'running' to - 'startup'. - - If the device does not support ':startup', ifAlias MUST - be mapped to the 'description' leaf in the 'running' - datastore."; - reference - "RFC 2863: The Interfaces Group MIB - ifAlias"; - } - - leaf type { - type ianaift:iana-if-type; - mandatory true; - description - "The type of the interface. - - When an interface entry is created, a server MAY - initialize the type leaf with a valid value, e.g., if it - is possible to derive the type from the name of the - interface. - - If a client tries to set the type of an interface to a - value that can never be used by the system, e.g., if the - type is not supported or if the type does not match the - name of the interface, the server MUST reject the request. - A NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf enabled { - type boolean; - default "true"; - description - "This leaf contains the configured, desired state of the - interface. - - Systems that implement the IF-MIB use the value of this - leaf in the 'running' datastore to set - IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry - has been initialized, as described in RFC 2863. - - Changes in this leaf in the 'running' datastore are - reflected in ifAdminStatus, but if ifAdminStatus is - changed over SNMP, this leaf is not affected."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf link-up-down-trap-enable { - if-feature if-mib; - type enumeration { - enum enabled { - value 1; - } - enum disabled { - value 2; - } - } - description - "Controls whether linkUp/linkDown SNMP notifications - should be generated for this interface. - - If this node is not configured, the value 'enabled' is - operationally used by the server for interfaces which do - not operate on top of any other interface (i.e., there are - no 'lower-layer-if' entries), and 'disabled' otherwise."; - reference - "RFC 2863: The Interfaces Group MIB - - ifLinkUpDownTrapEnable"; - } - } - } - - container interfaces-state { - config false; - description - "Data nodes for the operational state of interfaces."; - - list interface { - key "name"; - - description - "The list of interfaces on the device. - - System-controlled interfaces created by the system are - always present in this list, whether they are configured or - not."; - - leaf name { - type string; - description - "The name of the interface. - - This leaf MAY be mapped to ifName by an implementation."; - reference - "RFC 2863: The Interfaces Group MIB - ifName"; - } - - leaf type { - type ianaift:iana-if-type; - mandatory true; - description - "The type of the interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf admin-status { - if-feature if-mib; - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "Not ready to pass packets and not in some test mode."; - } - enum testing { - value 3; - description - "In some test mode."; - } - } - mandatory true; - description - "The desired state of the interface. - - This leaf has the same read semantics as ifAdminStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf oper-status { - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "The interface does not pass any packets."; - } - enum testing { - value 3; - description - "In some test mode. No operational packets can - be passed."; - } - enum unknown { - value 4; - description - "Status cannot be determined for some reason."; - } - enum dormant { - value 5; - description - "Waiting for some external event."; - } - enum not-present { - value 6; - description - "Some component (typically hardware) is missing."; - } - enum lower-layer-down { - value 7; - description - "Down due to state of lower-layer interface(s)."; - } - } - mandatory true; - description - "The current operational state of the interface. - - This leaf has the same semantics as ifOperStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifOperStatus"; - } - - leaf last-change { - type yang:date-and-time; - description - "The time the interface entered its current operational - state. If the current state was entered prior to the - last re-initialization of the local network management - subsystem, then this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifLastChange"; - } - - leaf if-index { - if-feature if-mib; - type int32 { - range "1..2147483647"; - } - mandatory true; - description - "The ifIndex value for the ifEntry represented by this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifIndex"; - } - - leaf phys-address { - type yang:phys-address; - description - "The interface's address at its protocol sub-layer. For - example, for an 802.x interface, this object normally - contains a MAC address. The interface's media-specific - modules must define the bit and byte ordering and the - format of the value of this object. For interfaces that do - not have such an address (e.g., a serial line), this node - is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifPhysAddress"; - } - - leaf-list higher-layer-if { - type interface-state-ref; - description - "A list of references to interfaces layered on top of this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf-list lower-layer-if { - type interface-state-ref; - description - "A list of references to interfaces layered underneath this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf speed { - type yang:gauge64; - units "bits / second"; - description - "An estimate of the interface's current bandwidth in bits - per second. For interfaces that do not vary in - bandwidth or for those where no accurate estimation can - be made, this node should contain the nominal bandwidth. - For interfaces that have no concept of bandwidth, this - node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - - ifSpeed, ifHighSpeed"; - } - - container statistics { - description - "A collection of interface-related statistics objects."; - - leaf discontinuity-time { - type yang:date-and-time; - mandatory true; - description - "The time on the most recent occasion at which any one or - more of this interface's counters suffered a - discontinuity. If no such discontinuities have occurred - since the last re-initialization of the local management - subsystem, then this node contains the time the local - management subsystem re-initialized itself."; - } - - leaf in-octets { - type yang:counter64; - description - "The total number of octets received on the interface, - including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; - } - leaf in-unicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were not addressed to a - multicast or broadcast address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; - } - leaf in-broadcast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were addressed to a broadcast - address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInBroadcastPkts"; - } - leaf in-multicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were addressed to a multicast - address at this sub-layer. For a MAC layer protocol, - this includes both Group and Functional addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInMulticastPkts"; - } - leaf in-discards { - type yang:counter32; - description - "The number of inbound packets which were chosen to be - discarded even though no errors had been detected to - prevent their being deliverable to a higher-layer - protocol. One possible reason for discarding such a - packet could be to free up buffer space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInDiscards"; - } - leaf in-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of inbound - packets that contained errors preventing them from being - deliverable to a higher-layer protocol. For character- - oriented or fixed-length interfaces, the number of - inbound transmission units that contained errors - preventing them from being deliverable to a higher-layer - protocol. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInErrors"; - } - leaf in-unknown-protos { - type yang:counter32; - description - "For packet-oriented interfaces, the number of packets - received via the interface which were discarded because - of an unknown or unsupported protocol. For - character-oriented or fixed-length interfaces that - support protocol multiplexing the number of transmission - units received via the interface which were discarded - because of an unknown or unsupported protocol. For any - interface that does not support protocol multiplexing, - this counter is not present. - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; - } - - leaf out-octets { - type yang:counter64; - description - "The total number of octets transmitted out of the - interface, including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; - } - leaf out-unicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were not addressed - to a multicast or broadcast address at this sub-layer, - including those that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; - } - leaf out-broadcast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were addressed to a - broadcast address at this sub-layer, including those - that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutBroadcastPkts"; - } - leaf out-multicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were addressed to a - multicast address at this sub-layer, including those - that were discarded or not sent. For a MAC layer - protocol, this includes both Group and Functional - addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutMulticastPkts"; - } - leaf out-discards { - type yang:counter32; - description - "The number of outbound packets which were chosen to be - discarded even though no errors had been detected to - prevent their being transmitted. One possible reason - for discarding such a packet could be to free up buffer - space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; - } - leaf out-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of outbound - packets that could not be transmitted because of errors. - For character-oriented or fixed-length interfaces, the - number of outbound transmission units that could not be - transmitted because of errors. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutErrors"; - } - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-restconf@2013-10-19.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-restconf@2013-10-19.yang deleted file mode 100644 index 16766b0979..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-restconf@2013-10-19.yang +++ /dev/null @@ -1,684 +0,0 @@ -module ietf-restconf { - namespace "urn:ietf:params:xml:ns:yang:ietf-restconf"; - prefix "restconf"; - - import ietf-yang-types { prefix yang; } - import ietf-inet-types { prefix inet; } - - organization - "IETF NETCONF (Network Configuration) Working Group"; - - contact - "Editor: Andy Bierman - - - Editor: Martin Bjorklund - - - Editor: Kent Watsen - - - Editor: Rex Fernando - "; - - description - "This module contains conceptual YANG specifications - for the YANG Patch and error content that is used in - RESTCONF protocol messages. A conceptual container - representing the RESTCONF API nodes (media type - application/yang.api). - - Note that the YANG definitions within this module do not - represent configuration data of any kind. - The YANG grouping statements provide a normative syntax - for XML and JSON message encoding purposes. - Copyright (c) 2013 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - - // RFC Ed.: remove this note - // Note: extracted from draft-bierman-netconf-restconf-02.txt - - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - revision 2013-10-19 { - description - "Initial revision."; - reference - "RFC XXXX: RESTCONF Protocol."; - } - - typedef data-resource-identifier { - type string { - length "1 .. max"; - } - description - "Contains a Data Resource Identifier formatted string - to identify a specific data node. The data node that - uses this data type SHOULD define the document root - for data resource identifiers. The default document - root is the target datastore conceptual root node. - Data resource identifiers are defined relative to - this document root."; - reference - "RFC XXXX: [sec. 5.3.1.1 ABNF For Data Resource Identifiers]"; - } - - // this typedef is TBD; not currently used - typedef datastore-identifier { - type union { - type enumeration { - enum candidate { - description - "Identifies the NETCONF shared candidate datastore."; - reference - "RFC 6241, section 8.3"; - } - enum running { - description - "Identifies the NETCONF running datastore."; - reference - "RFC 6241, section 5.1"; - } - enum startup { - description - "Identifies the NETCONF startup datastore."; - reference - "RFC 6241, section 8.7"; - } - } - type string; - } - description - "Contains a string to identify a specific datastore. - The enumerated datastore identifier values are - reserved for standard datastore names."; - } - - typedef revision-identifier { - type string { - pattern '\d{4}-\d{2}-\d{2}'; - } - description - "Represents a specific date in YYYY-MM-DD format. - TBD: make pattern more precise to exclude leading zeros."; - } - - grouping yang-patch { - description - "A grouping that contains a YANG container - representing the syntax and semantics of a - YANG Patch edit request message."; - - container yang-patch { - description - "Represents a conceptual sequence of datastore edits, - called a patch. Each patch is given a client-assigned - patch identifier. Each edit MUST be applied - in ascending order, and all edits MUST be applied. - If any errors occur, then the target datastore MUST NOT - be changed by the patch operation. - - A patch MUST be validated by the server to be a - well-formed message before any of the patch edits - are validated or attempted. - - YANG datastore validation (defined in RFC 6020, section - 8.3.3) is performed after all edits have been - individually validated. - - It is possible for a datastore constraint violation to occur - due to any node in the datastore, including nodes not - included in the edit list. Any validation errors MUST - be reported in the reply message."; - - reference - "RFC 6020, section 8.3."; - - leaf patch-id { - type string; - description - "An arbitrary string provided by the client to identify - the entire patch. This value SHOULD be present in any - audit logging records generated by the server for the - patch. Error messages returned by the server pertaining - to this patch will be identified by this patch-id value."; - } - - leaf comment { - type string { - length "0 .. 1024"; - } - description - "An arbitrary string provided by the client to describe - the entire patch. This value SHOULD be present in any - audit logging records generated by the server for the - patch."; - } - - list edit { - key edit-id; - ordered-by user; - - description - "Represents one edit within the YANG Patch - request message."; - leaf edit-id { - type string; - description - "Arbitrary string index for the edit. - Error messages returned by the server pertaining - to a specific edit will be identified by this - value."; - } - - leaf operation { - type enumeration { - enum create { - description - "The target data node is created using the - supplied value, only if it does not already - exist."; - } - enum delete { - description - "Delete the target node, only if the data resource - currently exists, otherwise return an error."; - } - enum insert { - description - "Insert the supplied value into a user-ordered - list or leaf-list entry. The target node must - represent a new data resource."; - } - enum merge { - description - "The supplied value is merged with the target data - node."; - } - enum move { - description - "Move the target node. Reorder a user-ordered - list or leaf-list. The target node must represent - an existing data resource."; - } - enum replace { - description - "The supplied value is used to replace the target - data node."; - } - enum remove { - description - "Delete the target node if it currently exists."; - } - } - mandatory true; - description - "The datastore operation requested for the associated - edit entry"; - } - - leaf target { - type data-resource-identifier; - mandatory true; - description - "Identifies the target data resource for the edit - operation."; - } - - leaf point { - when "(../operation = 'insert' or " + - "../operation = 'move') and " + - "(../where = 'before' or ../where = 'after')" { - description - "Point leaf only applies for insert or move - operations, before or after an existing entry."; - } - type data-resource-identifier; - description - "The absolute URL path for the data node that is being - used as the insertion point or move point for the - target of this edit entry."; - } - - leaf where { - when "../operation = 'insert' or ../operation = 'move'" { - description - "Where leaf only applies for insert or move - operations."; - } - type enumeration { - enum before { - description - "Insert or move a data node before the data resource - identified by the 'point' parameter."; - } - enum after { - description - "Insert or move a data node after the data resource - identified by the 'point' parameter."; - } - enum first { - description - "Insert or move a data node so it becomes ordered - as the first entry."; - } - enum last { - description - "Insert or move a data node so it becomes ordered - as the last entry."; - } - - } - default last; - description - "Identifies where a data resource will be inserted or - moved. YANG only allows these operations for - list and leaf-list data nodes that are ordered-by - user."; - } - - anyxml value { - when "(../operation = 'create' or " + - "../operation = 'merge' " + - "or ../operation = 'replace' or " + - "../operation = 'insert')" { - description - "Value node only used for create, merge, - replace, and insert operations"; - } - description - "Value used for this edit operation."; - } - } - } - - } // grouping yang-patch - - - grouping yang-patch-status { - - description - "A grouping that contains a YANG container - representing the syntax and semantics of - YANG Patch status response message."; - - container yang-patch-status { - description - "A container representing the response message - sent by the server after a YANG Patch edit - request message has been processed."; - - leaf patch-id { - type string; - description - "The patch-id value used in the request"; - } - - choice global-status { - description - "Report global errors or complete success. - If there is no case selected then errors - are reported in the edit-status container."; - - case global-errors { - uses errors; - description - "This container will be present if global - errors unrelated to a specific edit occurred."; - } - leaf ok { - type empty; - description - "This leaf will be present if the request succeeded - and there are no errors reported in the edit-status - container."; - } - } - - container edit-status { - description - "This container will be present if there are - edit-specific status responses to report."; - - list edit { - key edit-id; - - description - "Represents a list of status responses, - corresponding to edits in the YANG Patch - request message. If an edit entry was - skipped or not reached by the server, - then this list will not contain a corresponding - entry for that edit."; - - leaf edit-id { - type string; - description - "Response status is for the edit list entry - with this edit-id value."; - } - choice edit-status-choice { - description - "A choice between different types of status - responses for each edit entry."; - leaf ok { - type empty; - description - "This edit entry was invoked without any - errors detected by the server associated - with this edit."; - } - leaf location { - type inet:uri; - description - "Contains the Location header value that would be - returned if this edit causes a new resource to be - created. If the edit identified by the same edit-id - value was successfully invoked and a new resource - was created, then this field will be returned - instead of 'ok'."; - } - case errors { - uses errors; - description - "The server detected errors associated with the - edit identified by the same edit-id value."; - } - } - } - } - } - } // grouping yang-patch-status - - - grouping errors { - - description - "A grouping that contains a YANG container - representing the syntax and semantics of a - YANG Patch errors report within a response message."; - - container errors { - config false; // needed so list error does not need a key - description - "Represents an error report returned by the server if - a request results in an error."; - - list error { - description - "An entry containing information about one - specific error that occurred while processing - a RESTCONF request."; - reference "RFC 6241, Section 4.3"; - - leaf error-type { - type enumeration { - enum transport { - description "The transport layer"; - } - enum rpc { - description "The rpc or notification layer"; - } - enum protocol { - description "The protocol operation layer"; - } - enum application { - description "The server application layer"; - } - } - mandatory true; - description - "The protocol layer where the error occurred."; - } - - leaf error-tag { - type string; - mandatory true; - description - "The enumerated error tag."; - } - - leaf error-app-tag { - type string; - description - "The application-specific error tag."; - } - - leaf error-path { - type data-resource-identifier; - description - "The target data resource identifier associated - with the error, if any."; - } - leaf error-message { - type string; - description - "A message describing the error."; - } - - container error-info { - description - "A container allowing additional information - to be included in the error report."; - // arbitrary anyxml content here - } - } - } - } // grouping errors - - - grouping restconf { - - description - "A grouping that contains a YANG container - representing the syntax and semantics of - the RESTCONF API resource."; - - container restconf { - description - "Conceptual container representing the - application/yang.api resource type."; - - container config { - description - "Container representing the application/yang.datastore - resource type. Represents the conceptual root of the - unified configuration datastore containing YANG data - nodes. The child nodes of this container are - configuration data resources (application/yang.data) - defined as top-level YANG data nodes from the modules - advertised by the server in /restconf/modules."; - } - - container operational { - description - "Container representing the application/yang.datastore - resource type. Represents the conceptual root of the - operational data supported by the server. The child - nodes of this container are operational data resources - (application/yang.data) defined as top-level - YANG data nodes from the modules advertised by - the server in /restconf/modules."; - } - - container modules { - description - "Contains a list of module description entries. - These modules are currently loaded into the server."; - - list module { - key "name revision"; - description - "Each entry represents one module currently - supported by the server."; - - leaf name { - type yang:yang-identifier; - description "The YANG module name."; - } - leaf revision { - type union { - type revision-identifier; - type string { length 0; } - } - description - "The YANG module revision date. An empty string is - used if no revision statement is present in the - YANG module."; - } - leaf namespace { - type inet:uri; - mandatory true; - description - "The XML namespace identifier for this module."; - } - leaf-list feature { - type yang:yang-identifier; - description - "List of YANG feature names from this module that are - supported by the server."; - } - leaf-list deviation { - type yang:yang-identifier; - description - "List of YANG deviation module names used by this - server to modify the conformance of the module - associated with this entry."; - } - } - } - - container operations { - description - "Container for all operation resources - (application/yang.operation), - - Each resource is represented as an empty leaf with the - name of the RPC operation from the YANG rpc statement. - - E.g.; - - POST /restconf/operations/show-log-errors - - leaf show-log-errors { - type empty; - } - "; - } - - container streams { - description - "Container representing the notification event streams - supported by the server."; - reference - "RFC 5277, Section 3.4, element."; - - list stream { - key name; - description - "Each entry describes an event stream supported by - the server."; - - leaf name { - type string; - description "The stream name"; - reference "RFC 5277, Section 3.4, element."; - } - - leaf description { - type string; - description "Description of stream content"; - reference - "RFC 5277, Section 3.4, element."; - } - - leaf replay-support { - type boolean; - description - "Indicates if replay buffer supported for this stream"; - reference - "RFC 5277, Section 3.4, element."; - } - - leaf replay-log-creation-time { - type yang:date-and-time; - description - "Indicates the time the replay log for this stream - was created."; - reference - "RFC 5277, Section 3.4, - element."; - } - - leaf events { - type empty; - description - "Represents the entry point for establishing - notification delivery via server sent events."; - } - } - } - - leaf version { - type enumeration { - enum "1.0" { - description - "Version 1.0 of the RESTCONF protocol."; - } - } - config false; - description - "Contains the RESTCONF protocol version."; - } - } - } // grouping restconf - - - grouping notification { - description - "Contains the notification message wrapper definition."; - - container notification { - description - "RESTCONF notification message wrapper."; - leaf event-time { - type yang:date-and-time; - mandatory true; - description - "The time the event was generated by the - event source."; - reference - "RFC 5277, section 4, element."; - } - - /* The YANG-specific notification container is encoded - * after the 'event-time' element. The format - * corresponds to the notificationContent element - * in RFC 5277, section 4. For example: - * - * module example-one { - * ... - * notification event1 { ... } - * - * } - * - * Encoded as element 'event1' in the namespace - * for module 'example-one'. - */ - } - } // grouping notification - - } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-yang-types.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-yang-types.yang deleted file mode 100644 index 07e50b3913..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/ietf-yang-types.yang +++ /dev/null @@ -1,417 +0,0 @@ - module ietf-yang-types { - - namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types"; - prefix "yang"; - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Partain - - - WG Chair: David Kessens - - - Editor: Juergen Schoenwaelder - "; - - description - "This module contains a collection of generally useful derived - YANG data types. - - Copyright (c) 2010 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, is permitted pursuant to, and subject to the license - terms contained in, the Simplified BSD License set forth in Section - 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC 6021; see - the RFC itself for full legal notices."; - - revision 2010-09-24 { - description - "Initial revision."; - reference - "RFC 6021: Common YANG Data Types"; - } - - /*** collection of counter and gauge types ***/ - - typedef counter32 { - type uint32; - description - "The counter32 type represents a non-negative integer - that monotonically increases until it reaches a - maximum value of 2^32-1 (4294967295 decimal), when it - wraps around and starts increasing again from zero. - - Counters have no defined 'initial' value, and thus, a - single value of a counter has (in general) no information - content. Discontinuities in the monotonically increasing - value normally occur at re-initialization of the - management system, and at other times as specified in the - description of a schema node using this type. If such - other times can occur, for example, the creation of - a schema node of type counter32 at times other than - re-initialization, then a corresponding schema node - should be defined, with an appropriate type, to indicate - the last discontinuity. - - The counter32 type should not be used for configuration - schema nodes. A default statement SHOULD NOT be used in - combination with the type counter32. - - In the value set and its semantics, this type is equivalent - to the Counter32 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef zero-based-counter32 { - type yang:counter32; - default "0"; - description - "The zero-based-counter32 type represents a counter32 - that has the defined 'initial' value zero. - - A schema node of this type will be set to zero (0) on creation - and will thereafter increase monotonically until it reaches - a maximum value of 2^32-1 (4294967295 decimal), when it - wraps around and starts increasing again from zero. - - Provided that an application discovers a new schema node - of this type within the minimum time to wrap, it can use the - 'initial' value as a delta. It is important for a management - station to be aware of this minimum time and the actual time - between polls, and to discard data if the actual time is too - long or there is no defined minimum time. - - In the value set and its semantics, this type is equivalent - to the ZeroBasedCounter32 textual convention of the SMIv2."; - reference - "RFC 4502: Remote Network Monitoring Management Information - Base Version 2"; - } - - typedef counter64 { - type uint64; - description - "The counter64 type represents a non-negative integer - that monotonically increases until it reaches a - maximum value of 2^64-1 (18446744073709551615 decimal), - when it wraps around and starts increasing again from zero. - - Counters have no defined 'initial' value, and thus, a - single value of a counter has (in general) no information - content. Discontinuities in the monotonically increasing - value normally occur at re-initialization of the - management system, and at other times as specified in the - description of a schema node using this type. If such - other times can occur, for example, the creation of - a schema node of type counter64 at times other than - re-initialization, then a corresponding schema node - should be defined, with an appropriate type, to indicate - the last discontinuity. - - The counter64 type should not be used for configuration - schema nodes. A default statement SHOULD NOT be used in - combination with the type counter64. - - In the value set and its semantics, this type is equivalent - to the Counter64 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef zero-based-counter64 { - type yang:counter64; - default "0"; - description - "The zero-based-counter64 type represents a counter64 that - has the defined 'initial' value zero. - - A schema node of this type will be set to zero (0) on creation - and will thereafter increase monotonically until it reaches - a maximum value of 2^64-1 (18446744073709551615 decimal), - when it wraps around and starts increasing again from zero. - - Provided that an application discovers a new schema node - of this type within the minimum time to wrap, it can use the - 'initial' value as a delta. It is important for a management - station to be aware of this minimum time and the actual time - between polls, and to discard data if the actual time is too - long or there is no defined minimum time. - - In the value set and its semantics, this type is equivalent - to the ZeroBasedCounter64 textual convention of the SMIv2."; - reference - "RFC 2856: Textual Conventions for Additional High Capacity - Data Types"; - } - - typedef gauge32 { - type uint32; - description - "The gauge32 type represents a non-negative integer, which - may increase or decrease, but shall never exceed a maximum - value, nor fall below a minimum value. The maximum value - cannot be greater than 2^32-1 (4294967295 decimal), and - the minimum value cannot be smaller than 0. The value of - a gauge32 has its maximum value whenever the information - being modeled is greater than or equal to its maximum - value, and has its minimum value whenever the information - being modeled is smaller than or equal to its minimum value. - If the information being modeled subsequently decreases - below (increases above) the maximum (minimum) value, the - gauge32 also decreases (increases). - - In the value set and its semantics, this type is equivalent - to the Gauge32 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef gauge64 { - type uint64; - description - "The gauge64 type represents a non-negative integer, which - may increase or decrease, but shall never exceed a maximum - value, nor fall below a minimum value. The maximum value - cannot be greater than 2^64-1 (18446744073709551615), and - the minimum value cannot be smaller than 0. The value of - a gauge64 has its maximum value whenever the information - being modeled is greater than or equal to its maximum - value, and has its minimum value whenever the information - being modeled is smaller than or equal to its minimum value. - If the information being modeled subsequently decreases - below (increases above) the maximum (minimum) value, the - gauge64 also decreases (increases). - - In the value set and its semantics, this type is equivalent - to the CounterBasedGauge64 SMIv2 textual convention defined - in RFC 2856"; - reference - "RFC 2856: Textual Conventions for Additional High Capacity - Data Types"; - } - - /*** collection of identifier related types ***/ - - typedef object-identifier { - type string { - pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))' - + '(\.(0|([1-9]\d*)))*'; - } - description - "The object-identifier type represents administratively - assigned names in a registration-hierarchical-name tree. - - Values of this type are denoted as a sequence of numerical - non-negative sub-identifier values. Each sub-identifier - value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers - are separated by single dots and without any intermediate - whitespace. - - The ASN.1 standard restricts the value space of the first - sub-identifier to 0, 1, or 2. Furthermore, the value space - of the second sub-identifier is restricted to the range - 0 to 39 if the first sub-identifier is 0 or 1. Finally, - the ASN.1 standard requires that an object identifier - has always at least two sub-identifier. The pattern - captures these restrictions. - - Although the number of sub-identifiers is not limited, - module designers should realize that there may be - implementations that stick with the SMIv2 limit of 128 - sub-identifiers. - - This type is a superset of the SMIv2 OBJECT IDENTIFIER type - since it is not restricted to 128 sub-identifiers. Hence, - this type SHOULD NOT be used to represent the SMIv2 OBJECT - IDENTIFIER type, the object-identifier-128 type SHOULD be - used instead."; - reference - "ISO9834-1: Information technology -- Open Systems - Interconnection -- Procedures for the operation of OSI - Registration Authorities: General procedures and top - arcs of the ASN.1 Object Identifier tree"; - } - - - - - typedef object-identifier-128 { - type object-identifier { - pattern '\d*(\.\d*){1,127}'; - } - description - "This type represents object-identifiers restricted to 128 - sub-identifiers. - - In the value set and its semantics, this type is equivalent - to the OBJECT IDENTIFIER type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef yang-identifier { - type string { - length "1..max"; - pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*'; - pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*'; - } - description - "A YANG identifier string as defined by the 'identifier' - rule in Section 12 of RFC 6020. An identifier must - start with an alphabetic character or an underscore - followed by an arbitrary sequence of alphabetic or - numeric characters, underscores, hyphens, or dots. - - A YANG identifier MUST NOT start with any possible - combination of the lowercase or uppercase character - sequence 'xml'."; - reference - "RFC 6020: YANG - A Data Modeling Language for the Network - Configuration Protocol (NETCONF)"; - } - - /*** collection of date and time related types ***/ - - typedef date-and-time { - type string { - pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?' - + '(Z|[\+\-]\d{2}:\d{2})'; - } - description - "The date-and-time type is a profile of the ISO 8601 - standard for representation of dates and times using the - Gregorian calendar. The profile is defined by the - date-time production in Section 5.6 of RFC 3339. - - The date-and-time type is compatible with the dateTime XML - schema type with the following notable exceptions: - - (a) The date-and-time type does not allow negative years. - - (b) The date-and-time time-offset -00:00 indicates an unknown - time zone (see RFC 3339) while -00:00 and +00:00 and Z all - represent the same time zone in dateTime. - - (c) The canonical format (see below) of data-and-time values - differs from the canonical format used by the dateTime XML - schema type, which requires all times to be in UTC using the - time-offset 'Z'. - - This type is not equivalent to the DateAndTime textual - convention of the SMIv2 since RFC 3339 uses a different - separator between full-date and full-time and provides - higher resolution of time-secfrac. - - The canonical format for date-and-time values with a known time - zone uses a numeric time zone offset that is calculated using - the device's configured known offset to UTC time. A change of - the device's offset to UTC time will cause date-and-time values - to change accordingly. Such changes might happen periodically - in case a server follows automatically daylight saving time - (DST) time zone offset changes. The canonical format for - date-and-time values with an unknown time zone (usually referring - to the notion of local time) uses the time-offset -00:00."; - reference - "RFC 3339: Date and Time on the Internet: Timestamps - RFC 2579: Textual Conventions for SMIv2 - XSD-TYPES: XML Schema Part 2: Datatypes Second Edition"; - } - - typedef timeticks { - type uint32; - description - "The timeticks type represents a non-negative integer that - represents the time, modulo 2^32 (4294967296 decimal), in - hundredths of a second between two epochs. When a schema - node is defined that uses this type, the description of - the schema node identifies both of the reference epochs. - - In the value set and its semantics, this type is equivalent - to the TimeTicks type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef timestamp { - type yang:timeticks; - description - "The timestamp type represents the value of an associated - timeticks schema node at which a specific occurrence happened. - The specific occurrence must be defined in the description - of any schema node defined using this type. When the specific - occurrence occurred prior to the last time the associated - timeticks attribute was zero, then the timestamp value is - zero. Note that this requires all timestamp values to be - reset to zero when the value of the associated timeticks - attribute reaches 497+ days and wraps around to zero. - - The associated timeticks schema node must be specified - in the description of any schema node using this type. - - In the value set and its semantics, this type is equivalent - to the TimeStamp textual convention of the SMIv2."; - reference - "RFC 2579: Textual Conventions for SMIv2"; - } - - /*** collection of generic address types ***/ - - typedef phys-address { - type string { - pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?'; - } - description - "Represents media- or physical-level addresses represented - as a sequence octets, each octet represented by two hexadecimal - numbers. Octets are separated by colons. The canonical - representation uses lowercase characters. - - In the value set and its semantics, this type is equivalent - to the PhysAddress textual convention of the SMIv2."; - reference - "RFC 2579: Textual Conventions for SMIv2"; - } - - typedef mac-address { - type string { - pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'; - } - description - "The mac-address type represents an IEEE 802 MAC address. - The canonical representation uses lowercase characters. - - In the value set and its semantics, this type is equivalent - to the MacAddress textual convention of the SMIv2."; - reference - "IEEE 802: IEEE Standard for Local and Metropolitan Area - Networks: Overview and Architecture - RFC 2579: Textual Conventions for SMIv2"; - } - - /*** collection of XML specific types ***/ - - typedef xpath1.0 { - type string; - description - "This type represents an XPATH 1.0 expression. - - When a schema node is defined that uses this type, the - description of the schema node MUST specify the XPath - context in which the XPath expression is evaluated."; - reference - "XPATH: XML Path Language (XPath) Version 1.0"; - } - - } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module1.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module1.yang deleted file mode 100644 index 604fe9458c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module1.yang +++ /dev/null @@ -1,12 +0,0 @@ -module module1 { - namespace "module:1"; - prefix "mod1"; - revision "2014-01-01"; - - rpc dummy-rpc1-module1 { - } - - rpc dummy-rpc2-module1 { - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module2.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module2.yang deleted file mode 100644 index 7b359f3efb..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module2.yang +++ /dev/null @@ -1,11 +0,0 @@ -module module2 { - namespace "module:2"; - prefix "mod2"; - revision "2014-01-02"; - - rpc dummy-rpc1-module2 { - } - - rpc dummy-rpc2-module2 { - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module3.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module3.yang deleted file mode 100644 index 39bb690be0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/module3.yang +++ /dev/null @@ -1,5 +0,0 @@ -module module3 { - namespace "module:3"; - prefix "mod3"; - revision "2014-01-03"; -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/iana-if-type.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/iana-if-type.yang deleted file mode 100644 index 7bd0003b5d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/iana-if-type.yang +++ /dev/null @@ -1,1517 +0,0 @@ -module iana-if-type { - namespace "urn:ietf:params:xml:ns:yang:iana-if-type"; - prefix ianaift; - - organization "IANA"; - contact - " Internet Assigned Numbers Authority - - Postal: ICANN - 4676 Admiralty Way, Suite 330 - Marina del Rey, CA 90292 - - Tel: +1 310 823 9358 - E-Mail: iana&iana.org"; - description - "This YANG module defines the iana-if-type typedef, which - contains YANG definitions for IANA-registered interface types. - - This YANG module is maintained by IANA, and reflects the - 'ifType definitions' registry. - - The latest revision of this YANG module can be obtained from - the IANA web site. - - Copyright (c) 2011 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - revision 2013-07-04 { - description - "Initial revision."; - reference - "RFC XXXX: IANA Interface Type YANG Module"; - } - - typedef iana-if-type { - type enumeration { - enum "other" { - value 1; - description - "None of the following"; - } - enum "regular1822" { - value 2; - } - enum "hdh1822" { - value 3; - } - enum "ddnX25" { - value 4; - } - enum "rfc877x25" { - value 5; - reference - "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer"; - } - enum "ethernetCsmacd" { - value 6; - description - "For all ethernet-like interfaces, regardless of speed, - as per RFC3635."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "iso88023Csmacd" { - value 7; - status deprecated; - description - "Deprecated via RFC3635. - Use ethernetCsmacd(6) instead."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "iso88024TokenBus" { - value 8; - } - enum "iso88025TokenRing" { - value 9; - } - enum "iso88026Man" { - value 10; - } - enum "starLan" { - value 11; - status deprecated; - description - "Deprecated via RFC3635. - Use ethernetCsmacd(6) instead."; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "proteon10Mbit" { - value 12; - } - enum "proteon80Mbit" { - value 13; - } - enum "hyperchannel" { - value 14; - } - enum "fddi" { - value 15; - reference - "RFC 1512 - FDDI Management Information Base"; - } - enum "lapb" { - value 16; - reference - "RFC 1381 - SNMP MIB Extension for X.25 LAPB"; - } - enum "sdlc" { - value 17; - } - enum "ds1" { - value 18; - description - "DS1-MIB"; - reference - "RFC 4805 - Definitions of Managed Objects for the - DS1, J1, E1, DS2, and E2 Interface Types"; - } - enum "e1" { - value 19; - status obsolete; - description - "Obsolete see DS1-MIB"; - reference - "RFC 4805 - Definitions of Managed Objects for the - DS1, J1, E1, DS2, and E2 Interface Types"; - } - enum "basicISDN" { - value 20; - description - "see also RFC2127"; - } - enum "primaryISDN" { - value 21; - } - enum "propPointToPointSerial" { - value 22; - description - "proprietary serial"; - } - enum "ppp" { - value 23; - } - enum "softwareLoopback" { - value 24; - } - enum "eon" { - value 25; - description - "CLNP over IP"; - } - enum "ethernet3Mbit" { - value 26; - } - enum "nsip" { - value 27; - description - "XNS over IP"; - } - enum "slip" { - value 28; - description - "generic SLIP"; - } - enum "ultra" { - value 29; - description - "ULTRA technologies"; - } - enum "ds3" { - value 30; - description - "DS3-MIB"; - reference - "RFC 3896 - Definitions of Managed Objects for the - DS3/E3 Interface Type"; - } - enum "sip" { - value 31; - description - "SMDS, coffee"; - reference - "RFC 1694 - Definitions of Managed Objects for SMDS - Interfaces using SMIv2"; - } - enum "frameRelay" { - value 32; - description - "DTE only."; - reference - "RFC 2115 - Management Information Base for Frame Relay - DTEs Using SMIv2"; - } - enum "rs232" { - value 33; - reference - "RFC 1659 - Definitions of Managed Objects for RS-232-like - Hardware Devices using SMIv2"; - } - enum "para" { - value 34; - description - "parallel-port"; - reference - "RFC 1660 - Definitions of Managed Objects for - Parallel-printer-like Hardware Devices using - SMIv2"; - } - enum "arcnet" { - value 35; - description - "arcnet"; - } - enum "arcnetPlus" { - value 36; - description - "arcnet plus"; - } - enum "atm" { - value 37; - description - "ATM cells"; - } - enum "miox25" { - value 38; - reference - "RFC 1461 - SNMP MIB extension for Multiprotocol - Interconnect over X.25"; - } - enum "sonet" { - value 39; - description - "SONET or SDH"; - } - enum "x25ple" { - value 40; - reference - "RFC 2127 - ISDN Management Information Base using SMIv2"; - } - enum "iso88022llc" { - value 41; - } - enum "localTalk" { - value 42; - } - enum "smdsDxi" { - value 43; - } - enum "frameRelayService" { - value 44; - description - "FRNETSERV-MIB"; - reference - "RFC 2954 - Definitions of Managed Objects for Frame - Relay Service"; - } - enum "v35" { - value 45; - } - enum "hssi" { - value 46; - } - enum "hippi" { - value 47; - } - enum "modem" { - value 48; - description - "Generic modem"; - } - enum "aal5" { - value 49; - description - "AAL5 over ATM"; - } - enum "sonetPath" { - value 50; - } - enum "sonetVT" { - value 51; - } - enum "smdsIcip" { - value 52; - description - "SMDS InterCarrier Interface"; - } - enum "propVirtual" { - value 53; - description - "proprietary virtual/internal"; - reference - "RFC 2863 - The Interfaces Group MIB"; - } - enum "propMultiplexor" { - value 54; - description - "proprietary multiplexing"; - reference - "RFC 2863 - The Interfaces Group MIB"; - } - enum "ieee80212" { - value 55; - description - "100BaseVG"; - } - enum "fibreChannel" { - value 56; - description - "Fibre Channel"; - } - enum "hippiInterface" { - value 57; - description - "HIPPI interfaces"; - } - enum "frameRelayInterconnect" { - value 58; - status obsolete; - description - "Obsolete use either - frameRelay(32) or frameRelayService(44)."; - } - enum "aflane8023" { - value 59; - description - "ATM Emulated LAN for 802.3"; - } - enum "aflane8025" { - value 60; - description - "ATM Emulated LAN for 802.5"; - } - enum "cctEmul" { - value 61; - description - "ATM Emulated circuit"; - } - enum "fastEther" { - value 62; - status deprecated; - description - "Obsoleted via RFC3635. - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "isdn" { - value 63; - description - "ISDN and X.25"; - reference - "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN - in the Packet Mode"; - } - enum "v11" { - value 64; - description - "CCITT V.11/X.21"; - } - enum "v36" { - value 65; - description - "CCITT V.36"; - } - enum "g703at64k" { - value 66; - description - "CCITT G703 at 64Kbps"; - } - enum "g703at2mb" { - value 67; - status obsolete; - description - "Obsolete see DS1-MIB"; - } - enum "qllc" { - value 68; - description - "SNA QLLC"; - } - enum "fastEtherFX" { - value 69; - status deprecated; - description - "Obsoleted via RFC3635 - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "channel" { - value 70; - description - "channel"; - } - enum "ieee80211" { - value 71; - description - "radio spread spectrum"; - } - enum "ibm370parChan" { - value 72; - description - "IBM System 360/370 OEMI Channel"; - } - enum "escon" { - value 73; - description - "IBM Enterprise Systems Connection"; - } - enum "dlsw" { - value 74; - description - "Data Link Switching"; - } - enum "isdns" { - value 75; - description - "ISDN S/T interface"; - } - enum "isdnu" { - value 76; - description - "ISDN U interface"; - } - enum "lapd" { - value 77; - description - "Link Access Protocol D"; - } - enum "ipSwitch" { - value 78; - description - "IP Switching Objects"; - } - enum "rsrb" { - value 79; - description - "Remote Source Route Bridging"; - } - enum "atmLogical" { - value 80; - description - "ATM Logical Port"; - reference - "RFC 3606 - Definitions of Supplemental Managed Objects - for ATM Interface"; - } - enum "ds0" { - value 81; - description - "Digital Signal Level 0"; - reference - "RFC 2494 - Definitions of Managed Objects for the DS0 - and DS0 Bundle Interface Type"; - } - enum "ds0Bundle" { - value 82; - description - "group of ds0s on the same ds1"; - reference - "RFC 2494 - Definitions of Managed Objects for the DS0 - and DS0 Bundle Interface Type"; - } - enum "bsc" { - value 83; - description - "Bisynchronous Protocol"; - } - enum "async" { - value 84; - description - "Asynchronous Protocol"; - } - enum "cnr" { - value 85; - description - "Combat Net Radio"; - } - enum "iso88025Dtr" { - value 86; - description - "ISO 802.5r DTR"; - } - enum "eplrs" { - value 87; - description - "Ext Pos Loc Report Sys"; - } - enum "arap" { - value 88; - description - "Appletalk Remote Access Protocol"; - } - enum "propCnls" { - value 89; - description - "Proprietary Connectionless Protocol"; - } - enum "hostPad" { - value 90; - description - "CCITT-ITU X.29 PAD Protocol"; - } - enum "termPad" { - value 91; - description - "CCITT-ITU X.3 PAD Facility"; - } - enum "frameRelayMPI" { - value 92; - description - "Multiproto Interconnect over FR"; - } - enum "x213" { - value 93; - description - "CCITT-ITU X213"; - } - enum "adsl" { - value 94; - description - "Asymmetric Digital Subscriber Loop"; - } - enum "radsl" { - value 95; - description - "Rate-Adapt. Digital Subscriber Loop"; - } - enum "sdsl" { - value 96; - description - "Symmetric Digital Subscriber Loop"; - } - enum "vdsl" { - value 97; - description - "Very H-Speed Digital Subscrib. Loop"; - } - enum "iso88025CRFPInt" { - value 98; - description - "ISO 802.5 CRFP"; - } - enum "myrinet" { - value 99; - description - "Myricom Myrinet"; - } - enum "voiceEM" { - value 100; - description - "voice recEive and transMit"; - } - enum "voiceFXO" { - value 101; - description - "voice Foreign Exchange Office"; - } - enum "voiceFXS" { - value 102; - description - "voice Foreign Exchange Station"; - } - enum "voiceEncap" { - value 103; - description - "voice encapsulation"; - } - enum "voiceOverIp" { - value 104; - description - "voice over IP encapsulation"; - } - enum "atmDxi" { - value 105; - description - "ATM DXI"; - } - enum "atmFuni" { - value 106; - description - "ATM FUNI"; - } - enum "atmIma" { - value 107; - description - "ATM IMA"; - } - enum "pppMultilinkBundle" { - value 108; - description - "PPP Multilink Bundle"; - } - enum "ipOverCdlc" { - value 109; - description - "IBM ipOverCdlc"; - } - enum "ipOverClaw" { - value 110; - description - "IBM Common Link Access to Workstn"; - } - enum "stackToStack" { - value 111; - description - "IBM stackToStack"; - } - enum "virtualIpAddress" { - value 112; - description - "IBM VIPA"; - } - enum "mpc" { - value 113; - description - "IBM multi-protocol channel support"; - } - enum "ipOverAtm" { - value 114; - description - "IBM ipOverAtm"; - reference - "RFC 2320 - Definitions of Managed Objects for Classical IP - and ARP Over ATM Using SMIv2 (IPOA-MIB)"; - } - enum "iso88025Fiber" { - value 115; - description - "ISO 802.5j Fiber Token Ring"; - } - enum "tdlc" { - value 116; - description - "IBM twinaxial data link control"; - } - enum "gigabitEthernet" { - value 117; - status deprecated; - description - "Obsoleted via RFC3635 - ethernetCsmacd(6) should be used instead"; - reference - "RFC 3635 - Definitions of Managed Objects for the - Ethernet-like Interface Types."; - } - enum "hdlc" { - value 118; - description - "HDLC"; - } - enum "lapf" { - value 119; - description - "LAP F"; - } - enum "v37" { - value 120; - description - "V.37"; - } - enum "x25mlp" { - value 121; - description - "Multi-Link Protocol"; - } - enum "x25huntGroup" { - value 122; - description - "X25 Hunt Group"; - } - enum "transpHdlc" { - value 123; - description - "Transp HDLC"; - } - enum "interleave" { - value 124; - description - "Interleave channel"; - } - enum "fast" { - value 125; - description - "Fast channel"; - } - enum "ip" { - value 126; - description - "IP (for APPN HPR in IP networks)"; - } - enum "docsCableMaclayer" { - value 127; - description - "CATV Mac Layer"; - } - enum "docsCableDownstream" { - value 128; - description - "CATV Downstream interface"; - } - enum "docsCableUpstream" { - value 129; - description - "CATV Upstream interface"; - } - enum "a12MppSwitch" { - value 130; - description - "Avalon Parallel Processor"; - } - enum "tunnel" { - value 131; - description - "Encapsulation interface"; - } - enum "coffee" { - value 132; - description - "coffee pot"; - reference - "RFC 2325 - Coffee MIB"; - } - enum "ces" { - value 133; - description - "Circuit Emulation Service"; - } - enum "atmSubInterface" { - value 134; - description - "ATM Sub Interface"; - } - enum "l2vlan" { - value 135; - description - "Layer 2 Virtual LAN using 802.1Q"; - } - enum "l3ipvlan" { - value 136; - description - "Layer 3 Virtual LAN using IP"; - } - enum "l3ipxvlan" { - value 137; - description - "Layer 3 Virtual LAN using IPX"; - } - enum "digitalPowerline" { - value 138; - description - "IP over Power Lines"; - } - enum "mediaMailOverIp" { - value 139; - description - "Multimedia Mail over IP"; - } - enum "dtm" { - value 140; - description - "Dynamic syncronous Transfer Mode"; - } - enum "dcn" { - value 141; - description - "Data Communications Network"; - } - enum "ipForward" { - value 142; - description - "IP Forwarding Interface"; - } - enum "msdsl" { - value 143; - description - "Multi-rate Symmetric DSL"; - } - enum "ieee1394" { - value 144; - description - "IEEE1394 High Performance Serial Bus"; - } - enum "if-gsn" { - value 145; - description - "HIPPI-6400"; - } - enum "dvbRccMacLayer" { - value 146; - description - "DVB-RCC MAC Layer"; - } - enum "dvbRccDownstream" { - value 147; - description - "DVB-RCC Downstream Channel"; - } - enum "dvbRccUpstream" { - value 148; - description - "DVB-RCC Upstream Channel"; - } - enum "atmVirtual" { - value 149; - description - "ATM Virtual Interface"; - } - enum "mplsTunnel" { - value 150; - description - "MPLS Tunnel Virtual Interface"; - } - enum "srp" { - value 151; - description - "Spatial Reuse Protocol"; - } - enum "voiceOverAtm" { - value 152; - description - "Voice Over ATM"; - } - enum "voiceOverFrameRelay" { - value 153; - description - "Voice Over Frame Relay"; - } - enum "idsl" { - value 154; - description - "Digital Subscriber Loop over ISDN"; - } - enum "compositeLink" { - value 155; - description - "Avici Composite Link Interface"; - } - enum "ss7SigLink" { - value 156; - description - "SS7 Signaling Link"; - } - enum "propWirelessP2P" { - value 157; - description - "Prop. P2P wireless interface"; - } - enum "frForward" { - value 158; - description - "Frame Forward Interface"; - } - enum "rfc1483" { - value 159; - description - "Multiprotocol over ATM AAL5"; - reference - "RFC 1483 - Multiprotocol Encapsulation over ATM - Adaptation Layer 5"; - } - enum "usb" { - value 160; - description - "USB Interface"; - } - enum "ieee8023adLag" { - value 161; - description - "IEEE 802.3ad Link Aggregate"; - } - enum "bgppolicyaccounting" { - value 162; - description - "BGP Policy Accounting"; - } - enum "frf16MfrBundle" { - value 163; - description - "FRF .16 Multilink Frame Relay"; - } - enum "h323Gatekeeper" { - value 164; - description - "H323 Gatekeeper"; - } - enum "h323Proxy" { - value 165; - description - "H323 Voice and Video Proxy"; - } - enum "mpls" { - value 166; - description - "MPLS"; - } - enum "mfSigLink" { - value 167; - description - "Multi-frequency signaling link"; - } - enum "hdsl2" { - value 168; - description - "High Bit-Rate DSL - 2nd generation"; - } - enum "shdsl" { - value 169; - description - "Multirate HDSL2"; - } - enum "ds1FDL" { - value 170; - description - "Facility Data Link 4Kbps on a DS1"; - } - enum "pos" { - value 171; - description - "Packet over SONET/SDH Interface"; - } - enum "dvbAsiIn" { - value 172; - description - "DVB-ASI Input"; - } - enum "dvbAsiOut" { - value 173; - description - "DVB-ASI Output"; - } - enum "plc" { - value 174; - description - "Power Line Communtications"; - } - enum "nfas" { - value 175; - description - "Non Facility Associated Signaling"; - } - enum "tr008" { - value 176; - description - "TR008"; - } - enum "gr303RDT" { - value 177; - description - "Remote Digital Terminal"; - } - enum "gr303IDT" { - value 178; - description - "Integrated Digital Terminal"; - } - enum "isup" { - value 179; - description - "ISUP"; - } - enum "propDocsWirelessMaclayer" { - value 180; - description - "Cisco proprietary Maclayer"; - } - enum "propDocsWirelessDownstream" { - value 181; - description - "Cisco proprietary Downstream"; - } - enum "propDocsWirelessUpstream" { - value 182; - description - "Cisco proprietary Upstream"; - } - enum "hiperlan2" { - value 183; - description - "HIPERLAN Type 2 Radio Interface"; - } - enum "propBWAp2Mp" { - value 184; - description - "PropBroadbandWirelessAccesspt2multipt use of this value - for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f - is deprecated and ieee80216WMAN(237) should be used - instead."; - } - enum "sonetOverheadChannel" { - value 185; - description - "SONET Overhead Channel"; - } - enum "digitalWrapperOverheadChannel" { - value 186; - description - "Digital Wrapper"; - } - enum "aal2" { - value 187; - description - "ATM adaptation layer 2"; - } - enum "radioMAC" { - value 188; - description - "MAC layer over radio links"; - } - enum "atmRadio" { - value 189; - description - "ATM over radio links"; - } - enum "imt" { - value 190; - description - "Inter Machine Trunks"; - } - enum "mvl" { - value 191; - description - "Multiple Virtual Lines DSL"; - } - enum "reachDSL" { - value 192; - description - "Long Reach DSL"; - } - enum "frDlciEndPt" { - value 193; - description - "Frame Relay DLCI End Point"; - } - enum "atmVciEndPt" { - value 194; - description - "ATM VCI End Point"; - } - enum "opticalChannel" { - value 195; - description - "Optical Channel"; - } - enum "opticalTransport" { - value 196; - description - "Optical Transport"; - } - enum "propAtm" { - value 197; - description - "Proprietary ATM"; - } - enum "voiceOverCable" { - value 198; - description - "Voice Over Cable Interface"; - } - enum "infiniband" { - value 199; - description - "Infiniband"; - } - enum "teLink" { - value 200; - description - "TE Link"; - } - enum "q2931" { - value 201; - description - "Q.2931"; - } - enum "virtualTg" { - value 202; - description - "Virtual Trunk Group"; - } - enum "sipTg" { - value 203; - description - "SIP Trunk Group"; - } - enum "sipSig" { - value 204; - description - "SIP Signaling"; - } - enum "docsCableUpstreamChannel" { - value 205; - description - "CATV Upstream Channel"; - } - enum "econet" { - value 206; - description - "Acorn Econet"; - } - enum "pon155" { - value 207; - description - "FSAN 155Mb Symetrical PON interface"; - } - enum "pon622" { - value 208; - description - "FSAN622Mb Symetrical PON interface"; - } - enum "bridge" { - value 209; - description - "Transparent bridge interface"; - } - enum "linegroup" { - value 210; - description - "Interface common to multiple lines"; - } - enum "voiceEMFGD" { - value 211; - description - "voice E&M Feature Group D"; - } - enum "voiceFGDEANA" { - value 212; - description - "voice FGD Exchange Access North American"; - } - enum "voiceDID" { - value 213; - description - "voice Direct Inward Dialing"; - } - enum "mpegTransport" { - value 214; - description - "MPEG transport interface"; - } - enum "sixToFour" { - value 215; - status deprecated; - description - "6to4 interface (DEPRECATED)"; - reference - "RFC 4087 - IP Tunnel MIB"; - } - enum "gtp" { - value 216; - description - "GTP (GPRS Tunneling Protocol)"; - } - enum "pdnEtherLoop1" { - value 217; - description - "Paradyne EtherLoop 1"; - } - enum "pdnEtherLoop2" { - value 218; - description - "Paradyne EtherLoop 2"; - } - enum "opticalChannelGroup" { - value 219; - description - "Optical Channel Group"; - } - enum "homepna" { - value 220; - description - "HomePNA ITU-T G.989"; - } - enum "gfp" { - value 221; - description - "Generic Framing Procedure (GFP)"; - } - enum "ciscoISLvlan" { - value 222; - description - "Layer 2 Virtual LAN using Cisco ISL"; - } - enum "actelisMetaLOOP" { - value 223; - description - "Acteleis proprietary MetaLOOP High Speed Link"; - } - enum "fcipLink" { - value 224; - description - "FCIP Link"; - } - enum "rpr" { - value 225; - description - "Resilient Packet Ring Interface Type"; - } - enum "qam" { - value 226; - description - "RF Qam Interface"; - } - enum "lmp" { - value 227; - description - "Link Management Protocol"; - reference - "RFC 4327 - Link Management Protocol (LMP) Management - Information Base (MIB)"; - } - enum "cblVectaStar" { - value 228; - description - "Cambridge Broadband Networks Limited VectaStar"; - } - enum "docsCableMCmtsDownstream" { - value 229; - description - "CATV Modular CMTS Downstream Interface"; - } - enum "adsl2" { - value 230; - status deprecated; - description - "Asymmetric Digital Subscriber Loop Version 2 - (DEPRECATED/OBSOLETED - please use adsl2plus(238) - instead)"; - reference - "RFC 4706 - Definitions of Managed Objects for Asymmetric - Digital Subscriber Line 2 (ADSL2)"; - } - enum "macSecControlledIF" { - value 231; - description - "MACSecControlled"; - } - enum "macSecUncontrolledIF" { - value 232; - description - "MACSecUncontrolled"; - } - enum "aviciOpticalEther" { - value 233; - description - "Avici Optical Ethernet Aggregate"; - } - enum "atmbond" { - value 234; - description - "atmbond"; - } - enum "voiceFGDOS" { - value 235; - description - "voice FGD Operator Services"; - } - enum "mocaVersion1" { - value 236; - description - "MultiMedia over Coax Alliance (MoCA) Interface - as documented in information provided privately to IANA"; - } - enum "ieee80216WMAN" { - value 237; - description - "IEEE 802.16 WMAN interface"; - } - enum "adsl2plus" { - value 238; - description - "Asymmetric Digital Subscriber Loop Version 2, - Version 2 Plus and all variants"; - } - enum "dvbRcsMacLayer" { - value 239; - description - "DVB-RCS MAC Layer"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "dvbTdm" { - value 240; - description - "DVB Satellite TDM"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "dvbRcsTdma" { - value 241; - description - "DVB-RCS TDMA"; - reference - "RFC 5728 - The SatLabs Group DVB-RCS MIB"; - } - enum "x86Laps" { - value 242; - description - "LAPS based on ITU-T X.86/Y.1323"; - } - enum "wwanPP" { - value 243; - description - "3GPP WWAN"; - } - enum "wwanPP2" { - value 244; - description - "3GPP2 WWAN"; - } - enum "voiceEBS" { - value 245; - description - "voice P-phone EBS physical interface"; - } - enum "ifPwType" { - value 246; - description - "Pseudowire interface type"; - reference - "RFC 5601 - Pseudowire (PW) Management Information Base"; - } - enum "ilan" { - value 247; - description - "Internal LAN on a bridge per IEEE 802.1ap"; - } - enum "pip" { - value 248; - description - "Provider Instance Port on a bridge per IEEE 802.1ah PBB"; - } - enum "aluELP" { - value 249; - description - "Alcatel-Lucent Ethernet Link Protection"; - } - enum "gpon" { - value 250; - description - "Gigabit-capable passive optical networks (G-PON) as per - ITU-T G.948"; - } - enum "vdsl2" { - value 251; - description - "Very high speed digital subscriber line Version 2 - (as per ITU-T Recommendation G.993.2)"; - reference - "RFC 5650 - Definitions of Managed Objects for Very High - Speed Digital Subscriber Line 2 (VDSL2)"; - } - enum "capwapDot11Profile" { - value 252; - description - "WLAN Profile Interface"; - reference - "RFC 5834 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Binding MIB for - IEEE 802.11"; - } - enum "capwapDot11Bss" { - value 253; - description - "WLAN BSS Interface"; - reference - "RFC 5834 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Binding MIB for - IEEE 802.11"; - } - enum "capwapWtpVirtualRadio" { - value 254; - description - "WTP Virtual Radio Interface"; - reference - "RFC 5833 - Control and Provisioning of Wireless Access - Points (CAPWAP) Protocol Base MIB"; - } - enum "bits" { - value 255; - description - "bitsport"; - } - enum "docsCableUpstreamRfPort" { - value 256; - description - "DOCSIS CATV Upstream RF Port"; - } - enum "cableDownstreamRfPort" { - value 257; - description - "CATV downstream RF port"; - } - enum "vmwareVirtualNic" { - value 258; - description - "VMware Virtual Network Interface"; - } - enum "ieee802154" { - value 259; - description - "IEEE 802.15.4 WPAN interface"; - reference - "IEEE 802.15.4-2006"; - } - enum "otnOdu" { - value 260; - description - "OTN Optical Data Unit"; - } - enum "otnOtu" { - value 261; - description - "OTN Optical channel Transport Unit"; - } - enum "ifVfiType" { - value 262; - description - "VPLS Forwarding Instance Interface Type"; - } - enum "g9981" { - value 263; - description - "G.998.1 bonded interface"; - } - enum "g9982" { - value 264; - description - "G.998.2 bonded interface"; - } - enum "g9983" { - value 265; - description - "G.998.3 bonded interface"; - } - enum "aluEpon" { - value 266; - description - "Ethernet Passive Optical Networks (E-PON)"; - } - enum "aluEponOnu" { - value 267; - description - "EPON Optical Network Unit"; - } - enum "aluEponPhysicalUni" { - value 268; - description - "EPON physical User to Network interface"; - } - enum "aluEponLogicalLink" { - value 269; - description - "The emulation of a point-to-point link over the EPON - layer"; - } - enum "aluGponOnu" { - value 270; - description - "GPON Optical Network Unit"; - reference - "ITU-T G.984.2"; - } - enum "aluGponPhysicalUni" { - value 271; - description - "GPON physical User to Network interface"; - reference - "ITU-T G.984.2"; - } - enum "vmwareNicTeam" { - value 272; - description - "VMware NIC Team"; - } - // value 273 reserved by IANA - } - description - "This data type is used as the syntax of the 'type' - leaf in the 'interface' list in the YANG module - ietf-interface. - - The definition of this typedef with the - addition of newly assigned values is published - periodically by the IANA, in either the Assigned - Numbers RFC, or some derivative of it specific to - Internet Network Management number assignments. (The - latest arrangements can be obtained by contacting the - IANA.) - - Requests for new values should be made to IANA via - email (iana&iana.org)."; - reference - "IANA ifType definitions registry. - "; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-inet-types.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-inet-types.yang deleted file mode 100644 index de20febbb7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-inet-types.yang +++ /dev/null @@ -1,418 +0,0 @@ - module ietf-inet-types { - - namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types"; - prefix "inet"; - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Partain - - - WG Chair: David Kessens - - - Editor: Juergen Schoenwaelder - "; - - description - "This module contains a collection of generally useful derived - YANG data types for Internet addresses and related things. - - Copyright (c) 2010 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, is permitted pursuant to, and subject to the license - terms contained in, the Simplified BSD License set forth in Section - 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC 6021; see - the RFC itself for full legal notices."; - - revision 2010-09-24 { - description - "Initial revision."; - reference - "RFC 6021: Common YANG Data Types"; - } - - /*** collection of protocol field related types ***/ - - typedef ip-version { - type enumeration { - enum unknown { - value "0"; - description - "An unknown or unspecified version of the Internet protocol."; - } - enum ipv4 { - value "1"; - description - "The IPv4 protocol as defined in RFC 791."; - } - enum ipv6 { - value "2"; - description - "The IPv6 protocol as defined in RFC 2460."; - } - } - description - "This value represents the version of the IP protocol. - - In the value set and its semantics, this type is equivalent - to the InetVersion textual convention of the SMIv2."; - reference - "RFC 791: Internet Protocol - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - typedef dscp { - type uint8 { - range "0..63"; - } - description - "The dscp type represents a Differentiated Services Code-Point - that may be used for marking packets in a traffic stream. - - In the value set and its semantics, this type is equivalent - to the Dscp textual convention of the SMIv2."; - reference - "RFC 3289: Management Information Base for the Differentiated - Services Architecture - RFC 2474: Definition of the Differentiated Services Field - (DS Field) in the IPv4 and IPv6 Headers - RFC 2780: IANA Allocation Guidelines For Values In - the Internet Protocol and Related Headers"; - } - - typedef ipv6-flow-label { - type uint32 { - range "0..1048575"; - } - description - "The flow-label type represents flow identifier or Flow Label - in an IPv6 packet header that may be used to discriminate - traffic flows. - - In the value set and its semantics, this type is equivalent - to the IPv6FlowLabel textual convention of the SMIv2."; - reference - "RFC 3595: Textual Conventions for IPv6 Flow Label - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"; - } - - typedef port-number { - type uint16 { - range "0..65535"; - } - description - "The port-number type represents a 16-bit port number of an - Internet transport layer protocol such as UDP, TCP, DCCP, or - SCTP. Port numbers are assigned by IANA. A current list of - all assignments is available from . - - Note that the port number value zero is reserved by IANA. In - situations where the value zero does not make sense, it can - be excluded by subtyping the port-number type. - - In the value set and its semantics, this type is equivalent - to the InetPortNumber textual convention of the SMIv2."; - reference - "RFC 768: User Datagram Protocol - RFC 793: Transmission Control Protocol - RFC 4960: Stream Control Transmission Protocol - RFC 4340: Datagram Congestion Control Protocol (DCCP) - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - /*** collection of autonomous system related types ***/ - - typedef as-number { - type uint32; - description - "The as-number type represents autonomous system numbers - which identify an Autonomous System (AS). An AS is a set - of routers under a single technical administration, using - an interior gateway protocol and common metrics to route - packets within the AS, and using an exterior gateway - protocol to route packets to other ASs'. IANA maintains - the AS number space and has delegated large parts to the - regional registries. - - Autonomous system numbers were originally limited to 16 - bits. BGP extensions have enlarged the autonomous system - number space to 32 bits. This type therefore uses an uint32 - base type without a range restriction in order to support - a larger autonomous system number space. - - In the value set and its semantics, this type is equivalent - to the InetAutonomousSystemNumber textual convention of - the SMIv2."; - reference - "RFC 1930: Guidelines for creation, selection, and registration - of an Autonomous System (AS) - RFC 4271: A Border Gateway Protocol 4 (BGP-4) - RFC 4893: BGP Support for Four-octet AS Number Space - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - /*** collection of IP address and hostname related types ***/ - - typedef ip-address { - type union { - type inet:ipv4-address; - type inet:ipv6-address; - } - description - "The ip-address type represents an IP address and is IP - version neutral. The format of the textual representations - implies the IP version."; - } - - typedef ipv4-address { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' - + '(%[\p{N}\p{L}]+)?'; - } - description - "The ipv4-address type represents an IPv4 address in - dotted-quad notation. The IPv4 address may include a zone - index, separated by a % sign. - - The zone index is used to disambiguate identical address - values. For link-local addresses, the zone index will - typically be the interface index number or the name of an - interface. If the zone index is not present, the default - zone of the device will be used. - - The canonical format for the zone index is the numerical - format"; - } - - typedef ipv6-address { - type string { - pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' - + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' - + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' - + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' - + '(%[\p{N}\p{L}]+)?'; - pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' - + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' - + '(%.+)?'; - } - description - "The ipv6-address type represents an IPv6 address in full, - mixed, shortened, and shortened-mixed notation. The IPv6 - address may include a zone index, separated by a % sign. - - The zone index is used to disambiguate identical address - values. For link-local addresses, the zone index will - typically be the interface index number or the name of an - interface. If the zone index is not present, the default - zone of the device will be used. - - The canonical format of IPv6 addresses uses the compressed - format described in RFC 4291, Section 2.2, item 2 with the - following additional rules: the :: substitution must be - applied to the longest sequence of all-zero 16-bit chunks - in an IPv6 address. If there is a tie, the first sequence - of all-zero 16-bit chunks is replaced by ::. Single - all-zero 16-bit chunks are not compressed. The canonical - format uses lowercase characters and leading zeros are - not allowed. The canonical format for the zone index is - the numerical format as described in RFC 4007, Section - 11.2."; - reference - "RFC 4291: IP Version 6 Addressing Architecture - RFC 4007: IPv6 Scoped Address Architecture - RFC 5952: A Recommendation for IPv6 Address Text Representation"; - } - - typedef ip-prefix { - type union { - type inet:ipv4-prefix; - type inet:ipv6-prefix; - } - description - "The ip-prefix type represents an IP prefix and is IP - version neutral. The format of the textual representations - implies the IP version."; - } - - typedef ipv4-prefix { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' - + '/(([0-9])|([1-2][0-9])|(3[0-2]))'; - } - description - "The ipv4-prefix type represents an IPv4 address prefix. - The prefix length is given by the number following the - slash character and must be less than or equal to 32. - - A prefix length value of n corresponds to an IP address - mask that has n contiguous 1-bits from the most - significant bit (MSB) and all other bits set to 0. - - The canonical format of an IPv4 prefix has all bits of - the IPv4 address set to zero that are not part of the - IPv4 prefix."; - } - - typedef ipv6-prefix { - type string { - pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' - + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' - + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' - + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' - + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'; - pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' - + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' - + '(/.+)'; - } - description - "The ipv6-prefix type represents an IPv6 address prefix. - The prefix length is given by the number following the - slash character and must be less than or equal 128. - - A prefix length value of n corresponds to an IP address - mask that has n contiguous 1-bits from the most - significant bit (MSB) and all other bits set to 0. - - The IPv6 address should have all bits that do not belong - to the prefix set to zero. - - The canonical format of an IPv6 prefix has all bits of - the IPv6 address set to zero that are not part of the - IPv6 prefix. Furthermore, IPv6 address is represented - in the compressed format described in RFC 4291, Section - 2.2, item 2 with the following additional rules: the :: - substitution must be applied to the longest sequence of - all-zero 16-bit chunks in an IPv6 address. If there is - a tie, the first sequence of all-zero 16-bit chunks is - replaced by ::. Single all-zero 16-bit chunks are not - compressed. The canonical format uses lowercase - characters and leading zeros are not allowed."; - reference - "RFC 4291: IP Version 6 Addressing Architecture"; - } - - /*** collection of domain name and URI types ***/ - - typedef domain-name { - type string { - pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' - + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' - + '|\.'; - length "1..253"; - } - description - "The domain-name type represents a DNS domain name. The - name SHOULD be fully qualified whenever possible. - - Internet domain names are only loosely specified. Section - 3.5 of RFC 1034 recommends a syntax (modified in Section - 2.1 of RFC 1123). The pattern above is intended to allow - for current practice in domain name use, and some possible - future expansion. It is designed to hold various types of - domain names, including names used for A or AAAA records - (host names) and other records, such as SRV records. Note - that Internet host names have a stricter syntax (described - in RFC 952) than the DNS recommendations in RFCs 1034 and - 1123, and that systems that want to store host names in - schema nodes using the domain-name type are recommended to - adhere to this stricter standard to ensure interoperability. - - The encoding of DNS names in the DNS protocol is limited - to 255 characters. Since the encoding consists of labels - prefixed by a length bytes and there is a trailing NULL - byte, only 253 characters can appear in the textual dotted - notation. - - The description clause of schema nodes using the domain-name - type MUST describe when and how these names are resolved to - IP addresses. Note that the resolution of a domain-name value - may require to query multiple DNS records (e.g., A for IPv4 - and AAAA for IPv6). The order of the resolution process and - which DNS record takes precedence can either be defined - explicitely or it may depend on the configuration of the - resolver. - - Domain-name values use the US-ASCII encoding. Their canonical - format uses lowercase US-ASCII characters. Internationalized - domain names MUST be encoded in punycode as described in RFC - 3492"; - reference - "RFC 952: DoD Internet Host Table Specification - RFC 1034: Domain Names - Concepts and Facilities - RFC 1123: Requirements for Internet Hosts -- Application - and Support - RFC 2782: A DNS RR for specifying the location of services - (DNS SRV) - RFC 3492: Punycode: A Bootstring encoding of Unicode for - Internationalized Domain Names in Applications - (IDNA) - RFC 5891: Internationalizing Domain Names in Applications - (IDNA): Protocol"; - } - - typedef host { - type union { - type inet:ip-address; - type inet:domain-name; - } - description - "The host type represents either an IP address or a DNS - domain name."; - } - - typedef uri { - type string; - description - "The uri type represents a Uniform Resource Identifier - (URI) as defined by STD 66. - - Objects using the uri type MUST be in US-ASCII encoding, - and MUST be normalized as described by RFC 3986 Sections - 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary - percent-encoding is removed, and all case-insensitive - characters are set to lowercase except for hexadecimal - digits, which are normalized to uppercase as described in - Section 6.2.2.1. - - The purpose of this normalization is to help provide - unique URIs. Note that this normalization is not - sufficient to provide uniqueness. Two URIs that are - textually distinct after this normalization may still be - equivalent. - - Objects using the uri type may restrict the schemes that - they permit. For example, 'data:' and 'urn:' schemes - might not be appropriate. - - A zero-length URI is not a valid URI. This can be used to - express 'URI absent' where required. - - In the value set and its semantics, this type is equivalent - to the Uri SMIv2 textual convention defined in RFC 5017."; - reference - "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax - RFC 3305: Report from the Joint W3C/IETF URI Planning Interest - Group: Uniform Resource Identifiers (URIs), URLs, - and Uniform Resource Names (URNs): Clarifications - and Recommendations - RFC 5017: MIB Textual Conventions for Uniform Resource - Identifiers (URIs)"; - } - - } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-interfaces@2013-07-04.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-interfaces@2013-07-04.yang deleted file mode 100644 index 9db753c440..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-interfaces@2013-07-04.yang +++ /dev/null @@ -1,673 +0,0 @@ -module ietf-interfaces { - - namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces"; - prefix if; - - import ietf-yang-types { - prefix yang; - } - import iana-if-type { - prefix ianaift; - } - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Kessens - - - WG Chair: Juergen Schoenwaelder - - - Editor: Martin Bjorklund - "; - - description - "This module contains a collection of YANG definitions for - managing network interfaces. - - Copyright (c) 2013 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - revision 2013-07-04 { - description - "Initial revision."; - reference - "RFC XXXX: A YANG Data Model for Interface Management"; - } - - /* Typedefs */ - - typedef interface-ref { - type leafref { - path "/if:interfaces/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - configured interfaces."; - } - - typedef interface-state-ref { - type leafref { - path "/if:interfaces-state/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - the operationally present interfaces."; - } - - /* Features */ - - feature arbitrary-names { - description - "This feature indicates that the device allows user-controlled - interfaces to be named arbitrarily."; - } - - feature pre-provisioning { - description - "This feature indicates that the device supports - pre-provisioning of interface configuration, i.e., it is - possible to configure an interface whose physical interface - hardware is not present on the device."; - } - - feature if-mib { - description - "This feature indicates that the device implements IF-MIB."; - reference - "RFC 2863: The Interfaces Group MIB"; - } - - /* Data nodes */ - - container interfaces { - description - "Interface configuration parameters."; - - list interface { - key "name"; - - description - "The list of configured interfaces on the device. - - The operational state of an interface is available in the - /interfaces-state/interface list. If the configuration of a - system-controlled interface cannot be used by the system - (e.g., the interface hardware present does not match the - interface type), then the configuration is not applied to - the system-controlled interface shown in the - /interfaces-state/interface list. If the the configuration - of a user-controlled interface cannot be used by the system, - the configured interface is not instantiated in the - /interfaces-state/interface list."; - - leaf name { - type string; - description - "The name of the interface. - - A device MAY restrict the allowed values for this leaf, - possibly depending on the type of the interface. - - For system-controlled interfaces, this leaf is the - device-specific name of the interface. The 'config false' - list /interfaces-state/interface contains the currently - existing interfaces on the device. - - If a client tries to create configuration for a - system-controlled interface that is not present in the - /interfaces-state/interface list, the server MAY reject - the request, if the implementation does not support - pre-provisioning of interfaces, or if the name refers to - an interface that can never exist in the system. A - NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case. - - If the device supports pre-provisioning of interface - configuration, the feature 'pre-provisioning' is - advertised. - - If the device allows arbitrarily named user-controlled - interfaces, the feature 'arbitrary-names' is advertised. - - When a configured user-controlled interface is created by - the system, it is instantiated with the same name in the - /interface-state/interface list. Since the name in that - list MAY be mapped to ifName by an implementation, such an - implementation MUST restrict the allowed values for this - leaf so that it matches the restrictions of ifName. - - If a NETCONF server that implements this restriction is - sent a value that doesn't match the restriction, it MUST - reply with an rpc-error with the error-tag - 'invalid-value'."; - } - - leaf description { - type string; - description - "A textual description of the interface. - - This leaf MAY be mapped to ifAlias by an implementation. - Such an implementation MUST restrict the allowed values - for this leaf so that it matches the restrictions of - ifAlias. - - If a NETCONF server that implements this restriction is - sent a value that doesn't match the restriction, it MUST - reply with an rpc-error with the error-tag - 'invalid-value'. - - Since ifAlias is defined to be stored in non-volatile - storage, the MIB implementation MUST map ifAlias to the - value of 'description' in the persistently stored - datastore. - - Specifically, if the device supports ':startup', when - ifAlias is read the device MUST return the value of - 'description' in the 'startup' datastore, and when it is - written, it MUST be written to the 'running' and 'startup' - datastores. Note that it is up to the implementation if - it modifies this single leaf in 'startup', or if it - performs an implicit copy-config from 'running' to - 'startup'. - - If the device does not support ':startup', ifAlias MUST - be mapped to the 'description' leaf in the 'running' - datastore."; - reference - "RFC 2863: The Interfaces Group MIB - ifAlias"; - } - - leaf type { - type ianaift:iana-if-type; - mandatory true; - description - "The type of the interface. - - When an interface entry is created, a server MAY - initialize the type leaf with a valid value, e.g., if it - is possible to derive the type from the name of the - interface. - - If a client tries to set the type of an interface to a - value that can never be used by the system, e.g., if the - type is not supported or if the type does not match the - name of the interface, the server MUST reject the request. - A NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf enabled { - type boolean; - default "true"; - description - "This leaf contains the configured, desired state of the - interface. - - Systems that implement the IF-MIB use the value of this - leaf in the 'running' datastore to set - IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry - has been initialized, as described in RFC 2863. - - Changes in this leaf in the 'running' datastore are - reflected in ifAdminStatus, but if ifAdminStatus is - changed over SNMP, this leaf is not affected."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf link-up-down-trap-enable { - if-feature if-mib; - type enumeration { - enum enabled { - value 1; - } - enum disabled { - value 2; - } - } - description - "Controls whether linkUp/linkDown SNMP notifications - should be generated for this interface. - - If this node is not configured, the value 'enabled' is - operationally used by the server for interfaces which do - not operate on top of any other interface (i.e., there are - no 'lower-layer-if' entries), and 'disabled' otherwise."; - reference - "RFC 2863: The Interfaces Group MIB - - ifLinkUpDownTrapEnable"; - } - } - } - - container interfaces-state { - config false; - description - "Data nodes for the operational state of interfaces."; - - list interface { - key "name"; - - description - "The list of interfaces on the device. - - System-controlled interfaces created by the system are - always present in this list, whether they are configured or - not."; - - leaf name { - type string; - description - "The name of the interface. - - This leaf MAY be mapped to ifName by an implementation."; - reference - "RFC 2863: The Interfaces Group MIB - ifName"; - } - - leaf type { - type ianaift:iana-if-type; - mandatory true; - description - "The type of the interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf admin-status { - if-feature if-mib; - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "Not ready to pass packets and not in some test mode."; - } - enum testing { - value 3; - description - "In some test mode."; - } - } - mandatory true; - description - "The desired state of the interface. - - This leaf has the same read semantics as ifAdminStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf oper-status { - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "The interface does not pass any packets."; - } - enum testing { - value 3; - description - "In some test mode. No operational packets can - be passed."; - } - enum unknown { - value 4; - description - "Status cannot be determined for some reason."; - } - enum dormant { - value 5; - description - "Waiting for some external event."; - } - enum not-present { - value 6; - description - "Some component (typically hardware) is missing."; - } - enum lower-layer-down { - value 7; - description - "Down due to state of lower-layer interface(s)."; - } - } - mandatory true; - description - "The current operational state of the interface. - - This leaf has the same semantics as ifOperStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifOperStatus"; - } - - leaf last-change { - type yang:date-and-time; - description - "The time the interface entered its current operational - state. If the current state was entered prior to the - last re-initialization of the local network management - subsystem, then this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifLastChange"; - } - - leaf if-index { - if-feature if-mib; - type int32 { - range "1..2147483647"; - } - mandatory true; - description - "The ifIndex value for the ifEntry represented by this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifIndex"; - } - - leaf phys-address { - type yang:phys-address; - description - "The interface's address at its protocol sub-layer. For - example, for an 802.x interface, this object normally - contains a MAC address. The interface's media-specific - modules must define the bit and byte ordering and the - format of the value of this object. For interfaces that do - not have such an address (e.g., a serial line), this node - is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifPhysAddress"; - } - - leaf-list higher-layer-if { - type interface-state-ref; - description - "A list of references to interfaces layered on top of this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf-list lower-layer-if { - type interface-state-ref; - description - "A list of references to interfaces layered underneath this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf speed { - type yang:gauge64; - units "bits / second"; - description - "An estimate of the interface's current bandwidth in bits - per second. For interfaces that do not vary in - bandwidth or for those where no accurate estimation can - be made, this node should contain the nominal bandwidth. - For interfaces that have no concept of bandwidth, this - node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - - ifSpeed, ifHighSpeed"; - } - - container statistics { - description - "A collection of interface-related statistics objects."; - - leaf discontinuity-time { - type yang:date-and-time; - mandatory true; - description - "The time on the most recent occasion at which any one or - more of this interface's counters suffered a - discontinuity. If no such discontinuities have occurred - since the last re-initialization of the local management - subsystem, then this node contains the time the local - management subsystem re-initialized itself."; - } - - leaf in-octets { - type yang:counter64; - description - "The total number of octets received on the interface, - including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; - } - leaf in-unicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were not addressed to a - multicast or broadcast address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; - } - leaf in-broadcast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were addressed to a broadcast - address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInBroadcastPkts"; - } - leaf in-multicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, which were addressed to a multicast - address at this sub-layer. For a MAC layer protocol, - this includes both Group and Functional addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInMulticastPkts"; - } - leaf in-discards { - type yang:counter32; - description - "The number of inbound packets which were chosen to be - discarded even though no errors had been detected to - prevent their being deliverable to a higher-layer - protocol. One possible reason for discarding such a - packet could be to free up buffer space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInDiscards"; - } - leaf in-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of inbound - packets that contained errors preventing them from being - deliverable to a higher-layer protocol. For character- - oriented or fixed-length interfaces, the number of - inbound transmission units that contained errors - preventing them from being deliverable to a higher-layer - protocol. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInErrors"; - } - leaf in-unknown-protos { - type yang:counter32; - description - "For packet-oriented interfaces, the number of packets - received via the interface which were discarded because - of an unknown or unsupported protocol. For - character-oriented or fixed-length interfaces that - support protocol multiplexing the number of transmission - units received via the interface which were discarded - because of an unknown or unsupported protocol. For any - interface that does not support protocol multiplexing, - this counter is not present. - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; - } - - leaf out-octets { - type yang:counter64; - description - "The total number of octets transmitted out of the - interface, including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; - } - leaf out-unicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were not addressed - to a multicast or broadcast address at this sub-layer, - including those that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; - } - leaf out-broadcast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were addressed to a - broadcast address at this sub-layer, including those - that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutBroadcastPkts"; - } - leaf out-multicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and which were addressed to a - multicast address at this sub-layer, including those - that were discarded or not sent. For a MAC layer - protocol, this includes both Group and Functional - addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutMulticastPkts"; - } - leaf out-discards { - type yang:counter32; - description - "The number of outbound packets which were chosen to be - discarded even though no errors had been detected to - prevent their being transmitted. One possible reason - for discarding such a packet could be to free up buffer - space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; - } - leaf out-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of outbound - packets that could not be transmitted because of errors. - For character-oriented or fixed-length interfaces, the - number of outbound transmission units that could not be - transmitted because of errors. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutErrors"; - } - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-restconf@2013-10-19.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-restconf@2013-10-19.yang deleted file mode 100644 index 16766b0979..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-restconf@2013-10-19.yang +++ /dev/null @@ -1,684 +0,0 @@ -module ietf-restconf { - namespace "urn:ietf:params:xml:ns:yang:ietf-restconf"; - prefix "restconf"; - - import ietf-yang-types { prefix yang; } - import ietf-inet-types { prefix inet; } - - organization - "IETF NETCONF (Network Configuration) Working Group"; - - contact - "Editor: Andy Bierman - - - Editor: Martin Bjorklund - - - Editor: Kent Watsen - - - Editor: Rex Fernando - "; - - description - "This module contains conceptual YANG specifications - for the YANG Patch and error content that is used in - RESTCONF protocol messages. A conceptual container - representing the RESTCONF API nodes (media type - application/yang.api). - - Note that the YANG definitions within this module do not - represent configuration data of any kind. - The YANG grouping statements provide a normative syntax - for XML and JSON message encoding purposes. - Copyright (c) 2013 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC XXXX; see - the RFC itself for full legal notices."; - - // RFC Ed.: replace XXXX with actual RFC number and remove this - // note. - - // RFC Ed.: remove this note - // Note: extracted from draft-bierman-netconf-restconf-02.txt - - // RFC Ed.: update the date below with the date of RFC publication - // and remove this note. - revision 2013-10-19 { - description - "Initial revision."; - reference - "RFC XXXX: RESTCONF Protocol."; - } - - typedef data-resource-identifier { - type string { - length "1 .. max"; - } - description - "Contains a Data Resource Identifier formatted string - to identify a specific data node. The data node that - uses this data type SHOULD define the document root - for data resource identifiers. The default document - root is the target datastore conceptual root node. - Data resource identifiers are defined relative to - this document root."; - reference - "RFC XXXX: [sec. 5.3.1.1 ABNF For Data Resource Identifiers]"; - } - - // this typedef is TBD; not currently used - typedef datastore-identifier { - type union { - type enumeration { - enum candidate { - description - "Identifies the NETCONF shared candidate datastore."; - reference - "RFC 6241, section 8.3"; - } - enum running { - description - "Identifies the NETCONF running datastore."; - reference - "RFC 6241, section 5.1"; - } - enum startup { - description - "Identifies the NETCONF startup datastore."; - reference - "RFC 6241, section 8.7"; - } - } - type string; - } - description - "Contains a string to identify a specific datastore. - The enumerated datastore identifier values are - reserved for standard datastore names."; - } - - typedef revision-identifier { - type string { - pattern '\d{4}-\d{2}-\d{2}'; - } - description - "Represents a specific date in YYYY-MM-DD format. - TBD: make pattern more precise to exclude leading zeros."; - } - - grouping yang-patch { - description - "A grouping that contains a YANG container - representing the syntax and semantics of a - YANG Patch edit request message."; - - container yang-patch { - description - "Represents a conceptual sequence of datastore edits, - called a patch. Each patch is given a client-assigned - patch identifier. Each edit MUST be applied - in ascending order, and all edits MUST be applied. - If any errors occur, then the target datastore MUST NOT - be changed by the patch operation. - - A patch MUST be validated by the server to be a - well-formed message before any of the patch edits - are validated or attempted. - - YANG datastore validation (defined in RFC 6020, section - 8.3.3) is performed after all edits have been - individually validated. - - It is possible for a datastore constraint violation to occur - due to any node in the datastore, including nodes not - included in the edit list. Any validation errors MUST - be reported in the reply message."; - - reference - "RFC 6020, section 8.3."; - - leaf patch-id { - type string; - description - "An arbitrary string provided by the client to identify - the entire patch. This value SHOULD be present in any - audit logging records generated by the server for the - patch. Error messages returned by the server pertaining - to this patch will be identified by this patch-id value."; - } - - leaf comment { - type string { - length "0 .. 1024"; - } - description - "An arbitrary string provided by the client to describe - the entire patch. This value SHOULD be present in any - audit logging records generated by the server for the - patch."; - } - - list edit { - key edit-id; - ordered-by user; - - description - "Represents one edit within the YANG Patch - request message."; - leaf edit-id { - type string; - description - "Arbitrary string index for the edit. - Error messages returned by the server pertaining - to a specific edit will be identified by this - value."; - } - - leaf operation { - type enumeration { - enum create { - description - "The target data node is created using the - supplied value, only if it does not already - exist."; - } - enum delete { - description - "Delete the target node, only if the data resource - currently exists, otherwise return an error."; - } - enum insert { - description - "Insert the supplied value into a user-ordered - list or leaf-list entry. The target node must - represent a new data resource."; - } - enum merge { - description - "The supplied value is merged with the target data - node."; - } - enum move { - description - "Move the target node. Reorder a user-ordered - list or leaf-list. The target node must represent - an existing data resource."; - } - enum replace { - description - "The supplied value is used to replace the target - data node."; - } - enum remove { - description - "Delete the target node if it currently exists."; - } - } - mandatory true; - description - "The datastore operation requested for the associated - edit entry"; - } - - leaf target { - type data-resource-identifier; - mandatory true; - description - "Identifies the target data resource for the edit - operation."; - } - - leaf point { - when "(../operation = 'insert' or " + - "../operation = 'move') and " + - "(../where = 'before' or ../where = 'after')" { - description - "Point leaf only applies for insert or move - operations, before or after an existing entry."; - } - type data-resource-identifier; - description - "The absolute URL path for the data node that is being - used as the insertion point or move point for the - target of this edit entry."; - } - - leaf where { - when "../operation = 'insert' or ../operation = 'move'" { - description - "Where leaf only applies for insert or move - operations."; - } - type enumeration { - enum before { - description - "Insert or move a data node before the data resource - identified by the 'point' parameter."; - } - enum after { - description - "Insert or move a data node after the data resource - identified by the 'point' parameter."; - } - enum first { - description - "Insert or move a data node so it becomes ordered - as the first entry."; - } - enum last { - description - "Insert or move a data node so it becomes ordered - as the last entry."; - } - - } - default last; - description - "Identifies where a data resource will be inserted or - moved. YANG only allows these operations for - list and leaf-list data nodes that are ordered-by - user."; - } - - anyxml value { - when "(../operation = 'create' or " + - "../operation = 'merge' " + - "or ../operation = 'replace' or " + - "../operation = 'insert')" { - description - "Value node only used for create, merge, - replace, and insert operations"; - } - description - "Value used for this edit operation."; - } - } - } - - } // grouping yang-patch - - - grouping yang-patch-status { - - description - "A grouping that contains a YANG container - representing the syntax and semantics of - YANG Patch status response message."; - - container yang-patch-status { - description - "A container representing the response message - sent by the server after a YANG Patch edit - request message has been processed."; - - leaf patch-id { - type string; - description - "The patch-id value used in the request"; - } - - choice global-status { - description - "Report global errors or complete success. - If there is no case selected then errors - are reported in the edit-status container."; - - case global-errors { - uses errors; - description - "This container will be present if global - errors unrelated to a specific edit occurred."; - } - leaf ok { - type empty; - description - "This leaf will be present if the request succeeded - and there are no errors reported in the edit-status - container."; - } - } - - container edit-status { - description - "This container will be present if there are - edit-specific status responses to report."; - - list edit { - key edit-id; - - description - "Represents a list of status responses, - corresponding to edits in the YANG Patch - request message. If an edit entry was - skipped or not reached by the server, - then this list will not contain a corresponding - entry for that edit."; - - leaf edit-id { - type string; - description - "Response status is for the edit list entry - with this edit-id value."; - } - choice edit-status-choice { - description - "A choice between different types of status - responses for each edit entry."; - leaf ok { - type empty; - description - "This edit entry was invoked without any - errors detected by the server associated - with this edit."; - } - leaf location { - type inet:uri; - description - "Contains the Location header value that would be - returned if this edit causes a new resource to be - created. If the edit identified by the same edit-id - value was successfully invoked and a new resource - was created, then this field will be returned - instead of 'ok'."; - } - case errors { - uses errors; - description - "The server detected errors associated with the - edit identified by the same edit-id value."; - } - } - } - } - } - } // grouping yang-patch-status - - - grouping errors { - - description - "A grouping that contains a YANG container - representing the syntax and semantics of a - YANG Patch errors report within a response message."; - - container errors { - config false; // needed so list error does not need a key - description - "Represents an error report returned by the server if - a request results in an error."; - - list error { - description - "An entry containing information about one - specific error that occurred while processing - a RESTCONF request."; - reference "RFC 6241, Section 4.3"; - - leaf error-type { - type enumeration { - enum transport { - description "The transport layer"; - } - enum rpc { - description "The rpc or notification layer"; - } - enum protocol { - description "The protocol operation layer"; - } - enum application { - description "The server application layer"; - } - } - mandatory true; - description - "The protocol layer where the error occurred."; - } - - leaf error-tag { - type string; - mandatory true; - description - "The enumerated error tag."; - } - - leaf error-app-tag { - type string; - description - "The application-specific error tag."; - } - - leaf error-path { - type data-resource-identifier; - description - "The target data resource identifier associated - with the error, if any."; - } - leaf error-message { - type string; - description - "A message describing the error."; - } - - container error-info { - description - "A container allowing additional information - to be included in the error report."; - // arbitrary anyxml content here - } - } - } - } // grouping errors - - - grouping restconf { - - description - "A grouping that contains a YANG container - representing the syntax and semantics of - the RESTCONF API resource."; - - container restconf { - description - "Conceptual container representing the - application/yang.api resource type."; - - container config { - description - "Container representing the application/yang.datastore - resource type. Represents the conceptual root of the - unified configuration datastore containing YANG data - nodes. The child nodes of this container are - configuration data resources (application/yang.data) - defined as top-level YANG data nodes from the modules - advertised by the server in /restconf/modules."; - } - - container operational { - description - "Container representing the application/yang.datastore - resource type. Represents the conceptual root of the - operational data supported by the server. The child - nodes of this container are operational data resources - (application/yang.data) defined as top-level - YANG data nodes from the modules advertised by - the server in /restconf/modules."; - } - - container modules { - description - "Contains a list of module description entries. - These modules are currently loaded into the server."; - - list module { - key "name revision"; - description - "Each entry represents one module currently - supported by the server."; - - leaf name { - type yang:yang-identifier; - description "The YANG module name."; - } - leaf revision { - type union { - type revision-identifier; - type string { length 0; } - } - description - "The YANG module revision date. An empty string is - used if no revision statement is present in the - YANG module."; - } - leaf namespace { - type inet:uri; - mandatory true; - description - "The XML namespace identifier for this module."; - } - leaf-list feature { - type yang:yang-identifier; - description - "List of YANG feature names from this module that are - supported by the server."; - } - leaf-list deviation { - type yang:yang-identifier; - description - "List of YANG deviation module names used by this - server to modify the conformance of the module - associated with this entry."; - } - } - } - - container operations { - description - "Container for all operation resources - (application/yang.operation), - - Each resource is represented as an empty leaf with the - name of the RPC operation from the YANG rpc statement. - - E.g.; - - POST /restconf/operations/show-log-errors - - leaf show-log-errors { - type empty; - } - "; - } - - container streams { - description - "Container representing the notification event streams - supported by the server."; - reference - "RFC 5277, Section 3.4, element."; - - list stream { - key name; - description - "Each entry describes an event stream supported by - the server."; - - leaf name { - type string; - description "The stream name"; - reference "RFC 5277, Section 3.4, element."; - } - - leaf description { - type string; - description "Description of stream content"; - reference - "RFC 5277, Section 3.4, element."; - } - - leaf replay-support { - type boolean; - description - "Indicates if replay buffer supported for this stream"; - reference - "RFC 5277, Section 3.4, element."; - } - - leaf replay-log-creation-time { - type yang:date-and-time; - description - "Indicates the time the replay log for this stream - was created."; - reference - "RFC 5277, Section 3.4, - element."; - } - - leaf events { - type empty; - description - "Represents the entry point for establishing - notification delivery via server sent events."; - } - } - } - - leaf version { - type enumeration { - enum "1.0" { - description - "Version 1.0 of the RESTCONF protocol."; - } - } - config false; - description - "Contains the RESTCONF protocol version."; - } - } - } // grouping restconf - - - grouping notification { - description - "Contains the notification message wrapper definition."; - - container notification { - description - "RESTCONF notification message wrapper."; - leaf event-time { - type yang:date-and-time; - mandatory true; - description - "The time the event was generated by the - event source."; - reference - "RFC 5277, section 4, element."; - } - - /* The YANG-specific notification container is encoded - * after the 'event-time' element. The format - * corresponds to the notificationContent element - * in RFC 5277, section 4. For example: - * - * module example-one { - * ... - * notification event1 { ... } - * - * } - * - * Encoded as element 'event1' in the namespace - * for module 'example-one'. - */ - } - } // grouping notification - - } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-yang-types.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-yang-types.yang deleted file mode 100644 index 07e50b3913..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-yang-types.yang +++ /dev/null @@ -1,417 +0,0 @@ - module ietf-yang-types { - - namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types"; - prefix "yang"; - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Partain - - - WG Chair: David Kessens - - - Editor: Juergen Schoenwaelder - "; - - description - "This module contains a collection of generally useful derived - YANG data types. - - Copyright (c) 2010 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, is permitted pursuant to, and subject to the license - terms contained in, the Simplified BSD License set forth in Section - 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC 6021; see - the RFC itself for full legal notices."; - - revision 2010-09-24 { - description - "Initial revision."; - reference - "RFC 6021: Common YANG Data Types"; - } - - /*** collection of counter and gauge types ***/ - - typedef counter32 { - type uint32; - description - "The counter32 type represents a non-negative integer - that monotonically increases until it reaches a - maximum value of 2^32-1 (4294967295 decimal), when it - wraps around and starts increasing again from zero. - - Counters have no defined 'initial' value, and thus, a - single value of a counter has (in general) no information - content. Discontinuities in the monotonically increasing - value normally occur at re-initialization of the - management system, and at other times as specified in the - description of a schema node using this type. If such - other times can occur, for example, the creation of - a schema node of type counter32 at times other than - re-initialization, then a corresponding schema node - should be defined, with an appropriate type, to indicate - the last discontinuity. - - The counter32 type should not be used for configuration - schema nodes. A default statement SHOULD NOT be used in - combination with the type counter32. - - In the value set and its semantics, this type is equivalent - to the Counter32 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef zero-based-counter32 { - type yang:counter32; - default "0"; - description - "The zero-based-counter32 type represents a counter32 - that has the defined 'initial' value zero. - - A schema node of this type will be set to zero (0) on creation - and will thereafter increase monotonically until it reaches - a maximum value of 2^32-1 (4294967295 decimal), when it - wraps around and starts increasing again from zero. - - Provided that an application discovers a new schema node - of this type within the minimum time to wrap, it can use the - 'initial' value as a delta. It is important for a management - station to be aware of this minimum time and the actual time - between polls, and to discard data if the actual time is too - long or there is no defined minimum time. - - In the value set and its semantics, this type is equivalent - to the ZeroBasedCounter32 textual convention of the SMIv2."; - reference - "RFC 4502: Remote Network Monitoring Management Information - Base Version 2"; - } - - typedef counter64 { - type uint64; - description - "The counter64 type represents a non-negative integer - that monotonically increases until it reaches a - maximum value of 2^64-1 (18446744073709551615 decimal), - when it wraps around and starts increasing again from zero. - - Counters have no defined 'initial' value, and thus, a - single value of a counter has (in general) no information - content. Discontinuities in the monotonically increasing - value normally occur at re-initialization of the - management system, and at other times as specified in the - description of a schema node using this type. If such - other times can occur, for example, the creation of - a schema node of type counter64 at times other than - re-initialization, then a corresponding schema node - should be defined, with an appropriate type, to indicate - the last discontinuity. - - The counter64 type should not be used for configuration - schema nodes. A default statement SHOULD NOT be used in - combination with the type counter64. - - In the value set and its semantics, this type is equivalent - to the Counter64 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef zero-based-counter64 { - type yang:counter64; - default "0"; - description - "The zero-based-counter64 type represents a counter64 that - has the defined 'initial' value zero. - - A schema node of this type will be set to zero (0) on creation - and will thereafter increase monotonically until it reaches - a maximum value of 2^64-1 (18446744073709551615 decimal), - when it wraps around and starts increasing again from zero. - - Provided that an application discovers a new schema node - of this type within the minimum time to wrap, it can use the - 'initial' value as a delta. It is important for a management - station to be aware of this minimum time and the actual time - between polls, and to discard data if the actual time is too - long or there is no defined minimum time. - - In the value set and its semantics, this type is equivalent - to the ZeroBasedCounter64 textual convention of the SMIv2."; - reference - "RFC 2856: Textual Conventions for Additional High Capacity - Data Types"; - } - - typedef gauge32 { - type uint32; - description - "The gauge32 type represents a non-negative integer, which - may increase or decrease, but shall never exceed a maximum - value, nor fall below a minimum value. The maximum value - cannot be greater than 2^32-1 (4294967295 decimal), and - the minimum value cannot be smaller than 0. The value of - a gauge32 has its maximum value whenever the information - being modeled is greater than or equal to its maximum - value, and has its minimum value whenever the information - being modeled is smaller than or equal to its minimum value. - If the information being modeled subsequently decreases - below (increases above) the maximum (minimum) value, the - gauge32 also decreases (increases). - - In the value set and its semantics, this type is equivalent - to the Gauge32 type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef gauge64 { - type uint64; - description - "The gauge64 type represents a non-negative integer, which - may increase or decrease, but shall never exceed a maximum - value, nor fall below a minimum value. The maximum value - cannot be greater than 2^64-1 (18446744073709551615), and - the minimum value cannot be smaller than 0. The value of - a gauge64 has its maximum value whenever the information - being modeled is greater than or equal to its maximum - value, and has its minimum value whenever the information - being modeled is smaller than or equal to its minimum value. - If the information being modeled subsequently decreases - below (increases above) the maximum (minimum) value, the - gauge64 also decreases (increases). - - In the value set and its semantics, this type is equivalent - to the CounterBasedGauge64 SMIv2 textual convention defined - in RFC 2856"; - reference - "RFC 2856: Textual Conventions for Additional High Capacity - Data Types"; - } - - /*** collection of identifier related types ***/ - - typedef object-identifier { - type string { - pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))' - + '(\.(0|([1-9]\d*)))*'; - } - description - "The object-identifier type represents administratively - assigned names in a registration-hierarchical-name tree. - - Values of this type are denoted as a sequence of numerical - non-negative sub-identifier values. Each sub-identifier - value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers - are separated by single dots and without any intermediate - whitespace. - - The ASN.1 standard restricts the value space of the first - sub-identifier to 0, 1, or 2. Furthermore, the value space - of the second sub-identifier is restricted to the range - 0 to 39 if the first sub-identifier is 0 or 1. Finally, - the ASN.1 standard requires that an object identifier - has always at least two sub-identifier. The pattern - captures these restrictions. - - Although the number of sub-identifiers is not limited, - module designers should realize that there may be - implementations that stick with the SMIv2 limit of 128 - sub-identifiers. - - This type is a superset of the SMIv2 OBJECT IDENTIFIER type - since it is not restricted to 128 sub-identifiers. Hence, - this type SHOULD NOT be used to represent the SMIv2 OBJECT - IDENTIFIER type, the object-identifier-128 type SHOULD be - used instead."; - reference - "ISO9834-1: Information technology -- Open Systems - Interconnection -- Procedures for the operation of OSI - Registration Authorities: General procedures and top - arcs of the ASN.1 Object Identifier tree"; - } - - - - - typedef object-identifier-128 { - type object-identifier { - pattern '\d*(\.\d*){1,127}'; - } - description - "This type represents object-identifiers restricted to 128 - sub-identifiers. - - In the value set and its semantics, this type is equivalent - to the OBJECT IDENTIFIER type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef yang-identifier { - type string { - length "1..max"; - pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*'; - pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*'; - } - description - "A YANG identifier string as defined by the 'identifier' - rule in Section 12 of RFC 6020. An identifier must - start with an alphabetic character or an underscore - followed by an arbitrary sequence of alphabetic or - numeric characters, underscores, hyphens, or dots. - - A YANG identifier MUST NOT start with any possible - combination of the lowercase or uppercase character - sequence 'xml'."; - reference - "RFC 6020: YANG - A Data Modeling Language for the Network - Configuration Protocol (NETCONF)"; - } - - /*** collection of date and time related types ***/ - - typedef date-and-time { - type string { - pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?' - + '(Z|[\+\-]\d{2}:\d{2})'; - } - description - "The date-and-time type is a profile of the ISO 8601 - standard for representation of dates and times using the - Gregorian calendar. The profile is defined by the - date-time production in Section 5.6 of RFC 3339. - - The date-and-time type is compatible with the dateTime XML - schema type with the following notable exceptions: - - (a) The date-and-time type does not allow negative years. - - (b) The date-and-time time-offset -00:00 indicates an unknown - time zone (see RFC 3339) while -00:00 and +00:00 and Z all - represent the same time zone in dateTime. - - (c) The canonical format (see below) of data-and-time values - differs from the canonical format used by the dateTime XML - schema type, which requires all times to be in UTC using the - time-offset 'Z'. - - This type is not equivalent to the DateAndTime textual - convention of the SMIv2 since RFC 3339 uses a different - separator between full-date and full-time and provides - higher resolution of time-secfrac. - - The canonical format for date-and-time values with a known time - zone uses a numeric time zone offset that is calculated using - the device's configured known offset to UTC time. A change of - the device's offset to UTC time will cause date-and-time values - to change accordingly. Such changes might happen periodically - in case a server follows automatically daylight saving time - (DST) time zone offset changes. The canonical format for - date-and-time values with an unknown time zone (usually referring - to the notion of local time) uses the time-offset -00:00."; - reference - "RFC 3339: Date and Time on the Internet: Timestamps - RFC 2579: Textual Conventions for SMIv2 - XSD-TYPES: XML Schema Part 2: Datatypes Second Edition"; - } - - typedef timeticks { - type uint32; - description - "The timeticks type represents a non-negative integer that - represents the time, modulo 2^32 (4294967296 decimal), in - hundredths of a second between two epochs. When a schema - node is defined that uses this type, the description of - the schema node identifies both of the reference epochs. - - In the value set and its semantics, this type is equivalent - to the TimeTicks type of the SMIv2."; - reference - "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; - } - - typedef timestamp { - type yang:timeticks; - description - "The timestamp type represents the value of an associated - timeticks schema node at which a specific occurrence happened. - The specific occurrence must be defined in the description - of any schema node defined using this type. When the specific - occurrence occurred prior to the last time the associated - timeticks attribute was zero, then the timestamp value is - zero. Note that this requires all timestamp values to be - reset to zero when the value of the associated timeticks - attribute reaches 497+ days and wraps around to zero. - - The associated timeticks schema node must be specified - in the description of any schema node using this type. - - In the value set and its semantics, this type is equivalent - to the TimeStamp textual convention of the SMIv2."; - reference - "RFC 2579: Textual Conventions for SMIv2"; - } - - /*** collection of generic address types ***/ - - typedef phys-address { - type string { - pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?'; - } - description - "Represents media- or physical-level addresses represented - as a sequence octets, each octet represented by two hexadecimal - numbers. Octets are separated by colons. The canonical - representation uses lowercase characters. - - In the value set and its semantics, this type is equivalent - to the PhysAddress textual convention of the SMIv2."; - reference - "RFC 2579: Textual Conventions for SMIv2"; - } - - typedef mac-address { - type string { - pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'; - } - description - "The mac-address type represents an IEEE 802 MAC address. - The canonical representation uses lowercase characters. - - In the value set and its semantics, this type is equivalent - to the MacAddress textual convention of the SMIv2."; - reference - "IEEE 802: IEEE Standard for Local and Metropolitan Area - Networks: Overview and Architecture - RFC 2579: Textual Conventions for SMIv2"; - } - - /*** collection of XML specific types ***/ - - typedef xpath1.0 { - type string; - description - "This type represents an XPATH 1.0 expression. - - When a schema node is defined that uses this type, the - description of the schema node MUST specify the XPath - context in which the XPath expression is evaluated."; - reference - "XPATH: XML Path Language (XPath) Version 1.0"; - } - - } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/module1-behind-mount-point.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/module1-behind-mount-point.yang deleted file mode 100644 index e48184b4df..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/module1-behind-mount-point.yang +++ /dev/null @@ -1,10 +0,0 @@ -module module1-behind-mount-point { - namespace "module:1:behind:mount:point"; - prefix "mod1bemopo"; - revision "2014-02-03"; - - rpc rpc-behind-module1 { - } - - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/module2-behind-mount-point.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/module2-behind-mount-point.yang deleted file mode 100644 index 89b8c02eba..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/module2-behind-mount-point.yang +++ /dev/null @@ -1,9 +0,0 @@ -module module2-behind-mount-point { - namespace "module:2:behind:mount:point"; - prefix "mod2bemopo"; - revision "2014-02-04"; - - rpc rpc-behind-module2 { - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/nested-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/nested-module.yang deleted file mode 100644 index 726b8d9a5b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/nested-module.yang +++ /dev/null @@ -1,65 +0,0 @@ -module nested-module { - namespace "urn:nested:module"; - prefix "nested"; - revision "2014-06-3"; - - container depth1-cont { - list depth2-cont1 { - container depth3-cont1 { - container depth4-cont1 { - leaf depth5-leaf1 { - type string; - } - } - - leaf depth4-leaf1 { - type string; - } - } - - leaf depth3-leaf1 { - type string; - } - } - - /* list depth2-list2 was added to test keyed list */ - list depth2-list2 { - key "depth3-lf1-key depth3-lf2-key"; - leaf depth3-lf1-key { - type string; - } - leaf depth3-lf2-key { - type string; - } - leaf depth3-lf3 { - type string; - } - } - - leaf-list depth2-lfLst1 { - type string; - } - - container depth2-cont2 { - container depth3-cont2 { - container depth4-cont2 { - leaf depth5-leaf2 { - type string; - } - } - - leaf depth4-leaf2 { - type string; - } - } - - leaf depth3-leaf2 { - type string; - } - } - - leaf depth2-leaf1 { - type string; - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/multiple-nodes/multiple-nodes.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/multiple-nodes/multiple-nodes.yang deleted file mode 100644 index 22a1dae8ac..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/multiple-nodes/multiple-nodes.yang +++ /dev/null @@ -1,17 +0,0 @@ -module multiple-nodes { - namespace "multiple:nodes"; - prefix "mod1"; - revision "2014-06-23"; - - container cont { - container cont1 { - leaf lf11 { - type string; - } - } - - leaf lf1 { - type string; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-container.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-container.yang deleted file mode 100644 index 7efe4f75e9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-container.yang +++ /dev/null @@ -1,22 +0,0 @@ -module augment-container { - namespace "ns:augment:container"; - prefix "augcont"; - - - import yang {prefix yng; revision-date 2013-11-26;} - - - revision "2013-11-26" { - } - - augment "/yng:cont" { - container cont1 { - leaf lf11 { - type string; - } - } - } - - - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-leaf.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-leaf.yang deleted file mode 100644 index 248d3bb8b0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-leaf.yang +++ /dev/null @@ -1,18 +0,0 @@ -module augment-leaf { - namespace "ns:augment:leaf"; - prefix "auglf"; - - - import yang {prefix yng; revision-date 2013-11-26;} - - - revision "2013-11-26" { - } - - augment "/yng:cont" { - leaf lf2 { - type string; - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-leaflist.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-leaflist.yang deleted file mode 100644 index 1f4b93702f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-leaflist.yang +++ /dev/null @@ -1,20 +0,0 @@ -module augment-leaflist { - namespace "ns:augment:leaflist"; - prefix "auglflst"; - - - import yang {prefix yng; revision-date 2013-11-26;} - - - revision "2013-11-26" { - } - - augment "/yng:cont" { - leaf-list lflst1 { - type string; - } - } - - - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-list.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-list.yang deleted file mode 100644 index a35a87e90e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/augment-list.yang +++ /dev/null @@ -1,22 +0,0 @@ -module augment-list { - namespace "ns:augment:list"; - prefix "auglst"; - - - import yang {prefix yng; revision-date 2013-11-26;} - - - revision "2013-11-26" { - } - - augment "/yng:cont" { - list lst1 { - leaf lf11 { - type string; - } - } - } - - - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/xml/data.xml deleted file mode 100644 index fec62092c0..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/xml/data.xml +++ /dev/null @@ -1,16 +0,0 @@ - - lf1 - lf2 - - lf11 - - - lf1_1 - - - lf1_2 - - lflst1_1 - lflst1_2 - lflst1_3 - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/yang.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/yang.yang deleted file mode 100644 index 64bf6f56d3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/augmentation/yang.yang +++ /dev/null @@ -1,30 +0,0 @@ -module yang { - namespace "ns:yang"; - - prefix "yng"; - revision 2013-11-26 { - } - - container cont { - leaf lf1 { - type string; - } - leaf lf2 { - type string; - } - container cont1{ - leaf lf11 { - type string; - } - } - - list lst1{ - leaf lf11 { - type string; - } - } - leaf-list lflst1{ - type string; - } - } -}l \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/choice.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/choice.yang deleted file mode 100644 index 22430b98cc..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/choice.yang +++ /dev/null @@ -1,125 +0,0 @@ -module choice-case-test { - namespace "choice:case:test"; - - prefix "chcatst"; - revision 2013-11-27 { - } - - container cont { - leaf lf1 { - type string; - } - - choice choi1 { - case a1 { - leaf lf1a { - type uint16; - } - choice choi1a { - case aa1 { - leaf lf1aa { - type string; - } - choice choi1aa { - case aaa1 { - leaf lf1aaa { - type string; - } - } - case aab1 { - leaf lf1aab { - type string; - } - } - } - } - case ab1 { - leaf lf1ab { - type string; - } - } - } - } - case b1 { - list lst1b { - leaf lf11b { - type string; - } - } - } - case c1 { - container cont1c { - leaf lf11c { - type string; - } - } - } - case d1 { - leaf-list lflst1d { - type string; - } - } - leaf e1 { - type uint32; - } - } - - choice choi2 { - case a2 { - leaf lf2a { - type string; - } - } - case b2 { - leaf lf2b { - type string; - } - } - } - - choice choi4 { - case a4 { - list lst4a { - choice choi4aa { - case aa1 { - leaf lf4aa { - type string; - } - } - case ab2 { - leaf lf4ab { - type int16; - } - } - } - } - } - case b4 { - leaf-list lflst4b { - type uint32; - } - } - - } - -/* equal identifiers in various cases are illegal 7.9.2 rfc6020 */ -/* - choice choi3 { - case 3a { - leaf lf3a { - type string; - } - } - case 3b { - leaf lf3b { - type string; - } - } - } -*/ - - } - - - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_case_defined_without_case.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_case_defined_without_case.xml deleted file mode 100644 index 1d3f99f00a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_case_defined_without_case.xml +++ /dev/null @@ -1,4 +0,0 @@ - - 45 - lf2b val - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_container.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_container.xml deleted file mode 100644 index 146e2566cf..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_container.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - lf11c val - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_leaflist.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_leaflist.xml deleted file mode 100644 index f501e043f2..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_leaflist.xml +++ /dev/null @@ -1,4 +0,0 @@ - - lflst1d_1 val - lflst1d_2 val - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_list.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_list.xml deleted file mode 100644 index 6694b48379..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_list.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - lf11b_1 val - - - lf11b_2 val - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_more_choices_same_level.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_more_choices_same_level.xml deleted file mode 100644 index 3d2742aaa5..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_more_choices_same_level.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - lf11c val - - lf2b value - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_more_choices_same_level_various_paths_err.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_more_choices_same_level_various_paths_err.xml deleted file mode 100644 index aa9e24c89b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_more_choices_same_level_various_paths_err.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - lf11c val - - lf2b value - lf2b value - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_no_first_case.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_no_first_case.xml deleted file mode 100644 index cc6f019289..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_no_first_case.xml +++ /dev/null @@ -1,5 +0,0 @@ - - lf1 val - 121 - lf1ab val - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_random_level.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_random_level.xml deleted file mode 100644 index 05ca42fab6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_random_level.xml +++ /dev/null @@ -1,6 +0,0 @@ - - lf1aa val - lf1 val - 121 - lf1aaa val - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_three_choices_same_level.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_three_choices_same_level.xml deleted file mode 100644 index 7e5430118a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_three_choices_same_level.xml +++ /dev/null @@ -1,13 +0,0 @@ - - lf1aaa value - lf2b value - - 33 - - - 33 - - - 37 - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_various_path_err.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_various_path_err.xml deleted file mode 100644 index 5274679e90..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/choice/xml/data_various_path_err.xml +++ /dev/null @@ -1,6 +0,0 @@ - - lf1aa val - lf1 val - 121 - lf1ab value - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/data-of-several-modules/yang/module1.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/data-of-several-modules/yang/module1.yang deleted file mode 100644 index 72a82caec4..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/data-of-several-modules/yang/module1.yang +++ /dev/null @@ -1,20 +0,0 @@ -module module1 { - namespace "module:one"; - - prefix "m1"; - revision 2014-01-17 { - } - - container cont_m1 { - leaf lf1_m1 { - type string; - } - uses confB_gr; - } - - grouping confB_gr { - container contB_m1 { - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/data-of-several-modules/yang/module2.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/data-of-several-modules/yang/module2.yang deleted file mode 100644 index 521d9c0e63..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/data-of-several-modules/yang/module2.yang +++ /dev/null @@ -1,20 +0,0 @@ -module module2 { - namespace "module:two"; - - prefix "m2"; - revision 2014-01-17 { - } - - container cont_m2 { - leaf lf1_m2 { - type string; - } - uses confB_gr; - } - - grouping confB_gr { - container contB_m2 { - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/identityref/identity-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/identityref/identity-module.yang deleted file mode 100644 index 30890bf9c3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/identityref/identity-module.yang +++ /dev/null @@ -1,10 +0,0 @@ -module identity-module { - namespace "identity:module"; - - prefix "idemod"; - revision 2013-12-2 { - } - - identity iden { - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/identityref/identityref-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/identityref/identityref-module.yang deleted file mode 100644 index 20f91b2bdd..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/identityref/identityref-module.yang +++ /dev/null @@ -1,21 +0,0 @@ -module identityref-module { - namespace "identityref:module"; - - prefix "iderefmod"; - - import identity-module {prefix idemo; revision-date 2013-12-2;} - - revision 2013-12-2 { - } - - container cont { - container cont1 { - leaf lf1 { - type identityref { - base "idemo:iden"; - } - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/invalid-top-level-element/invalid-top-level-element.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/invalid-top-level-element/invalid-top-level-element.yang deleted file mode 100644 index a9df486b13..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/invalid-top-level-element/invalid-top-level-element.yang +++ /dev/null @@ -1,13 +0,0 @@ -module invalid-top-level-element { - namespace "invalid:top:level:element"; - - prefix "intoleel"; - revision 2013-12-17 { - } - - - leaf lf { - type string; - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/cont-augment-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/cont-augment-module.yang deleted file mode 100644 index 528eb5e420..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/cont-augment-module.yang +++ /dev/null @@ -1,39 +0,0 @@ -module cont-augment-module { - namespace "cont:augment:module"; - - prefix "cntaugmod"; - - import main-module {prefix mamo; revision-date 2013-12-2;} - - revision 2013-12-2 { - - } - - augment "/mamo:cont" { - leaf-list lflst1 { - type leafref { - path "../mamo:lf1"; - } - } - - leaf lf4 { - type leafref { - path "../mamo:lf1"; - } - } - - /* reference to not leaf element */ - leaf lf6 { - type leafref { - path "../lflst1"; - } - } - - leaf lf7 { - type leafref { - path "../lf4"; - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/main-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/main-module.yang deleted file mode 100644 index 1641aaae6e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/main-module.yang +++ /dev/null @@ -1,50 +0,0 @@ -module main-module { - namespace "main:module"; - - prefix "mainmod"; - revision 2013-12-2 { - } - - container cont { - leaf lf1 { - /* - *FIX ME - * If is this leaf lf1 called from cont-augment-module.yang - * from lf4, type that will be returned to the lf1 is string. - * Than there are failing tests because of we have string, - * do not number(uint32) - */ -// type uint32; - type string; - } - - container cont1 { - leaf lf11 { - /* - * FIX ME TOO WITH BAD PARSING - */ -// type boolean; - type string; - } - } - - leaf lf2 { - type leafref { - path "../lf1"; - } - } - - leaf lf3 { - type leafref { - path "/cont/cont1/lf11"; - } - } - - /* reference to nonexisting leaf */ - leaf lf5 { - type leafref { - path "/cont/lf"; - } - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_absolut_ref_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_absolut_ref_to_existing_leaf.xml deleted file mode 100644 index bd5b6a2544..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_absolut_ref_to_existing_leaf.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - true - - true - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_from_leafref_to_leafref.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_from_leafref_to_leafref.xml deleted file mode 100644 index 7b1c2776b3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_from_leafref_to_leafref.xml +++ /dev/null @@ -1,4 +0,0 @@ - - 200 - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_ref_to_non_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_ref_to_non_existing_leaf.xml deleted file mode 100644 index cdbd56bc08..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_ref_to_non_existing_leaf.xml +++ /dev/null @@ -1,4 +0,0 @@ - - 137 - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_ref_to_not_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_ref_to_not_leaf.xml deleted file mode 100644 index 953280b9dd..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_ref_to_not_leaf.xml +++ /dev/null @@ -1,4 +0,0 @@ - - 44 - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml deleted file mode 100644 index 8fe0ac4ab5..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml +++ /dev/null @@ -1,6 +0,0 @@ - - 345 - 346 - 347 - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_relativ_ref_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_relativ_ref_to_existing_leaf.xml deleted file mode 100644 index 14a2544f88..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/leafref/xml/data_relativ_ref_to_existing_leaf.xml +++ /dev/null @@ -1,5 +0,0 @@ - - 121 - 121 - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/list/list-types-module b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/list/list-types-module deleted file mode 100644 index 9bdea81579..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/list/list-types-module +++ /dev/null @@ -1,274 +0,0 @@ -module simple-data-types { - namespace "simple:data:types"; - - prefix "smpdtp"; - revision 2013-11-12 { - } - - identity iden { - } - - typedef tpdfempty { - type empty; - } - - typedef tpdfbit { - type bits { - bit b1; - bit b2; - bit b3; - } - } - - typedef tpdfun4 { - type boolean; - } - - typedef tpdfun3 { - type union { - type tpdfbit; - type tpdfempty; - } - } - - typedef tpdfun2 { - type union { - type tpdfun3; - type tpdfun4; - } - } - - typedef tpdfun1 { - type union { - type uint8; - type decimal64 { - fraction-digits 2; - } - } - } - - container cont { - leaf lfnint8Min { - type int8; - } - leaf lfnint8Max { - type int8; - } - leaf lfnint16Min { - type int16; - } - leaf lfnint16Max { - type int16; - } - leaf lfnint32Min { - type int32; - } - leaf lfnint32Max { - type int32; - } - leaf lfnint64Min { - type int64; - } - leaf lfnint64Max { - type int64; - } - - leaf lfnuint8Max { - type uint8; - } - leaf lfnuint16Max { - type uint16; - } - leaf lfnuint32Max { - type uint32; - } - leaf lfuint64Max { - type uint64; - } - leaf lfstr { - type string; - } - leaf lfstr1 { - type string; - } - leaf lfbool1 { - type boolean; - } - leaf lfbool2 { - type boolean; - } - leaf lfbool3 { - type boolean; - } - leaf lfdecimal1 { - type decimal64 { - fraction-digits 2; - } - } - leaf lfdecimal2 { - type decimal64 { - fraction-digits 2; - } - } - leaf lfdecimal3 { - type decimal64 { - fraction-digits 2; - } - } - - leaf lfdecimal4 { - type decimal64 { - fraction-digits 2; - } - } - - - leaf lfdecimal6 { - type decimal64 { - fraction-digits 2; - } - } - - leaf lfenum { - type enumeration { - enum enum1; - enum enum2; - enum enum3; - enum enum4; - } - } - - leaf lfbits { - type bits { - bit bit1; - bit bit2; - bit bit3; - bit bit4; - } - } - - leaf lfbinary { - type binary; - } - - leaf lfref1 { //reference to string type - type leafref { - path "../lfstr"; - } - } - - leaf lfref2 { //reference to number type - type leafref { - path "../lfnint8Max"; - } - } - - leaf lfempty { - type empty; - } - - leaf lfunion1 { - type union { - type uint16; - type string; - } - } - leaf lfunion2 { - type union { - type decimal64 { - fraction-digits 2; - } - type string; - } - } - - leaf lfunion3 { - type union { - type empty; - type string; - } - } - - leaf lfunion4 { - type union { - type boolean; - type string; - } - } - - leaf lfunion5 { - type union { - type uint16; - type string; - } - } - - leaf lfunion6 { - type union { - type uint16; - type empty; - } - } - - leaf lfunion7 { - type tpdfun3; - } - - leaf lfunion8 { - type union { - type uint16; - type string; - } - } - - leaf lfunion9 { - type union { - type uint16; - type boolean; - } - } - - leaf lfunion10 { - type union { - type bits { - bit bt1; - bit bt2; - } - type boolean; - } - } - - leaf lfunion11 { - type union { - type tpdfun1; - type tpdfun2; - } - } - - leaf lfunion12 { - type tpdfun2; - } - - leaf lfunion13 { - type tpdfbit; - } - - leaf lfunion14 { - type union { - type enumeration { - enum zero; - enum one; - } - type uint16; - } - } - - leaf identityref1 { - type identityref { - base iden; - } - } - - - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/simple-data-types.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/simple-data-types.yang deleted file mode 100644 index cf6e513b30..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/simple-data-types.yang +++ /dev/null @@ -1,278 +0,0 @@ -module simple-data-types { - namespace "simple:data:types"; - - prefix "smpdtp"; - revision 2013-11-12 { - } - - identity iden { - } - - typedef tpdfempty { - type empty; - } - - typedef tpdfbit { - type bits { - bit b1; - bit b2; - bit b3; - } - } - - typedef tpdfun4 { - type boolean; - } - - typedef tpdfun3 { - type union { - type tpdfbit; - type tpdfempty; - } - } - - typedef tpdfun2 { - type union { - type tpdfun3; - type tpdfun4; - } - } - - typedef tpdfun1 { - type union { - type uint8; - type decimal64 { - fraction-digits 2; - } - } - } - - container cont { - leaf lfnint8Min { - type int8; - } - leaf lfnint8Max { - type int8; - } - leaf lfnint16Min { - type int16; - } - leaf lfnint16Max { - type int16; - } - leaf lfnint32Min { - type int32; - } - leaf lfnint32Max { - type int32; - } - leaf lfnint64Min { - type int64; - } - leaf lfnint64Max { - type int64; - } - - leaf lfnuint8Max { - type uint8; - } - leaf lfnuint16Max { - type uint16; - } - leaf lfnuint32Max { - type uint32; - } - leaf lfuint64Max { - type uint64; - } - leaf lfstr { - type string; - } - leaf lfstr1 { - type string; - } - leaf lfbool1 { - type boolean; - } - leaf lfbool2 { - type boolean; - } - leaf lfbool3 { - type boolean; - } - leaf lfdecimal1 { - type decimal64 { - fraction-digits 2; - } - } - leaf lfdecimal2 { - type decimal64 { - fraction-digits 2; - } - } - leaf lfdecimal3 { - type decimal64 { - fraction-digits 2; - } - } - - leaf lfdecimal4 { - type decimal64 { - fraction-digits 2; - } - } - - - leaf lfdecimal6 { - type decimal64 { - fraction-digits 2; - } - } - - leaf lfenum { - type enumeration { - enum enum1; - enum enum2; - enum enum3; - enum enum4; - } - } - - leaf lfbits { - type bits { - bit bit1; - bit bit2; - bit bit3; - bit bit4; - } - } - - leaf lfbinary { - type binary; - } - - leaf lfref1 { //reference to string type - type leafref { - path "../lfstr"; - } - } - - leaf lfref2 { //reference to number type - type leafref { - path "../lfnint8Max"; - } - } - - leaf lfempty { - type empty; - } - - leaf lfunion1 { - type union { - type uint16; - type string; - } - } - leaf lfunion2 { - type union { - type decimal64 { - fraction-digits 2; - } - type string; - } - } - - leaf lfunion3 { - type union { - type empty; - type string; - } - } - - leaf lfunion4 { - type union { - type boolean; - type string; - } - } - - leaf lfunion5 { - type union { - type uint16; - type string; - } - } - - leaf lfunion6 { - type union { - type uint16; - type empty; - } - } - - leaf lfunion7 { - type tpdfun3; - } - - leaf lfunion8 { - type union { - type uint16; - type string; - } - } - - leaf lfunion9 { - type union { - type uint16; - type boolean; - } - } - - leaf lfunion10 { - type union { - type bits { - bit bt1; - bit bt2; - } - type boolean; - } - } - - leaf lfunion11 { - type union { - type tpdfun1; - type tpdfun2; - } - } - - leaf lfunion12 { - type tpdfun2; - } - - leaf lfunion13 { - type tpdfbit; - } - - leaf lfunion14 { - type union { - type enumeration { - enum zero; - enum one; - } - type uint16; - } - } - - leaf identityref1 { - type identityref { - base iden; - } - } - - anyxml complex-any; - - anyxml simple-any; - - anyxml empty-any; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/xml/bad-data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/xml/bad-data.xml deleted file mode 100644 index 31dfad1595..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/xml/bad-data.xml +++ /dev/null @@ -1,3 +0,0 @@ - - invalid - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/xml/data.xml deleted file mode 100644 index 86043d7441..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-data-types/xml/data.xml +++ /dev/null @@ -1,71 +0,0 @@ - - -128 - 127 - -32768 - 32767 - -2147483648 - 2147483647 - -9223372036854775808 - 9223372036854775807 - 255 - 65535 - 4294967295 - lfstr - - true - false - bla - 43.32 - -0.43 - 43 - 43E3 - 33.12345 - enum3 - bit3 bit2 - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz - 324 - 33.3 - 55 - true - true - 10 - - - - bt1 - 33 - false - b1 - zero - - x:iden - - - leaf1-value - leaf2-value - - leaf-list-value1 - leaf-list-value2 - - - - nested-value1 - - - nested-value2 - - - - - - nested-value3 - - - nested-value4 - - - - - simple - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/simple-yang-types.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/simple-yang-types.yang deleted file mode 100644 index fdb3bfb9ea..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/simple-yang-types.yang +++ /dev/null @@ -1,57 +0,0 @@ -module simple-yang-types { - namespace "simple:yang:types"; - - prefix "smptp"; - revision 2013-11-5 { - description "Initial revision."; - } - - container cont1 { - leaf lf11 { - type string; - } - leaf-list lflst11 { - type int32; - } - leaf-list lflst12 { - type string; - } - list lst11 { - key "lf111"; - leaf lf111 { - type uint8; - } - leaf lf112 { - type string; - } - container cont111 { - leaf lf1111 { - type string; - } - leaf-list lflst1111 { - type int32; - } - list lst1111 { - leaf lf1111A { - type string; - } - leaf lf1111B { - type uint8; - } - } - } - list lst111 { - leaf lf1111 { - type int32; - } - } - list lst112 { - leaf lf1121 { - type string; - } - } - } - - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/awaited_output_data.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/awaited_output_data.json deleted file mode 100644 index 8888e7f5fb..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/awaited_output_data.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "cont1": { - "lf11":"lf", - "lflst11": [55,56,57], - "lflst12": ["lflst12 str1", "lflst12 str2", "lflst12 str3"], - "lst11": [ - { - "lf111":140, - "lf112":"lf112 str", - "cont111": { - "lf1111":"lf1111 str", - "lflst1111": [2048, 1024, 4096], - "lst1111": [ - { - "lf1111A": "lf1111A str11", - "lf1111B": 4 - }, - { - "lf1111A": "lf1111A str12", - "lf1111B": 7 - } - ] - }, - "lst111" : [ - { - "lf1111" : 65 - } - ], - "lst112" : [ - { - "lf1121" : "lf1121 str11" - } - ] - - }, - { - "lf111":141, - "lf112":"lf112 str2", - "cont111": { - "lf1111":"lf1111 str2", - "lflst1111": [2049, 1025, 4097], - "lst1111": [ - { - "lf1111A": "lf1111A str21", - "lf1111B": 5 - }, - { - "lf1111A": "lf1111A str22", - "lf1111B": 8 - } - ] - }, - "lst111" : [ - { - "lf1111" : 55 - }, - { - "lf1111" : 56 - } - ], - "lst112" : [ - { - "lf1121" : "lf1121 str21" - }, - { - "lf1121" : "lf1121 str22" - } - ] - } - ] - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/awaited_output_empty_data.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/awaited_output_empty_data.json deleted file mode 100644 index 4b199888b8..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/awaited_output_empty_data.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "cont1": { - "lst11": [ - { - "lf111": 1, - "lst111": [ - { - "lf1111": 34 - }, - { - "lf1111": 35 - }, - {}, - {} - ], - "cont111": {} - }, - { - "lf111": 2, - "cont111": { - "lflst1111": [ - 1024, - 4096 - ], - "lst1111": [ - { - "lf1111B": 4 - }, - { - "lf1111A": "lf1111A str12" - } - ] - }, - "lst112": [ - {} - ] - }, - { - "lf111": 3, - "cont111": { - "lst1111": [ - {}, - {} - ] - } - } - ] - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/data.xml deleted file mode 100644 index 1df9ca5a6e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/data.xml +++ /dev/null @@ -1,63 +0,0 @@ - - lf - 56 - 55 - 57 - lflst12 str3 - - - lf1121 str22 - - 141 - lf112 str2 - - 55 - - - 4097 - 2049 - 1025 - - lf1111A str22 - 8 - - lf1111 str2 - - 5 - lf1111A str21 - - - - 56 - - - lf1121 str21 - - - lflst12 str1 - - 140 - lf112 str - - lf1111 str - 2048 - 1024 - 4096 - - lf1111A str11 - 4 - - - lf1111A str12 - 7 - - - - 65 - - - lf1121 str11 - - - lflst12 str2 - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/empty_data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/empty_data.xml deleted file mode 100644 index 9cd503e09b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-json/simple-yang-types/xml/empty_data.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 1 - - - - - - - 35 - - - - - 2 - - - - 1024 - 4096 - - 4 - - - lf1111A str12 - - - - - - 3 - - - - - - - - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/choice/module-with-choice.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/choice/module-with-choice.yang deleted file mode 100644 index 84547847ee..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/choice/module-with-choice.yang +++ /dev/null @@ -1,25 +0,0 @@ -module module-with-choice { - namespace "module:with:choice"; - - prefix "mowicho"; - - revision 2013-12-18 { - } - - - container cont { - choice choA { - case caA1 { - leaf lf1 { - type string; - } - } - case caA2 { - leaf lf2 { - type string; - } - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/data-of-several-modules/yang/module1.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/data-of-several-modules/yang/module1.yang deleted file mode 100644 index 72a82caec4..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/data-of-several-modules/yang/module1.yang +++ /dev/null @@ -1,20 +0,0 @@ -module module1 { - namespace "module:one"; - - prefix "m1"; - revision 2014-01-17 { - } - - container cont_m1 { - leaf lf1_m1 { - type string; - } - uses confB_gr; - } - - grouping confB_gr { - container contB_m1 { - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/data-of-several-modules/yang/module2.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/data-of-several-modules/yang/module2.yang deleted file mode 100644 index 521d9c0e63..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/data-of-several-modules/yang/module2.yang +++ /dev/null @@ -1,20 +0,0 @@ -module module2 { - namespace "module:two"; - - prefix "m2"; - revision 2014-01-17 { - } - - container cont_m2 { - leaf lf1_m2 { - type string; - } - uses confB_gr; - } - - grouping confB_gr { - container contB_m2 { - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/aug-referenced-elements-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/aug-referenced-elements-module.yang deleted file mode 100644 index 1b861f5765..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/aug-referenced-elements-module.yang +++ /dev/null @@ -1,18 +0,0 @@ -module aug-referenced-elements-module { - namespace "aug:referenced:elements:module"; - - prefix "augrefelmo"; - - import referenced-elements-module {prefix refelmo; revision-date 2013-12-3;} - - revision 2013-12-3 { - } - - augment "/refelmo:cont" { - leaf lf2 { - type boolean; - } - } - - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/eferenced-elements-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/eferenced-elements-module.yang deleted file mode 100644 index fd6e0fb27a..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/eferenced-elements-module.yang +++ /dev/null @@ -1,20 +0,0 @@ -module referenced-elements-module { - namespace "referenced:elements:module"; - - prefix "refelmo"; - - revision 2013-12-3 { - } - - container cont { - leaf lf1 { - type string; - } - } - leaf-list lflst1 { - type uint32; - } - - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/rinstance-identifier-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/rinstance-identifier-module.yang deleted file mode 100644 index 61ce8228b7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/instance_identifier/rinstance-identifier-module.yang +++ /dev/null @@ -1,16 +0,0 @@ -module instance-identifier-module { - namespace "instance:identifier:module"; - - prefix "inidmod"; - - revision 2013-12-3 { - } - - container cont { - leaf lf1 { - type instance-identifier { - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/yang/basic-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/yang/basic-module.yang deleted file mode 100644 index 9c61d47b1f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/yang/basic-module.yang +++ /dev/null @@ -1,106 +0,0 @@ -module basic-module { - namespace "basic:module"; - - prefix "basmod"; - - import referenced-module {prefix refmo; revision-date 2013-12-2;} - - revision 2013-12-2 { - } - - container cont { - container cont1 { - leaf lf11 { - type identityref { - base "refmo:iden"; - } - } - } - leaf lfStr { - type string; - } - leaf lfInt8 { - type int8; - } - - leaf lfInt16 { - type int16; - } - - leaf lfInt32 { - type int32; - } - - leaf lfInt64 { - type int64; - } - - leaf lfUint8 { - type uint8; - } - - leaf lfUint16 { - type uint16; - } - - leaf lfUint32 { - type uint32; - } - - leaf lfUint64 { - type uint64; - } - - leaf lfBinary { - type binary; - } - - leaf lfBits { - type bits { - bit one; - bit two; - bit three; - } - } - - leaf lfEnumeration { - type enumeration { - enum enum1; - enum enum2; - enum enum3; - } - } - - leaf lfEmpty { - type empty; - } - - leaf lfBoolean { - type boolean; - } - - leaf lfUnion { - type union { - type int8; - type string; - type bits { - bit first; - bit second; - } - type boolean; - } - } - - leaf lfLfref { - type leafref { - path "/cont/lfBoolean"; - } - } - - leaf lfInIdentifier { - type instance-identifier; - } - - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/yang/referenced-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/yang/referenced-module.yang deleted file mode 100644 index 9821b1e169..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/nn-to-xml/yang/referenced-module.yang +++ /dev/null @@ -1,10 +0,0 @@ -module referenced-module { - namespace "referenced:module"; - - prefix "refmod"; - revision 2013-12-2 { - } - - identity iden { - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/normalize-node/yang/normalize-node-module b/opendaylight/md-sal/sal-rest-connector/src/test/resources/normalize-node/yang/normalize-node-module deleted file mode 100644 index 15e68ef225..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/normalize-node/yang/normalize-node-module +++ /dev/null @@ -1,14 +0,0 @@ -module normalize-node-module { - namespace "normalize:node:module"; - - prefix "nonomo"; - revision 2014-01-09 { - } - - container cont { - leaf lf1 { - type int32; - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces.json deleted file mode 100644 index 0b39dc7241..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "interface":[ - { - "name":"eth0", - "type":"ethernetCsmacd", - "enabled":false, - "description": "some interface" - } - ] -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces.xml deleted file mode 100644 index 19569b5598..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces.xml +++ /dev/null @@ -1,6 +0,0 @@ - - eth0 - ethernetCsmacd - false - some interface - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces2.xml deleted file mode 100644 index b4bdec8b8d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces2.xml +++ /dev/null @@ -1,5 +0,0 @@ - - xxx -
bbb
- ccc -
\ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.json deleted file mode 100644 index 7de7fac444..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ietf-interfaces:interfaces":{ - "interface":[ - { - "name":"eth0", - "type":"ethernetCsmacd", - "enabled":false, - "description": "some interface" - } - ] - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.xml deleted file mode 100644 index 313f32dce1..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - eth0 - ethernetCsmacd - false - some interface - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path2.xml deleted file mode 100644 index 77cb0267c9..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path2.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - eth0 - ethernetCsmacd - false - some interface - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_interface_absolute_path.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_interface_absolute_path.xml deleted file mode 100644 index 19569b5598..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_interface_absolute_path.xml +++ /dev/null @@ -1,6 +0,0 @@ - - eth0 - ethernetCsmacd - false - some interface - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface.yang deleted file mode 100644 index 7502f8514f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface.yang +++ /dev/null @@ -1,30 +0,0 @@ -module mount-interface { - yang-version 1; - namespace "urn:ietf:params:xml:ns:yang:mount-interface"; - prefix "sn"; - - description - "test file"; - - revision "2014-07-01" { - description - "Initial revision"; - reference "will be defined"; - } - - container interfaces { - list interface { - key "name"; - - leaf name { - type string; - } - leaf type { - type string; - } - leaf enabled { - type string; - } - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface2.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface2.yang deleted file mode 100644 index 086d68287b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface2.yang +++ /dev/null @@ -1,27 +0,0 @@ -module mount-interface2 { - yang-version 1; - namespace "urn:ietf:params:xml:ns:yang:mount-interface2"; - prefix "snn"; - - description - "test file"; - - revision "2014-08-01" { - description - "Initial revision"; - reference "will be defined"; - } - - container class { - list student { - key "name"; - - leaf name { - type string; - } - leaf age { - type string; - } - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/block-data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/block-data.xml deleted file mode 100644 index 625b04d0fe..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/block-data.xml +++ /dev/null @@ -1,4 +0,0 @@ - -
456
- First -
\ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/data2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/data2.xml deleted file mode 100644 index 21712cb1b1..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/data2.xml +++ /dev/null @@ -1,4 +0,0 @@ - - Vojtech - 17 - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface.xml deleted file mode 100644 index 755c8a9b0f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - eth0 - ethernetCsmacd - false - - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface2.xml deleted file mode 100644 index 05db4a5ccc..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface2.xml +++ /dev/null @@ -1,5 +0,0 @@ - - eth0 - ethernetCsmacd - false - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface3.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface3.xml deleted file mode 100644 index e59ba178b7..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/test-interface3.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Thomas - 23 - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang1/test-interface.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang1/test-interface.yang deleted file mode 100644 index d0699e2e04..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang1/test-interface.yang +++ /dev/null @@ -1,49 +0,0 @@ -module test-interface { - yang-version 1; - namespace "urn:ietf:params:xml:ns:yang:test-interface"; - prefix "sn"; - - description - "test file"; - - revision "2014-07-01" { - description - "Initial revision"; - reference "will be defined"; - } - - container interfaces { - - container block { - - leaf address { - type string; - } - leaf location { - type string; - } - } - - list interface { - key "name"; - - list sub-interface { - key "sub-name"; - - leaf sub-name { - type string; - } - } - - leaf name { - type string; - } - leaf type { - type string; - } - leaf enabled { - type string; - } - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang2/test-interface2.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang2/test-interface2.yang deleted file mode 100644 index 13bc0ebf9d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang2/test-interface2.yang +++ /dev/null @@ -1,27 +0,0 @@ -module test-interface2 { - yang-version 1; - namespace "urn:ietf:params:xml:ns:yang:test-interface2"; - prefix "snn"; - - description - "test file"; - - revision "2014-08-01" { - description - "Initial revision"; - reference "will be defined"; - } - - container class { - list student { - key "name"; - - leaf name { - type string; - } - leaf age { - type string; - } - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/varioustest/xmldata.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/varioustest/xmldata.xml deleted file mode 100644 index 5d45980685..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/varioustest/xmldata.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - /prefix:somepath1/prefix2:somepath2 - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container-yang/data-container.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container-yang/data-container.yang deleted file mode 100644 index b038eb193c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container-yang/data-container.yang +++ /dev/null @@ -1,35 +0,0 @@ -module data-container-yang { - namespace "data:container:yang"; - - prefix "dtconyg"; - revision 2013-11-19 { - } - - container cont { - leaf lf1 { - type string; - } - - leaf lf2 { - type string; - } - - leaf lf3 { - type empty; - } - - leaf-list lflst1 { - type string; - } - list lst1 { - leaf lf11 { - type string; - } - } - container cont1 { - leaf lf11 { - type uint8; - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container.xml deleted file mode 100644 index 841d351049..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container.xml +++ /dev/null @@ -1,14 +0,0 @@ - - str0 - - - 121 - 131 - str1 - - str2 - - - 100 - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list-yang/data-container.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list-yang/data-container.yang deleted file mode 100644 index 3df34134f4..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list-yang/data-container.yang +++ /dev/null @@ -1,28 +0,0 @@ -module data-container-yang { - namespace "data:container:yang"; - - prefix "dtconyg"; - revision 2013-11-19 { - } - - container cont { - list lst1 { - leaf lf11 { - type string; - } - leaf-list lflst11 { - type string; - } - list lst11 { - leaf lf111 { - type string; - } - } - container cont11 { - leaf lf111 { - type uint8; - } - } - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list-yang/data-list.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list-yang/data-list.yang deleted file mode 100644 index 47e2a450e6..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list-yang/data-list.yang +++ /dev/null @@ -1,22 +0,0 @@ -module data-list-yang { - namespace "data:list:yang"; - - prefix "dtlstyg"; - - import data-container-yang { - prefix "dtconyg"; - revision-date 2013-11-19; - } - - - revision 2013-11-19 { - } - - - - augment "/dtconyg:cont" { - leaf lf1 { - type string; - } - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list.xml deleted file mode 100644 index 9c4256a50c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - str0 - 121 - 131 - str1 - - str2 - - - 100 - - - - 221 - - 100 - - - lf1 - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-nmspc-in-attributes.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-nmspc-in-attributes.xml deleted file mode 100644 index 848c02047f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-nmspc-in-attributes.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - c:iden - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-of-several-modules/yang/module1.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-of-several-modules/yang/module1.yang deleted file mode 100644 index f6a81ae664..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-of-several-modules/yang/module1.yang +++ /dev/null @@ -1,16 +0,0 @@ -module module1 { - namespace "module:one"; - - prefix "m1"; - revision 2014-01-17 { - } - - container cont_m1 { - leaf lf1_m1 { - type string; - } - } - container contB_m1 { - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-of-several-modules/yang/module2.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-of-several-modules/yang/module2.yang deleted file mode 100644 index bdd8ece24c..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-of-several-modules/yang/module2.yang +++ /dev/null @@ -1,17 +0,0 @@ -module module2 { - namespace "module:two"; - - prefix "m2"; - revision 2014-01-17 { - } - - container cont_m2 { - leaf lf1_m2 { - type string; - } - } - container contB_m2 { - } - - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/empty-data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/empty-data.xml deleted file mode 100644 index 7d62b9e24d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/empty-data.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/identity-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/identity-module.yang deleted file mode 100644 index 30890bf9c3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/identity-module.yang +++ /dev/null @@ -1,10 +0,0 @@ -module identity-module { - namespace "identity:module"; - - prefix "idemod"; - revision 2013-12-2 { - } - - identity iden { - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/identityref-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/identityref-module.yang deleted file mode 100644 index a43d43990d..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/identityref-module.yang +++ /dev/null @@ -1,21 +0,0 @@ -module identityref-module { - namespace "identityref:module"; - - prefix "iderefmod"; - - import identity-module {prefix idemo; revision-date 2013-12-2;} - - revision 2013-12-2 { - } - - container cont { - container cont1 { - leaf lf11 { - type identityref { - base "idemo:iden"; - } - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-element.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-element.xml deleted file mode 100644 index ebf7ac61ea..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-element.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - iden - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-parrent-element.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-parrent-element.xml deleted file mode 100644 index 3fe1e4bf48..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-parrent-element.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - iden - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-element.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-element.xml deleted file mode 100644 index 76de72d9f4..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-element.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - c:iden - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-parrent-element.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-parrent-element.xml deleted file mode 100644 index 30a54185ff..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-parrent-element.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - z:iden - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-with-prefix.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-with-prefix.xml deleted file mode 100644 index 7d31fa7a95..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-with-prefix.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - x:iden - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-without-prefix.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-without-prefix.xml deleted file mode 100644 index c65df1ab1e..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-without-prefix.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - iden - - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/general-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/general-module.yang deleted file mode 100644 index f1a1ea6260..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/general-module.yang +++ /dev/null @@ -1,14 +0,0 @@ -module general-module { - namespace "general:module"; - - prefix "genmod"; - revision 2013-12-12 { - } - - container cont { - container cont1 { - } - } - - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/identity-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/identity-module.yang deleted file mode 100644 index 30890bf9c3..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/identity-module.yang +++ /dev/null @@ -1,10 +0,0 @@ -module identity-module { - namespace "identity:module"; - - prefix "idemod"; - revision 2013-12-2 { - } - - identity iden { - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/identityref-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/identityref-module.yang deleted file mode 100644 index 719ac12226..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/yang-augments/identityref-module.yang +++ /dev/null @@ -1,20 +0,0 @@ -module identityref-module { - namespace "identityref:module"; - - prefix "iderefmod"; - - import identity-module {prefix idemo; revision-date 2013-12-2;} - import general-module {prefix gmo; revision-date 2013-12-12;} - - revision 2013-12-2 { - } - - augment "/gmo:cont/gmo:cont1" { - leaf lf11 { - type identityref { - base "idemo:iden"; - } - } - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/leafref-module b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/leafref-module deleted file mode 100644 index 6fe770b40b..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/leafref-module +++ /dev/null @@ -1,61 +0,0 @@ -module leafref-module { - namespace "leafref:module"; - - prefix "lfrfmo"; - revision 2013-11-18 { - } - - identity base {} - - container cont { - leaf lf1 { - type int32; - } - leaf lf2 { - type leafref { - path "/cont/lf1"; - } - } - - leaf lf-ident { - type identityref { - base "lfrfmo:base"; - } - } - - leaf lf-ident-ref { - type leafref { - path "/cont/lf-ident"; - } - } - - leaf lf-ident-ref-relative { - type leafref { - path "../lf-ident"; - } - } - - leaf lf-ident-ref-relative-cnd { - type leafref { - path "/lfrfmo:cont/lfrfmo:lis[lfrfmo:id='abc']/lf-ident-ref"; - } - } - - - list lis { - key "id"; - - leaf id { - type string; - } - - leaf lf-ident-ref { - type leafref { - path "/cont/lf-ident"; - } - } - } - - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/xml/data.xml deleted file mode 100644 index c3071e5610..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/xml/data.xml +++ /dev/null @@ -1,8 +0,0 @@ - - 121 - 121 - a:base - a:base - a:base - a:base - \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml b/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml deleted file mode 100644 index c7d0f69fb9..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - 4.0.0 - - org.opendaylight.controller - sal-parent - 1.3.0-SNAPSHOT - - - sal-rest-docgen-maven - jar - - - - com.fasterxml.jackson.core - jackson-databind - - - org.opendaylight.controller - sal-rest-docgen - - - org.apache.maven - maven-core - provided - - - org.opendaylight.yangtools - yang-maven-plugin-spi - - - diff --git a/opendaylight/md-sal/sal-rest-docgen-maven/src/main/java/org/opendaylight/controller/sal/rest/doc/maven/StaticDocGenerator.java b/opendaylight/md-sal/sal-rest-docgen-maven/src/main/java/org/opendaylight/controller/sal/rest/doc/maven/StaticDocGenerator.java deleted file mode 100644 index 0007bd45c1..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen-maven/src/main/java/org/opendaylight/controller/sal/rest/doc/maven/StaticDocGenerator.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.maven; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.ws.rs.core.UriInfo; -import org.apache.maven.project.MavenProject; -import org.opendaylight.controller.sal.rest.doc.impl.ApiDocGenerator; -import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration; -import org.opendaylight.controller.sal.rest.doc.swagger.Resource; -import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang2sources.spi.BasicCodeGenerator; -import org.opendaylight.yangtools.yang2sources.spi.MavenProjectAware; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class gathers all yang defined {@link Module}s and generates Swagger compliant documentation. - */ -public class StaticDocGenerator extends ApiDocGenerator implements BasicCodeGenerator, MavenProjectAware { - - private static final String DEFAULT_OUTPUT_BASE_DIR_PATH = "target" + File.separator + "generated-resources" - + File.separator + "swagger-api-documentation"; - - private static final Logger _logger = LoggerFactory.getLogger(ApiDocGenerator.class); - - private MavenProject mavenProject; - private File projectBaseDir; - private Map additionalConfig; - private File resourceBaseDir; - - /** - * - * @param context - * @param outputDir - * @param yangModules - * @return - * @throws IOException - */ - @Override - public Collection generateSources(final SchemaContext context, final File outputDir, final Set yangModules) throws IOException { - List result = new ArrayList<>(); - - // Create Base Directory - final File outputBaseDir; - if (outputDir == null) { - outputBaseDir = new File(DEFAULT_OUTPUT_BASE_DIR_PATH); - } else { - outputBaseDir = outputDir; - } - outputBaseDir.mkdirs(); - - // Create Resources directory - File resourcesDir = new File(outputBaseDir, "resources"); - resourcesDir.mkdirs(); - - // Create JS file - File resourcesJsFile = new File(outputBaseDir, "resources.js"); - resourcesJsFile.createNewFile(); - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(resourcesJsFile)); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - - // Write resource listing to JS file - ResourceList resourceList = super.getResourceListing(null, context, ""); - String resourceListJson = mapper.writeValueAsString(resourceList); - resourceListJson = resourceListJson.replace("\'", "\\\'").replace("\\n", "\\\\n"); - bufferedWriter.write("function getSpec() {\n\treturn \'" + resourceListJson + "\';\n}\n\n"); - - // Write resources/APIs to JS file and to disk - bufferedWriter.write("function jsonFor(resource) {\n\tswitch(resource) {\n"); - for (Resource resource : resourceList.getApis()) { - int revisionIndex = resource.getPath().indexOf('('); - String name = resource.getPath().substring(0, revisionIndex); - String revision = resource.getPath().substring(revisionIndex + 1, resource.getPath().length() - 1); - ApiDeclaration apiDeclaration = super.getApiDeclaration(name, revision, null, context, ""); - String json = mapper.writeValueAsString(apiDeclaration); - // Manually insert models because org.json.JSONObject cannot be serialized by ObjectMapper - json = json.replace("\"models\":{}", "\"models\":" + apiDeclaration.getModels().toString().replace("\\\"", "\"")); - // Escape single quotes and new lines - json = json.replace("\'", "\\\'").replace("\\n", "\\\\n"); - bufferedWriter.write("\t\tcase \"" + name + "(" + revision + ")\": return \'" + json + "\';\n"); - - File resourceFile = new File(resourcesDir, name + "(" + revision + ").json"); - BufferedWriter resourceFileWriter = new BufferedWriter(new FileWriter(resourceFile)); - resourceFileWriter.write(json); - resourceFileWriter.close(); - result.add(resourceFile); - } - bufferedWriter.write("\t}\n\treturn \"\";\n}"); - bufferedWriter.close(); - - result.add(resourcesJsFile); - return result; - } - - @Override - protected String generatePath(final UriInfo uriInfo, final String name, final String revision) { - if (uriInfo == null) { - return name + "(" + revision + ")"; - } - return super.generatePath(uriInfo, name, revision); - } - - @Override - protected String createBasePathFromUriInfo(final UriInfo uriInfo) { - if (uriInfo == null) { - return RESTCONF_CONTEXT_ROOT; - } - return super.createBasePathFromUriInfo(uriInfo); - } - - @Override - public void setAdditionalConfig(final Map additionalConfig) { - this.additionalConfig = additionalConfig; - } - - @Override - public void setResourceBaseDir(final File resourceBaseDir) { - this.resourceBaseDir = resourceBaseDir; - } - - @Override - public void setMavenProject(final MavenProject mavenProject) { - this.mavenProject = mavenProject; - this.projectBaseDir = mavenProject.getBasedir(); - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/pom.xml b/opendaylight/md-sal/sal-rest-docgen/pom.xml deleted file mode 100644 index 4e371a5b42..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - sal-parent - 1.3.0-SNAPSHOT - - - sal-rest-docgen - bundle - - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.datatype - jackson-datatype-json-org - - - - com.google.guava - guava - - - - org.apache.commons - commons-lang3 - - - - - org.jboss.resteasy - jaxrs-api - - - - org.json - json - - - - org.opendaylight.controller - sal-core-api - - - org.opendaylight.yangtools - yang-common - - - - org.opendaylight.yangtools - yang-model-api - - - org.opendaylight.yangtools - yang-model-util - - - org.opendaylight.yangtools - yang-parser-api - - - - org.opendaylight.yangtools - yang-parser-impl - - - - org.osgi - org.osgi.core - - - - org.slf4j - slf4j-api - - - junit - junit - test - - - org.mockito - mockito-all - test - - - org.opendaylight.yangtools - yang-data-api - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - - MD SAL Rest Api Doc Generator - !org.apache.maven.plugin.logging, - !org.apache.maven.project, - !org.opendaylight.yangtools.yang2sources.spi, - *, - com.sun.jersey.spi.container.servlet, org.eclipse.jetty.servlets - - org.opendaylight.controller.sal.rest.doc.DocProvider - /apidoc - - - - - - - diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/DocProvider.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/DocProvider.java deleted file mode 100644 index ca11b9ddd4..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/DocProvider.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.core.api.Broker; -import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; -import org.opendaylight.controller.sal.rest.doc.impl.ApiDocGenerator; -import org.opendaylight.controller.sal.rest.doc.mountpoints.MountPointSwagger; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; -import org.osgi.util.tracker.ServiceTrackerCustomizer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DocProvider implements BundleActivator, ServiceTrackerCustomizer, - Provider, AutoCloseable { - - private final Logger _logger = LoggerFactory.getLogger(DocProvider.class); - - private ServiceTracker brokerServiceTracker; - private BundleContext bundleContext; - private Broker.ProviderSession session; - - private final List toClose = new LinkedList<>(); - - @Override - public void close() throws Exception { - stop(bundleContext); - } - - @Override - public void onSessionInitiated(Broker.ProviderSession providerSession) { - SchemaService schemaService = providerSession.getService(SchemaService.class); - ApiDocGenerator.getInstance().setSchemaService(schemaService); - - DOMMountPointService mountService = providerSession - .getService(DOMMountPointService.class); - ListenerRegistration registration = mountService - .registerProvisionListener(MountPointSwagger.getInstance()); - MountPointSwagger.getInstance().setGlobalSchema(schemaService); - synchronized (toClose) { - toClose.add(registration); - } - MountPointSwagger.getInstance().setMountService(mountService); - - _logger.debug("Restconf API Explorer started"); - } - - @Override - public Collection getProviderFunctionality() { - return Collections.emptySet(); - } - - @Override - public void start(BundleContext context) throws Exception { - bundleContext = context; - brokerServiceTracker = new ServiceTracker<>(context, Broker.class, this); - brokerServiceTracker.open(); - } - - @Override - public void stop(BundleContext context) throws Exception { - if (brokerServiceTracker != null) { - brokerServiceTracker.close(); - } - - if (session != null) { - session.close(); - } - - synchronized (toClose) { - for (AutoCloseable close : toClose) { - close.close(); - } - } - } - - @Override - public Broker addingService(ServiceReference reference) { - Broker broker = bundleContext.getService(reference); - session = broker.registerProvider(this, bundleContext); - return broker; - } - - @Override - public void modifiedService(ServiceReference reference, Broker service) { - if (session != null) { - session.close(); - } - - Broker broker = bundleContext.getService(reference); - session = broker.registerProvider(this, bundleContext); - } - - @Override - public void removedService(ServiceReference reference, Broker service) { - bundleContext.ungetService(reference); - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/api/ApiDocService.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/api/ApiDocService.java deleted file mode 100644 index 2646a6a245..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/api/ApiDocService.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.api; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * This service generates swagger (See https://helloreverb.com/developers/swagger) compliant documentation for - * RESTCONF APIs. The output of this is used by embedded Swagger UI. - */ -@Path("/") -public interface ApiDocService { - - /** - * Generates index document for Swagger UI. This document lists out all - * modules with link to get APIs for each module. The API for each module is - * served by getDocByModule() method. - * - * @param uriInfo - * @return - */ - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getRootDoc(@Context javax.ws.rs.core.UriInfo uriInfo); - - /** - * Generates Swagger compliant document listing APIs for module. - * - * @param module - * @param revision - * @param uriInfo - * @return - */ - @GET - @Path("/{module}({revision})") - @Produces(MediaType.APPLICATION_JSON) - public Response getDocByModule(@PathParam("module") String module, - @PathParam("revision") String revision, @Context javax.ws.rs.core.UriInfo uriInfo); - - /** - * Redirects to embedded swagger ui. - * - * @param uriInfo - * @return - */ - @GET - @Path("/ui") - @Produces(MediaType.TEXT_HTML) - public Response getApiExplorer(@Context javax.ws.rs.core.UriInfo uriInfo); - - /** - * Generates index document for Swagger UI. This document lists out all - * modules with link to get APIs for each module. The API for each module is - * served by getDocByModule() method. - * - * @param uriInfo - * @return - */ - @GET - @Path("/mounts") - @Produces(MediaType.APPLICATION_JSON) - public Response getListOfMounts(@Context javax.ws.rs.core.UriInfo uriInfo); - - @GET - @Path("/mounts/{instance}") - @Produces(MediaType.APPLICATION_JSON) - public Response getMountRootDoc(@PathParam("instance") String instanceNum, - @Context javax.ws.rs.core.UriInfo uriInfo); - - /** - * Generates Swagger compliant document listing APIs for module. - * - * @param module - * @param revision - * @param uriInfo - * @return - */ - @GET - @Path("/mounts/{instance}/{module}({revision})") - @Produces(MediaType.APPLICATION_JSON) - public Response getMountDocByModule(@PathParam("instance") String instanceNum, - @PathParam("module") String module, @PathParam("revision") String revision, - @Context javax.ws.rs.core.UriInfo uriInfo); - -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGenerator.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGenerator.java deleted file mode 100644 index a89cbe5deb..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGenerator.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.impl; - -import com.google.common.base.Preconditions; -import javax.ws.rs.core.UriInfo; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration; -import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * This class gathers all yang defined {@link Module}s and generates Swagger compliant documentation. - */ -public class ApiDocGenerator extends BaseYangSwaggerGenerator { - - private static final ApiDocGenerator INSTANCE = new ApiDocGenerator(); - private SchemaService schemaService; - - public ResourceList getResourceListing(UriInfo uriInfo) { - Preconditions.checkState(schemaService != null); - SchemaContext schemaContext = schemaService.getGlobalContext(); - Preconditions.checkState(schemaContext != null); - return super.getResourceListing(uriInfo, schemaContext, ""); - } - - public ApiDeclaration getApiDeclaration(String module, String revision, UriInfo uriInfo) { - SchemaContext schemaContext = schemaService.getGlobalContext(); - Preconditions.checkState(schemaContext != null); - return super.getApiDeclaration(module, revision, uriInfo, schemaContext, ""); - } - - /** - * Returns singleton instance - * - * @return - */ - public static ApiDocGenerator getInstance() { - return INSTANCE; - } - - /** - * - * @param schemaService - */ - public void setSchemaService(SchemaService schemaService) { - this.schemaService = schemaService; - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocServiceImpl.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocServiceImpl.java deleted file mode 100644 index c95f41c0bd..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocServiceImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.impl; - -import java.io.ByteArrayOutputStream; -import java.io.OutputStreamWriter; -import java.util.Map.Entry; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import org.json.JSONWriter; -import org.opendaylight.controller.sal.rest.doc.api.ApiDocService; -import org.opendaylight.controller.sal.rest.doc.mountpoints.MountPointSwagger; -import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration; -import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList; - -/** - * This service generates swagger (See https://helloreverb.com/developers/swagger) compliant documentation for - * RESTCONF APIs. The output of this is used by embedded Swagger UI. - * - * NOTE: These API's need to be synchronized due to bug 1198. Thread access to - * the SchemaContext is not synchronized properly and thus you can end up with - * missing definitions without this synchronization. There are likely otherways - * to work around this limitation, but given that this API is a dev only tool - * and not dependent UI, this was the fastest work around. - * - */ -public class ApiDocServiceImpl implements ApiDocService { - - private static final ApiDocService INSTANCE = new ApiDocServiceImpl(); - - public static ApiDocService getInstance() { - return INSTANCE; - } - - /** - * Generates index document for Swagger UI. This document lists out all - * modules with link to get APIs for each module. The API for each module is - * served by getDocByModule() method. - * - * @param uriInfo - * @return - */ - @Override - public synchronized Response getRootDoc(UriInfo uriInfo) { - ApiDocGenerator generator = ApiDocGenerator.getInstance(); - ResourceList rootDoc = generator.getResourceListing(uriInfo); - - return Response.ok(rootDoc).build(); - } - - /** - * Generates Swagger compliant document listing APIs for module. - * - * @param module - * @param revision - * @param uriInfo - * @return - */ - @Override - public synchronized Response getDocByModule(String module, String revision, UriInfo uriInfo) { - ApiDocGenerator generator = ApiDocGenerator.getInstance(); - - ApiDeclaration doc = generator.getApiDeclaration(module, revision, uriInfo); - return Response.ok(doc).build(); - } - - /** - * Redirects to embedded swagger ui. - * - * @param uriInfo - * @return - */ - @Override - public synchronized Response getApiExplorer(UriInfo uriInfo) { - return Response - .seeOther(uriInfo.getBaseUriBuilder().path("../explorer/index.html").build()) - .build(); - } - - @Override - public synchronized Response getListOfMounts(UriInfo uriInfo) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (OutputStreamWriter streamWriter = new OutputStreamWriter(baos)) { - JSONWriter writer = new JSONWriter(streamWriter); - writer.array(); - for (Entry entry : MountPointSwagger.getInstance() - .getInstanceIdentifiers().entrySet()) { - writer.object(); - writer.key("instance").value(entry.getKey()); - writer.key("id").value(entry.getValue()); - writer.endObject(); - } - writer.endArray(); - } catch (Exception e) { - return Response.status(500).entity(e.getMessage()).build(); - } - return Response.status(200).entity(baos.toString()).build(); - } - - @Override - public synchronized Response getMountRootDoc(String instanceNum, UriInfo uriInfo) { - ResourceList resourceList = MountPointSwagger.getInstance().getResourceList(uriInfo, - Long.parseLong(instanceNum)); - return Response.ok(resourceList).build(); - } - - @Override - public synchronized Response getMountDocByModule(String instanceNum, String module, - String revision, UriInfo uriInfo) { - ApiDeclaration api = MountPointSwagger.getInstance().getMountPointApi(uriInfo, - Long.parseLong(instanceNum), module, revision); - return Response.ok(api).build(); - } - -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/BaseYangSwaggerGenerator.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/BaseYangSwaggerGenerator.java deleted file mode 100644 index c40eca0051..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/BaseYangSwaggerGenerator.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.impl; - -import static org.opendaylight.controller.sal.rest.doc.util.RestDocgenUtil.resolvePathArgumentsName; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; -import com.google.common.base.Preconditions; -import java.io.IOException; -import java.net.URI; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import javax.ws.rs.core.UriInfo; -import org.json.JSONException; -import org.json.JSONObject; -import org.opendaylight.controller.sal.rest.doc.model.builder.OperationBuilder; -import org.opendaylight.controller.sal.rest.doc.swagger.Api; -import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration; -import org.opendaylight.controller.sal.rest.doc.swagger.Operation; -import org.opendaylight.controller.sal.rest.doc.swagger.Parameter; -import org.opendaylight.controller.sal.rest.doc.swagger.Resource; -import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BaseYangSwaggerGenerator { - - private static final Logger LOG = LoggerFactory.getLogger(BaseYangSwaggerGenerator.class); - - protected static final String API_VERSION = "1.0.0"; - protected static final String SWAGGER_VERSION = "1.2"; - protected static final String RESTCONF_CONTEXT_ROOT = "restconf"; - - static final String MODULE_NAME_SUFFIX = "_module"; - protected final DateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - private final ModelGenerator jsonConverter = new ModelGenerator(); - - // private Map MODULE_DOC_CACHE = new HashMap<>() - private final ObjectMapper mapper = new ObjectMapper(); - - protected BaseYangSwaggerGenerator() { - mapper.registerModule(new JsonOrgModule()); - mapper.configure(SerializationFeature.INDENT_OUTPUT, true); - } - - /** - * - * @param uriInfo - * @param operType - * @return list of modules converted to swagger compliant resource list. - */ - public ResourceList getResourceListing(UriInfo uriInfo, SchemaContext schemaContext, String context) { - - ResourceList resourceList = createResourceList(); - - Set modules = getSortedModules(schemaContext); - - List resources = new ArrayList<>(modules.size()); - - LOG.info("Modules found [{}]", modules.size()); - - for (Module module : modules) { - String revisionString = SIMPLE_DATE_FORMAT.format(module.getRevision()); - Resource resource = new Resource(); - LOG.debug("Working on [{},{}]...", module.getName(), revisionString); - ApiDeclaration doc = getApiDeclaration(module.getName(), revisionString, uriInfo, schemaContext, context); - - if (doc != null) { - resource.setPath(generatePath(uriInfo, module.getName(), revisionString)); - resources.add(resource); - } else { - LOG.debug("Could not generate doc for {},{}", module.getName(), revisionString); - } - } - - resourceList.setApis(resources); - - return resourceList; - } - - protected ResourceList createResourceList() { - ResourceList resourceList = new ResourceList(); - resourceList.setApiVersion(API_VERSION); - resourceList.setSwaggerVersion(SWAGGER_VERSION); - return resourceList; - } - - protected String generatePath(UriInfo uriInfo, String name, String revision) { - URI uri = uriInfo.getRequestUriBuilder().path(generateCacheKey(name, revision)).build(); - return uri.toASCIIString(); - } - - public ApiDeclaration getApiDeclaration(String module, String revision, UriInfo uriInfo, SchemaContext schemaContext, String context) { - Date rev = null; - - try { - if(revision != null && !revision.equals("0000-00-00")) { - rev = SIMPLE_DATE_FORMAT.parse(revision); - } - } catch (ParseException e) { - throw new IllegalArgumentException(e); - } - - if(rev != null) { - Calendar cal = new GregorianCalendar(); - - cal.setTime(rev); - - if(cal.get(Calendar.YEAR) < 1970) { - rev = null; - } - } - - Module m = schemaContext.findModuleByName(module, rev); - Preconditions.checkArgument(m != null, "Could not find module by name,revision: " + module + "," + revision); - - return getApiDeclaration(m, rev, uriInfo, context, schemaContext); - } - - public ApiDeclaration getApiDeclaration(Module module, Date revision, UriInfo uriInfo, String context, SchemaContext schemaContext) { - String basePath = createBasePathFromUriInfo(uriInfo); - - ApiDeclaration doc = getSwaggerDocSpec(module, basePath, context, schemaContext); - if (doc != null) { - return doc; - } - return null; - } - - protected String createBasePathFromUriInfo(UriInfo uriInfo) { - String portPart = ""; - int port = uriInfo.getBaseUri().getPort(); - if (port != -1) { - portPart = ":" + port; - } - String basePath = new StringBuilder(uriInfo.getBaseUri().getScheme()).append("://") - .append(uriInfo.getBaseUri().getHost()).append(portPart).append("/").append(RESTCONF_CONTEXT_ROOT) - .toString(); - return basePath; - } - - public ApiDeclaration getSwaggerDocSpec(Module m, String basePath, String context, SchemaContext schemaContext) { - ApiDeclaration doc = createApiDeclaration(basePath); - - List apis = new ArrayList(); - - Collection dataSchemaNodes = m.getChildNodes(); - LOG.debug("child nodes size [{}]", dataSchemaNodes.size()); - for (DataSchemaNode node : dataSchemaNodes) { - if ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) { - - LOG.debug("Is Configuration node [{}] [{}]", node.isConfiguration(), node.getQName().getLocalName()); - - List pathParams = new ArrayList(); - String resourcePath = getDataStorePath("/config/", context); - addRootPostLink(m, (DataNodeContainer) node, pathParams, resourcePath, apis); - addApis(node, apis, resourcePath, pathParams, schemaContext, true); - - pathParams = new ArrayList(); - resourcePath = getDataStorePath("/operational/", context); - addApis(node, apis, resourcePath, pathParams, schemaContext, false); - } - } - - Set rpcs = m.getRpcs(); - for (RpcDefinition rpcDefinition : rpcs) { - String resourcePath = getDataStorePath("/operations/", context); - addRpcs(rpcDefinition, apis, resourcePath, schemaContext); - } - - LOG.debug("Number of APIs found [{}]", apis.size()); - - if (!apis.isEmpty()) { - doc.setApis(apis); - JSONObject models = null; - - try { - models = jsonConverter.convertToJsonSchema(m, schemaContext); - doc.setModels(models); - if (LOG.isDebugEnabled()) { - LOG.debug(mapper.writeValueAsString(doc)); - } - } catch (IOException | JSONException e) { - e.printStackTrace(); - } - - return doc; - } - return null; - } - - private void addRootPostLink(final Module m, final DataNodeContainer node, final List pathParams, - final String resourcePath, final List apis) { - if (containsListOrContainer(m.getChildNodes())) { - final Api apiForRootPostUri = new Api(); - apiForRootPostUri.setPath(resourcePath); - apiForRootPostUri.setOperations(operationPost(m.getName()+MODULE_NAME_SUFFIX, m.getDescription(), m, pathParams, true)); - apis.add(apiForRootPostUri); - } - } - - protected ApiDeclaration createApiDeclaration(String basePath) { - ApiDeclaration doc = new ApiDeclaration(); - doc.setApiVersion(API_VERSION); - doc.setSwaggerVersion(SWAGGER_VERSION); - doc.setBasePath(basePath); - doc.setProduces(Arrays.asList("application/json", "application/xml")); - return doc; - } - - protected String getDataStorePath(String dataStore, String context) { - return dataStore + context; - } - - private String generateCacheKey(Module m) { - return generateCacheKey(m.getName(), SIMPLE_DATE_FORMAT.format(m.getRevision())); - } - - private String generateCacheKey(String module, String revision) { - return module + "(" + revision + ")"; - } - - private void addApis(DataSchemaNode node, List apis, String parentPath, List parentPathParams, SchemaContext schemaContext, - boolean addConfigApi) { - - Api api = new Api(); - List pathParams = new ArrayList(parentPathParams); - - String resourcePath = parentPath + createPath(node, pathParams, schemaContext) + "/"; - LOG.debug("Adding path: [{}]", resourcePath); - api.setPath(resourcePath); - - Iterable childSchemaNodes = Collections. emptySet(); - if ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) { - DataNodeContainer dataNodeContainer = (DataNodeContainer) node; - childSchemaNodes = dataNodeContainer.getChildNodes(); - } - api.setOperations(operation(node, pathParams, addConfigApi, childSchemaNodes)); - apis.add(api); - - for (DataSchemaNode childNode : childSchemaNodes) { - if (childNode instanceof ListSchemaNode || childNode instanceof ContainerSchemaNode) { - // keep config and operation attributes separate. - if (childNode.isConfiguration() == addConfigApi) { - addApis(childNode, apis, resourcePath, pathParams, schemaContext, addConfigApi); - } - } - } - - } - - private boolean containsListOrContainer(final Iterable nodes) { - for (DataSchemaNode child : nodes) { - if (child instanceof ListSchemaNode || child instanceof ContainerSchemaNode) { - return true; - } - } - return false; - } - - /** - * @param node - * @param pathParams - * @return - */ - private List operation(DataSchemaNode node, List pathParams, boolean isConfig, Iterable childSchemaNodes) { - List operations = new ArrayList<>(); - - OperationBuilder.Get getBuilder = new OperationBuilder.Get(node, isConfig); - operations.add(getBuilder.pathParams(pathParams).build()); - - if (isConfig) { - OperationBuilder.Put putBuilder = new OperationBuilder.Put(node.getQName().getLocalName(), - node.getDescription()); - operations.add(putBuilder.pathParams(pathParams).build()); - - OperationBuilder.Delete deleteBuilder = new OperationBuilder.Delete(node); - operations.add(deleteBuilder.pathParams(pathParams).build()); - - if (containsListOrContainer(childSchemaNodes)) { - operations.addAll(operationPost(node.getQName().getLocalName(), node.getDescription(), (DataNodeContainer) node, - pathParams, isConfig)); - } - } - return operations; - } - - /** - * @param node - * @param pathParams - * @return - */ - private List operationPost(final String name, final String description, final DataNodeContainer dataNodeContainer, List pathParams, boolean isConfig) { - List operations = new ArrayList<>(); - if (isConfig) { - OperationBuilder.Post postBuilder = new OperationBuilder.Post(name, description, dataNodeContainer); - operations.add(postBuilder.pathParams(pathParams).build()); - } - return operations; - } - - private String createPath(final DataSchemaNode schemaNode, List pathParams, SchemaContext schemaContext) { - ArrayList pathListParams = new ArrayList(); - StringBuilder path = new StringBuilder(); - String localName = resolvePathArgumentsName(schemaNode, schemaContext); - path.append(localName); - - if ((schemaNode instanceof ListSchemaNode)) { - final List listKeys = ((ListSchemaNode) schemaNode).getKeyDefinition(); - for (final QName listKey : listKeys) { - DataSchemaNode _dataChildByName = ((DataNodeContainer) schemaNode).getDataChildByName(listKey); - pathListParams.add(((LeafSchemaNode) _dataChildByName)); - - String pathParamIdentifier = new StringBuilder("/{").append(listKey.getLocalName()).append("}") - .toString(); - path.append(pathParamIdentifier); - - Parameter pathParam = new Parameter(); - pathParam.setName(listKey.getLocalName()); - pathParam.setDescription(_dataChildByName.getDescription()); - pathParam.setType("string"); - pathParam.setParamType("path"); - - pathParams.add(pathParam); - } - } - return path.toString(); - } - - protected void addRpcs(RpcDefinition rpcDefn, List apis, String parentPath, SchemaContext schemaContext) { - Api rpc = new Api(); - String resourcePath = parentPath + resolvePathArgumentsName(rpcDefn, schemaContext); - rpc.setPath(resourcePath); - - Operation operationSpec = new Operation(); - operationSpec.setMethod("POST"); - operationSpec.setNotes(rpcDefn.getDescription()); - operationSpec.setNickname(rpcDefn.getQName().getLocalName()); - if (rpcDefn.getOutput() != null) { - operationSpec.setType("(" + rpcDefn.getQName().getLocalName() + ")output"); - } - if (rpcDefn.getInput() != null) { - Parameter payload = new Parameter(); - payload.setParamType("body"); - payload.setType("(" + rpcDefn.getQName().getLocalName() + ")input"); - operationSpec.setParameters(Collections.singletonList(payload)); - operationSpec.setConsumes(OperationBuilder.CONSUMES_PUT_POST); - } - - rpc.setOperations(Arrays.asList(operationSpec)); - - apis.add(rpc); - } - - protected SortedSet getSortedModules(SchemaContext schemaContext) { - if (schemaContext == null) { - return new TreeSet<>(); - } - - Set modules = schemaContext.getModules(); - - SortedSet sortedModules = new TreeSet<>(new Comparator() { - @Override - public int compare(Module module1, Module module2) { - int result = module1.getName().compareTo(module2.getName()); - if (result == 0) { - Date module1Revision = module1.getRevision() != null ? module1.getRevision() : new Date(0); - Date module2Revision = module2.getRevision() != null ? module2.getRevision() : new Date(0); - result = module1Revision.compareTo(module2Revision); - } - if (result == 0) { - result = module1.getNamespace().compareTo(module2.getNamespace()); - } - return result; - } - }); - for (Module m : modules) { - if (m != null) { - sortedModules.add(m); - } - } - return sortedModules; - } - -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGenerator.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGenerator.java deleted file mode 100644 index 93daf05b50..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGenerator.java +++ /dev/null @@ -1,614 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.impl; - -import static org.opendaylight.controller.sal.rest.doc.impl.BaseYangSwaggerGenerator.MODULE_NAME_SUFFIX; -import static org.opendaylight.controller.sal.rest.doc.model.builder.OperationBuilder.Post.METHOD_NAME; -import static org.opendaylight.controller.sal.rest.doc.util.RestDocgenUtil.resolveNodesName; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.annotation.concurrent.NotThreadSafe; -import org.apache.commons.lang3.BooleanUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.opendaylight.controller.sal.rest.doc.model.builder.OperationBuilder; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit; -import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair; -import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; -import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition; -import org.opendaylight.yangtools.yang.model.util.BooleanType; -import org.opendaylight.yangtools.yang.model.util.Decimal64; -import org.opendaylight.yangtools.yang.model.util.EnumerationType; -import org.opendaylight.yangtools.yang.model.util.ExtendedType; -import org.opendaylight.yangtools.yang.model.util.Int16; -import org.opendaylight.yangtools.yang.model.util.Int32; -import org.opendaylight.yangtools.yang.model.util.Int64; -import org.opendaylight.yangtools.yang.model.util.Int8; -import org.opendaylight.yangtools.yang.model.util.StringType; -import org.opendaylight.yangtools.yang.model.util.Uint16; -import org.opendaylight.yangtools.yang.model.util.Uint32; -import org.opendaylight.yangtools.yang.model.util.Uint64; -import org.opendaylight.yangtools.yang.model.util.Uint8; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Generates JSON Schema for data defined in Yang - */ -@NotThreadSafe -public class ModelGenerator { - - private static final Logger LOG = LoggerFactory.getLogger(ModelGenerator.class); - - private static final String BASE_64 = "base64"; - private static final String BINARY_ENCODING_KEY = "binaryEncoding"; - private static final String MEDIA_KEY = "media"; - private static final String ONE_OF_KEY = "oneOf"; - private static final String UNIQUE_ITEMS_KEY = "uniqueItems"; - private static final String MAX_ITEMS = "maxItems"; - private static final String MIN_ITEMS = "minItems"; - private static final String SCHEMA_URL = "http://json-schema.org/draft-04/schema"; - private static final String SCHEMA_KEY = "$schema"; - private static final String MAX_LENGTH_KEY = "maxLength"; - private static final String MIN_LENGTH_KEY = "minLength"; - private static final String REQUIRED_KEY = "required"; - private static final String REF_KEY = "$ref"; - private static final String ITEMS_KEY = "items"; - private static final String TYPE_KEY = "type"; - private static final String PROPERTIES_KEY = "properties"; - private static final String DESCRIPTION_KEY = "description"; - private static final String OBJECT_TYPE = "object"; - private static final String ARRAY_TYPE = "array"; - private static final String ENUM = "enum"; - private static final String INTEGER = "integer"; - private static final String NUMBER = "number"; - private static final String BOOLEAN = "boolean"; - private static final String STRING = "string"; - private static final String ID_KEY = "id"; - private static final String SUB_TYPES_KEY = "subTypes"; - - private static final Map, String> YANG_TYPE_TO_JSON_TYPE_MAPPING; - - static { - final Builder, String> b = ImmutableMap.builder(); - - b.put(StringType.class, STRING); - b.put(BooleanType.class, BOOLEAN); - b.put(Int8.class, INTEGER); - b.put(Int16.class, INTEGER); - b.put(Int32.class, INTEGER); - b.put(Int64.class, INTEGER); - b.put(Uint16.class, INTEGER); - b.put(Uint32.class, INTEGER); - b.put(Uint64.class, INTEGER); - b.put(Uint8.class, INTEGER); - b.put(Decimal64.class, NUMBER); - b.put(EnumerationType.class, ENUM); - // TODO: Binary type - - YANG_TYPE_TO_JSON_TYPE_MAPPING = b.build(); - } - - private Module topLevelModule; - - public ModelGenerator() { - } - - public JSONObject convertToJsonSchema(final Module module, final SchemaContext schemaContext) throws IOException, JSONException { - JSONObject models = new JSONObject(); - topLevelModule = module; - processModules(module, models); - processContainersAndLists(module, models, schemaContext); - processRPCs(module, models, schemaContext); - processIdentities(module, models); - return models; - } - - private void processModules(final Module module, final JSONObject models) throws JSONException { - createConcreteModelForPost(models, module.getName()+MODULE_NAME_SUFFIX, createPropertiesForPost(module)); - } - - private void processContainersAndLists(final Module module, final JSONObject models, final SchemaContext schemaContext) - throws IOException, JSONException { - - String moduleName = module.getName(); - - for (DataSchemaNode childNode : module.getChildNodes()) { - // For every container and list in the module - if (childNode instanceof ContainerSchemaNode || childNode instanceof ListSchemaNode) { - processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, true, schemaContext); - processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, false, schemaContext); - } - } - - } - - /** - * Process the RPCs for a Module Spits out a file each of the name -input.json and -output.json - * for each RPC that contains input & output elements - * - * @param module - * @throws JSONException - * @throws IOException - */ - private void processRPCs(final Module module, final JSONObject models, final SchemaContext schemaContext) throws JSONException, - IOException { - - Set rpcs = module.getRpcs(); - String moduleName = module.getName(); - for (RpcDefinition rpc : rpcs) { - - ContainerSchemaNode input = rpc.getInput(); - if (input != null) { - JSONObject inputJSON = processDataNodeContainer(input, moduleName, models, schemaContext); - String filename = "(" + rpc.getQName().getLocalName() + ")input"; - inputJSON.put("id", filename); - // writeToFile(filename, inputJSON.toString(2), moduleName); - models.put(filename, inputJSON); - } - - ContainerSchemaNode output = rpc.getOutput(); - if (output != null) { - JSONObject outputJSON = processDataNodeContainer(output, moduleName, models, schemaContext); - String filename = "(" + rpc.getQName().getLocalName() + ")output"; - outputJSON.put("id", filename); - models.put(filename, outputJSON); - } - } - } - - /** - * Processes the 'identity' statement in a yang model and maps it to a 'model' in the Swagger JSON spec. - * - * @param module - * The module from which the identity stmt will be processed - * @param models - * The JSONObject in which the parsed identity will be put as a 'model' obj - * @throws JSONException - */ - private void processIdentities(final Module module, final JSONObject models) throws JSONException { - - String moduleName = module.getName(); - Set idNodes = module.getIdentities(); - LOG.debug("Processing Identities for module {} . Found {} identity statements", moduleName, idNodes.size()); - - for (IdentitySchemaNode idNode : idNodes) { - JSONObject identityObj = new JSONObject(); - String identityName = idNode.getQName().getLocalName(); - LOG.debug("Processing Identity: {}", identityName); - - identityObj.put(ID_KEY, identityName); - identityObj.put(DESCRIPTION_KEY, idNode.getDescription()); - - JSONObject props = new JSONObject(); - IdentitySchemaNode baseId = idNode.getBaseIdentity(); - - if (baseId == null) { - /** - * This is a base identity. So lets see if it has sub types. If it does, then add them to the model - * definition. - */ - Set derivedIds = idNode.getDerivedIdentities(); - - if (derivedIds != null) { - JSONArray subTypes = new JSONArray(); - for (IdentitySchemaNode derivedId : derivedIds) { - subTypes.put(derivedId.getQName().getLocalName()); - } - identityObj.put(SUB_TYPES_KEY, subTypes); - } - } else { - /** - * This is a derived entity. Add it's base type & move on. - */ - props.put(TYPE_KEY, baseId.getQName().getLocalName()); - } - - // Add the properties. For a base type, this will be an empty object as required by the Swagger spec. - identityObj.put(PROPERTIES_KEY, props); - models.put(identityName, identityObj); - } - } - - /** - * Processes the container and list nodes and populates the moduleJSON - * - * @param container - * @param moduleName - * @param isConfig - * @throws JSONException - * @throws IOException - */ - private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models, - final SchemaContext schemaContext) throws JSONException, IOException { - return processDataNodeContainer(dataNode, moduleName, models, (Boolean) null, schemaContext); - } - - private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models, - final Boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException { - if (dataNode instanceof ListSchemaNode || dataNode instanceof ContainerSchemaNode) { - Preconditions.checkArgument(dataNode instanceof SchemaNode, "Data node should be also schema node"); - Iterable containerChildren = dataNode.getChildNodes(); - JSONObject properties = processChildren(containerChildren, ((SchemaNode) dataNode).getQName(), moduleName, - models, isConfig, schemaContext); - - String nodeName = (BooleanUtils.isNotFalse(isConfig) ? OperationBuilder.CONFIG - : OperationBuilder.OPERATIONAL) + ((SchemaNode) dataNode).getQName().getLocalName(); - - JSONObject childSchema = getSchemaTemplate(); - childSchema.put(TYPE_KEY, OBJECT_TYPE); - childSchema.put(PROPERTIES_KEY, properties); - childSchema.put("id", nodeName); - models.put(nodeName, childSchema); - - if (BooleanUtils.isNotFalse(isConfig)) { - createConcreteModelForPost(models, ((SchemaNode) dataNode).getQName().getLocalName(), - createPropertiesForPost(dataNode)); - } - - JSONObject items = new JSONObject(); - items.put(REF_KEY, nodeName); - JSONObject dataNodeProperties = new JSONObject(); - dataNodeProperties.put(TYPE_KEY, dataNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE); - dataNodeProperties.put(ITEMS_KEY, items); - - return dataNodeProperties; - } - return null; - } - - private void createConcreteModelForPost(final JSONObject models, final String localName, final JSONObject properties) - throws JSONException { - String nodePostName = OperationBuilder.CONFIG + localName + METHOD_NAME; - JSONObject postSchema = getSchemaTemplate(); - postSchema.put(TYPE_KEY, OBJECT_TYPE); - postSchema.put("id", nodePostName); - postSchema.put(PROPERTIES_KEY, properties); - models.put(nodePostName, postSchema); - } - - private JSONObject createPropertiesForPost(final DataNodeContainer dataNodeContainer) throws JSONException { - JSONObject properties = new JSONObject(); - for (DataSchemaNode childNode : dataNodeContainer.getChildNodes()) { - if (childNode instanceof ListSchemaNode || childNode instanceof ContainerSchemaNode) { - JSONObject items = new JSONObject(); - items.put(REF_KEY, "(config)" + childNode.getQName().getLocalName()); - JSONObject property = new JSONObject(); - property.put(TYPE_KEY, childNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE); - property.put(ITEMS_KEY, items); - properties.put(childNode.getQName().getLocalName(), property); - } else if (childNode instanceof LeafSchemaNode){ - JSONObject property = processLeafNode((LeafSchemaNode)childNode); - properties.put(childNode.getQName().getLocalName(), property); - } - } - return properties; - } - - private JSONObject processChildren(final Iterable nodes, final QName parentQName, final String moduleName, - final JSONObject models, final SchemaContext schemaContext) throws JSONException, IOException { - return processChildren(nodes, parentQName, moduleName, models, null, schemaContext); - } - - /** - * Processes the nodes - * - * @param nodes - * @param parentQName - * @param moduleName - * @param isConfig - * @return - * @throws JSONException - * @throws IOException - */ - private JSONObject processChildren(final Iterable nodes, final QName parentQName, final String moduleName, - final JSONObject models, final Boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException { - - JSONObject properties = new JSONObject(); - - for (DataSchemaNode node : nodes) { - if (isConfig == null || node.isConfiguration() == isConfig) { - - String name = resolveNodesName(node, topLevelModule, schemaContext); - JSONObject property = null; - if (node instanceof LeafSchemaNode) { - property = processLeafNode((LeafSchemaNode) node); - } else if (node instanceof ListSchemaNode) { - property = processDataNodeContainer((ListSchemaNode) node, moduleName, models, isConfig, - schemaContext); - - } else if (node instanceof LeafListSchemaNode) { - property = processLeafListNode((LeafListSchemaNode) node); - - } else if (node instanceof ChoiceSchemaNode) { - property = processChoiceNode((ChoiceSchemaNode) node, moduleName, models, schemaContext); - - } else if (node instanceof AnyXmlSchemaNode) { - property = processAnyXMLNode((AnyXmlSchemaNode) node); - - } else if (node instanceof ContainerSchemaNode) { - property = processDataNodeContainer((ContainerSchemaNode) node, moduleName, models, isConfig, - schemaContext); - - } else { - throw new IllegalArgumentException("Unknown DataSchemaNode type: " + node.getClass()); - } - - property.putOpt(DESCRIPTION_KEY, node.getDescription()); - properties.put(name, property); - } - } - return properties; - } - - /** - * - * @param listNode - * @throws JSONException - */ - private JSONObject processLeafListNode(final LeafListSchemaNode listNode) throws JSONException { - JSONObject props = new JSONObject(); - props.put(TYPE_KEY, ARRAY_TYPE); - - JSONObject itemsVal = new JSONObject(); - processTypeDef(listNode.getType(), itemsVal); - props.put(ITEMS_KEY, itemsVal); - - ConstraintDefinition constraints = listNode.getConstraints(); - processConstraints(constraints, props); - - return props; - } - - /** - * - * @param choiceNode - * @param moduleName - * @throws JSONException - * @throws IOException - */ - private JSONObject processChoiceNode(final ChoiceSchemaNode choiceNode, final String moduleName, final JSONObject models, - final SchemaContext schemaContext) throws JSONException, IOException { - - Set cases = choiceNode.getCases(); - - JSONArray choiceProps = new JSONArray(); - for (ChoiceCaseNode choiceCase : cases) { - String choiceName = choiceCase.getQName().getLocalName(); - JSONObject choiceProp = processChildren(choiceCase.getChildNodes(), choiceCase.getQName(), moduleName, - models, schemaContext); - JSONObject choiceObj = new JSONObject(); - choiceObj.put(choiceName, choiceProp); - choiceObj.put(TYPE_KEY, OBJECT_TYPE); - choiceProps.put(choiceObj); - } - - JSONObject oneOfProps = new JSONObject(); - oneOfProps.put(ONE_OF_KEY, choiceProps); - oneOfProps.put(TYPE_KEY, OBJECT_TYPE); - - return oneOfProps; - } - - /** - * - * @param constraints - * @param props - * @throws JSONException - */ - private void processConstraints(final ConstraintDefinition constraints, final JSONObject props) throws JSONException { - boolean isMandatory = constraints.isMandatory(); - props.put(REQUIRED_KEY, isMandatory); - - Integer minElements = constraints.getMinElements(); - Integer maxElements = constraints.getMaxElements(); - if (minElements != null) { - props.put(MIN_ITEMS, minElements); - } - if (maxElements != null) { - props.put(MAX_ITEMS, maxElements); - } - } - - /** - * - * @param leafNode - * @return - * @throws JSONException - */ - private JSONObject processLeafNode(final LeafSchemaNode leafNode) throws JSONException { - JSONObject property = new JSONObject(); - - String leafDescription = leafNode.getDescription(); - property.put(DESCRIPTION_KEY, leafDescription); - - processConstraints(leafNode.getConstraints(), property); - processTypeDef(leafNode.getType(), property); - - return property; - } - - /** - * - * @param leafNode - * @return - * @throws JSONException - */ - private JSONObject processAnyXMLNode(final AnyXmlSchemaNode leafNode) throws JSONException { - JSONObject property = new JSONObject(); - - String leafDescription = leafNode.getDescription(); - property.put(DESCRIPTION_KEY, leafDescription); - - processConstraints(leafNode.getConstraints(), property); - - return property; - } - - /** - * @param property - * @throws JSONException - */ - private void processTypeDef(final TypeDefinition leafTypeDef, final JSONObject property) throws JSONException { - - if (leafTypeDef instanceof ExtendedType) { - processExtendedType(leafTypeDef, property); - } else if (leafTypeDef instanceof EnumerationType) { - processEnumType((EnumerationType) leafTypeDef, property); - - } else if (leafTypeDef instanceof BitsTypeDefinition) { - processBitsType((BitsTypeDefinition) leafTypeDef, property); - - } else if (leafTypeDef instanceof UnionTypeDefinition) { - processUnionType((UnionTypeDefinition) leafTypeDef, property); - - } else if (leafTypeDef instanceof IdentityrefTypeDefinition) { - property.putOpt(TYPE_KEY, ((IdentityrefTypeDefinition) leafTypeDef).getIdentity().getQName().getLocalName()); - } else if (leafTypeDef instanceof BinaryTypeDefinition) { - processBinaryType((BinaryTypeDefinition) leafTypeDef, property); - } else { - // System.out.println("In else: " + leafTypeDef.getClass()); - String jsonType = YANG_TYPE_TO_JSON_TYPE_MAPPING.get(leafTypeDef.getClass()); - if (jsonType == null) { - jsonType = "object"; - } - property.putOpt(TYPE_KEY, jsonType); - } - } - - /** - * - * @param leafTypeDef - * @param property - * @throws JSONException - */ - private void processExtendedType(final TypeDefinition leafTypeDef, final JSONObject property) throws JSONException { - Object leafBaseType = leafTypeDef.getBaseType(); - if (leafBaseType instanceof ExtendedType) { - // recursively process an extended type until we hit a base type - processExtendedType((TypeDefinition) leafBaseType, property); - } else { - List lengthConstraints = ((ExtendedType) leafTypeDef).getLengthConstraints(); - for (LengthConstraint lengthConstraint : lengthConstraints) { - Number min = lengthConstraint.getMin(); - Number max = lengthConstraint.getMax(); - property.putOpt(MIN_LENGTH_KEY, min); - property.putOpt(MAX_LENGTH_KEY, max); - } - String jsonType = YANG_TYPE_TO_JSON_TYPE_MAPPING.get(leafBaseType.getClass()); - property.putOpt(TYPE_KEY, jsonType); - } - - } - - /* - * - */ - private void processBinaryType(final BinaryTypeDefinition binaryType, final JSONObject property) throws JSONException { - property.put(TYPE_KEY, STRING); - JSONObject media = new JSONObject(); - media.put(BINARY_ENCODING_KEY, BASE_64); - property.put(MEDIA_KEY, media); - } - - /** - * - * @param enumLeafType - * @param property - * @throws JSONException - */ - private void processEnumType(final EnumerationType enumLeafType, final JSONObject property) throws JSONException { - List enumPairs = enumLeafType.getValues(); - List enumNames = new ArrayList(); - for (EnumPair enumPair : enumPairs) { - enumNames.add(enumPair.getName()); - } - property.putOpt(ENUM, new JSONArray(enumNames)); - } - - /** - * - * @param bitsType - * @param property - * @throws JSONException - */ - private void processBitsType(final BitsTypeDefinition bitsType, final JSONObject property) throws JSONException { - property.put(TYPE_KEY, ARRAY_TYPE); - property.put(MIN_ITEMS, 0); - property.put(UNIQUE_ITEMS_KEY, true); - JSONArray enumValues = new JSONArray(); - - List bits = bitsType.getBits(); - for (Bit bit : bits) { - enumValues.put(bit.getName()); - } - JSONObject itemsValue = new JSONObject(); - itemsValue.put(ENUM, enumValues); - property.put(ITEMS_KEY, itemsValue); - } - - /** - * - * @param unionType - * @param property - * @throws JSONException - */ - private void processUnionType(final UnionTypeDefinition unionType, final JSONObject property) throws JSONException { - - StringBuilder type = new StringBuilder(); - for (TypeDefinition typeDef : unionType.getTypes()) { - if (type.length() > 0) { - type.append(" or "); - } - type.append(YANG_TYPE_TO_JSON_TYPE_MAPPING.get(typeDef.getClass())); - } - - property.put(TYPE_KEY, type); - } - - /** - * Helper method to generate a pre-filled JSON schema object. - * - * @return - * @throws JSONException - */ - private JSONObject getSchemaTemplate() throws JSONException { - JSONObject schemaJSON = new JSONObject(); - schemaJSON.put(SCHEMA_KEY, SCHEMA_URL); - - return schemaJSON; - } - -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/jaxrs/ApiDocApplication.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/jaxrs/ApiDocApplication.java deleted file mode 100644 index e833c61399..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/jaxrs/ApiDocApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.jaxrs; - -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.core.Application; - -import org.opendaylight.controller.sal.rest.doc.impl.ApiDocServiceImpl; - -public class ApiDocApplication extends Application { - @Override - public Set getSingletons() { - Set singletons = new HashSet<>(); - singletons.add(ApiDocServiceImpl.getInstance()); - singletons.add(new JaxbContextResolver()); - return singletons; - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/jaxrs/JaxbContextResolver.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/jaxrs/JaxbContextResolver.java deleted file mode 100644 index 66fc80fdc7..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/jaxrs/JaxbContextResolver.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.jaxrs; - -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; - -import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; - -@Provider -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public class JaxbContextResolver implements ContextResolver { - - private final ObjectMapper ctx; - - public JaxbContextResolver() { - ctx = new ObjectMapper(); - ctx.registerModule(new JsonOrgModule()); - ctx.getSerializationConfig().withSerializationInclusion(JsonInclude.Include.ALWAYS); - } - - @Override - public ObjectMapper getContext(Class aClass) { - - if (ApiDeclaration.class.isAssignableFrom(aClass)) { - return ctx; - } - - return null;// must return null so that jax-rs can continue context - // search - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/model/builder/OperationBuilder.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/model/builder/OperationBuilder.java deleted file mode 100644 index 88ca3bcd01..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/model/builder/OperationBuilder.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.model.builder; - -import java.util.ArrayList; -import java.util.List; -import org.opendaylight.controller.sal.rest.doc.swagger.Operation; -import org.opendaylight.controller.sal.rest.doc.swagger.Parameter; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; - -public final class OperationBuilder { - - public static final String OPERATIONAL = "(operational)"; - public static final String CONFIG = "(config)"; - - public static final List CONSUMES_PUT_POST = new ArrayList<>(); - static { - CONSUMES_PUT_POST.add("application/json"); - CONSUMES_PUT_POST.add("application/xml"); - } - - public static class Get { - - protected Operation spec; - protected DataSchemaNode schemaNode; - private static final String METHOD_NAME = "GET"; - - public Get(DataSchemaNode node, boolean isConfig) { - this.schemaNode = node; - spec = new Operation(); - spec.setMethod(METHOD_NAME); - spec.setNickname(METHOD_NAME + "-" + node.getQName().getLocalName()); - spec.setType((isConfig ? CONFIG : OPERATIONAL) + node.getQName().getLocalName()); - spec.setNotes(node.getDescription()); - } - - public Get pathParams(List params) { - List pathParameters = new ArrayList<>(params); - spec.setParameters(pathParameters); - return this; - } - - public Operation build() { - return spec; - } - } - - public static class Put { - protected Operation spec; - protected String nodeName; - private static final String METHOD_NAME = "PUT"; - - public Put(String nodeName, final String description) { - this.nodeName = nodeName; - spec = new Operation(); - spec.setType(CONFIG + nodeName); - spec.setNotes(description); - spec.setConsumes(CONSUMES_PUT_POST); - } - - public Put pathParams(List params) { - List parameters = new ArrayList<>(params); - Parameter payload = new Parameter(); - payload.setParamType("body"); - payload.setType(CONFIG + nodeName); - parameters.add(payload); - spec.setParameters(parameters); - return this; - } - - public Operation build() { - spec.setMethod(METHOD_NAME); - spec.setNickname(METHOD_NAME + "-" + nodeName); - return spec; - } - } - - public static final class Post extends Put { - - public static final String METHOD_NAME = "POST"; - private final DataNodeContainer dataNodeContainer; - - public Post(final String nodeName, final String description, final DataNodeContainer dataNodeContainer) { - super(nodeName, description); - this.dataNodeContainer = dataNodeContainer; - spec.setType(CONFIG + nodeName + METHOD_NAME); - spec.setConsumes(CONSUMES_PUT_POST); - } - - @Override - public Operation build() { - spec.setMethod(METHOD_NAME); - spec.setNickname(METHOD_NAME + "-" + nodeName); - return spec; - } - - @Override - public Put pathParams(List params) { - List parameters = new ArrayList<>(params); - for (DataSchemaNode node : dataNodeContainer.getChildNodes()) { - if (node instanceof ListSchemaNode || node instanceof ContainerSchemaNode) { - Parameter payload = new Parameter(); - payload.setParamType("body"); - payload.setType(CONFIG + node.getQName().getLocalName()); - payload.setName("**"+CONFIG + node.getQName().getLocalName()); - parameters.add(payload); - } - } - spec.setParameters(parameters); - return this; - - } - - public Post summary(final String summary) { - spec.setSummary(summary); - return this; - } - } - - public static final class Delete extends Get { - private static final String METHOD_NAME = "DELETE"; - - public Delete(DataSchemaNode node) { - super(node, false); - } - - @Override - public Operation build() { - spec.setMethod(METHOD_NAME); - spec.setNickname(METHOD_NAME + "-" + schemaNode.getQName().getLocalName()); - spec.setType(null); - return spec; - } - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java deleted file mode 100644 index e20e8a79e1..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.mountpoints; - -import com.google.common.base.Optional; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; -import javax.ws.rs.core.UriInfo; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; -import org.opendaylight.controller.sal.rest.doc.impl.BaseYangSwaggerGenerator; -import org.opendaylight.controller.sal.rest.doc.swagger.Api; -import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration; -import org.opendaylight.controller.sal.rest.doc.swagger.Operation; -import org.opendaylight.controller.sal.rest.doc.swagger.Resource; -import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class MountPointSwagger extends BaseYangSwaggerGenerator implements MountProvisionListener { - - private static final String DATASTORES_REVISION = "-"; - private static final String DATASTORES_LABEL = "Datastores"; - - private DOMMountPointService mountService; - private final Map instanceIdToLongId = new TreeMap<>( - new Comparator() { - @Override - public int compare(final YangInstanceIdentifier o1, final YangInstanceIdentifier o2) { - return o1.toString().compareToIgnoreCase(o2.toString()); - } - }); - private final Map longIdToInstanceId = new HashMap<>(); - private final Object lock = new Object(); - - private final AtomicLong idKey = new AtomicLong(0); - - private static AtomicReference selfRef = new AtomicReference<>(); - private SchemaService globalSchema; - - public Map getInstanceIdentifiers() { - Map urlToId = new HashMap<>(); - synchronized (lock) { - SchemaContext context = globalSchema.getGlobalContext(); - for (Entry entry : instanceIdToLongId.entrySet()) { - String modName = findModuleName(entry.getKey(), context); - urlToId.put(generateUrlPrefixFromInstanceID(entry.getKey(), modName), - entry.getValue()); - } - } - return urlToId; - } - - public void setGlobalSchema(final SchemaService globalSchema) { - this.globalSchema = globalSchema; - } - - private String findModuleName(final YangInstanceIdentifier id, final SchemaContext context) { - PathArgument rootQName = id.getPathArguments().iterator().next(); - for (Module mod : context.getModules()) { - if (mod.getDataChildByName(rootQName.getNodeType()) != null) { - return mod.getName(); - } - } - return null; - } - - private String generateUrlPrefixFromInstanceID(final YangInstanceIdentifier key, final String moduleName) { - StringBuilder builder = new StringBuilder(); - if (moduleName != null) { - builder.append(moduleName); - builder.append(':'); - } - for (PathArgument arg : key.getPathArguments()) { - String name = arg.getNodeType().getLocalName(); - if (arg instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) { - NodeIdentifierWithPredicates nodeId = (NodeIdentifierWithPredicates) arg; - for (Entry entry : nodeId.getKeyValues().entrySet()) { - builder.append(entry.getValue()).append('/'); - } - } else { - builder.append(name); - builder.append('/'); - } - } - return builder.toString(); - } - - private String getYangMountUrl(final YangInstanceIdentifier key) { - String modName = findModuleName(key, globalSchema.getGlobalContext()); - return generateUrlPrefixFromInstanceID(key, modName) + "yang-ext:mount/"; - } - - public ResourceList getResourceList(final UriInfo uriInfo, final Long id) { - YangInstanceIdentifier iid = getInstanceId(id); - if (iid == null) { - return null; // indicating not found. - } - SchemaContext context = getSchemaContext(iid); - String urlPrefix = getYangMountUrl(iid); - if (context == null) { - return createResourceList(); - } - List resources = new LinkedList<>(); - Resource dataStores = new Resource(); - dataStores.setDescription("Provides methods for accessing the data stores."); - dataStores.setPath(generatePath(uriInfo, DATASTORES_LABEL, DATASTORES_REVISION)); - resources.add(dataStores); - ResourceList list = super.getResourceListing(uriInfo, context, urlPrefix); - resources.addAll(list.getApis()); - list.setApis(resources); - return list; - } - - private YangInstanceIdentifier getInstanceId(final Long id) { - YangInstanceIdentifier instanceId; - synchronized (lock) { - instanceId = longIdToInstanceId.get(id); - } - return instanceId; - } - - private SchemaContext getSchemaContext(final YangInstanceIdentifier id) { - - if (id == null) { - return null; - } - - Optional mountPoint = mountService.getMountPoint(id); - if (!mountPoint.isPresent()) { - return null; - } - - SchemaContext context = mountPoint.get().getSchemaContext(); - if (context == null) { - return null; - } - return context; - } - - public ApiDeclaration getMountPointApi(final UriInfo uriInfo, final Long id, final String module, final String revision) { - YangInstanceIdentifier iid = getInstanceId(id); - SchemaContext context = getSchemaContext(iid); - String urlPrefix = getYangMountUrl(iid); - if (context == null) { - return null; - } - - if (DATASTORES_LABEL.equals(module) && DATASTORES_REVISION.equals(revision)) { - return generateDataStoreApiDoc(uriInfo, urlPrefix); - } - return super.getApiDeclaration(module, revision, uriInfo, context, urlPrefix); - } - - private ApiDeclaration generateDataStoreApiDoc(final UriInfo uriInfo, final String context) { - - ApiDeclaration declaration = super.createApiDeclaration(createBasePathFromUriInfo(uriInfo)); - List apis = new LinkedList<>(); - apis.add(createGetApi("config", - "Queries the config (startup) datastore on the mounted hosted.", context)); - apis.add(createGetApi("operational", - "Queries the operational (running) datastore on the mounted hosted.", context)); - apis.add(createGetApi("operations", - "Queries the available operations (RPC calls) on the mounted hosted.", context)); - declaration.setApis(apis); - return declaration; - - } - - private Api createGetApi(final String datastore, final String note, final String context) { - Operation getConfig = new Operation(); - getConfig.setMethod("GET"); - getConfig.setNickname("GET " + datastore); - getConfig.setNotes(note); - - Api api = new Api(); - api.setPath(getDataStorePath("/" + datastore + "/", context)); - api.setOperations(Collections.singletonList(getConfig)); - - return api; - } - - public void setMountService(final DOMMountPointService mountService) { - this.mountService = mountService; - } - - @Override - public void onMountPointCreated(final YangInstanceIdentifier path) { - synchronized (lock) { - Long idLong = idKey.incrementAndGet(); - instanceIdToLongId.put(path, idLong); - longIdToInstanceId.put(idLong, path); - } - } - - @Override - public void onMountPointRemoved(final YangInstanceIdentifier path) { - synchronized (lock) { - Long id = instanceIdToLongId.remove(path); - longIdToInstanceId.remove(id); - } - } - - public static MountPointSwagger getInstance() { - MountPointSwagger swagger = selfRef.get(); - if (swagger == null) { - selfRef.compareAndSet(null, new MountPointSwagger()); - swagger = selfRef.get(); - } - return swagger; - } - -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Api.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Api.java deleted file mode 100644 index cc45875dfb..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Api.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.swagger; - -import java.util.List; - -/** - * Implementation of swagger spec (see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#522-api - * -object) - */ -public class Api { - - private String path; - private List operations; - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public List getOperations() { - return operations; - } - - public void setOperations(List operations) { - this.operations = operations; - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ApiDeclaration.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ApiDeclaration.java deleted file mode 100644 index 4ba0ab2255..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ApiDeclaration.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.swagger; - -import java.util.List; - -import org.json.JSONObject; - -/** - * Implementation of swagger spec (see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#52-api- - * declaration) - */ -public class ApiDeclaration { - private String apiVersion; - private String swaggerVersion; - private String basePath; - private String resourcePath; - private List produces; - private List apis; - private JSONObject models; - - public JSONObject getModels() { - return models; - } - - public void setModels(JSONObject models) { - this.models = models; - } - - public String getApiVersion() { - return apiVersion; - } - - public void setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - } - - public String getSwaggerVersion() { - return swaggerVersion; - } - - public void setSwaggerVersion(String swaggerVersion) { - this.swaggerVersion = swaggerVersion; - } - - public String getBasePath() { - return basePath; - } - - public void setBasePath(String basePath) { - this.basePath = basePath; - } - - public String getResourcePath() { - return resourcePath; - } - - public void setResourcePath(String resourcePath) { - this.resourcePath = resourcePath; - } - - public List getProduces() { - return produces; - } - - public void setProduces(List produces) { - this.produces = produces; - } - - public List getApis() { - return apis; - } - - public void setApis(List apis) { - this.apis = apis; - } - - public boolean hasApi() { - return (apis != null && !apis.isEmpty()); - } - - public boolean hasModel() { - return (models != null && models.length() > 0); - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Operation.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Operation.java deleted file mode 100644 index ba0c7966ec..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Operation.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.swagger; - -import java.util.List; - -/** - * Implementation of swagger spec (see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#523- - * operation-object) - */ -public class Operation { - private String method; - private String summary; - private String notes; - private String type; - private String nickname; - private List consumes; - private List parameters; - private List responseMessages; - - public String getMethod() { - return method; - } - - public void setMethod(String method) { - this.method = method; - } - - public String getSummary() { - return summary; - } - - public void setSummary(String summary) { - this.summary = summary; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getNickname() { - return nickname; - } - - public void setNickname(String nickname) { - this.nickname = nickname; - } - - public List getConsumes() { - return consumes; - } - - public void setConsumes(List consumes) { - this.consumes = consumes; - } - - public List getParameters() { - return parameters; - } - - public void setParameters(List parameters) { - this.parameters = parameters; - } - - public List getResponseMessages() { - return responseMessages; - } - - public void setResponseMessages(List responseMessages) { - this.responseMessages = responseMessages; - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Parameter.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Parameter.java deleted file mode 100644 index 41cec4db54..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Parameter.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.swagger; - -/** - * Implementation of swagger spec (see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#524- - * parameter-object) - */ -public class Parameter { - private String name; - private String description; - private boolean required; - private String type; - private String paramType; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public boolean isRequired() { - return required; - } - - public void setRequired(boolean required) { - this.required = required; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getParamType() { - return paramType; - } - - public void setParamType(String paramType) { - this.paramType = paramType; - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Resource.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Resource.java deleted file mode 100644 index cb5b200c60..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/Resource.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.swagger; - -/** - * Implementation of swagger spec (see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#512- - * resource-object) - */ -public class Resource { - private String path; - private String description; - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ResourceList.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ResourceList.java deleted file mode 100644 index 48362dc4ed..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ResourceList.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.swagger; - -import java.util.List; - -/** - * Implementation of swagger spec (see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#51- - * resource-listing) - */ -public class ResourceList { - private String apiVersion; - private String swaggerVersion; - private List apis; - - public String getApiVersion() { - return apiVersion; - } - - public void setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - } - - public String getSwaggerVersion() { - return swaggerVersion; - } - - public void setSwaggerVersion(String swaggerVersion) { - this.swaggerVersion = swaggerVersion; - } - - public List getApis() { - return apis; - } - - public void setApis(List apis) { - this.apis = apis; - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ResponseMessage.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ResponseMessage.java deleted file mode 100644 index d82e1f4a81..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/swagger/ResponseMessage.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.swagger; - -/** - * Implementation of swagger spec (see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#525- - * response-message-object) - */ -public class ResponseMessage { - private int code; - private String message; - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/util/RestDocgenUtil.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/util/RestDocgenUtil.java deleted file mode 100644 index 9e1d82ae05..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/util/RestDocgenUtil.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.rest.doc.util; - -import java.net.URI; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; - -public class RestDocgenUtil { - - private RestDocgenUtil() { - } - - private static Map> namespaceAndRevisionToModule = new HashMap>(); - - /** - * Resolve path argument name for {@code node}. - * - * The name can contain also prefix which consists of module name followed by colon. The module prefix is presented - * if namespace of {@code node} and its parent is different. In other cases only name of {@code node} is returned. - * - * @return name of {@code node} - */ - public static String resolvePathArgumentsName(final SchemaNode node, final SchemaContext schemaContext) { - Iterable schemaPath = node.getPath().getPathTowardsRoot(); - Iterator it = schemaPath.iterator(); - QName nodeQName = it.next(); - - QName parentQName = null; - if (it.hasNext()) { - parentQName = it.next(); - } - if (isEqualNamespaceAndRevision(parentQName, nodeQName)) { - return node.getQName().getLocalName(); - } else { - return resolveFullNameFromNode(node, schemaContext); - } - } - - private synchronized static String resolveFullNameFromNode(final SchemaNode node, final SchemaContext schemaContext) { - final URI namespace = node.getQName().getNamespace(); - final Date revision = node.getQName().getRevision(); - - Map revisionToModule = namespaceAndRevisionToModule.get(namespace); - if (revisionToModule == null) { - revisionToModule = new HashMap<>(); - namespaceAndRevisionToModule.put(namespace, revisionToModule); - } - Module module = revisionToModule.get(revision); - if (module == null) { - module = schemaContext.findModuleByNamespaceAndRevision(namespace, revision); - revisionToModule.put(revision, module); - } - if (module != null) { - return module.getName() + ":" + node.getQName().getLocalName(); - } - return node.getQName().getLocalName(); - } - - public static String resolveNodesName(final SchemaNode node, final Module module, final SchemaContext schemaContext) { - if (node.getQName().getNamespace().equals(module.getQNameModule().getNamespace()) - && node.getQName().getRevision().equals(module.getQNameModule().getRevision())) { - return node.getQName().getLocalName(); - } else { - return resolveFullNameFromNode(node, schemaContext); - } - } - - private static boolean isEqualNamespaceAndRevision(QName parentQName, QName nodeQName) { - if (parentQName == null) { - if (nodeQName == null) { - return true; - } - return false; - } - return parentQName.getNamespace().equals(nodeQName.getNamespace()) - && parentQName.getRevision().equals(nodeQName.getRevision()); - } -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/README.txt b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/README.txt deleted file mode 100644 index 7e72e8347c..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/README.txt +++ /dev/null @@ -1,79 +0,0 @@ -This component offers Swagger documentation of the RestConf APIs. - -This Swagger documentation can be accessed in two ways: -I. Running server -Open a browser and go to http://:8181/apidoc/explorer/index.html - -II. Static documentation generation -By adding a reference to the StaticDocGenerator class in any pom.xml, -static documentation will be generated. This static documentation will -document all the RestConf APIs for the YANG files in that artifact and -all the YANG files in that artifact's dependencies. - -In order to generate static documentation for all resources, -this should be placed in a downstream project. - -Below is what you would add to the section under . - - org.apache.maven.plugins - maven-dependency-plugin - 2.8 - - - unpack-static-documentation - - unpack-dependencies - - generate-resources - - ${project.build.directory}/generated-resources/swagger-api-documentation - sal-rest-docgen - **/explorer/css/**/*, **/explorer/images/**/*, **/explorer/lib/**/*, **/explorer/static/**/*, - true - false - - - - - - org.opendaylight.yangtools - yang-maven-plugin - ${yangtools.version} - - - org.opendaylight.yangtools - maven-sal-api-gen-plugin - ${yangtools.version} - jar - - - org.opendaylight.yangtools - yang-binding - ${yangtools.version} - jar - - - org.opendaylight.controller - sal-rest-docgen - ${mdsal.version} - jar - - - - - - generate-sources - - - src - - - org.opendaylight.controller.sal.rest.doc.impl.StaticDocGenerator - ${project.build.directory}/generated-resources/swagger-api-documentation/explorer/static - - - true - - - - diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/WEB-INF/web.xml b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/WEB-INF/web.xml deleted file mode 100644 index 0e660eaf6d..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/WEB-INF/web.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - index.html - - - JAXRSApiDoc - com.sun.jersey.spi.container.servlet.ServletContainer - - javax.ws.rs.Application - org.opendaylight.controller.sal.rest.doc.jaxrs.ApiDocApplication - - - - com.sun.jersey.spi.container.ContainerRequestFilters - org.opendaylight.aaa.sts.TokenAuthFilter - - 1 - - - - JAXRSApiDoc - /apis/* - - - - cross-origin-api-doc - org.eclipse.jetty.servlets.CrossOriginFilter - - allowedOrigins - * - - - allowedMethods - GET,POST,OPTIONS,DELETE,PUT,HEAD - - - allowedHeaders - origin, content-type, accept, authorization - - - - cross-origin-api-doc - /apis/* - - - - - - API Doc - /* - - - - diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/highlight.default.css b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/highlight.default.css deleted file mode 100644 index e417fc1799..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/highlight.default.css +++ /dev/null @@ -1,135 +0,0 @@ -/* - -Original style from softwaremaniacs.org (c) Ivan Sagalaev - -*/ - -pre code { - display: block; padding: 0.5em; - background: #F0F0F0; -} - -pre code, -pre .subst, -pre .tag .title, -pre .lisp .title, -pre .clojure .built_in, -pre .nginx .title { - color: black; -} - -pre .string, -pre .title, -pre .constant, -pre .parent, -pre .tag .value, -pre .rules .value, -pre .rules .value .number, -pre .preprocessor, -pre .ruby .symbol, -pre .ruby .symbol .string, -pre .aggregate, -pre .template_tag, -pre .django .variable, -pre .smalltalk .class, -pre .addition, -pre .flow, -pre .stream, -pre .bash .variable, -pre .apache .tag, -pre .apache .cbracket, -pre .tex .command, -pre .tex .special, -pre .erlang_repl .function_or_atom, -pre .markdown .header { - color: #800; -} - -pre .comment, -pre .annotation, -pre .template_comment, -pre .diff .header, -pre .chunk, -pre .markdown .blockquote { - color: #888; -} - -pre .number, -pre .date, -pre .regexp, -pre .literal, -pre .smalltalk .symbol, -pre .smalltalk .char, -pre .go .constant, -pre .change, -pre .markdown .bullet, -pre .markdown .link_url { - color: #080; -} - -pre .label, -pre .javadoc, -pre .ruby .string, -pre .decorator, -pre .filter .argument, -pre .localvars, -pre .array, -pre .attr_selector, -pre .important, -pre .pseudo, -pre .pi, -pre .doctype, -pre .deletion, -pre .envvar, -pre .shebang, -pre .apache .sqbracket, -pre .nginx .built_in, -pre .tex .formula, -pre .erlang_repl .reserved, -pre .prompt, -pre .markdown .link_label, -pre .vhdl .attribute, -pre .clojure .attribute, -pre .coffeescript .property { - color: #88F -} - -pre .keyword, -pre .id, -pre .phpdoc, -pre .title, -pre .built_in, -pre .aggregate, -pre .css .tag, -pre .javadoctag, -pre .phpdoc, -pre .yardoctag, -pre .smalltalk .class, -pre .winutils, -pre .bash .variable, -pre .apache .tag, -pre .go .typename, -pre .tex .command, -pre .markdown .strong, -pre .request, -pre .status { - font-weight: bold; -} - -pre .markdown .emphasis { - font-style: italic; -} - -pre .nginx .built_in { - font-weight: normal; -} - -pre .coffeescript .javascript, -pre .javascript .xml, -pre .tex .formula, -pre .xml .javascript, -pre .xml .vbscript, -pre .xml .css, -pre .xml .cdata { - opacity: 0.5; -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/screen.css b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/screen.css deleted file mode 100644 index 1627ecd0d3..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/screen.css +++ /dev/null @@ -1,1070 +0,0 @@ -/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */ -html, -body, -div, -span, -applet, -object, -iframe, -h1, -h2, -h3, -h4, -h5, -h6, -p, -blockquote, -pre, -a, -abbr, -acronym, -address, -big, -cite, -code, -del, -dfn, -em, -img, -ins, -kbd, -q, -s, -samp, -small, -strike, -strong, -sub, -sup, -tt, -var, -b, -u, -i, -center, -dl, -dt, -dd, -ol, -ul, -li, -fieldset, -form, -label, -legend, -table, -caption, -tbody, -tfoot, -thead, -tr, -th, -td, -article, -aside, -canvas, -details, -embed, -figure, -figcaption, -footer, -header, -hgroup, -menu, -nav, -output, -ruby, -section, -summary, -time, -mark, -audio, -video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} -/* HTML5 display-role reset for older browsers */ -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -menu, -nav, -section { - display: block; -} -body { - line-height: 1; -} -ol, -ul { - list-style: none; -} -blockquote, -q { - quotes: none; -} -blockquote:before, -blockquote:after, -q:before, -q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -.swagger-ui-wrap { - line-height: 1; - font-family: "Droid Sans", sans-serif; - max-width: 960px; - margin-left: auto; - margin-right: auto; -} -.swagger-ui-wrap b, -.swagger-ui-wrap strong { - font-family: "Droid Sans", sans-serif; - font-weight: bold; -} -.swagger-ui-wrap q, -.swagger-ui-wrap blockquote { - quotes: none; -} -.swagger-ui-wrap p { - line-height: 1.4em; - padding: 0 0 10px; - color: #333333; -} -.swagger-ui-wrap q:before, -.swagger-ui-wrap q:after, -.swagger-ui-wrap blockquote:before, -.swagger-ui-wrap blockquote:after { - content: none; -} -.swagger-ui-wrap .heading_with_menu h1, -.swagger-ui-wrap .heading_with_menu h2, -.swagger-ui-wrap .heading_with_menu h3, -.swagger-ui-wrap .heading_with_menu h4, -.swagger-ui-wrap .heading_with_menu h5, -.swagger-ui-wrap .heading_with_menu h6 { - display: block; - clear: none; - float: left; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; - width: 60%; -} -.swagger-ui-wrap table { - border-collapse: collapse; - border-spacing: 0; -} -.swagger-ui-wrap table thead tr th { - padding: 5px; - font-size: 0.9em; - color: #666666; - border-bottom: 1px solid #999999; -} -.swagger-ui-wrap table tbody tr:last-child td { - border-bottom: none; -} -.swagger-ui-wrap table tbody tr.offset { - background-color: #f0f0f0; -} -.swagger-ui-wrap table tbody tr td { - padding: 6px; - font-size: 0.9em; - border-bottom: 1px solid #cccccc; - vertical-align: top; - line-height: 1.3em; -} -.swagger-ui-wrap ol { - margin: 0px 0 10px; - padding: 0 0 0 18px; - list-style-type: decimal; -} -.swagger-ui-wrap ol li { - padding: 5px 0px; - font-size: 0.9em; - color: #333333; -} -.swagger-ui-wrap ol, -.swagger-ui-wrap ul { - list-style: none; -} -.swagger-ui-wrap h1 a, -.swagger-ui-wrap h2 a, -.swagger-ui-wrap h3 a, -.swagger-ui-wrap h4 a, -.swagger-ui-wrap h5 a, -.swagger-ui-wrap h6 a { - text-decoration: none; -} -.swagger-ui-wrap h1 a:hover, -.swagger-ui-wrap h2 a:hover, -.swagger-ui-wrap h3 a:hover, -.swagger-ui-wrap h4 a:hover, -.swagger-ui-wrap h5 a:hover, -.swagger-ui-wrap h6 a:hover { - text-decoration: underline; -} -.swagger-ui-wrap h1 span.divider, -.swagger-ui-wrap h2 span.divider, -.swagger-ui-wrap h3 span.divider, -.swagger-ui-wrap h4 span.divider, -.swagger-ui-wrap h5 span.divider, -.swagger-ui-wrap h6 span.divider { - color: #aaaaaa; -} -.swagger-ui-wrap a { - color: #547f00; -} -.swagger-ui-wrap a img { - border: none; -} -.swagger-ui-wrap article, -.swagger-ui-wrap aside, -.swagger-ui-wrap details, -.swagger-ui-wrap figcaption, -.swagger-ui-wrap figure, -.swagger-ui-wrap footer, -.swagger-ui-wrap header, -.swagger-ui-wrap hgroup, -.swagger-ui-wrap menu, -.swagger-ui-wrap nav, -.swagger-ui-wrap section, -.swagger-ui-wrap summary { - display: block; -} -.swagger-ui-wrap pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - background-color: #fcf6db; - border: 1px solid #e5e0c6; - padding: 10px; -} -.swagger-ui-wrap pre code { - line-height: 1.6em; - background: none; -} -.swagger-ui-wrap .content > .content-type > div > label { - clear: both; - display: block; - color: #0F6AB4; - font-size: 1.1em; - margin: 0; - padding: 15px 0 5px; -} -.swagger-ui-wrap .content pre { - font-size: 12px; - margin-top: 5px; - padding: 5px; -} -.swagger-ui-wrap .icon-btn { - cursor: pointer; -} -.swagger-ui-wrap .info_title { - padding-bottom: 10px; - font-weight: bold; - font-size: 25px; -} -.swagger-ui-wrap p.big, -.swagger-ui-wrap div.big p { - font-size: 1em; - margin-bottom: 10px; -} -.swagger-ui-wrap form.fullwidth ol li.string input, -.swagger-ui-wrap form.fullwidth ol li.url input, -.swagger-ui-wrap form.fullwidth ol li.text textarea, -.swagger-ui-wrap form.fullwidth ol li.numeric input { - width: 500px !important; -} -.swagger-ui-wrap .info_license { - padding-bottom: 5px; -} -.swagger-ui-wrap .info_tos { - padding-bottom: 5px; -} -.swagger-ui-wrap .message-fail { - color: #cc0000; -} -.swagger-ui-wrap .info_contact { - padding-bottom: 5px; -} -.swagger-ui-wrap .info_description { - padding-bottom: 10px; - font-size: 15px; -} -.swagger-ui-wrap .markdown ol li, -.swagger-ui-wrap .markdown ul li { - padding: 3px 0px; - line-height: 1.4em; - color: #333333; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input, -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input, -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input { - display: block; - padding: 4px; - width: auto; - clear: both; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input.title, -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input.title, -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input.title { - font-size: 1.3em; -} -.swagger-ui-wrap table.fullwidth { - width: 100%; -} -.swagger-ui-wrap .model-signature { - font-family: "Droid Sans", sans-serif; - font-size: 1em; - line-height: 1.5em; -} -.swagger-ui-wrap .model-signature .signature-nav a { - text-decoration: none; - color: #AAA; -} -.swagger-ui-wrap .model-signature .signature-nav a:hover { - text-decoration: underline; - color: black; -} -.swagger-ui-wrap .model-signature .signature-nav .selected { - color: black; - text-decoration: none; -} -.swagger-ui-wrap .model-signature .propType { - color: #5555aa; -} -.swagger-ui-wrap .model-signature pre:hover { - background-color: #ffffdd; -} -.swagger-ui-wrap .model-signature pre { - font-size: .85em; - line-height: 1.2em; - overflow: auto; - max-height: 200px; - cursor: pointer; -} -.swagger-ui-wrap .model-signature ul.signature-nav { - display: block; - margin: 0; - padding: 0; -} -.swagger-ui-wrap .model-signature ul.signature-nav li:last-child { - padding-right: 0; - border-right: none; -} -.swagger-ui-wrap .model-signature ul.signature-nav li { - float: left; - margin: 0 5px 5px 0; - padding: 2px 5px 2px 0; - border-right: 1px solid #ddd; -} -.swagger-ui-wrap .model-signature .propOpt { - color: #555; -} -.swagger-ui-wrap .model-signature .snippet small { - font-size: 0.75em; -} -.swagger-ui-wrap .model-signature .propOptKey { - font-style: italic; -} -.swagger-ui-wrap .model-signature .description .strong { - font-weight: bold; - color: #000; - font-size: .9em; -} -.swagger-ui-wrap .model-signature .description div { - font-size: 0.9em; - line-height: 1.5em; - margin-left: 1em; -} -.swagger-ui-wrap .model-signature .description .stronger { - font-weight: bold; - color: #000; -} -.swagger-ui-wrap .model-signature .propName { - font-weight: bold; -} -.swagger-ui-wrap .model-signature .signature-container { - clear: both; -} -.swagger-ui-wrap .body-textarea { - width: 300px; - height: 100px; - border: 1px solid #aaa; -} -.swagger-ui-wrap .markdown p code, -.swagger-ui-wrap .markdown li code { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - background-color: #f0f0f0; - color: black; - padding: 1px 3px; -} -.swagger-ui-wrap .required { - font-weight: bold; -} -.swagger-ui-wrap input.parameter { - width: 300px; - border: 1px solid #aaa; -} -.swagger-ui-wrap h1 { - color: black; - font-size: 1.5em; - line-height: 1.3em; - padding: 10px 0 10px 0; - font-family: "Droid Sans", sans-serif; - font-weight: bold; -} -.swagger-ui-wrap .heading_with_menu { - float: none; - clear: both; - overflow: hidden; - display: block; -} -.swagger-ui-wrap .heading_with_menu ul { - display: block; - clear: none; - float: right; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; - margin-top: 10px; -} -.swagger-ui-wrap h2 { - color: black; - font-size: 1.3em; - padding: 10px 0 10px 0; -} -.swagger-ui-wrap h2 a { - color: black; -} -.swagger-ui-wrap h2 span.sub { - font-size: 0.7em; - color: #999999; - font-style: italic; -} -.swagger-ui-wrap h2 span.sub a { - color: #777777; -} -.swagger-ui-wrap span.weak { - color: #666666; -} -.swagger-ui-wrap .message-success { - color: #89BF04; -} -.swagger-ui-wrap caption, -.swagger-ui-wrap th, -.swagger-ui-wrap td { - text-align: left; - font-weight: normal; - vertical-align: middle; -} -.swagger-ui-wrap .code { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.text textarea { - font-family: "Droid Sans", sans-serif; - height: 250px; - padding: 4px; - display: block; - clear: both; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.select select { - display: block; - clear: both; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean { - float: none; - clear: both; - overflow: hidden; - display: block; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean label { - display: block; - float: left; - clear: none; - margin: 0; - padding: 0; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean input { - display: block; - float: left; - clear: none; - margin: 0 5px 0 0; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li.required label { - color: black; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li label { - display: block; - clear: both; - width: auto; - padding: 0 0 3px; - color: #666666; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li label abbr { - padding-left: 3px; - color: #888888; -} -.swagger-ui-wrap form.formtastic fieldset.inputs ol li p.inline-hints { - margin-left: 0; - font-style: italic; - font-size: 0.9em; - margin: 0; -} -.swagger-ui-wrap form.formtastic fieldset.buttons { - margin: 0; - padding: 0; -} -.swagger-ui-wrap span.blank, -.swagger-ui-wrap span.empty { - color: #888888; - font-style: italic; -} -.swagger-ui-wrap .markdown h3 { - color: #547f00; -} -.swagger-ui-wrap .markdown h4 { - color: #666666; -} -.swagger-ui-wrap .markdown pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - background-color: #fcf6db; - border: 1px solid #e5e0c6; - padding: 10px; - margin: 0 0 10px 0; -} -.swagger-ui-wrap .markdown pre code { - line-height: 1.6em; -} -.swagger-ui-wrap div.gist { - margin: 20px 0 25px 0 !important; -} -.swagger-ui-wrap ul#resources { - font-family: "Droid Sans", sans-serif; - font-size: 0.9em; -} -.swagger-ui-wrap ul#resources li.resource { - border-bottom: 1px solid #dddddd; -} -.swagger-ui-wrap ul#resources li.resource:hover div.heading h2 a, -.swagger-ui-wrap ul#resources li.resource.active div.heading h2 a { - color: black; -} -.swagger-ui-wrap ul#resources li.resource:hover div.heading ul.options li a, -.swagger-ui-wrap ul#resources li.resource.active div.heading ul.options li a { - color: #555555; -} -.swagger-ui-wrap ul#resources li.resource:last-child { - border-bottom: none; -} -.swagger-ui-wrap ul#resources li.resource div.heading { - border: 1px solid transparent; - float: none; - clear: both; - overflow: hidden; - display: block; -} -.swagger-ui-wrap ul#resources li.resource div.heading ul.options { - overflow: hidden; - padding: 0; - display: block; - clear: none; - float: right; - margin: 14px 10px 0 0; -} -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - border-right: 1px solid #dddddd; - color: #666666; - font-size: 0.9em; -} -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a { - color: #aaaaaa; - text-decoration: none; -} -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover { - text-decoration: underline; - color: black; -} -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover, -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:active, -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a.active { - text-decoration: underline; -} -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li:first-child, -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li.first { - padding-left: 0; -} -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li:last-child, -.swagger-ui-wrap ul#resources li.resource div.heading ul.options li.last { - padding-right: 0; - border-right: none; -} -.swagger-ui-wrap ul#resources li.resource div.heading ul.options:first-child, -.swagger-ui-wrap ul#resources li.resource div.heading ul.options.first { - padding-left: 0; -} -.swagger-ui-wrap ul#resources li.resource div.heading h2 { - color: #999999; - padding-left: 0; - display: block; - clear: none; - float: left; - font-family: "Droid Sans", sans-serif; - font-weight: bold; -} -.swagger-ui-wrap ul#resources li.resource div.heading h2 a { - color: #999999; -} -.swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover { - color: black; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 10px; - padding: 0; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0; - padding: 0; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 { - display: block; - clear: none; - float: left; - width: auto; - margin: 0; - padding: 0; - line-height: 1.1em; - color: black; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path { - padding-left: 10px; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a { - color: black; - text-decoration: none; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a:hover { - text-decoration: underline; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.http_method a { - text-transform: uppercase; - text-decoration: none; - color: white; - display: inline-block; - width: 50px; - font-size: 0.7em; - text-align: center; - padding: 7px 0 4px; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - -o-border-radius: 2px; - -ms-border-radius: 2px; - -khtml-border-radius: 2px; - border-radius: 2px; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span { - margin: 0; - padding: 0; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options { - overflow: hidden; - padding: 0; - display: block; - clear: none; - float: right; - margin: 6px 10px 0 0; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - font-size: 0.9em; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li a { - text-decoration: none; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content { - border-top: none; - padding: 10px; - -moz-border-radius-bottomleft: 6px; - -webkit-border-bottom-left-radius: 6px; - -o-border-bottom-left-radius: 6px; - -ms-border-bottom-left-radius: 6px; - -khtml-border-bottom-left-radius: 6px; - border-bottom-left-radius: 6px; - -moz-border-radius-bottomright: 6px; - -webkit-border-bottom-right-radius: 6px; - -o-border-bottom-right-radius: 6px; - -ms-border-bottom-right-radius: 6px; - -khtml-border-bottom-right-radius: 6px; - border-bottom-right-radius: 6px; - margin: 0 0 20px; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content h4 { - font-size: 1.1em; - margin: 0; - padding: 15px 0 5px; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header { - float: none; - clear: both; - overflow: hidden; - display: block; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header a { - padding: 4px 0 0 10px; - display: inline-block; - font-size: 0.9em; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header img { - display: block; - clear: none; - float: right; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit { - display: block; - clear: none; - float: left; - padding: 6px 8px; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error { - outline: 2px solid black; - outline-color: #cc0000; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - padding: 10px; - font-size: 0.9em; - max-height: 400px; - overflow-y: auto; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading { - background-color: #f9f2e9; - border: 1px solid #f0e0ca; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.http_method a { - background-color: #c5862b; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li { - border-right: 1px solid #dddddd; - border-right-color: #f0e0ca; - color: #c5862b; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a { - color: #c5862b; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content { - background-color: #faf5ee; - border: 1px solid #f0e0ca; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content h4 { - color: #c5862b; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a { - color: #dcb67f; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading { - background-color: #fcffcd; - border: 1px solid black; - border-color: #ffd20f; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading h3 span.http_method a { - text-transform: uppercase; - background-color: #ffd20f; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li { - border-right: 1px solid #dddddd; - border-right-color: #ffd20f; - color: #ffd20f; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li a { - color: #ffd20f; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content { - background-color: #fcffcd; - border: 1px solid black; - border-color: #ffd20f; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content h4 { - color: #ffd20f; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content div.sandbox_header a { - color: #6fc992; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading { - background-color: #f5e8e8; - border: 1px solid #e8c6c7; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a { - text-transform: uppercase; - background-color: #a41e22; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li { - border-right: 1px solid #dddddd; - border-right-color: #e8c6c7; - color: #a41e22; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a { - color: #a41e22; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content { - background-color: #f7eded; - border: 1px solid #e8c6c7; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content h4 { - color: #a41e22; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header a { - color: #c8787a; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading { - background-color: #e7f6ec; - border: 1px solid #c3e8d1; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.http_method a { - background-color: #10a54a; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li { - border-right: 1px solid #dddddd; - border-right-color: #c3e8d1; - color: #10a54a; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a { - color: #10a54a; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content { - background-color: #ebf7f0; - border: 1px solid #c3e8d1; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content h4 { - color: #10a54a; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header a { - color: #6fc992; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading { - background-color: #FCE9E3; - border: 1px solid #F5D5C3; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.http_method a { - background-color: #D38042; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li { - border-right: 1px solid #dddddd; - border-right-color: #f0cecb; - color: #D38042; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a { - color: #D38042; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content { - background-color: #faf0ef; - border: 1px solid #f0cecb; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content h4 { - color: #D38042; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header a { - color: #dcb67f; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading { - background-color: #e7f0f7; - border: 1px solid #c3d9ec; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.http_method a { - background-color: #0f6ab4; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li { - border-right: 1px solid #dddddd; - border-right-color: #c3d9ec; - color: #0f6ab4; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a { - color: #0f6ab4; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content { - background-color: #ebf3f9; - border: 1px solid #c3d9ec; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content h4 { - color: #0f6ab4; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a { - color: #6fa5d2; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content { - border-top: none; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:last-child, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:last-child, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li:last-child, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:last-child, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li:last-child, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:last-child, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.last, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.last, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li.last, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.last, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li.last, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.last { - padding-right: 0; - border-right: none; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:hover, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a.active { - text-decoration: underline; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li:first-child, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li.first { - padding-left: 0; -} -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations:first-child, -.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations.first { - padding-left: 0; -} -.swagger-ui-wrap p#colophon { - margin: 0 15px 40px 15px; - padding: 10px 0; - font-size: 0.8em; - border-top: 1px solid #dddddd; - font-family: "Droid Sans", sans-serif; - color: #999999; - font-style: italic; -} -.swagger-ui-wrap p#colophon a { - text-decoration: none; - color: #547f00; -} -.swagger-ui-wrap h3 { - color: black; - font-size: 1.1em; - padding: 10px 0 10px 0; -} -.swagger-ui-wrap .markdown ol, -.swagger-ui-wrap .markdown ul { - font-family: "Droid Sans", sans-serif; - margin: 5px 0 10px; - padding: 0 0 0 18px; - list-style-type: disc; -} -.swagger-ui-wrap form.form_box { - background-color: #ebf3f9; - border: 1px solid #c3d9ec; - padding: 10px; -} -.swagger-ui-wrap form.form_box label { - color: #0f6ab4 !important; -} -.swagger-ui-wrap form.form_box input[type=submit] { - display: block; - padding: 10px; -} -.swagger-ui-wrap form.form_box p.weak { - font-size: 0.8em; -} -.swagger-ui-wrap form.form_box p { - font-size: 0.9em; - padding: 0 0 15px; - color: #7e7b6d; -} -.swagger-ui-wrap form.form_box p a { - color: #646257; -} -.swagger-ui-wrap form.form_box p strong { - color: black; -} -#header { - background-color: #89bf04; - padding: 14px; -} -#header a#logo { - font-size: 1.5em; - font-weight: bold; - text-decoration: none; - background: transparent url(../images/logo_small.png) no-repeat left center; - padding: 20px 0 20px 40px; - color: white; -} -#header form#api_selector { - display: block; - clear: none; - float: right; -} -#header form#api_selector .input { - display: block; - clear: none; - float: left; - margin: 0 10px 0 0; -} -#header form#api_selector .input input#input_apiKey { - width: 200px; -} -#header form#api_selector .input input#input_baseUrl { - width: 400px; -} -#header form#api_selector .input a#explore { - display: block; - text-decoration: none; - font-weight: bold; - padding: 6px 8px; - font-size: 0.9em; - color: white; - background-color: #547f00; - -moz-border-radius: 4px; - -webkit-border-radius: 4px; - -o-border-radius: 4px; - -ms-border-radius: 4px; - -khtml-border-radius: 4px; - border-radius: 4px; -} -#header form#api_selector .input a#explore:hover { - background-color: #547f00; -} -#header form#api_selector .input input { - font-size: 0.9em; - padding: 3px; - margin: 0; -} -#content_message { - margin: 10px 15px; - font-style: italic; - color: #999999; -} -#message-bar { - min-height: 30px; - text-align: center; - padding-top: 10px; -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/animated-overlay.gif b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/animated-overlay.gif deleted file mode 100644 index d441f75ebf..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/animated-overlay.gif and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png deleted file mode 100644 index a28d6780ad..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png deleted file mode 100644 index ab561d2bda..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png deleted file mode 100644 index be5c4c6ea3..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png deleted file mode 100644 index c955a2cc06..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png deleted file mode 100644 index de7c46da1c..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png deleted file mode 100644 index 6cc858e6a9..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png deleted file mode 100644 index 653f494cd4..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png deleted file mode 100644 index 663b1129ec..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png deleted file mode 100644 index ee995d9e79..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_222222_256x240.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_222222_256x240.png deleted file mode 100644 index c1cb1170c8..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_228ef1_256x240.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_228ef1_256x240.png deleted file mode 100644 index 3a0140cff6..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_228ef1_256x240.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ef8c08_256x240.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ef8c08_256x240.png deleted file mode 100644 index 036ee072d4..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ef8c08_256x240.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ffd27a_256x240.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ffd27a_256x240.png deleted file mode 100644 index 8b6c05868b..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ffd27a_256x240.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ffffff_256x240.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ffffff_256x240.png deleted file mode 100644 index 4f624bb2b1..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/images/ui-icons_ffffff_256x240.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/jquery-ui-1.10.4.custom.css b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/jquery-ui-1.10.4.custom.css deleted file mode 100644 index a9aa9c4d6f..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/jquery-ui-1.10.4.custom.css +++ /dev/null @@ -1,1178 +0,0 @@ -/*! jQuery UI - v1.10.4 - 2014-06-03 -* http://jqueryui.com -* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css, jquery.ui.theme.css -* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS%2CTahoma%2CVerdana%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=gloss_wave&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=highlight_soft&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=glass&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=glass&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=highlight_soft&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=diagonals_thick&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=diagonals_thick&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=flat&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px -* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { - display: none; -} -.ui-helper-hidden-accessible { - border: 0; - clip: rect(0 0 0 0); - height: 1px; - margin: -1px; - overflow: hidden; - padding: 0; - position: absolute; - width: 1px; -} -.ui-helper-reset { - margin: 0; - padding: 0; - border: 0; - outline: 0; - line-height: 1.3; - text-decoration: none; - font-size: 100%; - list-style: none; -} -.ui-helper-clearfix:before, -.ui-helper-clearfix:after { - content: ""; - display: table; - border-collapse: collapse; -} -.ui-helper-clearfix:after { - clear: both; -} -.ui-helper-clearfix { - min-height: 0; /* support: IE7 */ -} -.ui-helper-zfix { - width: 100%; - height: 100%; - top: 0; - left: 0; - position: absolute; - opacity: 0; - filter:Alpha(Opacity=0); -} - -.ui-front { - z-index: 100; -} - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { - cursor: default !important; -} - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { - display: block; - text-indent: -99999px; - overflow: hidden; - background-repeat: no-repeat; -} - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; -} -.ui-resizable { - position: relative; -} -.ui-resizable-handle { - position: absolute; - font-size: 0.1px; - display: block; -} -.ui-resizable-disabled .ui-resizable-handle, -.ui-resizable-autohide .ui-resizable-handle { - display: none; -} -.ui-resizable-n { - cursor: n-resize; - height: 7px; - width: 100%; - top: -5px; - left: 0; -} -.ui-resizable-s { - cursor: s-resize; - height: 7px; - width: 100%; - bottom: -5px; - left: 0; -} -.ui-resizable-e { - cursor: e-resize; - width: 7px; - right: -5px; - top: 0; - height: 100%; -} -.ui-resizable-w { - cursor: w-resize; - width: 7px; - left: -5px; - top: 0; - height: 100%; -} -.ui-resizable-se { - cursor: se-resize; - width: 12px; - height: 12px; - right: 1px; - bottom: 1px; -} -.ui-resizable-sw { - cursor: sw-resize; - width: 9px; - height: 9px; - left: -5px; - bottom: -5px; -} -.ui-resizable-nw { - cursor: nw-resize; - width: 9px; - height: 9px; - left: -5px; - top: -5px; -} -.ui-resizable-ne { - cursor: ne-resize; - width: 9px; - height: 9px; - right: -5px; - top: -5px; -} -.ui-selectable-helper { - position: absolute; - z-index: 100; - border: 1px dotted black; -} -.ui-accordion .ui-accordion-header { - display: block; - cursor: pointer; - position: relative; - margin-top: 2px; - padding: .5em .5em .5em .7em; - min-height: 0; /* support: IE7 */ -} -.ui-accordion .ui-accordion-icons { - padding-left: 2.2em; -} -.ui-accordion .ui-accordion-noicons { - padding-left: .7em; -} -.ui-accordion .ui-accordion-icons .ui-accordion-icons { - padding-left: 2.2em; -} -.ui-accordion .ui-accordion-header .ui-accordion-header-icon { - position: absolute; - left: .5em; - top: 50%; - margin-top: -8px; -} -.ui-accordion .ui-accordion-content { - padding: 1em 2.2em; - border-top: 0; - overflow: auto; -} -.ui-autocomplete { - position: absolute; - top: 0; - left: 0; - cursor: default; -} -.ui-button { - display: inline-block; - position: relative; - padding: 0; - line-height: normal; - margin-right: .1em; - cursor: pointer; - vertical-align: middle; - text-align: center; - overflow: visible; /* removes extra width in IE */ -} -.ui-button, -.ui-button:link, -.ui-button:visited, -.ui-button:hover, -.ui-button:active { - text-decoration: none; -} -/* to make room for the icon, a width needs to be set here */ -.ui-button-icon-only { - width: 2.2em; -} -/* button elements seem to need a little more width */ -button.ui-button-icon-only { - width: 2.4em; -} -.ui-button-icons-only { - width: 3.4em; -} -button.ui-button-icons-only { - width: 3.7em; -} - -/* button text element */ -.ui-button .ui-button-text { - display: block; - line-height: normal; -} -.ui-button-text-only .ui-button-text { - padding: .4em 1em; -} -.ui-button-icon-only .ui-button-text, -.ui-button-icons-only .ui-button-text { - padding: .4em; - text-indent: -9999999px; -} -.ui-button-text-icon-primary .ui-button-text, -.ui-button-text-icons .ui-button-text { - padding: .4em 1em .4em 2.1em; -} -.ui-button-text-icon-secondary .ui-button-text, -.ui-button-text-icons .ui-button-text { - padding: .4em 2.1em .4em 1em; -} -.ui-button-text-icons .ui-button-text { - padding-left: 2.1em; - padding-right: 2.1em; -} -/* no icon support for input elements, provide padding by default */ -input.ui-button { - padding: .4em 1em; -} - -/* button icon element(s) */ -.ui-button-icon-only .ui-icon, -.ui-button-text-icon-primary .ui-icon, -.ui-button-text-icon-secondary .ui-icon, -.ui-button-text-icons .ui-icon, -.ui-button-icons-only .ui-icon { - position: absolute; - top: 50%; - margin-top: -8px; -} -.ui-button-icon-only .ui-icon { - left: 50%; - margin-left: -8px; -} -.ui-button-text-icon-primary .ui-button-icon-primary, -.ui-button-text-icons .ui-button-icon-primary, -.ui-button-icons-only .ui-button-icon-primary { - left: .5em; -} -.ui-button-text-icon-secondary .ui-button-icon-secondary, -.ui-button-text-icons .ui-button-icon-secondary, -.ui-button-icons-only .ui-button-icon-secondary { - right: .5em; -} - -/* button sets */ -.ui-buttonset { - margin-right: 7px; -} -.ui-buttonset .ui-button { - margin-left: 0; - margin-right: -.3em; -} - -/* workarounds */ -/* reset extra padding in Firefox, see h5bp.com/l */ -input.ui-button::-moz-focus-inner, -button.ui-button::-moz-focus-inner { - border: 0; - padding: 0; -} -.ui-datepicker { - width: 17em; - padding: .2em .2em 0; - display: none; -} -.ui-datepicker .ui-datepicker-header { - position: relative; - padding: .2em 0; -} -.ui-datepicker .ui-datepicker-prev, -.ui-datepicker .ui-datepicker-next { - position: absolute; - top: 2px; - width: 1.8em; - height: 1.8em; -} -.ui-datepicker .ui-datepicker-prev-hover, -.ui-datepicker .ui-datepicker-next-hover { - top: 1px; -} -.ui-datepicker .ui-datepicker-prev { - left: 2px; -} -.ui-datepicker .ui-datepicker-next { - right: 2px; -} -.ui-datepicker .ui-datepicker-prev-hover { - left: 1px; -} -.ui-datepicker .ui-datepicker-next-hover { - right: 1px; -} -.ui-datepicker .ui-datepicker-prev span, -.ui-datepicker .ui-datepicker-next span { - display: block; - position: absolute; - left: 50%; - margin-left: -8px; - top: 50%; - margin-top: -8px; -} -.ui-datepicker .ui-datepicker-title { - margin: 0 2.3em; - line-height: 1.8em; - text-align: center; -} -.ui-datepicker .ui-datepicker-title select { - font-size: 1em; - margin: 1px 0; -} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { - width: 49%; -} -.ui-datepicker table { - width: 100%; - font-size: .9em; - border-collapse: collapse; - margin: 0 0 .4em; -} -.ui-datepicker th { - padding: .7em .3em; - text-align: center; - font-weight: bold; - border: 0; -} -.ui-datepicker td { - border: 0; - padding: 1px; -} -.ui-datepicker td span, -.ui-datepicker td a { - display: block; - padding: .2em; - text-align: right; - text-decoration: none; -} -.ui-datepicker .ui-datepicker-buttonpane { - background-image: none; - margin: .7em 0 0 0; - padding: 0 .2em; - border-left: 0; - border-right: 0; - border-bottom: 0; -} -.ui-datepicker .ui-datepicker-buttonpane button { - float: right; - margin: .5em .2em .4em; - cursor: pointer; - padding: .2em .6em .3em .6em; - width: auto; - overflow: visible; -} -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { - float: left; -} - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { - width: auto; -} -.ui-datepicker-multi .ui-datepicker-group { - float: left; -} -.ui-datepicker-multi .ui-datepicker-group table { - width: 95%; - margin: 0 auto .4em; -} -.ui-datepicker-multi-2 .ui-datepicker-group { - width: 50%; -} -.ui-datepicker-multi-3 .ui-datepicker-group { - width: 33.3%; -} -.ui-datepicker-multi-4 .ui-datepicker-group { - width: 25%; -} -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header, -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { - border-left-width: 0; -} -.ui-datepicker-multi .ui-datepicker-buttonpane { - clear: left; -} -.ui-datepicker-row-break { - clear: both; - width: 100%; - font-size: 0; -} - -/* RTL support */ -.ui-datepicker-rtl { - direction: rtl; -} -.ui-datepicker-rtl .ui-datepicker-prev { - right: 2px; - left: auto; -} -.ui-datepicker-rtl .ui-datepicker-next { - left: 2px; - right: auto; -} -.ui-datepicker-rtl .ui-datepicker-prev:hover { - right: 1px; - left: auto; -} -.ui-datepicker-rtl .ui-datepicker-next:hover { - left: 1px; - right: auto; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane { - clear: right; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane button { - float: left; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current, -.ui-datepicker-rtl .ui-datepicker-group { - float: right; -} -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header, -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { - border-right-width: 0; - border-left-width: 1px; -} -.ui-dialog { - overflow: hidden; - position: absolute; - top: 0; - left: 0; - padding: .2em; - outline: 0; -} -.ui-dialog .ui-dialog-titlebar { - padding: .4em 1em; - position: relative; -} -.ui-dialog .ui-dialog-title { - float: left; - margin: .1em 0; - white-space: nowrap; - width: 90%; - overflow: hidden; - text-overflow: ellipsis; -} -.ui-dialog .ui-dialog-titlebar-close { - position: absolute; - right: .3em; - top: 50%; - width: 20px; - margin: -10px 0 0 0; - padding: 1px; - height: 20px; -} -.ui-dialog .ui-dialog-content { - position: relative; - border: 0; - padding: .5em 1em; - background: none; - overflow: auto; -} -.ui-dialog .ui-dialog-buttonpane { - text-align: left; - border-width: 1px 0 0 0; - background-image: none; - margin-top: .5em; - padding: .3em 1em .5em .4em; -} -.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { - float: right; -} -.ui-dialog .ui-dialog-buttonpane button { - margin: .5em .4em .5em 0; - cursor: pointer; -} -.ui-dialog .ui-resizable-se { - width: 12px; - height: 12px; - right: -5px; - bottom: -5px; - background-position: 16px 16px; -} -.ui-draggable .ui-dialog-titlebar { - cursor: move; -} -.ui-menu { - list-style: none; - padding: 2px; - margin: 0; - display: block; - outline: none; -} -.ui-menu .ui-menu { - margin-top: -3px; - position: absolute; -} -.ui-menu .ui-menu-item { - margin: 0; - padding: 0; - width: 100%; - /* support: IE10, see #8844 */ - list-style-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7); -} -.ui-menu .ui-menu-divider { - margin: 5px -2px 5px -2px; - height: 0; - font-size: 0; - line-height: 0; - border-width: 1px 0 0 0; -} -.ui-menu .ui-menu-item a { - text-decoration: none; - display: block; - padding: 2px .4em; - line-height: 1.5; - min-height: 0; /* support: IE7 */ - font-weight: normal; -} -.ui-menu .ui-menu-item a.ui-state-focus, -.ui-menu .ui-menu-item a.ui-state-active { - font-weight: normal; - margin: -1px; -} - -.ui-menu .ui-state-disabled { - font-weight: normal; - margin: .4em 0 .2em; - line-height: 1.5; -} -.ui-menu .ui-state-disabled a { - cursor: default; -} - -/* icon support */ -.ui-menu-icons { - position: relative; -} -.ui-menu-icons .ui-menu-item a { - position: relative; - padding-left: 2em; -} - -/* left-aligned */ -.ui-menu .ui-icon { - position: absolute; - top: .2em; - left: .2em; -} - -/* right-aligned */ -.ui-menu .ui-menu-icon { - position: static; - float: right; -} -.ui-progressbar { - height: 2em; - text-align: left; - overflow: hidden; -} -.ui-progressbar .ui-progressbar-value { - margin: -1px; - height: 100%; -} -.ui-progressbar .ui-progressbar-overlay { - background: url("images/animated-overlay.gif"); - height: 100%; - filter: alpha(opacity=25); - opacity: 0.25; -} -.ui-progressbar-indeterminate .ui-progressbar-value { - background-image: none; -} -.ui-slider { - position: relative; - text-align: left; -} -.ui-slider .ui-slider-handle { - position: absolute; - z-index: 2; - width: 1.2em; - height: 1.2em; - cursor: default; -} -.ui-slider .ui-slider-range { - position: absolute; - z-index: 1; - font-size: .7em; - display: block; - border: 0; - background-position: 0 0; -} - -/* For IE8 - See #6727 */ -.ui-slider.ui-state-disabled .ui-slider-handle, -.ui-slider.ui-state-disabled .ui-slider-range { - filter: inherit; -} - -.ui-slider-horizontal { - height: .8em; -} -.ui-slider-horizontal .ui-slider-handle { - top: -.3em; - margin-left: -.6em; -} -.ui-slider-horizontal .ui-slider-range { - top: 0; - height: 100%; -} -.ui-slider-horizontal .ui-slider-range-min { - left: 0; -} -.ui-slider-horizontal .ui-slider-range-max { - right: 0; -} - -.ui-slider-vertical { - width: .8em; - height: 100px; -} -.ui-slider-vertical .ui-slider-handle { - left: -.3em; - margin-left: 0; - margin-bottom: -.6em; -} -.ui-slider-vertical .ui-slider-range { - left: 0; - width: 100%; -} -.ui-slider-vertical .ui-slider-range-min { - bottom: 0; -} -.ui-slider-vertical .ui-slider-range-max { - top: 0; -} -.ui-spinner { - position: relative; - display: inline-block; - overflow: hidden; - padding: 0; - vertical-align: middle; -} -.ui-spinner-input { - border: none; - background: none; - color: inherit; - padding: 0; - margin: .2em 0; - vertical-align: middle; - margin-left: .4em; - margin-right: 22px; -} -.ui-spinner-button { - width: 16px; - height: 50%; - font-size: .5em; - padding: 0; - margin: 0; - text-align: center; - position: absolute; - cursor: default; - display: block; - overflow: hidden; - right: 0; -} -/* more specificity required here to override default borders */ -.ui-spinner a.ui-spinner-button { - border-top: none; - border-bottom: none; - border-right: none; -} -/* vertically center icon */ -.ui-spinner .ui-icon { - position: absolute; - margin-top: -8px; - top: 50%; - left: 0; -} -.ui-spinner-up { - top: 0; -} -.ui-spinner-down { - bottom: 0; -} - -/* TR overrides */ -.ui-spinner .ui-icon-triangle-1-s { - /* need to fix icons sprite */ - background-position: -65px -16px; -} -.ui-tabs { - position: relative;/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ - padding: .2em; -} -.ui-tabs .ui-tabs-nav { - margin: 0; - padding: .2em .2em 0; -} -.ui-tabs .ui-tabs-nav li { - list-style: none; - float: left; - position: relative; - top: 0; - margin: 1px .2em 0 0; - border-bottom-width: 0; - padding: 0; - white-space: nowrap; -} -.ui-tabs .ui-tabs-nav .ui-tabs-anchor { - float: left; - padding: .5em 1em; - text-decoration: none; -} -.ui-tabs .ui-tabs-nav li.ui-tabs-active { - margin-bottom: -1px; - padding-bottom: 1px; -} -.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor, -.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor, -.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor { - cursor: text; -} -.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor { - cursor: pointer; -} -.ui-tabs .ui-tabs-panel { - display: block; - border-width: 0; - padding: 1em 1.4em; - background: none; -} -.ui-tooltip { - padding: 8px; - position: absolute; - z-index: 9999; - max-width: 300px; - -webkit-box-shadow: 0 0 5px #aaa; - box-shadow: 0 0 5px #aaa; -} -body .ui-tooltip { - border-width: 2px; -} - -/* Component containers -----------------------------------*/ -.ui-widget { - font-family: Trebuchet MS,Tahoma,Verdana,Arial,sans-serif; - font-size: 1.1em; -} -.ui-widget .ui-widget { - font-size: 1em; -} -.ui-widget input, -.ui-widget select, -.ui-widget textarea, -.ui-widget button { - font-family: Trebuchet MS,Tahoma,Verdana,Arial,sans-serif; - font-size: 1em; -} -.ui-widget-content { - border: 1px solid #dddddd; - background: #eeeeee url("images/ui-bg_highlight-soft_100_eeeeee_1x100.png") 50% top repeat-x; - color: #333333; -} -.ui-widget-content a { - color: #333333; -} -.ui-widget-header { - border: 1px solid #e78f08; - background: #f6a828 url("images/ui-bg_gloss-wave_35_f6a828_500x100.png") 50% 50% repeat-x; - color: #ffffff; - font-weight: bold; -} -.ui-widget-header a { - color: #ffffff; -} - -/* Interaction states -----------------------------------*/ -.ui-state-default, -.ui-widget-content .ui-state-default, -.ui-widget-header .ui-state-default { - border: 1px solid #cccccc; - background: #f6f6f6 url("images/ui-bg_glass_100_f6f6f6_1x400.png") 50% 50% repeat-x; - font-weight: bold; - color: #1c94c4; -} -.ui-state-default a, -.ui-state-default a:link, -.ui-state-default a:visited { - color: #1c94c4; - text-decoration: none; -} -.ui-state-hover, -.ui-widget-content .ui-state-hover, -.ui-widget-header .ui-state-hover, -.ui-state-focus, -.ui-widget-content .ui-state-focus, -.ui-widget-header .ui-state-focus { - border: 1px solid #fbcb09; - background: #fdf5ce url("images/ui-bg_glass_100_fdf5ce_1x400.png") 50% 50% repeat-x; - font-weight: bold; - color: #c77405; -} -.ui-state-hover a, -.ui-state-hover a:hover, -.ui-state-hover a:link, -.ui-state-hover a:visited, -.ui-state-focus a, -.ui-state-focus a:hover, -.ui-state-focus a:link, -.ui-state-focus a:visited { - color: #c77405; - text-decoration: none; -} -.ui-state-active, -.ui-widget-content .ui-state-active, -.ui-widget-header .ui-state-active { - border: 1px solid #fbd850; - background: #ffffff url("images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x; - font-weight: bold; - color: #eb8f00; -} -.ui-state-active a, -.ui-state-active a:link, -.ui-state-active a:visited { - color: #eb8f00; - text-decoration: none; -} - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, -.ui-widget-content .ui-state-highlight, -.ui-widget-header .ui-state-highlight { - border: 1px solid #fed22f; - background: #ffe45c url("images/ui-bg_highlight-soft_75_ffe45c_1x100.png") 50% top repeat-x; - color: #363636; -} -.ui-state-highlight a, -.ui-widget-content .ui-state-highlight a, -.ui-widget-header .ui-state-highlight a { - color: #363636; -} -.ui-state-error, -.ui-widget-content .ui-state-error, -.ui-widget-header .ui-state-error { - border: 1px solid #cd0a0a; - background: #b81900 url("images/ui-bg_diagonals-thick_18_b81900_40x40.png") 50% 50% repeat; - color: #ffffff; -} -.ui-state-error a, -.ui-widget-content .ui-state-error a, -.ui-widget-header .ui-state-error a { - color: #ffffff; -} -.ui-state-error-text, -.ui-widget-content .ui-state-error-text, -.ui-widget-header .ui-state-error-text { - color: #ffffff; -} -.ui-priority-primary, -.ui-widget-content .ui-priority-primary, -.ui-widget-header .ui-priority-primary { - font-weight: bold; -} -.ui-priority-secondary, -.ui-widget-content .ui-priority-secondary, -.ui-widget-header .ui-priority-secondary { - opacity: .7; - filter:Alpha(Opacity=70); - font-weight: normal; -} -.ui-state-disabled, -.ui-widget-content .ui-state-disabled, -.ui-widget-header .ui-state-disabled { - opacity: .35; - filter:Alpha(Opacity=35); - background-image: none; -} -.ui-state-disabled .ui-icon { - filter:Alpha(Opacity=35); /* For IE8 - See #6059 */ -} - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { - width: 16px; - height: 16px; -} -.ui-icon, -.ui-widget-content .ui-icon { - background-image: url("images/ui-icons_222222_256x240.png"); -} -.ui-widget-header .ui-icon { - background-image: url("images/ui-icons_ffffff_256x240.png"); -} -.ui-state-default .ui-icon { - background-image: url("images/ui-icons_ef8c08_256x240.png"); -} -.ui-state-hover .ui-icon, -.ui-state-focus .ui-icon { - background-image: url("images/ui-icons_ef8c08_256x240.png"); -} -.ui-state-active .ui-icon { - background-image: url("images/ui-icons_ef8c08_256x240.png"); -} -.ui-state-highlight .ui-icon { - background-image: url("images/ui-icons_228ef1_256x240.png"); -} -.ui-state-error .ui-icon, -.ui-state-error-text .ui-icon { - background-image: url("images/ui-icons_ffd27a_256x240.png"); -} - -/* positioning */ -.ui-icon-blank { background-position: 16px 16px; } -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-on { background-position: -96px -144px; } -.ui-icon-radio-off { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, -.ui-corner-top, -.ui-corner-left, -.ui-corner-tl { - border-top-left-radius: 4px; -} -.ui-corner-all, -.ui-corner-top, -.ui-corner-right, -.ui-corner-tr { - border-top-right-radius: 4px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-left, -.ui-corner-bl { - border-bottom-left-radius: 4px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-right, -.ui-corner-br { - border-bottom-right-radius: 4px; -} - -/* Overlays */ -.ui-widget-overlay { - background: #666666 url("images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat; - opacity: .5; - filter: Alpha(Opacity=50); -} -.ui-widget-shadow { - margin: -5px 0 0 -5px; - padding: 5px; - background: #000000 url("images/ui-bg_flat_10_000000_40x100.png") 50% 50% repeat-x; - opacity: .2; - filter: Alpha(Opacity=20); - border-radius: 5px; -} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/jquery-ui-1.10.4.custom.min.css b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/jquery-ui-1.10.4.custom.min.css deleted file mode 100644 index b1f2f3c65f..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/css/ui-lightness/jquery-ui-1.10.4.custom.min.css +++ /dev/null @@ -1,7 +0,0 @@ -/*! jQuery UI - v1.10.4 - 2014-06-03 -* http://jqueryui.com -* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css, jquery.ui.theme.css -* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS%2CTahoma%2CVerdana%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=gloss_wave&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=highlight_soft&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=glass&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=glass&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=highlight_soft&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=diagonals_thick&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=diagonals_thick&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=flat&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px -* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ - -.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin-top:2px;padding:.5em .5em .5em .7em;min-height:0}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-noicons{padding-left:.7em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-button{display:inline-block;position:relative;padding:0;line-height:normal;margin-right:.1em;cursor:pointer;vertical-align:middle;text-align:center;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:normal}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}input.ui-button::-moz-focus-inner,button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-dialog{overflow:hidden;position:absolute;top:0;left:0;padding:.2em;outline:0}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 0;white-space:nowrap;width:90%;overflow:hidden;text-overflow:ellipsis}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:20px;margin:-10px 0 0 0;padding:1px;height:20px}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin-top:.5em;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:12px;height:12px;right:-5px;bottom:-5px;background-position:16px 16px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-menu{list-style:none;padding:2px;margin:0;display:block;outline:none}.ui-menu .ui-menu{margin-top:-3px;position:absolute}.ui-menu .ui-menu-item{margin:0;padding:0;width:100%;list-style-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}.ui-menu .ui-menu-divider{margin:5px -2px 5px -2px;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:2px .4em;line-height:1.5;min-height:0;font-weight:normal}.ui-menu .ui-menu-item a.ui-state-focus,.ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.ui-menu .ui-state-disabled{font-weight:normal;margin:.4em 0 .2em;line-height:1.5}.ui-menu .ui-state-disabled a{cursor:default}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item a{position:relative;padding-left:2em}.ui-menu .ui-icon{position:absolute;top:.2em;left:.2em}.ui-menu .ui-menu-icon{position:static;float:right}.ui-progressbar{height:2em;text-align:left;overflow:hidden}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-progressbar-overlay{background:url("images/animated-overlay.gif");height:100%;filter:alpha(opacity=25);opacity:0.25}.ui-progressbar-indeterminate .ui-progressbar-value{background-image:none}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider.ui-state-disabled .ui-slider-handle,.ui-slider.ui-state-disabled .ui-slider-range{filter:inherit}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-spinner{position:relative;display:inline-block;overflow:hidden;padding:0;vertical-align:middle}.ui-spinner-input{border:none;background:none;color:inherit;padding:0;margin:.2em 0;vertical-align:middle;margin-left:.4em;margin-right:22px}.ui-spinner-button{width:16px;height:50%;font-size:.5em;padding:0;margin:0;text-align:center;position:absolute;cursor:default;display:block;overflow:hidden;right:0}.ui-spinner a.ui-spinner-button{border-top:none;border-bottom:none;border-right:none}.ui-spinner .ui-icon{position:absolute;margin-top:-8px;top:50%;left:0}.ui-spinner-up{top:0}.ui-spinner-down{bottom:0}.ui-spinner .ui-icon-triangle-1-s{background-position:-65px -16px}.ui-tabs{position:relative;padding:.2em}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:0;margin:1px .2em 0 0;border-bottom-width:0;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav .ui-tabs-anchor{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-active{margin-bottom:-1px;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor{cursor:text}.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none}.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}body .ui-tooltip{border-width:2px}.ui-widget{font-family:Trebuchet MS,Tahoma,Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Trebuchet MS,Tahoma,Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #ddd;background:#eee url("images/ui-bg_highlight-soft_100_eeeeee_1x100.png") 50% top repeat-x;color:#333}.ui-widget-content a{color:#333}.ui-widget-header{border:1px solid #e78f08;background:#f6a828 url("images/ui-bg_gloss-wave_35_f6a828_500x100.png") 50% 50% repeat-x;color:#fff;font-weight:bold}.ui-widget-header a{color:#fff}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #ccc;background:#f6f6f6 url("images/ui-bg_glass_100_f6f6f6_1x400.png") 50% 50% repeat-x;font-weight:bold;color:#1c94c4}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#1c94c4;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #fbcb09;background:#fdf5ce url("images/ui-bg_glass_100_fdf5ce_1x400.png") 50% 50% repeat-x;font-weight:bold;color:#c77405}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited,.ui-state-focus a,.ui-state-focus a:hover,.ui-state-focus a:link,.ui-state-focus a:visited{color:#c77405;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #fbd850;background:#fff url("images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x;font-weight:bold;color:#eb8f00}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#eb8f00;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #fed22f;background:#ffe45c url("images/ui-bg_highlight-soft_75_ffe45c_1x100.png") 50% top repeat-x;color:#363636}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#363636}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #cd0a0a;background:#b81900 url("images/ui-bg_diagonals-thick_18_b81900_40x40.png") 50% 50% repeat;color:#fff}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#fff}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#fff}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px}.ui-icon,.ui-widget-content .ui-icon{background-image:url("images/ui-icons_222222_256x240.png")}.ui-widget-header .ui-icon{background-image:url("images/ui-icons_ffffff_256x240.png")}.ui-state-default .ui-icon{background-image:url("images/ui-icons_ef8c08_256x240.png")}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url("images/ui-icons_ef8c08_256x240.png")}.ui-state-active .ui-icon{background-image:url("images/ui-icons_ef8c08_256x240.png")}.ui-state-highlight .ui-icon{background-image:url("images/ui-icons_228ef1_256x240.png")}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url("images/ui-icons_ffd27a_256x240.png")}.ui-icon-blank{background-position:16px 16px}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:4px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:4px}.ui-widget-overlay{background:#666 url("images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat;opacity:.5;filter:Alpha(Opacity=50)}.ui-widget-shadow{margin:-5px 0 0 -5px;padding:5px;background:#000 url("images/ui-bg_flat_10_000000_40x100.png") 50% 50% repeat-x;opacity:.2;filter:Alpha(Opacity=20);border-radius:5px} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/logo_small.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/logo_small.png deleted file mode 100644 index 46c02e2aeb..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/logo_small.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/pet_store_api.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/pet_store_api.png deleted file mode 100644 index f9f9cd4aeb..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/pet_store_api.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/throbber.gif b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/throbber.gif deleted file mode 100644 index 0639388924..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/throbber.gif and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/wordnik_api.png b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/wordnik_api.png deleted file mode 100644 index dca4f1455a..0000000000 Binary files a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/images/wordnik_api.png and /dev/null differ diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/index.html b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/index.html deleted file mode 100644 index f12616bc4b..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/index.html +++ /dev/null @@ -1,117 +0,0 @@ - - - -RestConf Documentation - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - -

OpenDaylight RestConf API - Documentation

-
-
- - - - -
- - -
-
-

Below are the list of APIs supported by the Controller.

-
-
-
-
-

Mount Points - Select an API below for details on available - queries.

-
-
-
-
- -

- - -
- - -
- -
 
- - - diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/lib/backbone-min.js b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/lib/backbone-min.js deleted file mode 100644 index c1c0d4fff2..0000000000 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/lib/backbone-min.js +++ /dev/null @@ -1,38 +0,0 @@ -// Backbone.js 0.9.2 - -// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Backbone may be freely distributed under the MIT license. -// For all details and documentation: -// http://backbonejs.org -(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks= -{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g= -z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent= -{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null== -b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent: -b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)}; -a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error, -h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t(); -return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending= -{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length|| -!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator); -this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c=b))this.iframe=i('