From: Giovanni Meo Date: Fri, 16 May 2014 08:24:09 +0000 (+0000) Subject: Merge "Add lispflowmapping specific configuration options" X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~82 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=66249d6ccc367fad055a269f561860d2d96af385;hp=84790328004205e3bec8d8ce37813d6159dbbf2e Merge "Add lispflowmapping specific configuration options" --- diff --git a/opendaylight/appauth/pom.xml b/opendaylight/appauth/pom.xml index f07c855877..e74e3cb915 100644 --- a/opendaylight/appauth/pom.xml +++ b/opendaylight/appauth/pom.xml @@ -35,7 +35,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true @@ -48,7 +47,6 @@ org.apache.felix.dm, org.opendaylight.controller.appauth, org.opendaylight.controller.appauth.authorization - diff --git a/opendaylight/arphandler/pom.xml b/opendaylight/arphandler/pom.xml index 8d62c1da4b..064d04c25c 100644 --- a/opendaylight/arphandler/pom.xml +++ b/opendaylight/arphandler/pom.xml @@ -50,7 +50,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/clustering/services/pom.xml b/opendaylight/clustering/services/pom.xml index 3806421df8..3ff6bac21f 100644 --- a/opendaylight/clustering/services/pom.xml +++ b/opendaylight/clustering/services/pom.xml @@ -24,7 +24,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheConfigException.java b/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheConfigException.java index 32c3d08c91..e030142016 100644 --- a/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheConfigException.java +++ b/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheConfigException.java @@ -24,6 +24,7 @@ package org.opendaylight.controller.clustering.services; * passed and so on. */ public class CacheConfigException extends Exception { + private static final long serialVersionUID = 1L; /** * Instantiates a new cache config exception. diff --git a/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheExistException.java b/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheExistException.java index 583de7cb50..70165cce1f 100644 --- a/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheExistException.java +++ b/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheExistException.java @@ -23,6 +23,7 @@ package org.opendaylight.controller.clustering.services; * allocated already exists */ public class CacheExistException extends Exception { + private static final long serialVersionUID = 1L; /** * Instantiates a new cache exist exception. diff --git a/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheListenerAddException.java b/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheListenerAddException.java index 34ba41c5d4..996e0a0767 100644 --- a/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheListenerAddException.java +++ b/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/CacheListenerAddException.java @@ -21,6 +21,7 @@ package org.opendaylight.controller.clustering.services; * Listener being added fails for any reason */ public class CacheListenerAddException extends Exception { + private static final long serialVersionUID = 1L; /** * Instantiates a new cache listener add exception. diff --git a/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/ListenRoleChangeAddException.java b/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/ListenRoleChangeAddException.java index 523a1340c5..dd2585b17e 100644 --- a/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/ListenRoleChangeAddException.java +++ b/opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/ListenRoleChangeAddException.java @@ -20,7 +20,9 @@ package org.opendaylight.controller.clustering.services; * @deprecated for internal use * The Class ListenRoleChangeAddException. */ +@Deprecated public class ListenRoleChangeAddException extends Exception { + private static final long serialVersionUID = 1L; /** * Instantiates a new listen role change add exception. diff --git a/opendaylight/clustering/services_implementation/pom.xml b/opendaylight/clustering/services_implementation/pom.xml index 4acfae0d29..8d3f53b6c4 100644 --- a/opendaylight/clustering/services_implementation/pom.xml +++ b/opendaylight/clustering/services_implementation/pom.xml @@ -63,7 +63,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true @@ -75,9 +74,8 @@ !org.hornetq.*, !org.jboss.*, javax.transaction, - *, org.opendaylight.controller.clustering.services, - org.opendaylight.controller.sal.core + org.opendaylight.controller.sal.core,* org.opendaylight.controller.clustering.services_implementation.internal.Activator diff --git a/opendaylight/clustering/stub/pom.xml b/opendaylight/clustering/stub/pom.xml index 7a0c1378b6..6a0b3082fb 100644 --- a/opendaylight/clustering/stub/pom.xml +++ b/opendaylight/clustering/stub/pom.xml @@ -31,7 +31,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/clustering/test/pom.xml b/opendaylight/clustering/test/pom.xml index 02a231b78c..9021c9419e 100644 --- a/opendaylight/clustering/test/pom.xml +++ b/opendaylight/clustering/test/pom.xml @@ -60,7 +60,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexClass.java b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexClass.java index 076ec05e32..51f8128382 100644 --- a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexClass.java +++ b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexClass.java @@ -12,6 +12,7 @@ package org.opendaylight.controller.clustering.test.internal; import java.io.Serializable; public class ComplexClass implements IComplex, Serializable { + private static final long serialVersionUID = 1L; private String identity; public ComplexClass(String i) { diff --git a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexClass1.java b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexClass1.java index fda2ff10aa..876fb656ac 100644 --- a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexClass1.java +++ b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexClass1.java @@ -12,6 +12,7 @@ package org.opendaylight.controller.clustering.test.internal; import java.io.Serializable; public class ComplexClass1 implements IComplex, Serializable { + private static final long serialVersionUID = 1L; private String identity; public ComplexClass1(String i) { diff --git a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexContainer.java b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexContainer.java index adc062d4c4..d07c192241 100644 --- a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexContainer.java +++ b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/ComplexContainer.java @@ -12,9 +12,10 @@ package org.opendaylight.controller.clustering.test.internal; import java.io.Serializable; public class ComplexContainer implements Serializable { - private IComplex f; - private IComplex f1; - private Integer state; + private static final long serialVersionUID = 1L; + private final IComplex f; + private final IComplex f1; + private final Integer state; public ComplexContainer(String i, Integer s) { this.state = s; diff --git a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/StringContainer.java b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/StringContainer.java index 39ef1b0e29..7cdb032988 100644 --- a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/StringContainer.java +++ b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/StringContainer.java @@ -12,6 +12,7 @@ package org.opendaylight.controller.clustering.test.internal; import java.io.Serializable; public class StringContainer implements Serializable { + private static final long serialVersionUID = 1L; private String mystring; public StringContainer() { diff --git a/opendaylight/commons/concepts/pom.xml b/opendaylight/commons/concepts/pom.xml index de263cb41f..01dd61a1cb 100644 --- a/opendaylight/commons/concepts/pom.xml +++ b/opendaylight/commons/concepts/pom.xml @@ -23,7 +23,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/commons/httpclient/pom.xml b/opendaylight/commons/httpclient/pom.xml index f068fded4e..07d3cdda96 100644 --- a/opendaylight/commons/httpclient/pom.xml +++ b/opendaylight/commons/httpclient/pom.xml @@ -38,7 +38,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index c0fc4024ce..aaab66d4b0 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -22,7 +22,7 @@ 4.1 1.50 - 2.3.7 + 2.4.0 0.4.2-SNAPSHOT 2.10 0.5.1-SNAPSHOT @@ -52,11 +52,11 @@ 2.5.0 1.3.1 - 1.26.2 + 1.28 3.0.0 - 0000.0002.0038.0-SNAPSHOT + 0000.0002.0038.0 2.15 1.0.1 3.0.1 @@ -1339,16 +1339,6 @@ ganymed 1.1-SNAPSHOT - - org.opendaylight.controller.thirdparty - nagasena - ${exi.nagasena.version} - - - org.opendaylight.controller.thirdparty - nagasena-rta - ${exi.nagasena.version} - org.opendaylight.controller.thirdparty @@ -1483,6 +1473,16 @@ yang-ext ${yang-ext.version} + + org.openexi + nagasena + ${exi.nagasena.version} + + + org.openexi + nagasena-rta + ${exi.nagasena.version} + org.osgi org.osgi.compendium @@ -1773,6 +1773,11 @@ enunciate.xml + + org.codehaus.enunciate + enunciate-swagger + ${enunciate.version} + org.opendaylight.controller commons.logback_settings diff --git a/opendaylight/config/feature/pom.xml b/opendaylight/config/feature/pom.xml new file mode 100644 index 0000000000..aaf33ccc0f --- /dev/null +++ b/opendaylight/config/feature/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + org.opendaylight.controller + config-subsystem + 0.2.5-SNAPSHOT + + config-features + + pom + + + features.xml + + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + + scm:git:ssh://git.opendaylight.org:29418/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/config/feature/src/main/resources/features.xml b/opendaylight/config/feature/src/main/resources/features.xml new file mode 100644 index 0000000000..81972c3661 --- /dev/null +++ b/opendaylight/config/feature/src/main/resources/features.xml @@ -0,0 +1,27 @@ + + + + + odl-config-subsystem + + + + yangtools-concepts + yangtools-binding + yangtools-binding-generator + odl-mdsal-commons + mvn:org.opendaylight.controller/config-api/${project.version} + mvn:org.opendaylight.controller/config-manager/${project.version} + mvn:org.opendaylight.controller/yang-jmx-generator/${project.version} + mvn:org.opendaylight.controller/config-persister-api/${project.version} + mvn:org.opendaylight.controller/config-persister-file-xml-adapter/${project.version} + mvn:org.opendaylight.controller/config-persister-directory-xml-adapter/${project.version} + mvn:org.opendaylight.controller/shutdown-api/${project.version} + mvn:org.opendaylight.controller/shutdown-impl/${project.version} + mvn:org.osgi/org.osgi.core/${osgi.core.version} + wrap:mvn:com.google.guava/guava/${guava.version} + mvn:org.javassist/javassist/${javassist.version} + + \ No newline at end of file diff --git a/opendaylight/config/pom.xml b/opendaylight/config/pom.xml index 20b1b411a4..613940144b 100644 --- a/opendaylight/config/pom.xml +++ b/opendaylight/config/pom.xml @@ -40,6 +40,7 @@ shutdown-impl netconf-config-dispatcher config-module-archetype + feature @@ -162,7 +163,6 @@ org.jacoco jacoco-maven-plugin - ${jacoco.version} diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/ConcreteModuleGeneratedObjectFactory.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/ConcreteModuleGeneratedObjectFactory.java index fbc507d0b4..051b1a7f5b 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/ConcreteModuleGeneratedObjectFactory.java +++ b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/ConcreteModuleGeneratedObjectFactory.java @@ -1,7 +1,7 @@ package org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory; -import com.google.common.base.Joiner; -import com.google.common.base.Optional; +import java.util.LinkedHashMap; + import org.opendaylight.controller.config.api.DependencyResolver; import org.opendaylight.controller.config.api.ModuleIdentifier; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; @@ -11,7 +11,8 @@ import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.Generated import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.JavaFileInputBuilder; import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.TypeName; -import java.util.LinkedHashMap; +import com.google.common.base.Joiner; +import com.google.common.base.Optional; public class ConcreteModuleGeneratedObjectFactory { @@ -46,12 +47,10 @@ public class ConcreteModuleGeneratedObjectFactory { } private static String getNewCtor(FullyQualifiedName fqn) { - LinkedHashMap parameters = new LinkedHashMap(){ - { - put(ModuleIdentifier.class.getCanonicalName(), "identifier"); - put(DependencyResolver.class.getCanonicalName(), "dependencyResolver"); - } - }; + LinkedHashMap parameters = new LinkedHashMap<>(); + parameters.put(ModuleIdentifier.class.getCanonicalName(), "identifier"); + parameters.put(DependencyResolver.class.getCanonicalName(), "dependencyResolver"); + StringBuilder stringBuilder = getCtor(fqn, parameters); return stringBuilder.toString(); } @@ -72,14 +71,11 @@ public class ConcreteModuleGeneratedObjectFactory { } private static String getCopyCtor(final FullyQualifiedName fqn) { - LinkedHashMap parameters = new LinkedHashMap(){ - { - put(ModuleIdentifier.class.getCanonicalName(), "identifier"); - put(DependencyResolver.class.getCanonicalName(), "dependencyResolver"); - put(fqn.toString(), "oldModule"); - put(AutoCloseable.class.getCanonicalName(), "oldInstance"); - } - }; + LinkedHashMap parameters = new LinkedHashMap<>(); + parameters.put(ModuleIdentifier.class.getCanonicalName(), "identifier"); + parameters.put(DependencyResolver.class.getCanonicalName(), "dependencyResolver"); + parameters.put(fqn.toString(), "oldModule"); + parameters.put(AutoCloseable.class.getCanonicalName(), "oldInstance"); StringBuilder stringBuilder = getCtor(fqn, parameters); return stringBuilder.toString(); } diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtil.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtil.java index 265aea10c5..bcc55a203e 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtil.java +++ b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtil.java @@ -4,14 +4,11 @@ import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.google.common.base.Splitter; import com.google.common.base.Strings; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.FullyQualifiedName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.io.InputStream; import java.util.List; import java.util.regex.Pattern; @@ -61,13 +58,18 @@ public class StringUtil { public static Optional loadCopyright() { - try (InputStream in = StringUtil.class.getResourceAsStream("/copyright.txt")) { - if (in != null) { - return Optional.of(IOUtils.toString(in)); + /* + * FIXME: BUG-980: this is a nice feature, but the copyright needs to come + * from the project being processed, not this one. + try (InputStream in = StringUtil.class.getResourceAsStream("/copyright.txt")) { + if (in != null) { + return Optional.of(IOUtils.toString(in)); + } + } catch (IOException e) { + logger.warn("Cannot load copyright.txt", e); } - } catch (IOException e) { - logger.warn("Cannot load copyright.txt", e); - } + + */ return Optional.absent(); } diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/resources/copyright.txt b/opendaylight/config/yang-jmx-generator-plugin/src/main/resources/copyright.txt deleted file mode 100644 index 4a0c355685..0000000000 --- a/opendaylight/config/yang-jmx-generator-plugin/src/main/resources/copyright.txt +++ /dev/null @@ -1,5 +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 diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtilTest.java b/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtilTest.java index b0217a4ba9..1ad0207c2b 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtilTest.java +++ b/opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtilTest.java @@ -1,5 +1,6 @@ package org.opendaylight.controller.config.yangjmxgenerator.plugin.util; +import org.junit.Ignore; import org.junit.Test; import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.FullyQualifiedName; @@ -24,6 +25,7 @@ public class StringUtilTest { } @Test + @Ignore public void testCopyright() throws IOException { assertTrue(StringUtil.loadCopyright().isPresent()); } diff --git a/opendaylight/configuration/api/pom.xml b/opendaylight/configuration/api/pom.xml index 992e4b08d1..ef27bfd5e4 100644 --- a/opendaylight/configuration/api/pom.xml +++ b/opendaylight/configuration/api/pom.xml @@ -23,7 +23,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/configuration/implementation/pom.xml b/opendaylight/configuration/implementation/pom.xml index b6d2229121..a4a7ba6746 100644 --- a/opendaylight/configuration/implementation/pom.xml +++ b/opendaylight/configuration/implementation/pom.xml @@ -35,7 +35,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/connectionmanager/api/pom.xml b/opendaylight/connectionmanager/api/pom.xml index b3a427a8f7..c4ced042d0 100644 --- a/opendaylight/connectionmanager/api/pom.xml +++ b/opendaylight/connectionmanager/api/pom.xml @@ -27,7 +27,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/connectionmanager/implementation/pom.xml b/opendaylight/connectionmanager/implementation/pom.xml index 5adcc89ee8..8be119d507 100644 --- a/opendaylight/connectionmanager/implementation/pom.xml +++ b/opendaylight/connectionmanager/implementation/pom.xml @@ -39,7 +39,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/containermanager/api/pom.xml b/opendaylight/containermanager/api/pom.xml index 5bfededfe5..a19e27189a 100644 --- a/opendaylight/containermanager/api/pom.xml +++ b/opendaylight/containermanager/api/pom.xml @@ -27,7 +27,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/containermanager/implementation/pom.xml b/opendaylight/containermanager/implementation/pom.xml index b7b9e0abda..3ead8be65a 100644 --- a/opendaylight/containermanager/implementation/pom.xml +++ b/opendaylight/containermanager/implementation/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/containermanager/it.implementation/pom.xml b/opendaylight/containermanager/it.implementation/pom.xml index 2727f77d90..a3f140d7e1 100644 --- a/opendaylight/containermanager/it.implementation/pom.xml +++ b/opendaylight/containermanager/it.implementation/pom.xml @@ -35,7 +35,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/distribution/opendaylight-karaf/pom.xml b/opendaylight/distribution/opendaylight-karaf/pom.xml index 60f660a193..1414fac2f3 100644 --- a/opendaylight/distribution/opendaylight-karaf/pom.xml +++ b/opendaylight/distribution/opendaylight-karaf/pom.xml @@ -22,6 +22,14 @@ ${karaf.version} kar + + org.opendaylight.controller + config-features + ${config.version} + features + xml + runtime + @@ -42,6 +50,15 @@ xml runtime + --> + + org.opendaylight.controller + mdsal-features + ${mdsal.version} + features + xml + runtime + org.opendaylight.yangtools features-file @@ -50,7 +67,6 @@ xml runtime - --> @@ -172,6 +188,29 @@ **\/target\/,**\/bin\/,**\/target-ide\/,**\/configuration\/initial\/ + + maven-resources-plugin + 2.6 + + + copy-resources + + copy-resources + + + process-resources + + ${basedir}/target/assembly + true + + + ${basedir}/src/main/resources + + + + + + diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index 615668f5eb..72ce89d14e 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -1095,14 +1095,6 @@ org.opendaylight.controller.thirdparty ganymed - - org.opendaylight.controller.thirdparty - nagasena - - - org.opendaylight.controller.thirdparty - nagasena-rta - org.opendaylight.yangtools binding-generator-api @@ -1111,17 +1103,14 @@ org.opendaylight.yangtools binding-generator-impl - ${yangtools.version} org.opendaylight.yangtools binding-generator-spi - ${yangtools.version} org.opendaylight.yangtools binding-generator-util - ${yangtools.version} org.opendaylight.yangtools @@ -1131,7 +1120,6 @@ org.opendaylight.yangtools binding-type-provider - ${yangtools.version} org.opendaylight.yangtools @@ -1177,12 +1165,10 @@ org.opendaylight.yangtools yang-parser-api - ${yangtools.version} org.opendaylight.yangtools yang-parser-impl - ${yangtools.version} @@ -1216,6 +1202,14 @@ xtend-lib-osgi 2.4.3 + + org.openexi + nagasena + + + org.openexi + nagasena-rta + org.zeromq jeromq diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/03-toaster-sample.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/03-toaster-sample.xml index 6d5d0eb826..502bdebca2 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/03-toaster-sample.xml +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/03-toaster-sample.xml @@ -12,8 +12,8 @@ - - prefix:toaster-provider-impl + + toaster:toaster-provider-impl toaster-provider-impl @@ -22,6 +22,11 @@ binding-rpc-broker + + binding:binding-data-broker + binding-data-broker + + binding:binding-notification-service @@ -31,10 +36,10 @@ - - prefix:toaster-consumer-impl + + kitchen:kitchen-service-impl - toaster-consumer-impl + kitchen-service-impl binding:binding-rpc-registry @@ -49,20 +54,15 @@ - + - toaster:toaster-provider - - toaster-provider - /modules/module[type='toaster-provider-impl'][name='toaster-provider-impl'] - - - - toaster:toaster-consumer + + kitchen:kitchen-service + - toaster-consumer - /modules/module[type='toaster-consumer-impl'][name='toaster-consumer-impl'] + kitchen-service + /modules/module[type='kitchen-service-impl'][name='kitchen-service-impl'] @@ -71,10 +71,7 @@ - urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 - urn:opendaylight:params:xml:ns:yang:controller:config:toaster-consumer?module=toaster-consumer&revision=2014-01-31 - urn:opendaylight:params:xml:ns:yang:controller:config:toaster-consumer:impl?module=toaster-consumer-impl&revision=2014-01-31 - urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider?module=toaster-provider&revision=2014-01-31 + urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl?module=kitchen-service-impl&revision=2014-01-31 urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl?module=toaster-provider-impl&revision=2014-01-31 diff --git a/opendaylight/distribution/opendaylight/src/main/resources/run.sh b/opendaylight/distribution/opendaylight/src/main/resources/run.sh index 21245a0259..dba996a994 100755 --- a/opendaylight/distribution/opendaylight/src/main/resources/run.sh +++ b/opendaylight/distribution/opendaylight/src/main/resources/run.sh @@ -161,7 +161,7 @@ fi ######################################## # Now add to classpath the OSGi JAR ######################################## -CLASSPATH="${basedir}"/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar +CLASSPATH=${CLASSPATH}:${basedir}/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar FWCLASSPATH=file:"${basedir}"/lib/org.eclipse.osgi-3.8.1.v20120830-144521.jar ######################################## diff --git a/opendaylight/distribution/sanitytest/pom.xml b/opendaylight/distribution/sanitytest/pom.xml index 893776c567..793e835647 100644 --- a/opendaylight/distribution/sanitytest/pom.xml +++ b/opendaylight/distribution/sanitytest/pom.xml @@ -23,7 +23,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/dummy-console/README b/opendaylight/dummy-console/README new file mode 100644 index 0000000000..09974d5e54 --- /dev/null +++ b/opendaylight/dummy-console/README @@ -0,0 +1,2 @@ +This bundle is temporary only and should be removed as soon as possible +it is only for compatibility layer in Karaf. diff --git a/opendaylight/dummy-console/pom.xml b/opendaylight/dummy-console/pom.xml new file mode 100644 index 0000000000..6d90eb39da --- /dev/null +++ b/opendaylight/dummy-console/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.2-SNAPSHOT + ../commons/opendaylight + + dummy-console + 1.1.0-SNAPSHOT + bundle + Dummy Console Interfaces for Equinox-specific CLI + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + * + org.eclipse.osgi.framework.console + + + + + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + HEAD + https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main + + diff --git a/opendaylight/dummy-console/src/main/java/org/eclipse/osgi/framework/console/CommandInterpreter.java b/opendaylight/dummy-console/src/main/java/org/eclipse/osgi/framework/console/CommandInterpreter.java new file mode 100644 index 0000000000..29e9fc931b --- /dev/null +++ b/opendaylight/dummy-console/src/main/java/org/eclipse/osgi/framework/console/CommandInterpreter.java @@ -0,0 +1,12 @@ +/* + * Copyright(c)2014 Inocybe Technologies, 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.eclipse.osgi.framework.console; + +/** Empty tag interface for Command Interpreter **/ +public interface CommandInterpreter {} diff --git a/opendaylight/dummy-console/src/main/java/org/eclipse/osgi/framework/console/CommandProvider.java b/opendaylight/dummy-console/src/main/java/org/eclipse/osgi/framework/console/CommandProvider.java new file mode 100644 index 0000000000..a781f6f908 --- /dev/null +++ b/opendaylight/dummy-console/src/main/java/org/eclipse/osgi/framework/console/CommandProvider.java @@ -0,0 +1,12 @@ +/* + * Copyright(c)2014 Inocybe Technologies, 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.eclipse.osgi.framework.console; + +/** Empty tag interface for Command Provider **/ +public interface CommandProvider {} diff --git a/opendaylight/forwarding/staticrouting/pom.xml b/opendaylight/forwarding/staticrouting/pom.xml index 6a73a21e73..37c0a3a09d 100644 --- a/opendaylight/forwarding/staticrouting/pom.xml +++ b/opendaylight/forwarding/staticrouting/pom.xml @@ -39,7 +39,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/forwardingrulesmanager/api/pom.xml b/opendaylight/forwardingrulesmanager/api/pom.xml index 82f5f9b9e9..b6e1dd68d1 100644 --- a/opendaylight/forwardingrulesmanager/api/pom.xml +++ b/opendaylight/forwardingrulesmanager/api/pom.xml @@ -35,7 +35,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/forwardingrulesmanager/implementation/pom.xml b/opendaylight/forwardingrulesmanager/implementation/pom.xml index a5a15f685c..f87bed8780 100644 --- a/opendaylight/forwardingrulesmanager/implementation/pom.xml +++ b/opendaylight/forwardingrulesmanager/implementation/pom.xml @@ -55,7 +55,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java index f7b647dd72..46008b24c6 100644 --- a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java +++ b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java @@ -2342,7 +2342,7 @@ public class ForwardingRulesManager implements for (FlowConfig flowConfig : flowConfigForNode) { if (doesFlowContainNodeConnector(flowConfig.getFlow(), nodeConnector)) { if (flowConfig.installInHw() && !flowConfig.getStatus().equals(StatusCode.SUCCESS.toString())) { - Status status = this.installFlowEntry(flowConfig.getFlowEntry()); + Status status = this.installFlowEntryAsync(flowConfig.getFlowEntry()); if (!status.isSuccess()) { flowConfig.setStatus(status.getDescription()); } else { diff --git a/opendaylight/hosttracker/api/pom.xml b/opendaylight/hosttracker/api/pom.xml index d8f31ca65a..b48d7abd72 100644 --- a/opendaylight/hosttracker/api/pom.xml +++ b/opendaylight/hosttracker/api/pom.xml @@ -26,7 +26,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/hosttracker/implementation/pom.xml b/opendaylight/hosttracker/implementation/pom.xml index 9da62bdfe7..cb09322b64 100644 --- a/opendaylight/hosttracker/implementation/pom.xml +++ b/opendaylight/hosttracker/implementation/pom.xml @@ -58,7 +58,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/hosttracker_new/api/pom.xml b/opendaylight/hosttracker_new/api/pom.xml index 1dec4e5574..240976b9c8 100644 --- a/opendaylight/hosttracker_new/api/pom.xml +++ b/opendaylight/hosttracker_new/api/pom.xml @@ -38,7 +38,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/hosttracker_new/implementation/pom.xml b/opendaylight/hosttracker_new/implementation/pom.xml index aaaf3abacf..036dd5dd31 100644 --- a/opendaylight/hosttracker_new/implementation/pom.xml +++ b/opendaylight/hosttracker_new/implementation/pom.xml @@ -62,7 +62,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/logging/bridge/pom.xml b/opendaylight/logging/bridge/pom.xml index 26fd11c5ef..82bc6cd9c1 100644 --- a/opendaylight/logging/bridge/pom.xml +++ b/opendaylight/logging/bridge/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java index fad37ae4f3..c4c1ee9351 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java @@ -1,15 +1,16 @@ /** * 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.compatibility; -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; -import org.eclipse.xtext.xbase.lib.Exceptions; +import java.util.Date; +import java.util.HashSet; +import java.util.List; + import org.opendaylight.controller.sal.common.util.Arguments; import org.opendaylight.controller.sal.core.AdvertisedBandwidth; import org.opendaylight.controller.sal.core.Bandwidth; @@ -58,36 +59,30 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import java.util.Date; -import java.util.HashSet; -import java.util.List; +import com.google.common.base.Objects; +import com.google.common.base.Preconditions; -@SuppressWarnings("all") -public class NodeMapping { +public final class NodeMapping { public final static String MD_SAL_TYPE = "MD_SAL"; - + private final static Class NODE_CLASS = Node.class; - + private final static Class NODECONNECTOR_CLASS = NodeConnector.class; - + private NodeMapping() { throw new UnsupportedOperationException("Utility class. Instantiation is not allowed."); } - + public static org.opendaylight.controller.sal.core.Node toADNode(final InstanceIdentifier node) throws ConstructionException { NodeId nodeId = NodeMapping.toNodeId(node); return NodeMapping.toADNode(nodeId); } - - public static org.opendaylight.controller.sal.core.Node toADNode(final NodeId id) { - try { + + public static org.opendaylight.controller.sal.core.Node toADNode(final NodeId id) throws ConstructionException { String aDNodeId = NodeMapping.toADNodeId(id); return new org.opendaylight.controller.sal.core.Node(NodeMapping.MD_SAL_TYPE, aDNodeId); - } catch (Throwable e) { - throw Exceptions.sneakyThrow(e); - } } - + public static NodeId toNodeId(final InstanceIdentifier node) { Preconditions.>checkNotNull(node); List path = node.getPath(); @@ -96,16 +91,16 @@ public class NodeMapping { Preconditions.checkArgument(size >= 2); final PathArgument arg = path.get(1); final IdentifiableItem item = Arguments.checkInstanceOf(arg, IdentifiableItem.class); - Identifier key = item.getKey(); + Identifier key = item.getKey(); final NodeKey nodeKey = Arguments.checkInstanceOf(key, NodeKey.class); return nodeKey.getId(); } - + public static String toADNodeId(final NodeId nodeId) { Preconditions.checkNotNull(nodeId); return nodeId.getValue(); } - + public static org.opendaylight.controller.sal.core.NodeConnector toADNodeConnector(final NodeConnectorRef source) throws ConstructionException { Preconditions.checkNotNull(source); final InstanceIdentifier path = Preconditions.>checkNotNull(source.getValue()); @@ -115,18 +110,14 @@ public class NodeMapping { final NodeConnectorKey connectorKey = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class); return NodeMapping.toADNodeConnector(connectorKey.getId(), NodeMapping.toNodeId(path)); } - - public static org.opendaylight.controller.sal.core.NodeConnector toADNodeConnector(final NodeConnectorId ncid, final NodeId nid) { - try { - String nodeConnectorType = NodeMapping.toNodeConnectorType(ncid, nid); - Object aDNodeConnectorId = NodeMapping.toADNodeConnectorId(ncid, nid); - org.opendaylight.controller.sal.core.Node aDNode = NodeMapping.toADNode(nid); - return new org.opendaylight.controller.sal.core.NodeConnector(nodeConnectorType, aDNodeConnectorId, aDNode); - } catch (Throwable e) { - throw Exceptions.sneakyThrow(e); - } + + public static org.opendaylight.controller.sal.core.NodeConnector toADNodeConnector(final NodeConnectorId ncid, final NodeId nid) throws ConstructionException { + String nodeConnectorType = NodeMapping.toNodeConnectorType(ncid, nid); + Object aDNodeConnectorId = NodeMapping.toADNodeConnectorId(ncid, nid); + org.opendaylight.controller.sal.core.Node aDNode = NodeMapping.toADNode(nid); + return new org.opendaylight.controller.sal.core.NodeConnector(nodeConnectorType, aDNodeConnectorId, aDNode); } - + public static String toNodeConnectorType(final NodeConnectorId ncId, final NodeId nodeId) { if (ncId.equals(toLocalNodeConnectorId(nodeId))) { return NodeConnectorIDType.SWSTACK; @@ -146,19 +137,19 @@ public class NodeMapping { } return nodeConnectorId.getValue(); } - + public static NodeConnectorId toControllerNodeConnectorId(final NodeId node) { return new NodeConnectorId(node.getValue() + ":" + 4294967293L); } - + public static NodeConnectorId toLocalNodeConnectorId(final NodeId node) { return new NodeConnectorId(node.getValue() + ":" + 4294967294L); } - + public static NodeConnectorId toNormalNodeConnectorId(final NodeId node) { return new NodeConnectorId(node.getValue() + ":" + 4294967290L); } - + public static NodeRef toNodeRef(final org.opendaylight.controller.sal.core.Node node) { Preconditions.checkArgument(MD_SAL_TYPE.equals(node.getType())); final String nodeId = Arguments.checkInstanceOf(node.getID(), String.class); @@ -166,7 +157,7 @@ public class NodeMapping { final InstanceIdentifier nodePath = InstanceIdentifier.builder(Nodes.class).child(NODE_CLASS, nodeKey).toInstance(); return new NodeRef(nodePath); } - + public static NodeConnectorRef toNodeConnectorRef(final org.opendaylight.controller.sal.core.NodeConnector nodeConnector) { final NodeRef node = NodeMapping.toNodeRef(nodeConnector.getNode()); @@ -187,14 +178,14 @@ public class NodeMapping { nodeConnectorId = new NodeConnectorId(Arguments.checkInstanceOf(nodeConnector.getID(), String.class)); } final NodeConnectorKey connectorKey = new NodeConnectorKey(nodeConnectorId); - final InstanceIdentifier path = InstanceIdentifier.builder(nodePath).child(NODECONNECTOR_CLASS, connectorKey).toInstance(); + final InstanceIdentifier path = nodePath.child(NODECONNECTOR_CLASS, connectorKey); return new NodeConnectorRef(path); } - + public static org.opendaylight.controller.sal.core.Node toADNode(final NodeRef node) throws ConstructionException { return NodeMapping.toADNode(node.getValue()); } - + public static HashSet toADNodeConnectorProperties(final NodeConnectorUpdated nc) { final FlowCapableNodeConnectorUpdated fcncu = nc.getAugmentation(FlowCapableNodeConnectorUpdated.class); if (!Objects.equal(fcncu, null)) { @@ -202,7 +193,7 @@ public class NodeMapping { } return new HashSet(); } - + public static HashSet toADNodeConnectorProperties(final NodeConnector nc) { final FlowCapableNodeConnector fcnc = nc.getAugmentation(FlowCapableNodeConnector.class); if (!Objects.equal(fcnc, null)) { @@ -210,7 +201,7 @@ public class NodeMapping { } return new HashSet(); } - + public static HashSet toADNodeConnectorProperties(final FlowNodeConnector fcncu) { final HashSet props = new HashSet<>(); @@ -239,11 +230,11 @@ public class NodeMapping { } return props; } - + public static Name toAdName(final String name) { return new Name(name); } - + public static Config toAdConfig(final PortConfig pc) { Config config = null; if (pc.isPORTDOWN()) { @@ -253,7 +244,7 @@ public class NodeMapping { } return config; } - + public static org.opendaylight.controller.sal.core.State toAdState(final State s) { org.opendaylight.controller.sal.core.State state = null; @@ -264,7 +255,7 @@ public class NodeMapping { } return state; } - + public static Bandwidth toAdBandwidth(final PortFeatures pf) { Bandwidth bw = null; if (pf.isTenMbHd() || pf.isTenMbFd()) { @@ -286,7 +277,7 @@ public class NodeMapping { } return bw; } - + public static AdvertisedBandwidth toAdAdvertizedBandwidth(final PortFeatures pf) { AdvertisedBandwidth abw = null; final Bandwidth bw = toAdBandwidth(pf); @@ -295,7 +286,7 @@ public class NodeMapping { } return abw; } - + public static SupportedBandwidth toAdSupportedBandwidth(final PortFeatures pf) { SupportedBandwidth sbw = null; final Bandwidth bw = toAdBandwidth(pf); @@ -304,7 +295,7 @@ public class NodeMapping { } return sbw; } - + public static PeerBandwidth toAdPeerBandwidth(final PortFeatures pf) { PeerBandwidth pbw = null; final Bandwidth bw = toAdBandwidth(pf); @@ -313,7 +304,7 @@ public class NodeMapping { } return pbw; } - + public static HashSet toADNodeProperties(final NodeUpdated nu) { final FlowCapableNodeUpdated fcnu = nu.getAugmentation(FlowCapableNodeUpdated.class); if (fcnu != null) { @@ -321,7 +312,7 @@ public class NodeMapping { } return new HashSet(); } - + public static HashSet toADNodeProperties(final FlowNode fcnu, final NodeId id) { final HashSet props = new HashSet<>(); @@ -348,13 +339,13 @@ public class NodeMapping { } return props; } - + public static TimeStamp toADTimestamp() { final Date date = new Date(); final TimeStamp timestamp = new TimeStamp(date.getTime(), "connectedSince"); return timestamp; } - + public static MacAddress toADMacAddress(final NodeId id) { final String nodeId = id.getValue().replaceAll("openflow:", ""); long lNodeId = Long.parseLong(nodeId); @@ -362,11 +353,11 @@ public class NodeMapping { byte[] bytesFromDpid = ToSalConversionsUtils.bytesFromDpid(lNodeId); return new MacAddress(bytesFromDpid); } - + public static Tables toADTables(final Short tables) { return new Tables(tables.byteValue()); } - + public static Capabilities toADCapabiliities(final List> capabilities) { int b = 0; @@ -389,7 +380,7 @@ public class NodeMapping { } return new Capabilities(b); } - + public static Buffers toADBuffers(final Long buffers) { return new Buffers(buffers.intValue()); } diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.java index a35c3ed98c..e798b681df 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.java @@ -68,7 +68,7 @@ public class TopologyCommitHandler implements DataChangeListener { for (InstanceIdentifier path : modification.getRemovedOperationalData()) { if (path.getTargetType() == Link.class) { Link link = (Link) modification.getOriginalOperationalData().get(path); - msg.add(toTopoEdgeUpdate(toAdEdge(link, topology), UpdateType.CHANGED, reader)); + msg.add(toTopoEdgeUpdate(toAdEdge(link, topology), UpdateType.REMOVED, reader)); } } diff --git a/opendaylight/md-sal/feature/pom.xml b/opendaylight/md-sal/feature/pom.xml new file mode 100644 index 0000000000..c08c3e5606 --- /dev/null +++ b/opendaylight/md-sal/feature/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.1-SNAPSHOT + + mdsal-features + + pom + + + features.xml + + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + + scm:git:ssh://git.opendaylight.org:29418/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/feature/src/main/resources/features.xml b/opendaylight/md-sal/feature/src/main/resources/features.xml new file mode 100644 index 0000000000..f816018519 --- /dev/null +++ b/opendaylight/md-sal/feature/src/main/resources/features.xml @@ -0,0 +1,49 @@ + + + + + odl-mdsal-commons + odl-mdsal-broker + odl-mdsal-restconf + + + yangtools-concepts + yangtools-binding + mvn:org.opendaylight.controller/sal-common/${project.version} + mvn:org.opendaylight.controller/sal-common-api/${project.version} + mvn:org.opendaylight.controller/sal-common-impl/${project.version} + mvn:org.opendaylight.controller/sal-common-util/${project.version} + wrap:mvn:com.google.guava/guava/${guava.version} + wrap:mvn:org.eclipse.xtend/org.eclipse.xtend.lib/${xtend.version} + + + yangtools-concepts + yangtools-binding + odl-mdsal-commons + odl-config-subsystem + mvn:org.opendaylight.controller/sal-core-api/${project.version} + mvn:org.opendaylight.controller/sal-core-spi/${project.version} + mvn:org.opendaylight.controller/sal-broker-impl/${project.version} + mvn:org.opendaylight.controller/sal-binding-api/${project.version} + mvn:org.opendaylight.controller/sal-binding-config/${project.version} + mvn:org.opendaylight.controller/sal-binding-broker-impl/${project.version} + mvn:org.opendaylight.controller/sal-binding-util/${project.version} + mvn:org.opendaylight.controller/sal-connector-api/${project.version} + + + odl-mdsal-broker + mvn:org.opendaylight.controller/sal-rest-connector/${project.version} + wrap:mvn:com.google.code.gson/gson/${gson.version} + wrap:mvn:com.sun.jersey/jersey-core/${jersey.version} + wrap:mvn:com.sun.jersey/jersey-server/${jersey.version} + mvn:org.opendaylight.controller.thirdparty/com.sun.jersey.jersey-servlet/${jersey.version} + wrap:mvn:io.netty/netty-buffer/${netty.version} + wrap:mvn:io.netty/netty-codec/${netty.version} + wrap:mvn:io.netty/netty-codec-http/${netty.version} + wrap:mvn:io.netty/netty-common/${netty.version} + wrap:mvn:io.netty/netty-handler/${netty.version} + wrap:mvn:io.netty/netty-transport/${netty.version} + + \ No newline at end of file diff --git a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java index 03cdf973af..2a3d8fd37e 100644 --- a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java +++ b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java @@ -7,7 +7,6 @@ */ package org.opendaylight.controller.md.inventory.manager; -import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; @@ -37,10 +36,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.base.Objects; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.JdkFutureAdapters; public class NodeChangeCommiter implements OpendaylightInventoryListener { - private final static Logger LOG = LoggerFactory.getLogger(NodeChangeCommiter.class); + protected final static Logger LOG = LoggerFactory.getLogger(NodeChangeCommiter.class); private final FlowCapableInventoryProvider manager; @@ -57,15 +59,10 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener { final NodeConnectorRef ref = connector.getNodeConnectorRef(); final DataModificationTransaction it = this.getManager().startChange(); - NodeChangeCommiter.LOG.debug("removing node connector {} ", ref.getValue()); + LOG.debug("removing node connector {} ", ref.getValue()); it.removeOperationalData(ref.getValue()); Future> commitResult = it.commit(); - try { - commitResult.get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Node Connector {} not removed.", ref.getValue(), e); - } - + listenOnTransactionState(it.getIdentifier(), commitResult, "nodeConnector removal", ref.getValue()); } @Override @@ -85,16 +82,11 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener { data.addAugmentation(FlowCapableNodeConnector.class, augment); } InstanceIdentifier value = ref.getValue(); - NodeChangeCommiter.LOG.debug("updating node connector : {}.", value); + LOG.debug("updating node connector : {}.", value); NodeConnector build = data.build(); it.putOperationalData((value), build); Future> commitResult = it.commit(); - try { - commitResult.get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Node Connector {} not updated.", ref.getValue(), e); - } - + listenOnTransactionState(it.getIdentifier(), commitResult, "nodeConnector update", ref.getValue()); } @Override @@ -102,14 +94,10 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener { final NodeRef ref = node.getNodeRef(); final DataModificationTransaction it = this.manager.startChange(); - NodeChangeCommiter.LOG.debug("removing node : {}", ref.getValue()); + LOG.debug("removing node : {}", ref.getValue()); it.removeOperationalData((ref.getValue())); Future> commitResult = it.commit(); - try { - commitResult.get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Node {} not removed.", ref.getValue(), e); - } + listenOnTransactionState(it.getIdentifier(), commitResult, "node removal", ref.getValue()); } @Override @@ -128,19 +116,39 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener { final FlowCapableNode augment = InventoryMapping.toInventoryAugment(flowNode); nodeBuilder.addAugmentation(FlowCapableNode.class, augment); InstanceIdentifier value = ref.getValue(); - InstanceIdentifierBuilder builder = InstanceIdentifier. builder(((InstanceIdentifier) value)); + InstanceIdentifierBuilder builder = ((InstanceIdentifier) value).builder(); InstanceIdentifierBuilder augmentation = builder . augmentation(FlowCapableNode.class); final InstanceIdentifier path = augmentation.build(); - NodeChangeCommiter.LOG.debug("updating node :{} ", path); + LOG.debug("updating node :{} ", path); it.putOperationalData(path, augment); Future> commitResult = it.commit(); - try { - commitResult.get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Node {} not updated.", ref.getValue(), e); - } - + listenOnTransactionState(it.getIdentifier(), commitResult, "node update", ref.getValue()); + } + + /** + * @param txId transaction identificator + * @param future transaction result + * @param action performed by transaction + * @param nodeConnectorPath target value + */ + private static void listenOnTransactionState(final Object txId, Future> future, + final String action, final InstanceIdentifier nodeConnectorPath) { + Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallback>() { + + @Override + public void onFailure(Throwable t) { + LOG.error("Action {} [{}] failed for Tx:{}", action, nodeConnectorPath, txId, t); + + } + + @Override + public void onSuccess(RpcResult result) { + if(!result.isSuccessful()) { + LOG.error("Action {} [{}] failed for Tx:{}", action, nodeConnectorPath, txId); + } + } + }); } } diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 451edfdf78..a13d2bb06f 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -61,6 +61,10 @@ --> sal-rest-docgen + + + feature + @@ -157,7 +161,6 @@ org.opendaylight.yangtools yang-maven-plugin - ${yangtools.version} org.opendaylight.controller diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java index fc297261b7..871abb2117 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java @@ -15,7 +15,7 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerCo * component of the controller or application supplies a concrete implementation * of this interface. * - * A user-implemented component (application) which faciliates the SAL and SAL + * A user-implemented component (application) which facilitates the SAL and SAL * services to access infrastructure services or providers' functionality. * * diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java index 14006a3fce..750defc0e9 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java @@ -7,11 +7,10 @@ */ package org.opendaylight.controller.config.yang.md.sal.binding.impl; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; import java.util.Hashtable; import java.util.Map.Entry; import java.util.Set; + import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder; import org.opendaylight.yangtools.concepts.Delegator; import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl; @@ -28,6 +27,9 @@ import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; + /** * */ @@ -61,14 +63,13 @@ public final class RuntimeMappingModule extends @Override public java.lang.AutoCloseable createInstance() { - + RuntimeGeneratedMappingServiceProxy potential = tryToReuseGlobalInstance(); if(potential != null) { return potential; } - RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl(); - service.setPool(SingletonHolder.CLASS_POOL); - service.init(); + + final RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl(SingletonHolder.CLASS_POOL); bundleContext.registerService(SchemaServiceListener.class, service, new Hashtable()); return service; } @@ -98,7 +99,7 @@ public final class RuntimeMappingModule extends BindingIndependentMappingService, // Delegator, // AutoCloseable { - + private BindingIndependentMappingService delegate; private ServiceReference reference; private BundleContext bundleContext; @@ -111,35 +112,42 @@ public final class RuntimeMappingModule extends this.delegate = Preconditions.checkNotNull(delegate); } + @Override public CodecRegistry getCodecRegistry() { return delegate.getCodecRegistry(); } + @Override public CompositeNode toDataDom(DataObject data) { return delegate.toDataDom(data); } + @Override public Entry toDataDom( Entry, DataObject> entry) { return delegate.toDataDom(entry); } + @Override public InstanceIdentifier toDataDom( org.opendaylight.yangtools.yang.binding.InstanceIdentifier path) { return delegate.toDataDom(path); } + @Override public DataObject dataObjectFromDataDom( org.opendaylight.yangtools.yang.binding.InstanceIdentifier path, CompositeNode result) throws DeserializationException { return delegate.dataObjectFromDataDom(path, result); } + @Override public org.opendaylight.yangtools.yang.binding.InstanceIdentifier fromDataDom(InstanceIdentifier entry) throws DeserializationException { return delegate.fromDataDom(entry); } + @Override public Set getRpcQNamesFor(Class service) { return delegate.getRpcQNamesFor(service); } @@ -149,10 +157,11 @@ public final class RuntimeMappingModule extends return delegate.getRpcServiceClassFor(namespace,revision); } + @Override public DataContainer dataObjectFromDataDom(Class inputClass, CompositeNode domInput) { return delegate.dataObjectFromDataDom(inputClass, domInput); } - + @Override public void close() throws Exception { if(delegate != null) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java index 685a91979c..2a866a94b3 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java @@ -96,10 +96,14 @@ public abstract class AbstractForwardedDataBroker implements Delegator> entry : normalized .entrySet()) { try { - Entry, DataObject> binding = getCodec().toBinding(entry); - newMap.put(binding.getKey(), binding.getValue()); + Optional, DataObject>> potential = getCodec().toBinding( + entry); + if (potential.isPresent()) { + Entry, DataObject> binding = potential.get(); + newMap.put(binding.getKey(), binding.getValue()); + } } catch (DeserializationException e) { - LOG.debug("Omitting {}", entry, e); + LOG.warn("Failed to transform {}, omitting it", entry, e); } } return newMap; @@ -110,17 +114,20 @@ public abstract class AbstractForwardedDataBroker implements Delegator> hashSet = new HashSet<>(); for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath : normalized) { try { - InstanceIdentifier binding = getCodec().toBinding(normalizedPath); - hashSet.add(binding); + Optional> potential = getCodec().toBinding(normalizedPath); + if (potential.isPresent()) { + InstanceIdentifier binding = potential.get(); + hashSet.add(binding); + } } catch (DeserializationException e) { - LOG.debug("Omitting {}", normalizedPath, e); + LOG.warn("Failed to transform {}, omitting it", normalizedPath, e); } } return hashSet; } protected Optional toBindingData(final InstanceIdentifier path, final NormalizedNode data) { - if(path.isWildcarded()) { + if (path.isWildcarded()) { return Optional.absent(); } @@ -207,7 +214,11 @@ public abstract class AbstractForwardedDataBroker implements Delegator apply(@Nullable final Optional> normalizedNode) { - try { - final DataObject dataObject = normalizedNode.isPresent() ? codec.toBinding(path, - normalizedNode.get()) : null; + if (normalizedNode.isPresent()) { + final DataObject dataObject; + try { + dataObject = codec.toBinding(path, normalizedNode.get()); + } catch (DeserializationException e) { + LOG.warn("Failed to create dataobject from node {}", normalizedNode.get(), e); + throw new IllegalStateException("Failed to create dataobject", e); + } + if (dataObject != null) { updateCache(store, path, dataObject); + return Optional.of(dataObject); } - return Optional.fromNullable(dataObject); - } catch (DeserializationException e) { - Exceptions.sneakyThrow(e); } - return null; + return Optional.absent(); } }); } @@ -108,10 +111,10 @@ public class AbstractForwardedTransaction> normalized = codec .toNormalizedNode(path, data); - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey(); - ensureParentsByMerge(writeTransaction, store, normalized.getKey(), path); - LOG.debug("Tx: {} : Putting data {}",getDelegate().getIdentifier(),normalized.getKey()); - writeTransaction.put(store, normalized.getKey(), normalized.getValue()); + final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey(); + ensureParentsByMerge(writeTransaction, store, normalizedPath, path); + LOG.debug("Tx: {} : Putting data {}", getDelegate().getIdentifier(), normalizedPath); + writeTransaction.put(store, normalizedPath, normalized.getValue()); } protected void doMergeWithEnsureParents(final DOMDataReadWriteTransaction writeTransaction, @@ -120,10 +123,10 @@ public class AbstractForwardedTransaction> normalized = codec .toNormalizedNode(path, data); - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey(); - ensureParentsByMerge(writeTransaction, store, normalized.getKey(), path); - LOG.debug("Tx: {} : Merge data {}",getDelegate().getIdentifier(),normalized.getKey()); - writeTransaction.merge(store, normalized.getKey(), normalized.getValue()); + final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey(); + ensureParentsByMerge(writeTransaction, store, normalizedPath, path); + LOG.debug("Tx: {} : Merge data {}",getDelegate().getIdentifier(),normalizedPath); + writeTransaction.merge(store, normalizedPath, normalized.getValue()); } private void ensureParentsByMerge(final DOMDataReadWriteTransaction writeTransaction, diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java index 6329637dd0..53615ad7de 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java @@ -16,6 +16,7 @@ import java.util.Map.Entry; import java.util.concurrent.Callable; 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.yangtools.concepts.util.ClassLoaderUtils; import org.opendaylight.yangtools.yang.binding.Augmentation; @@ -42,6 +43,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; @@ -60,7 +62,8 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { public org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toNormalized( final InstanceIdentifier binding) { - // Used instance-identifier codec do not support serialization of last path + // Used instance-identifier codec do not support serialization of last + // path // argument if it is Augmentation (behaviour expected by old datastore) // in this case, we explicitly check if last argument is augmentation // to process it separately @@ -103,13 +106,24 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { } - public InstanceIdentifier toBinding( + /** + * + * Returns a Binding-Aware instance identifier from normalized + * instance-identifier if it is possible to create representation. + * + * Returns Optional.absent for cases where target is mixin node except + * augmentation. + * + */ + public Optional> toBinding( final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) throws DeserializationException { PathArgument lastArgument = Iterables.getLast(normalized.getPath()); - // Used instance-identifier codec do not support serialization of last path - // argument if it is AugmentationIdentifier (behaviour expected by old datastore) + // Used instance-identifier codec do not support serialization of last + // path + // argument if it is AugmentationIdentifier (behaviour expected by old + // datastore) // in this case, we explicitly check if last argument is augmentation // to process it separately if (lastArgument instanceof AugmentationIdentifier) { @@ -118,46 +132,71 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return toBindingImpl(normalized); } - private InstanceIdentifier toBindingAugmented( - final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) throws DeserializationException { - InstanceIdentifier potential = toBindingImpl(normalized); + private Optional> toBindingAugmented( + final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) + throws DeserializationException { + Optional> potential = toBindingImpl(normalized); // Shorthand check, if codec already supports deserialization // of AugmentationIdentifier we will return - if(isAugmentationIdentifier(potential)) { + if (potential.isPresent() && isAugmentationIdentifier(potential.get())) { return potential; } AugmentationIdentifier lastArgument = (AugmentationIdentifier) Iterables.getLast(normalized.getPath()); - // Here we employ small trick - Binding-aware Codec injects an pointer to augmentation class - // if child is referenced - so we will reference child and then shorten path. + // Here we employ small trick - Binding-aware Codec injects an pointer + // to augmentation class + // if child is referenced - so we will reference child and then shorten + // path. for (QName child : lastArgument.getPossibleChildNames()) { org.opendaylight.yangtools.yang.data.api.InstanceIdentifier childPath = new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier( - ImmutableList. builder() - .addAll(normalized.getPath()).add(new NodeIdentifier(child)).build()); + ImmutableList. builder().addAll(normalized.getPath()).add(new NodeIdentifier(child)) + .build()); try { - - InstanceIdentifier potentialPath = shortenToLastAugment(toBindingImpl(childPath)); - return potentialPath; + if (!isChoiceOrCasePath(childPath)) { + InstanceIdentifier potentialPath = shortenToLastAugment(toBindingImpl( + childPath).get()); + return Optional.> of(potentialPath); + } } catch (Exception e) { - LOG.trace("Unable to deserialize aug. child path for {}",childPath,e); + LOG.trace("Unable to deserialize aug. child path for {}", childPath, e); } } return toBindingImpl(normalized); } - private InstanceIdentifier toBindingImpl( + private Optional> toBindingImpl( final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) throws DeserializationException { org.opendaylight.yangtools.yang.data.api.InstanceIdentifier legacyPath; + try { + if (isChoiceOrCasePath(normalized)) { + return Optional.absent(); + } legacyPath = legacyToNormalized.toLegacy(normalized); } catch (DataNormalizationException e) { throw new IllegalStateException("Could not denormalize path.", e); } LOG.trace("InstanceIdentifier Path Deserialization: Legacy representation {}, Normalized representation: {}", legacyPath, normalized); - return bindingToLegacy.fromDataDom(legacyPath); + return Optional.> of(bindingToLegacy.fromDataDom(legacyPath)); + } + + private boolean isChoiceOrCasePath(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) + throws DataNormalizationException { + DataNormalizationOperation op = findNormalizationOperation(normalized); + return op.isMixin() && op.getIdentifier() instanceof NodeIdentifier; + } + + private DataNormalizationOperation findNormalizationOperation( + final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) + throws DataNormalizationException { + DataNormalizationOperation current = legacyToNormalized.getRootOperation(); + for (PathArgument arg : normalized.getPath()) { + current = current.getChild(arg); + } + return current; } private static final Entry, DataObject> toEntry( @@ -170,7 +209,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { public DataObject toBinding(final InstanceIdentifier path, final NormalizedNode normalizedNode) throws DeserializationException { CompositeNode legacy = null; - if(isAugmentationIdentifier(path) && normalizedNode instanceof AugmentationNode) { + if (isAugmentationIdentifier(path) && normalizedNode instanceof AugmentationNode) { QName augIdentifier = BindingReflections.findQName(path.getTargetType()); ContainerNode virtualNode = Builders.containerBuilder() // .withNodeIdentifier(new NodeIdentifier(augIdentifier)) // @@ -188,12 +227,20 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return legacyToNormalized; } - public Entry, DataObject> toBinding( + public Optional, DataObject>> toBinding( final Entry> normalized) throws DeserializationException { - InstanceIdentifier bindingPath = toBinding(normalized.getKey()); - DataObject bindingData = toBinding(bindingPath, normalized.getValue()); - return toEntry(bindingPath, bindingData); + Optional> potentialPath = toBinding(normalized.getKey()); + if (potentialPath.isPresent()) { + InstanceIdentifier bindingPath = potentialPath.get(); + DataObject bindingData = toBinding(bindingPath, normalized.getValue()); + if (bindingData == null) { + LOG.warn("Failed to deserialize {} to Binding format. Binding path is: {}", normalized, bindingPath); + } + return Optional.of(toEntry(bindingPath, bindingData)); + } else { + return Optional.absent(); + } } @Override @@ -206,14 +253,17 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { org.opendaylight.yangtools.yang.data.api.InstanceIdentifier processed = toNormalizedImpl(augPath); // If used instance identifier codec added supports for deserialization // of last AugmentationIdentifier we will just reuse it - if(isAugmentationIdentifier(processed)) { + if (isAugmentationIdentifier(processed)) { return processed; } - // Here we employ small trick - DataNormalizer injecst augmentation identifier if child is - // also part of the path (since using a child we can safely identify augmentation) + // Here we employ small trick - DataNormalizer injecst augmentation + // identifier if child is + // also part of the path (since using a child we can safely identify + // augmentation) // so, we scan augmentation for children add it to path // and use original algorithm, then shorten it to last augmentation - for (@SuppressWarnings("rawtypes") Class augChild : getAugmentationChildren(augPath.getTargetType())) { + for (@SuppressWarnings("rawtypes") + Class augChild : getAugmentationChildren(augPath.getTargetType())) { @SuppressWarnings("unchecked") InstanceIdentifier childPath = augPath.child(augChild); org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized = toNormalizedImpl(childPath); @@ -225,8 +275,6 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return processed; } - - private org.opendaylight.yangtools.yang.data.api.InstanceIdentifier shortenToLastAugmentation( final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalized) { int position = 0; @@ -248,7 +296,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { final InstanceIdentifier binding) { int position = 0; int foundPosition = -1; - for(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument arg : binding.getPathArguments()) { + for (org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument arg : binding.getPathArguments()) { position++; if (isAugmentation(arg.getType())) { foundPosition = position; @@ -257,8 +305,6 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return InstanceIdentifier.create(Iterables.limit(binding.getPathArguments(), foundPosition)); } - - private org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toNormalizedImpl( final InstanceIdentifier binding) { final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier legacyPath = bindingToLegacy @@ -326,13 +372,12 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener { return InstanceIdentifier.create(wildArgs); } - private static boolean isAugmentation(final Class type) { return Augmentation.class.isAssignableFrom(type); } - private static boolean isAugmentationIdentifier(final InstanceIdentifier path) { - return Augmentation.class.isAssignableFrom(path.getTargetType()); + private static boolean isAugmentationIdentifier(final InstanceIdentifier potential) { + return Augmentation.class.isAssignableFrom(potential.getTargetType()); } private boolean isAugmentationIdentifier(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier processed) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.java index ea8b6c0972..ae90a7739e 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.java @@ -7,151 +7,89 @@ */ package org.opendaylight.controller.sal.binding.codegen; -import com.google.common.base.Objects; import java.lang.reflect.Field; import java.util.Map; -import org.eclipse.xtext.xbase.lib.Exceptions; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification; + import org.opendaylight.yangtools.yang.binding.BaseIdentity; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; -@SuppressWarnings("all") -public class RuntimeCodeHelper { - /** - * Helper method to return delegate from ManagedDirectedProxy with use of reflection. - * - * Note: This method uses reflection, but access to delegate field should be - * avoided and called only if neccessary. - */ - public static T getDelegate(final RpcService proxy) { - try { - Class _class = proxy.getClass(); - final Field field = _class.getField(RuntimeCodeSpecification.DELEGATE_FIELD); - boolean _equals = Objects.equal(field, null); - if (_equals) { - UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("Unable to get delegate from proxy"); - throw _unsupportedOperationException; - } - try { - Object _get = field.get(proxy); - return ((T) _get); - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); - } - } catch (Throwable _e_1) { - throw Exceptions.sneakyThrow(_e_1); +public final class RuntimeCodeHelper { + private RuntimeCodeHelper() { + throw new UnsupportedOperationException("Utility class should never be instantiated"); + } + + private static Field getField(final Class cls, final String name) { + try { + return cls.getField(name); + } catch (NoSuchFieldException e) { + throw new IllegalArgumentException( + String.format("Class %s is missing field %s", cls, name), e); + } catch (SecurityException e) { + throw new IllegalStateException(String.format("Failed to examine class %s", cls), e); + } } - } - /** - * Helper method to set delegate to ManagedDirectedProxy with use of reflection. - * - * Note: This method uses reflection, but setting delegate field should not occur too much - * to introduce any significant performance hits. - */ - public static void setDelegate(final RpcService proxy, final RpcService delegate) { - try { - Class _class = proxy.getClass(); - final Field field = _class.getField(RuntimeCodeSpecification.DELEGATE_FIELD); - boolean _equals = Objects.equal(field, null); - if (_equals) { - UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("Unable to set delegate to proxy"); - throw _unsupportedOperationException; - } - boolean _or = false; - boolean _equals_1 = Objects.equal(delegate, null); - if (_equals_1) { - _or = true; - } else { - Class _type = field.getType(); - Class _class_1 = delegate.getClass(); - boolean _isAssignableFrom = _type.isAssignableFrom(_class_1); - _or = (_equals_1 || _isAssignableFrom); - } - if (_or) { - field.set(proxy, delegate); - } else { - IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("delegate class is not assignable to proxy"); - throw _illegalArgumentException; - } - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); + private static Field getDelegateField(final Class cls) { + return getField(cls, RuntimeCodeSpecification.DELEGATE_FIELD); } - } - /** - * Helper method to set delegate to ManagedDirectedProxy with use of reflection. - * - * Note: This method uses reflection, but setting delegate field should not occur too much - * to introduce any significant performance hits. - */ - public static void setDelegate(final Object proxy, final Object delegate) { - try { - Class _class = proxy.getClass(); - final Field field = _class.getField(RuntimeCodeSpecification.DELEGATE_FIELD); - boolean _equals = Objects.equal(field, null); - if (_equals) { - UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("Unable to set delegate to proxy"); - throw _unsupportedOperationException; - } - boolean _or = false; - boolean _equals_1 = Objects.equal(delegate, null); - if (_equals_1) { - _or = true; - } else { - Class _type = field.getType(); - Class _class_1 = delegate.getClass(); - boolean _isAssignableFrom = _type.isAssignableFrom(_class_1); - _or = (_equals_1 || _isAssignableFrom); - } - if (_or) { - field.set(proxy, delegate); - } else { - IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("delegate class is not assignable to proxy"); - throw _illegalArgumentException; - } - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); + private static Object getFieldValue(final Field field, final Object obj) { + try { + return field.get(obj); + } catch (IllegalAccessException e) { + throw new IllegalStateException(String.format("Failed to get field %s of object %s", field, obj), e); + } + } + + private static void setFieldValue(final Field field, final Object obj, final Object value) { + try { + field.set(obj, value); + } catch (IllegalAccessException e) { + throw new IllegalStateException(String.format("Failed to set field %s to %s", field, value), e); + } + } + + /** + * Helper method to return delegate from ManagedDirectedProxy with use of reflection. + * + * Note: This method uses reflection, but access to delegate field should be + * avoided and called only if necessary. + */ + @SuppressWarnings("unchecked") + public static T getDelegate(final RpcService proxy) { + return (T)getFieldValue(getDelegateField(proxy.getClass()), proxy); + } + + /** + * Helper method to set delegate to ManagedDirectedProxy with use of reflection. + * + * Note: This method uses reflection, but setting delegate field should not occur too much + * to introduce any significant performance hits. + */ + public static void setDelegate(final Object proxy, final Object delegate) { + final Field field = getDelegateField(proxy.getClass()); + + if (delegate != null) { + final Class ft = field.getType(); + if (!ft.isAssignableFrom(delegate.getClass())) { + throw new IllegalArgumentException( + String.format("Field %s type %s is not compatible with delegate type %s", + field, ft, delegate.getClass())); + } + } + + setFieldValue(field, proxy, delegate); } - } - public static Map,? extends RpcService> getRoutingTable(final RpcService target, final Class tableClass) { - try { - Class _class = target.getClass(); - String _routingTableField = RuntimeCodeSpecification.getRoutingTableField(tableClass); - final Field field = _class.getField(_routingTableField); - boolean _equals = Objects.equal(field, null); - if (_equals) { - UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException( - "Unable to get routing table. Table field does not exists"); - throw _unsupportedOperationException; - } - try { - Object _get = field.get(target); - return ((Map,? extends RpcService>) _get); - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); - } - } catch (Throwable _e_1) { - throw Exceptions.sneakyThrow(_e_1); + @SuppressWarnings("unchecked") + public static Map,? extends RpcService> getRoutingTable(final RpcService target, final Class tableClass) { + final Field field = getField(target.getClass(), RuntimeCodeSpecification.getRoutingTableField(tableClass)); + return (Map,? extends RpcService>) getFieldValue(field, target); } - } - public static void setRoutingTable(final RpcService target, final Class tableClass, final Map,? extends RpcService> routingTable) { - try { - Class _class = target.getClass(); - String _routingTableField = RuntimeCodeSpecification.getRoutingTableField(tableClass); - final Field field = _class.getField(_routingTableField); - boolean _equals = Objects.equal(field, null); - if (_equals) { - UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException( - "Unable to set routing table. Table field does not exists"); - throw _unsupportedOperationException; - } - field.set(target, routingTable); - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); + public static void setRoutingTable(final RpcService target, final Class tableClass, final Map,? extends RpcService> routingTable) { + final Field field = getField(target.getClass(), RuntimeCodeSpecification.getRoutingTableField(tableClass)); + setFieldValue(field, target, routingTable); } - } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend index 6723713645..465a1f7d9d 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend @@ -43,13 +43,11 @@ import javassist.LoaderClassPath class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory { val CtClass BROKER_NOTIFICATION_LISTENER; - val ClassPool classPool; val extension JavassistUtils utils; val Map, RuntimeGeneratedInvokerPrototype> invokerClasses; new(ClassPool pool) { - classPool = pool; utils = new JavassistUtils(pool); invokerClasses = new WeakHashMap(); BROKER_NOTIFICATION_LISTENER = org.opendaylight.controller.sal.binding.api.NotificationListener.asCtClass; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java index 4141bba2d4..8276446766 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java @@ -7,13 +7,6 @@ */ package org.opendaylight.controller.sal.binding.codegen.impl; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import javassist.ClassPool; -import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory; - import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -23,7 +16,20 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import javassist.ClassPool; + +import org.apache.commons.lang3.StringUtils; +import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator; +import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + public class SingletonHolder { + private static final Logger logger = LoggerFactory.getLogger(SingletonHolder.class); public static final ClassPool CLASS_POOL = ClassPool.getDefault(); public static final org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator( @@ -34,8 +40,9 @@ public class SingletonHolder { public static final int CORE_NOTIFICATION_THREADS = 4; public static final int MAX_NOTIFICATION_THREADS = 32; // block caller thread after MAX_NOTIFICATION_THREADS + MAX_NOTIFICATION_QUEUE_SIZE pending notifications - public static final int MAX_NOTIFICATION_QUEUE_SIZE = 10; + public static final int MAX_NOTIFICATION_QUEUE_SIZE = 1000; public static final int NOTIFICATION_THREAD_LIFE = 15; + private static final String NOTIFICATION_QUEUE_SIZE_PROPERTY = "mdsal.notificationqueue.size"; private static ListeningExecutorService NOTIFICATION_EXECUTOR = null; private static ListeningExecutorService COMMIT_EXECUTOR = null; @@ -46,14 +53,27 @@ public class SingletonHolder { * should use service injection to make the executor configurable. */ @Deprecated - public static synchronized final ListeningExecutorService getDefaultNotificationExecutor() { + public static synchronized ListeningExecutorService getDefaultNotificationExecutor() { if (NOTIFICATION_EXECUTOR == null) { + int queueSize = MAX_NOTIFICATION_QUEUE_SIZE; + String queueValue = System.getProperty(NOTIFICATION_QUEUE_SIZE_PROPERTY); + if (StringUtils.isNotBlank(queueValue)) { + try { + queueSize = Integer.parseInt(queueValue); + logger.trace("Queue size was set to {}", queueSize); + }catch(NumberFormatException e) { + logger.warn("Cannot parse {} as set by {}, using default {}", queueValue, + NOTIFICATION_QUEUE_SIZE_PROPERTY, queueSize); + } + } // Overriding the queue: // ThreadPoolExecutor would not create new threads if the queue is not full, thus adding // occurs in RejectedExecutionHandler. // This impl saturates threadpool first, then queue. When both are full caller will get blocked. - BlockingQueue queue = new LinkedBlockingQueue(MAX_NOTIFICATION_QUEUE_SIZE) { + BlockingQueue queue = new LinkedBlockingQueue(queueSize) { + private static final long serialVersionUID = 1L; + @Override public boolean offer(Runnable r) { // ThreadPoolExecutor will spawn a new thread after core size is reached only if the queue.offer returns false. @@ -89,7 +109,7 @@ public class SingletonHolder { * should use service injection to make the executor configurable. */ @Deprecated - public static synchronized final ListeningExecutorService getDefaultCommitExecutor() { + public static synchronized ListeningExecutorService getDefaultCommitExecutor() { if (COMMIT_EXECUTOR == null) { ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("md-sal-binding-commit-%d").build(); /* diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java index a398abc75a..b27c80d784 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java @@ -98,11 +98,8 @@ public class BindingIndependentConnector implements // Provider, // AutoCloseable { - - private final Logger LOG = LoggerFactory.getLogger(BindingIndependentConnector.class); - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier ROOT_BI = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier .builder().toInstance(); @@ -200,30 +197,30 @@ public class BindingIndependentConnector implements // private DataModificationTransaction createBindingToDomTransaction( final DataModification, DataObject> source) { DataModificationTransaction target = biDataService.beginTransaction(); - LOG.debug("Created DOM Transaction {} for {},", target.getIdentifier(),source.getIdentifier()); + LOG.debug("Created DOM Transaction {} for {},", target.getIdentifier(), source.getIdentifier()); for (InstanceIdentifier entry : source.getRemovedConfigurationData()) { org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biEntry = mappingService.toDataDom(entry); target.removeConfigurationData(biEntry); - LOG.debug("Delete of Binding Configuration Data {} is translated to {}",entry,biEntry); + LOG.debug("Delete of Binding Configuration Data {} is translated to {}", entry, biEntry); } for (InstanceIdentifier entry : source.getRemovedOperationalData()) { org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biEntry = mappingService.toDataDom(entry); target.removeOperationalData(biEntry); - LOG.debug("Delete of Binding Operational Data {} is translated to {}",entry,biEntry); + LOG.debug("Delete of Binding Operational Data {} is translated to {}", entry, biEntry); } for (Entry, DataObject> entry : source.getUpdatedConfigurationData() .entrySet()) { Entry biEntry = mappingService .toDataDom(entry); target.putConfigurationData(biEntry.getKey(), biEntry.getValue()); - LOG.debug("Update of Binding Configuration Data {} is translated to {}",entry,biEntry); + LOG.debug("Update of Binding Configuration Data {} is translated to {}", entry, biEntry); } for (Entry, DataObject> entry : source.getUpdatedOperationalData() .entrySet()) { Entry biEntry = mappingService .toDataDom(entry); target.putOperationalData(biEntry.getKey(), biEntry.getValue()); - LOG.debug("Update of Binding Operational Data {} is translated to {}",entry,biEntry); + LOG.debug("Update of Binding Operational Data {} is translated to {}", entry, biEntry); } return target; @@ -279,7 +276,8 @@ public class BindingIndependentConnector implements // return biDataService; } - protected void setDomDataService(final org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService) { + protected void setDomDataService( + final org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService) { this.biDataService = biDataService; } @@ -300,14 +298,14 @@ public class BindingIndependentConnector implements // } public void startDataForwarding() { - if(baDataService instanceof AbstractForwardedDataBroker) { + if (baDataService instanceof AbstractForwardedDataBroker) { dataForwarding = true; return; } final DataProviderService baData; if (baDataService instanceof BindingMountPointImpl) { - baData = ((BindingMountPointImpl)baDataService).getDataBrokerImpl(); + baData = ((BindingMountPointImpl) baDataService).getDataBrokerImpl(); LOG.debug("Extracted BA Data provider {} from mount point {}", baData, baDataService); } else { baData = baDataService; @@ -478,8 +476,8 @@ public class BindingIndependentConnector implements // } DataModificationTransaction domTransaction = createBindingToDomTransaction(bindingTransaction); BindingToDomTransaction wrapped = new BindingToDomTransaction(domTransaction, bindingTransaction); - LOG.trace("Forwarding Binding Transaction: {} as DOM Transaction: {} .", bindingTransaction.getIdentifier(), - domTransaction.getIdentifier()); + LOG.trace("Forwarding Binding Transaction: {} as DOM Transaction: {} .", + bindingTransaction.getIdentifier(), domTransaction.getIdentifier()); return wrapped; } } @@ -489,7 +487,8 @@ public class BindingIndependentConnector implements // DataCommitHandler { @Override - public void onRegister(final DataCommitHandlerRegistration, DataObject> registration) { + public void onRegister( + final DataCommitHandlerRegistration, DataObject> registration) { org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = mappingService.toDataDom(registration .getPath()); @@ -497,7 +496,8 @@ public class BindingIndependentConnector implements // } @Override - public void onUnregister(final DataCommitHandlerRegistration, DataObject> registration) { + public void onUnregister( + final DataCommitHandlerRegistration, DataObject> registration) { // NOOP for now // FIXME: do registration based on only active commit handlers. } @@ -531,8 +531,7 @@ public class BindingIndependentConnector implements // * */ private class DomToBindingRpcForwardingManager implements - RouteChangeListener>, - RouterInstantiationListener, + RouteChangeListener>, RouterInstantiationListener, GlobalRpcRegistrationListener { private final Map, DomToBindingRpcForwarder> forwarders = new WeakHashMap<>(); @@ -615,7 +614,7 @@ public class BindingIndependentConnector implements // } } catch (Exception e) { - LOG.error("Could not forward Rpcs of type {}", service.getName(),e); + LOG.error("Could not forward Rpcs of type {}", service.getName(), e); } registrations = ImmutableSet.of(); } @@ -626,7 +625,8 @@ public class BindingIndependentConnector implements // * @param service * @param context */ - public DomToBindingRpcForwarder(final Class service, final Class context) { + public DomToBindingRpcForwarder(final Class service, + final Class context) { this.rpcServiceType = new WeakReference>(service); this.supportedRpcs = mappingService.getRpcQNamesFor(service); Builder registrationsBuilder = ImmutableSet @@ -645,8 +645,8 @@ public class BindingIndependentConnector implements // registrations = registrationsBuilder.build(); } - public void registerPaths(final Class context, final Class service, - final Set> set) { + public void registerPaths(final Class context, + final Class service, final Set> set) { QName ctx = BindingReflections.findQName(context); for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path : FluentIterable.from(set).transform( toDOMInstanceIdentifier)) { @@ -656,7 +656,6 @@ public class BindingIndependentConnector implements // } } - @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { if (EQUALS_METHOD.equals(method)) { @@ -700,7 +699,6 @@ public class BindingIndependentConnector implements // } } - @Override public ListenableFuture> invokeRpc(final QName rpc, final CompositeNode domInput) { checkArgument(rpc != null); @@ -748,12 +746,12 @@ public class BindingIndependentConnector implements // strategy = new DefaultInvocationStrategy(rpc, targetMethod, outputClass.get(), inputClass .get()); } else { - strategy = new NoInputNoOutputInvocationStrategy(rpc, targetMethod); + strategy = new NoInputInvocationStrategy(rpc, targetMethod, outputClass.get()); } - } else if(inputClass.isPresent()){ - strategy = new NoOutputInvocationStrategy(rpc,targetMethod, inputClass.get()); + } else if (inputClass.isPresent()) { + strategy = new NoOutputInvocationStrategy(rpc, targetMethod, inputClass.get()); } else { - strategy = new NoInputNoOutputInvocationStrategy(rpc,targetMethod); + strategy = new NoInputNoOutputInvocationStrategy(rpc, targetMethod); } return strategy; } @@ -777,7 +775,8 @@ public class BindingIndependentConnector implements // public abstract RpcResult uncheckedInvoke(RpcService rpcService, CompositeNode domInput) throws Exception; - public RpcResult invokeOn(final RpcService rpcService, final CompositeNode domInput) throws Exception { + public RpcResult invokeOn(final RpcService rpcService, final CompositeNode domInput) + throws Exception { return uncheckedInvoke(rpcService, domInput); } } @@ -800,7 +799,8 @@ public class BindingIndependentConnector implements // @SuppressWarnings("unchecked") @Override - public RpcResult uncheckedInvoke(final RpcService rpcService, final CompositeNode domInput) throws Exception { + public RpcResult uncheckedInvoke(final RpcService rpcService, final CompositeNode domInput) + throws Exception { DataContainer bindingInput = mappingService.dataObjectFromDataDom(inputClass.get(), domInput); Future> futureResult = (Future>) targetMethod.invoke(rpcService, bindingInput); if (futureResult == null) { @@ -809,31 +809,84 @@ public class BindingIndependentConnector implements // RpcResult bindingResult = futureResult.get(); final Object resultObj = bindingResult.getResult(); if (resultObj instanceof DataObject) { - final CompositeNode output = mappingService.toDataDom((DataObject)resultObj); - return Rpcs.getRpcResult(true, output, Collections.emptySet()); + final CompositeNode output = mappingService.toDataDom((DataObject) resultObj); + return Rpcs.getRpcResult(true, output, Collections. emptySet()); } return Rpcs.getRpcResult(true); } @Override public ListenableFuture> forwardToDomBroker(final DataObject input) { - if(biRpcRegistry == null) { + if (biRpcRegistry == null) { return Futures.> immediateFuture(Rpcs.getRpcResult(false)); } CompositeNode xml = mappingService.toDataDom(input); CompositeNode wrappedXml = ImmutableCompositeNode.create(rpc, ImmutableList.> of(xml)); - return Futures.transform(biRpcRegistry.invokeRpc(rpc, wrappedXml), new Function, RpcResult>() { - @Override - public RpcResult apply(RpcResult input) { - Object baResultValue = null; - if (input.getResult() != null) { - baResultValue = mappingService.dataObjectFromDataDom(outputClass.get(), input.getResult()); - } - return Rpcs.getRpcResult(input.isSuccessful(), baResultValue, input.getErrors()); - } - }); + return Futures.transform(biRpcRegistry.invokeRpc(rpc, wrappedXml), + new Function, RpcResult>() { + @Override + public RpcResult apply(final RpcResult input) { + Object baResultValue = null; + if (input.getResult() != null) { + baResultValue = mappingService.dataObjectFromDataDom(outputClass.get(), + input.getResult()); + } + return Rpcs.getRpcResult(input.isSuccessful(), baResultValue, input.getErrors()); + } + }); + } + } + + private class NoInputInvocationStrategy extends RpcInvocationStrategy { + + @SuppressWarnings("rawtypes") + private final WeakReference outputClass; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public NoInputInvocationStrategy(final QName rpc, final Method targetMethod, final Class outputClass) { + super(rpc, targetMethod); + this.outputClass = new WeakReference(outputClass); + } + + @SuppressWarnings("unchecked") + @Override + public RpcResult uncheckedInvoke(final RpcService rpcService, final CompositeNode domInput) + throws Exception { + Future> futureResult = (Future>) targetMethod.invoke(rpcService); + if (futureResult == null) { + return Rpcs.getRpcResult(false); + } + RpcResult bindingResult = futureResult.get(); + final Object resultObj = bindingResult.getResult(); + if (resultObj instanceof DataObject) { + final CompositeNode output = mappingService.toDataDom((DataObject) resultObj); + return Rpcs.getRpcResult(true, output, Collections. emptySet()); + } + return Rpcs.getRpcResult(true); + } + + @Override + public Future> forwardToDomBroker(final DataObject input) { + if (biRpcRegistry != null) { + CompositeNode xml = mappingService.toDataDom(input); + CompositeNode wrappedXml = ImmutableCompositeNode.create(rpc, ImmutableList.> of(xml)); + return Futures.transform(biRpcRegistry.invokeRpc(rpc, wrappedXml), + new Function, RpcResult>() { + @Override + public RpcResult apply(final RpcResult input) { + Object baResultValue = null; + if (input.getResult() != null) { + baResultValue = mappingService.dataObjectFromDataDom(outputClass.get(), + input.getResult()); + } + return Rpcs.getRpcResult(input.isSuccessful(), baResultValue, input.getErrors()); + } + }); + } else { + return Futures.> immediateFuture(Rpcs.getRpcResult(false)); + } } } @@ -844,7 +897,8 @@ public class BindingIndependentConnector implements // } @Override - public RpcResult uncheckedInvoke(final RpcService rpcService, final CompositeNode domInput) throws Exception { + public RpcResult uncheckedInvoke(final RpcService rpcService, final CompositeNode domInput) + throws Exception { @SuppressWarnings("unchecked") Future> result = (Future>) targetMethod.invoke(rpcService); RpcResult bindingResult = result.get(); @@ -859,20 +913,19 @@ public class BindingIndependentConnector implements // private class NoOutputInvocationStrategy extends RpcInvocationStrategy { - @SuppressWarnings("rawtypes") private final WeakReference inputClass; @SuppressWarnings({ "rawtypes", "unchecked" }) public NoOutputInvocationStrategy(final QName rpc, final Method targetMethod, final Class inputClass) { - super(rpc,targetMethod); + super(rpc, targetMethod); this.inputClass = new WeakReference(inputClass); } - @Override - public RpcResult uncheckedInvoke(final RpcService rpcService, final CompositeNode domInput) throws Exception { + public RpcResult uncheckedInvoke(final RpcService rpcService, final CompositeNode domInput) + throws Exception { DataContainer bindingInput = mappingService.dataObjectFromDataDom(inputClass.get(), domInput); Future> result = (Future>) targetMethod.invoke(rpcService, bindingInput); if (result == null) { @@ -884,19 +937,20 @@ public class BindingIndependentConnector implements // @Override public ListenableFuture> forwardToDomBroker(final DataObject input) { - if(biRpcRegistry == null) { + if (biRpcRegistry == null) { return Futures.> immediateFuture(Rpcs.getRpcResult(false)); } CompositeNode xml = mappingService.toDataDom(input); - CompositeNode wrappedXml = ImmutableCompositeNode.create(rpc,ImmutableList.>of(xml)); + CompositeNode wrappedXml = ImmutableCompositeNode.create(rpc, ImmutableList.> of(xml)); - return Futures.transform(biRpcRegistry.invokeRpc(rpc, wrappedXml), new Function, RpcResult>() { - @Override - public RpcResult apply(RpcResult input) { - return Rpcs.getRpcResult(input.isSuccessful(), null, input.getErrors()); - } - }); + return Futures.transform(biRpcRegistry.invokeRpc(rpc, wrappedXml), + new Function, RpcResult>() { + @Override + public RpcResult apply(final RpcResult input) { + return Rpcs. getRpcResult(input.isSuccessful(), null, input.getErrors()); + } + }); } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/MultipleAugmentationPuts.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/MultipleAugmentationPuts.java index b147e03d56..6b2568aba7 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/MultipleAugmentationPuts.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/MultipleAugmentationPuts.java @@ -61,9 +61,8 @@ public class MultipleAugmentationPuts extends AbstractDataServiceTest implements private static final InstanceIdentifier NODES_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) // .toInstance(); - private static final InstanceIdentifier NODE_INSTANCE_ID_BA = InstanceIdentifier - .builder(NODES_INSTANCE_ID_BA) // - .child(Node.class, NODE_KEY).toInstance(); + private static final InstanceIdentifier NODE_INSTANCE_ID_BA = + NODES_INSTANCE_ID_BA.child(Node.class, NODE_KEY); private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = // org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // @@ -74,7 +73,7 @@ public class MultipleAugmentationPuts extends AbstractDataServiceTest implements /** * Test for Bug 148 - * + * * @throws Exception */ @Test @@ -111,12 +110,12 @@ public class MultipleAugmentationPuts extends AbstractDataServiceTest implements // Node meterStatsNodeWithDuration = createTestNode(NodeMeterStatistics.class, nodeMeterStatistics(5, true)); // commitNodeAndVerifyTransaction(meterStatsNodeWithDuration); // -// +// // Node nodeWithUpdatedList = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA); // AugmentationVerifier.from(nodeWithUpdatedList) // // .assertHasAugmentation(FlowCapableNode.class) // // .assertHasAugmentation(NodeMeterStatistics.class); -// +// // List meterStats = nodeWithUpdatedList.getAugmentation(NodeMeterStatistics.class).getMeterStatistics().getMeterStats(); // assertNotNull(meterStats); // assertFalse(meterStats.isEmpty()); diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java index 9cdf70322c..ae65c8889a 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java @@ -267,9 +267,7 @@ public class BindingTestContext implements AutoCloseable, SchemaContextProvider public void startBindingToDomMappingService() { checkState(classPool != null, "ClassPool needs to be present"); - mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl(); - mappingServiceImpl.setPool(classPool); - mappingServiceImpl.init(); + mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl(classPool); } public void updateYangSchema(final String[] files) { diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ConcurrentImplicitCreateTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ConcurrentImplicitCreateTest.java index 61a73d63f4..c5dbdcecae 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ConcurrentImplicitCreateTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ConcurrentImplicitCreateTest.java @@ -30,10 +30,8 @@ public class ConcurrentImplicitCreateTest extends AbstractDataServiceTest { private static final NodeKey NODE_FOO_KEY = new NodeKey(new NodeId("foo")); private static final NodeKey NODE_BAR_KEY = new NodeKey(new NodeId("foo")); private static InstanceIdentifier NODES_PATH = InstanceIdentifier.builder(Nodes.class).build(); - private static InstanceIdentifier NODE_FOO_PATH = InstanceIdentifier.builder(NODES_PATH) - .child(Node.class, NODE_FOO_KEY).build(); - private static InstanceIdentifier NODE_BAR_PATH = InstanceIdentifier.builder(NODES_PATH) - .child(Node.class, NODE_FOO_KEY).build(); + private static InstanceIdentifier NODE_FOO_PATH = NODES_PATH.child(Node.class, NODE_FOO_KEY); + private static InstanceIdentifier NODE_BAR_PATH = NODES_PATH.child(Node.class, NODE_FOO_KEY); @Test public void testConcurrentCreate() throws InterruptedException, ExecutionException { diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java index 0925e9bff4..800c1b4cc4 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java @@ -75,13 +75,13 @@ public class ListProcessingAndOrderingTest extends AbstractDataServiceTest { private static final UnorderedListKey UNORDERED_FOO_KEY = new UnorderedListKey("foo"); private static final UnorderedListKey UNORDERED_BAR_KEY = new UnorderedListKey("bar"); - private static final InstanceIdentifier UNORDERED_FOO_PATH = InstanceIdentifier.builder(UNORDERED_CONTAINER_PATH).child(UnorderedList.class,UNORDERED_FOO_KEY).build(); - private static final InstanceIdentifier UNORDERED_BAR_PATH = InstanceIdentifier.builder(UNORDERED_CONTAINER_PATH).child(UnorderedList.class,UNORDERED_BAR_KEY).build(); + private static final InstanceIdentifier UNORDERED_FOO_PATH = UNORDERED_CONTAINER_PATH.child(UnorderedList.class,UNORDERED_FOO_KEY); + private static final InstanceIdentifier UNORDERED_BAR_PATH = UNORDERED_CONTAINER_PATH.child(UnorderedList.class,UNORDERED_BAR_KEY); private static final OrderedListKey ORDERED_FOO_KEY = new OrderedListKey("foo"); private static final OrderedListKey ORDERED_BAR_KEY = new OrderedListKey("bar"); - private static final InstanceIdentifier ORDERED_FOO_PATH = InstanceIdentifier.builder(ORDERED_CONTAINER_PATH).child(OrderedList.class,ORDERED_FOO_KEY).build(); - private static final InstanceIdentifier ORDERED_BAR_PATH = InstanceIdentifier.builder(ORDERED_CONTAINER_PATH).child(OrderedList.class,ORDERED_BAR_KEY).build(); + private static final InstanceIdentifier ORDERED_FOO_PATH = ORDERED_CONTAINER_PATH.child(OrderedList.class,ORDERED_FOO_KEY); + private static final InstanceIdentifier ORDERED_BAR_PATH = ORDERED_CONTAINER_PATH.child(OrderedList.class,ORDERED_BAR_KEY); @Test diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java index 450ca1cb3b..6b4cc57798 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java @@ -78,14 +78,12 @@ public class WildcardedDataChangeListenerTest extends AbstractDataServiceTest { private static final FlowKey FLOW_KEY = new FlowKey(new FlowId("test")); - private static final InstanceIdentifier NODE_0_FLOW_PATH = InstanceIdentifier.builder(NODE_0_TABLE_PATH) - .child(Flow.class, FLOW_KEY).build(); + private static final InstanceIdentifier NODE_0_FLOW_PATH = NODE_0_TABLE_PATH.child(Flow.class, FLOW_KEY); - private static final InstanceIdentifier NODE_1_FLOW_PATH = InstanceIdentifier.builder(NODE_1_TABLE_PATH) - .child(Flow.class, FLOW_KEY).build(); + private static final InstanceIdentifier NODE_1_FLOW_PATH = NODE_1_TABLE_PATH.child(Flow.class, FLOW_KEY); - private static final InstanceIdentifier NODE_0_TABLE_FEATURES_PATH = InstanceIdentifier - .builder(NODE_0_TABLE_PATH).child(TableFeatures.class, TABLE_FEATURES_KEY).build(); + private static final InstanceIdentifier NODE_0_TABLE_FEATURES_PATH = + NODE_0_TABLE_PATH.child(TableFeatures.class, TABLE_FEATURES_KEY); private static final TableFeatures TABLE_FEATURES = new TableFeaturesBuilder()// .setKey(TABLE_FEATURES_KEY) // diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java index e89371337e..ccbd52fc77 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java @@ -60,13 +60,11 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh .toInstance(); - private static final InstanceIdentifier NODE_INSTANCE_ID_BA = InstanceIdentifier// - .builder(NODES_INSTANCE_ID_BA) // - .child(Node.class, NODE_KEY).toInstance(); + private static final InstanceIdentifier NODE_INSTANCE_ID_BA = NODES_INSTANCE_ID_BA.child(Node.class, NODE_KEY); - private static final InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BA = InstanceIdentifier// - .builder(NODES_INSTANCE_ID_BA) // + private static final InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BA = // + NODES_INSTANCE_ID_BA.builder() // .child(Node.class, NODE_KEY) // .augmentation(FlowCapableNode.class) // .child(SupportedActions.class) @@ -163,7 +161,7 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh NodeConnectorId ncId = new NodeConnectorId("openflow:1:bar"); NodeConnectorKey nodeKey = new NodeConnectorKey(ncId ); - InstanceIdentifier ncInstanceId = InstanceIdentifier.builder(NODE_INSTANCE_ID_BA).child(NodeConnector.class, nodeKey).toInstance(); + InstanceIdentifier ncInstanceId = NODE_INSTANCE_ID_BA.child(NodeConnector.class, nodeKey); NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder(); ncBuilder.setId(ncId); ncBuilder.setKey(nodeKey); diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java new file mode 100644 index 0000000000..c1eba3ee25 --- /dev/null +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java @@ -0,0 +1,96 @@ +package org.opendaylight.controller.sal.binding.test.bugfix; + +import static org.junit.Assert.assertFalse; + +import java.util.concurrent.ExecutionException; + +import org.junit.Test; +import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; +import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; +import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsDataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatisticsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import com.google.common.util.concurrent.SettableFuture; + +public class DeleteNestedAugmentationListenParentTest extends AbstractDataServiceTest { + + private static final NodeKey NODE_KEY = new NodeKey(new NodeId("foo")); + + private static final TableKey TABLE_KEY = new TableKey((short) 0); + + private static final FlowKey FLOW_KEY = new FlowKey(new FlowId("100")); + + private static final InstanceIdentifier LISTENER_PATH = InstanceIdentifier.builder(Nodes.class) // + .child(Node.class) + .augmentation(FlowCapableNode.class).build(); + + + private static final InstanceIdentifier NODE_AUGMENT_PATH = InstanceIdentifier.builder(Nodes.class) + .child(Node.class,NODE_KEY) + .augmentation(FlowCapableNode.class) + .build(); + + private static final InstanceIdentifier FLOW_PATH = NODE_AUGMENT_PATH.builder() + .child(Table.class,TABLE_KEY) + .child(Flow.class,FLOW_KEY) + .build(); + + + @Test + public void deleteChildListenParent() throws InterruptedException, ExecutionException { + DataModificationTransaction initTx = baDataService.beginTransaction(); + + initTx.putOperationalData(FLOW_PATH, flow()); + initTx.commit().get(); + + final SettableFuture, DataObject>> event = SettableFuture.create(); + + ListenerRegistration listenerReg = baDataService.registerDataChangeListener(FLOW_PATH, new DataChangeListener() { + + @Override + public void onDataChanged(final DataChangeEvent, DataObject> change) { + event.set(change); + } + }); + + DataModificationTransaction deleteTx = baDataService.beginTransaction(); + deleteTx.removeOperationalData(FLOW_PATH.augmentation(FlowStatisticsData.class)); + deleteTx.commit().get(); + + DataChangeEvent, DataObject> receivedEvent = event.get(); + assertFalse(receivedEvent.getRemovedOperationalData().contains(NODE_AUGMENT_PATH)); + } + + private Flow flow() { + FlowBuilder builder = new FlowBuilder() + .setKey(FLOW_KEY) + .addAugmentation(FlowStatisticsData.class,new FlowStatisticsDataBuilder() + .setFlowStatistics(new FlowStatisticsBuilder() + .setBarrier(true) + .setMatch(new MatchBuilder() + .build()) + .build()) + .build()) + ;//.build(); + return builder.build(); + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java index 023bd795af..30c7af705f 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java @@ -7,7 +7,15 @@ */ package org.opendaylight.controller.sal.binding.test.bugfix; -import com.google.common.collect.ImmutableSet; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import org.junit.Test; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; @@ -44,14 +52,7 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import com.google.common.collect.ImmutableSet; public class FlagsSerializationTest extends AbstractDataServiceTest { @@ -65,7 +66,7 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID)); private static final FlowKey FLOW_KEY = new FlowKey(new FlowId(FLOW_ID)); private static final TableKey TABLE_KEY = new TableKey(TABLE_ID); - + private static final Map NODE_KEY_BI = Collections. singletonMap(NODE_ID_QNAME, NODE_ID); @@ -83,12 +84,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { // private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier FLOW_INSTANCE_ID_BI = // // org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // -// +// // .node(Flows.QNAME) // // .nodeWithKey(Flow.QNAME, FLOW_KEY_BI) // // .toInstance(); private static final InstanceIdentifier FLOW_INSTANCE_ID_BA = // - InstanceIdentifier.builder(NODE_INSTANCE_ID_BA) // + NODE_INSTANCE_ID_BA.builder() // .augmentation(FlowCapableNode.class) .child(Table.class,TABLE_KEY) .child(Flow.class, FLOW_KEY) // @@ -101,34 +102,34 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { FlowModFlags checkOverlapFlags = new FlowModFlags(true,false,false,false,false); ImmutableSet domCheckOverlapFlags = ImmutableSet.of("CHECK_OVERLAP"); testFlags(checkOverlapFlags,domCheckOverlapFlags); - - - + + + FlowModFlags allFalseFlags = new FlowModFlags(false,false,false,false,false); ImmutableSet domAllFalseFlags = ImmutableSet.of(); testFlags(allFalseFlags,domAllFalseFlags); - + FlowModFlags allTrueFlags = new FlowModFlags(true,true,true,true,true); ImmutableSet domAllTrueFlags = ImmutableSet.of("CHECK_OVERLAP","NO_BYT_COUNTS", "NO_PKT_COUNTS", "RESET_COUNTS", "SEND_FLOW_REM"); testFlags(allTrueFlags,domAllTrueFlags); - + FlowModFlags nullFlags = null; ImmutableSet domNullFlags = null; testFlags(null,null); - - + + } private void testFlags(FlowModFlags flagsToTest, ImmutableSet domFlags) throws Exception { Flow flow = createFlow(flagsToTest); assertNotNull(flow); - + CompositeNode domFlow = biDataService.readConfigurationData(mappingService.toDataDom(FLOW_INSTANCE_ID_BA)); - + assertNotNull(domFlow); org.opendaylight.yangtools.yang.data.api.Node readedFlags = domFlow.getFirstSimpleByName(FLOW_FLAGS_QNAME); - + if(domFlags != null) { assertNotNull(readedFlags); assertEquals(domFlags,readedFlags.getValue()); @@ -136,12 +137,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { assertNull(readedFlags); } assertEquals(flagsToTest, flow.getFlags()); - + DataModificationTransaction transaction = baDataService.beginTransaction(); transaction.removeConfigurationData(FLOW_INSTANCE_ID_BA); RpcResult result = transaction.commit().get(); assertEquals(TransactionStatus.COMMITED, result.getResult()); - + } private Flow createFlow(FlowModFlags flagsToTest) throws Exception { @@ -158,12 +159,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { flow.setKey(FLOW_KEY); flow.setMatch(match.build()); - + flow.setFlags(flagsToTest); - + InstructionsBuilder instructions = new InstructionsBuilder(); InstructionBuilder instruction = new InstructionBuilder(); - + instruction.setOrder(10); ApplyActionsBuilder applyActions = new ApplyActionsBuilder(); List actionList = new ArrayList<>(); diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/PutAugmentationTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/PutAugmentationTest.java index 027a8eeb9f..7f16320814 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/PutAugmentationTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/PutAugmentationTest.java @@ -58,18 +58,18 @@ public class PutAugmentationTest extends AbstractDataServiceTest implements Data private static final InstanceIdentifier NODES_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) // .toInstance(); - private static final InstanceIdentifier NODE_INSTANCE_ID_BA = InstanceIdentifier// - .builder(NODES_INSTANCE_ID_BA) // + private static final InstanceIdentifier NODE_INSTANCE_ID_BA = // + NODES_INSTANCE_ID_BA.builder() // .child(Node.class, NODE_KEY).toInstance(); - private static final InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BA = InstanceIdentifier// - .builder(NODES_INSTANCE_ID_BA) // + private static final InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BA = // + NODES_INSTANCE_ID_BA.builder() // .child(Node.class, NODE_KEY) // .augmentation(FlowCapableNode.class) // .child(SupportedActions.class).toInstance(); - private static final InstanceIdentifier ALL_FLOW_CAPABLE_NODES = InstanceIdentifier // - .builder(NODES_INSTANCE_ID_BA) // + private static final InstanceIdentifier ALL_FLOW_CAPABLE_NODES = // + NODES_INSTANCE_ID_BA.builder() // .child(Node.class) // .augmentation(FlowCapableNode.class) // .build(); @@ -88,8 +88,8 @@ public class PutAugmentationTest extends AbstractDataServiceTest implements Data .nodeWithKey(Node.QNAME, NODE_KEY_BI) // .node(SUPPORTED_ACTIONS_QNAME) // .toInstance(); - private static final InstanceIdentifier FLOW_AUGMENTATION_PATH = InstanceIdentifier // - .builder(NODE_INSTANCE_ID_BA) // + private static final InstanceIdentifier FLOW_AUGMENTATION_PATH = + NODE_INSTANCE_ID_BA.builder() // .augmentation(FlowCapableNode.class) // .build(); @@ -126,8 +126,8 @@ public class PutAugmentationTest extends AbstractDataServiceTest implements Data fnub.setDescription("Description Foo"); fnub.setSoftware("JUnit emulated"); FlowCapableNode fnu = fnub.build(); - InstanceIdentifier augmentIdentifier = InstanceIdentifier.builder(NODE_INSTANCE_ID_BA) - .augmentation(FlowCapableNode.class).toInstance(); + InstanceIdentifier augmentIdentifier = NODE_INSTANCE_ID_BA + .augmentation(FlowCapableNode.class); DataModificationTransaction augmentedTransaction = baDataService.beginTransaction(); augmentedTransaction.putOperationalData(augmentIdentifier, fnu); @@ -183,8 +183,8 @@ public class PutAugmentationTest extends AbstractDataServiceTest implements Data lastReceivedChangeEvent = SettableFuture.create(); assertEquals(TransactionStatus.COMMITED, result.getResult()); - FlowCapableNode readedAugmentation = (FlowCapableNode) baDataService.readOperationalData(InstanceIdentifier - .builder(NODE_INSTANCE_ID_BA).augmentation(FlowCapableNode.class).toInstance()); + FlowCapableNode readedAugmentation = (FlowCapableNode) baDataService.readOperationalData( + NODE_INSTANCE_ID_BA.augmentation(FlowCapableNode.class)); assertNotNull(readedAugmentation); assertEquals(fnu.getHardware(), readedAugmentation.getHardware()); @@ -198,10 +198,10 @@ public class PutAugmentationTest extends AbstractDataServiceTest implements Data private void testPutNodeConnectorWithAugmentation() throws Exception { NodeConnectorKey ncKey = new NodeConnectorKey(new NodeConnectorId("test:0:0")); - InstanceIdentifier ncPath = InstanceIdentifier.builder(NODE_INSTANCE_ID_BA) - .child(NodeConnector.class, ncKey).toInstance(); - InstanceIdentifier ncAugmentPath = InstanceIdentifier.builder(ncPath) - .augmentation(FlowCapableNodeConnector.class).toInstance(); + InstanceIdentifier ncPath = NODE_INSTANCE_ID_BA + .child(NodeConnector.class, ncKey); + InstanceIdentifier ncAugmentPath = ncPath + .augmentation(FlowCapableNodeConnector.class); NodeConnectorBuilder nc = new NodeConnectorBuilder(); nc.setKey(ncKey); diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java index 35b4e92db4..f7b81a44e9 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java @@ -54,13 +54,11 @@ public class WriteParentReadChildTest extends AbstractDataServiceTest { .child(Node.class, NODE_KEY).toInstance(); private static final InstanceIdentifier TABLE_INSTANCE_ID_BA = // - InstanceIdentifier.builder(NODE_INSTANCE_ID_BA) // + NODE_INSTANCE_ID_BA.builder() // .augmentation(FlowCapableNode.class).child(Table.class, TABLE_KEY).build(); private static final InstanceIdentifier FLOW_INSTANCE_ID_BA = // - InstanceIdentifier.builder(TABLE_INSTANCE_ID_BA) // - .child(Flow.class, FLOW_KEY) // - .toInstance(); + TABLE_INSTANCE_ID_BA.child(Flow.class, FLOW_KEY); /** * * The scenario tests writing parent node, which also contains child items @@ -103,11 +101,11 @@ public class WriteParentReadChildTest extends AbstractDataServiceTest { DataObject readedTable = baDataService.readConfigurationData(TABLE_INSTANCE_ID_BA); assertNotNull("Readed table should not be nul.", readedTable); assertTrue(readedTable instanceof Table); - + DataObject readedFlow = baDataService.readConfigurationData(FLOW_INSTANCE_ID_BA); assertNotNull("Readed flow should not be null.",readedFlow); assertTrue(readedFlow instanceof Flow); assertEquals(flow, readedFlow); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java index 1661ff230d..422b9ccee5 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java @@ -110,16 +110,14 @@ public class ChangeOriginatedInDomBrokerTest extends AbstractDataServiceTest { private static final TableKey TABLE_KEY_BA = new TableKey((short) 0); private static final InstanceIdentifier FLOWS_PATH_BA = // - InstanceIdentifier.builder(NODE_INSTANCE_ID_BA) // + NODE_INSTANCE_ID_BA.builder() // .augmentation(FlowCapableNode.class) // .child(Table.class, TABLE_KEY_BA) // .child(Flow.class) // .toInstance(); private static final InstanceIdentifier FLOW_INSTANCE_ID_BA = // - InstanceIdentifier.builder(FLOWS_PATH_BA.firstIdentifierOf(Table.class)) // - .child(Flow.class, FLOW_KEY) // - .toInstance(); + FLOWS_PATH_BA.firstIdentifierOf(Table.class).child(Flow.class, FLOW_KEY); @Test public void simpleModifyOperation() throws Exception { diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java index 63094ef3cb..94570510ab 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java @@ -61,8 +61,8 @@ public class CrossBrokerMountPointTest { .child(Node.class, NODE_KEY).toInstance(); private static GroupKey GROUP_KEY = new GroupKey(new GroupId(0L)); - private static final InstanceIdentifier GROUP_STATISTICS_ID_BA = InstanceIdentifier - .builder(NODE_INSTANCE_ID_BA).augmentation(FlowCapableNode.class) // + private static final InstanceIdentifier GROUP_STATISTICS_ID_BA = NODE_INSTANCE_ID_BA + .builder().augmentation(FlowCapableNode.class) // .child(Group.class, GROUP_KEY) // .augmentation(NodeGroupStatistics.class) // .child(GroupStatistics.class) // diff --git a/opendaylight/md-sal/sal-binding-it/pom.xml b/opendaylight/md-sal/sal-binding-it/pom.xml index 0d20a07ad5..70847aabea 100644 --- a/opendaylight/md-sal/sal-binding-it/pom.xml +++ b/opendaylight/md-sal/sal-binding-it/pom.xml @@ -77,14 +77,6 @@ org.opendaylight.controller sal-binding-broker-impl - - org.opendaylight.controller.thirdparty - nagasena - - - org.opendaylight.controller.thirdparty - nagasena-rta - org.opendaylight.yangtools.thirdparty antlr4-runtime-osgi-nohead @@ -100,6 +92,14 @@ xtend-lib-osgi 2.4.3 + + org.openexi + nagasena + + + org.openexi + nagasena-rta + org.ops4j.pax.exam pax-exam diff --git a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java index 166216b226..734733a19c 100644 --- a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java +++ b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java @@ -68,8 +68,8 @@ public class TestHelper { mavenBundle(CONTROLLER, "netconf-client").versionAsInProject(), // mavenBundle(CONTROLLER, "netconf-util").versionAsInProject(), // - mavenBundle(CONTROLLER + ".thirdparty", "nagasena").versionAsInProject(), // - mavenBundle(CONTROLLER + ".thirdparty", "nagasena-rta").versionAsInProject(), // + mavenBundle("org.openexi", "nagasena").versionAsInProject(), // + mavenBundle("org.openexi", "nagasena-rta").versionAsInProject(), // mavenBundle(CONTROLLER + ".thirdparty", "ganymed").versionAsInProject(), // mavenBundle(CONTROLLER, "netconf-mapping-api").versionAsInProject(), // diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTest.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTest.java index 3d78f94861..b2f89cf779 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTest.java +++ b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTest.java @@ -70,8 +70,8 @@ public abstract class AbstractTest { mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), // mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), // mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), - mavenBundle("org.opendaylight.controller.thirdparty", "nagasena").versionAsInProject(), - mavenBundle("org.opendaylight.controller.thirdparty", "nagasena-rta").versionAsInProject(), + mavenBundle("org.openexi", "nagasena").versionAsInProject(), + mavenBundle("org.openexi", "nagasena-rta").versionAsInProject(), // systemProperty("osgi.bundles.defaultStartLevel").value("4"), systemPackages("sun.nio.ch"), diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java index 5200c90561..6ce7b5a5c7 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java @@ -15,4 +15,6 @@ public interface RoutedRegistration, S> extends Registratio void registerPath(C context, P path); void unregisterPath(C context, P path); + @Override + void close(); } diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.java index 82ce44c5e9..d8bde3d41a 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.java @@ -14,14 +14,12 @@ import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import org.eclipse.xtext.xbase.lib.Exceptions; import org.opendaylight.controller.md.sal.common.api.RegistrationListener; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; @@ -46,6 +44,7 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; +import com.google.common.base.Supplier; import com.google.common.collect.FluentIterable; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; @@ -120,9 +119,9 @@ public abstract class AbstractDataBroker

, D extends Object, DC } protected ImmutableList> affectedCommitHandlers(final Set

paths) { - final Callable>> _function = new Callable>>() { + final Supplier>> _function = new Supplier>>() { @Override - public ImmutableList> call() throws Exception { + public ImmutableList> get() { Map>> _asMap = commitHandlers.asMap(); Set>>> _entrySet = _asMap.entrySet(); FluentIterable>>> _from = FluentIterable @@ -163,9 +162,9 @@ public abstract class AbstractDataBroker

, D extends Object, DC } protected ImmutableList> probablyAffectedCommitHandlers(final HashSet

paths) { - final Callable>> _function = new Callable>>() { + final Supplier>> _function = new Supplier>>() { @Override - public ImmutableList> call() throws Exception { + public ImmutableList> get() { Map>> _asMap = commitHandlers.asMap(); Set>>> _entrySet = _asMap.entrySet(); FluentIterable>>> _from = FluentIterable @@ -221,12 +220,10 @@ public abstract class AbstractDataBroker

, D extends Object, DC return _dataReadRouter.readOperationalData(path); } - private static T withLock(final Lock lock, final Callable method) { + private static T withLock(final Lock lock, final Supplier method) { lock.lock(); try { - return method.call(); - } catch (Exception e) { - throw Exceptions.sneakyThrow(e); + return method.get(); } finally { lock.unlock(); } diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java index a36d984fa7..663493adcc 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java @@ -45,6 +45,7 @@ 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 com.google.common.base.Optional; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -223,20 +224,32 @@ public abstract class DataNormalizationOperation impleme if (potential != null) { return potential; } - potential = fromSchema(schema, child); + potential = fromLocalSchema(child); return register(potential); } + private DataNormalizationOperation fromLocalSchema(final PathArgument child) throws DataNormalizationException { + if (child instanceof AugmentationIdentifier) { + return fromSchemaAndQNameChecked(schema, ((AugmentationIdentifier) child).getPossibleChildNames() + .iterator().next()); + } + return fromSchemaAndQNameChecked(schema, child.getNodeType()); + } + @Override public DataNormalizationOperation getChild(final QName child) throws DataNormalizationException { DataNormalizationOperation potential = byQName.get(child); if (potential != null) { return potential; } - potential = fromSchemaAndPathArgument(schema, child); + potential = fromLocalSchemaAndQName(schema, child); return register(potential); } + protected DataNormalizationOperation fromLocalSchemaAndQName(final DataNodeContainer schema2, final QName child) throws DataNormalizationException { + return fromSchemaAndQNameChecked(schema2, child); + } + private DataNormalizationOperation register(final DataNormalizationOperation potential) { if (potential != null) { byArg.put(potential.getIdentifier(), potential); @@ -398,38 +411,34 @@ public abstract class DataNormalizationOperation impleme } } - private static final class AugmentationNormalization extends MixinNormalizationOp { - - private final Map> byQName; - private final Map> byArg; + private static final class AugmentationNormalization extends DataContainerNormalizationOperation { public AugmentationNormalization(final AugmentationSchema augmentation, final DataNodeContainer schema) { - super(augmentationIdentifierFrom(augmentation)); - - ImmutableMap.Builder> byQNameBuilder = ImmutableMap.builder(); - ImmutableMap.Builder> byArgBuilder = ImmutableMap.builder(); - - for (DataSchemaNode augNode : augmentation.getChildNodes()) { - DataSchemaNode resolvedNode = schema.getDataChildByName(augNode.getQName()); - DataNormalizationOperation resolvedOp = fromDataSchemaNode(resolvedNode); - byArgBuilder.put(resolvedOp.getIdentifier(), resolvedOp); - for (QName resQName : resolvedOp.getQNameIdentifiers()) { - byQNameBuilder.put(resQName, resolvedOp); - } - } - byQName = byQNameBuilder.build(); - byArg = byArgBuilder.build(); - + //super(); + super(augmentationIdentifierFrom(augmentation), augmentationProxy(augmentation,schema)); } @Override - public DataNormalizationOperation getChild(final PathArgument child) { - return byArg.get(child); + public boolean isMixin() { + return true; } + + @Override - public DataNormalizationOperation getChild(final QName child) { - return byQName.get(child); + protected DataNormalizationOperation fromLocalSchemaAndQName(final DataNodeContainer schema, final QName child) + throws DataNormalizationException { + Optional potential = findChildSchemaNode(schema, child); + if (!potential.isPresent()) { + return null; + } + + DataSchemaNode result = potential.get(); + // We try to look up if this node was added by augmentation + if ((schema instanceof DataSchemaNode) && result.isAugmenting()) { + return fromAugmentation(schema, (AugmentationTarget) schema, result); + } + return fromDataSchemaNode(result); } @Override @@ -591,23 +600,30 @@ public abstract class DataNormalizationOperation impleme } } - private static DataNormalizationOperation fromSchemaAndPathArgument(final DataNodeContainer schema, - final QName child) throws DataNormalizationException { - DataSchemaNode potential = schema.getDataChildByName(child); + private static final Optional findChildSchemaNode(final DataNodeContainer parent,final QName child) { + DataSchemaNode potential = parent.getDataChildByName(child); if (potential == null) { Iterable choices = FluentIterable.from( - schema.getChildNodes()).filter(org.opendaylight.yangtools.yang.model.api.ChoiceNode.class); + parent.getChildNodes()).filter(org.opendaylight.yangtools.yang.model.api.ChoiceNode.class); potential = findChoice(choices, child); } + return Optional.fromNullable(potential); + } - if (potential == null) { + private static DataNormalizationOperation fromSchemaAndQNameChecked(final DataNodeContainer schema, + final QName child) throws DataNormalizationException { + + Optional potential = findChildSchemaNode(schema, child); + if (!potential.isPresent()) { throw new DataNormalizationException(String.format("Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema,schema.getChildNodes())); } - if ((schema instanceof DataSchemaNode) && !((DataSchemaNode) schema).isAugmenting() && potential.isAugmenting()) { - return fromAugmentation(schema, (AugmentationTarget) schema, potential); + DataSchemaNode result = potential.get(); + // We try to look up if this node was added by augmentation + if ((schema instanceof DataSchemaNode) && result.isAugmenting()) { + return fromAugmentation(schema, (AugmentationTarget) schema, result); } - return fromDataSchemaNode(potential); + return fromDataSchemaNode(result); } private static org.opendaylight.yangtools.yang.model.api.ChoiceNode findChoice( @@ -615,7 +631,7 @@ public abstract class DataNormalizationOperation impleme org.opendaylight.yangtools.yang.model.api.ChoiceNode foundChoice = null; choiceLoop: for (org.opendaylight.yangtools.yang.model.api.ChoiceNode choice : choices) { for (ChoiceCaseNode caze : choice.getCases()) { - if (caze.getDataChildByName(child) != null) { + if (findChildSchemaNode(caze, child).isPresent()) { foundChoice = choice; break choiceLoop; } @@ -632,30 +648,44 @@ public abstract class DataNormalizationOperation impleme return new AugmentationIdentifier(null, potentialChildren.build()); } - private static AugmentationNormalization fromAugmentation(final DataNodeContainer schema, - final AugmentationTarget augments, final DataSchemaNode potential) { + private static DataNodeContainer augmentationProxy(final AugmentationSchema augmentation, final DataNodeContainer schema) { + Set children = new HashSet<>(); + for (DataSchemaNode augNode : augmentation.getChildNodes()) { + children.add(schema.getDataChildByName(augNode.getQName())); + } + return new DataSchemaContainerProxy(children); + } + + /** + * Returns a DataNormalizationOperation for provided child node + * + * If supplied child is added by Augmentation this operation returns + * a DataNormalizationOperation for augmentation, + * otherwise returns a DataNormalizationOperation for child as + * call for {@link #fromDataSchemaNode(DataSchemaNode)}. + * + * + * @param parent + * @param parentAug + * @param child + * @return + */ + private static DataNormalizationOperation fromAugmentation(final DataNodeContainer parent, + final AugmentationTarget parentAug, final DataSchemaNode child) { AugmentationSchema augmentation = null; - for (AugmentationSchema aug : augments.getAvailableAugmentations()) { - DataSchemaNode child = aug.getDataChildByName(potential.getQName()); - if (child != null) { + for (AugmentationSchema aug : parentAug.getAvailableAugmentations()) { + DataSchemaNode potential = aug.getDataChildByName(child.getQName()); + if (potential != null) { augmentation = aug; break; } } if (augmentation != null) { - return new AugmentationNormalization(augmentation, schema); + return new AugmentationNormalization(augmentation, parent); } else { - return null; - } - } - - private static DataNormalizationOperation fromSchema(final DataNodeContainer schema, final PathArgument child) throws DataNormalizationException { - if (child instanceof AugmentationIdentifier) { - return fromSchemaAndPathArgument(schema, ((AugmentationIdentifier) child).getPossibleChildNames() - .iterator().next()); + return fromDataSchemaNode(child); } - return fromSchemaAndPathArgument(schema, child.getNodeType()); } public static DataNormalizationOperation fromDataSchemaNode(final DataSchemaNode potential) { diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataSchemaContainerProxy.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataSchemaContainerProxy.java new file mode 100644 index 0000000000..d243c888bd --- /dev/null +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataSchemaContainerProxy.java @@ -0,0 +1,65 @@ +/* + * 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.common.impl.util.compat; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.opendaylight.yangtools.yang.common.QName; +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.TypeDefinition; +import org.opendaylight.yangtools.yang.model.api.UsesNode; + +class DataSchemaContainerProxy implements DataNodeContainer { + + private final Set realChildSchemas; + private final Map mappedChildSchemas; + + public DataSchemaContainerProxy(final Set realChildSchema) { + realChildSchemas = realChildSchema; + mappedChildSchemas = new HashMap(); + for(DataSchemaNode schema : realChildSchemas) { + mappedChildSchemas.put(schema.getQName(),schema); + } + } + + @Override + public DataSchemaNode getDataChildByName(final QName name) { + return mappedChildSchemas.get(name); + } + + @Override + public Set getChildNodes() { + return realChildSchemas; + } + + @Override + public DataSchemaNode getDataChildByName(final String arg0) { + throw new UnsupportedOperationException(); + } + + @Override + public Set getGroupings() { + return Collections.emptySet(); + } + + @Override + public Set> getTypeDefinitions() { + return Collections.emptySet(); + } + + @Override + public Set getUses() { + return Collections.emptySet(); + } + +} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java index 0006953542..3127df521f 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java @@ -17,7 +17,7 @@ import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; * component of the controller or application supplies a concrete implementation * of this interface. * - * A user-implemented component (application) which faciliates the SAL and SAL + * A user-implemented component (application) which facilitates the SAL and SAL * services to access infrastructure services or providers' functionality. * * diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java index e2df70baea..fef8618b2c 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java @@ -18,7 +18,7 @@ import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; * of this interface. * *

- * A user-implemented component (application) which faciliates the SAL and SAL + * A user-implemented component (application) which facilitates the SAL and SAL * services to access infrastructure services and to provide functionality to * {@link Consumer}s and other providers. * diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java index a7952ac824..375376f383 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java @@ -1,3 +1,10 @@ +/* + * 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.dom.store.impl; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java index 3dfca40b40..af479743aa 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java @@ -1,3 +1,10 @@ +/* + * 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.dom.store.impl; import java.util.Collections; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataAndMetadataSnapshot.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataAndMetadataSnapshot.java index 9961fcce8d..b540eeaf3a 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataAndMetadataSnapshot.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataAndMetadataSnapshot.java @@ -16,7 +16,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import com.google.common.base.Optional; -import com.google.common.primitives.UnsignedLong; class DataAndMetadataSnapshot { @@ -39,22 +38,14 @@ class DataAndMetadataSnapshot { public static DataAndMetadataSnapshot createEmpty(final NodeIdentifier rootNode) { NormalizedNode data = Builders.containerBuilder().withNodeIdentifier(rootNode).build(); - StoreMetadataNode metadata = StoreMetadataNode.builder() - .setNodeVersion(UnsignedLong.ZERO) - .setSubtreeVersion(UnsignedLong.ZERO) - .setData(data) - .build(); + StoreMetadataNode metadata = StoreMetadataNode.createEmpty(data); return new DataAndMetadataSnapshot(metadata,Optional.absent()); } public static DataAndMetadataSnapshot createEmpty(final SchemaContext ctx) { NodeIdentifier rootNodeIdentifier = new NodeIdentifier(ctx.getQName()); NormalizedNode data = Builders.containerBuilder().withNodeIdentifier(rootNodeIdentifier).build(); - StoreMetadataNode metadata = StoreMetadataNode.builder() - .setData(data) - .setNodeVersion(UnsignedLong.ZERO) - .setSubtreeVersion(UnsignedLong.ZERO) - .build(); + StoreMetadataNode metadata = StoreMetadataNode.createEmpty(data); return new DataAndMetadataSnapshot(metadata, Optional.of(ctx)); } @@ -75,14 +66,9 @@ class DataAndMetadataSnapshot { } public static class Builder { - private NormalizedNode dataTree; private StoreMetadataNode metadataTree; private SchemaContext schemaContext; - public NormalizedNode getDataTree() { - return dataTree; - } - public Builder setMetadataTree(final StoreMetadataNode metadataTree) { this.metadataTree = metadataTree; return this; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java index d3a892a2cd..d8f024017f 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java @@ -1,3 +1,10 @@ +/* + * 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.dom.store.impl; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -6,17 +13,11 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public interface DataChangeListenerRegistration>> -extends ListenerRegistration { - - +public interface DataChangeListenerRegistration>> extends ListenerRegistration { @Override - public L getInstance(); + L getInstance(); InstanceIdentifier getPath(); DataChangeScope getScope(); - - - } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataPreconditionFailedException.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataPreconditionFailedException.java new file mode 100644 index 0000000000..6baf7647bd --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataPreconditionFailedException.java @@ -0,0 +1,50 @@ +/* + * 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.dom.store.impl; + +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; + +public class DataPreconditionFailedException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 596430355175413427L; + private final InstanceIdentifier path; + + public DataPreconditionFailedException(final InstanceIdentifier path) { + this.path = path; + } + + public DataPreconditionFailedException(final InstanceIdentifier path,final String message) { + super(message); + this.path = path; + } + + + public DataPreconditionFailedException(final InstanceIdentifier path,final Throwable cause) { + super(cause); + this.path = path; + } + + public DataPreconditionFailedException(final InstanceIdentifier path,final String message, final Throwable cause) { + super(message, cause); + this.path = path; + } + + public DataPreconditionFailedException(final InstanceIdentifier path,final String message, final Throwable cause, final boolean enableSuppression, + final boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + this.path = path; + } + + public InstanceIdentifier getPath() { + return path; + } + +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java index 9bbba1e24d..e848a51a66 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java @@ -54,7 +54,6 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class); private static final InstanceIdentifier PUBLIC_ROOT_PATH = InstanceIdentifier.builder().build(); - private final ListeningExecutorService executor; private final String name; private final AtomicLong txCounter = new AtomicLong(0); @@ -90,7 +89,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch @Override public DOMStoreWriteTransaction newWriteOnlyTransaction() { - return new SnaphostBackedWriteTransaction(nextIdentifier(), snapshot.get(), this, operationTree); + return new SnapshotBackedWriteTransaction(nextIdentifier(), snapshot.get(), this, operationTree); } @Override @@ -104,15 +103,15 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch final InstanceIdentifier path, final L listener, final DataChangeScope scope) { /* - * Make sure commit is not occurring right now. Listener has to be registered and its - * state capture enqueued at a consistent point. + * Make sure commit is not occurring right now. Listener has to be + * registered and its state capture enqueued at a consistent point. * - * FIXME: improve this to read-write lock, such that multiple listener registrations - * can occur simultaneously + * FIXME: improve this to read-write lock, such that multiple listener + * registrations can occur simultaneously */ final DataChangeListenerRegistration reg; synchronized (this) { - LOG.debug("{}: Registering data change listener {} for {}",name,listener,path); + LOG.debug("{}: Registering data change listener {} for {}", name, listener, path); reg = listenerTree.registerDataChangeListener(path, listener, scope); @@ -138,9 +137,8 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch }; } - private synchronized DOMStoreThreePhaseCommitCohort submit( - final SnaphostBackedWriteTransaction writeTx) { - LOG.debug("Tx: {} is submitted. Modifications: {}",writeTx.getIdentifier(),writeTx.getMutatedView()); + private synchronized DOMStoreThreePhaseCommitCohort submit(final SnapshotBackedWriteTransaction writeTx) { + LOG.debug("Tx: {} is submitted. Modifications: {}", writeTx.getIdentifier(), writeTx.getMutatedView()); return new ThreePhaseCommitImpl(writeTx); } @@ -148,12 +146,13 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch return name + "-" + txCounter.getAndIncrement(); } - private void commit(final DataAndMetadataSnapshot currentSnapshot, - final StoreMetadataNode newDataTree, final ResolveDataChangeEventsTask listenerResolver) { - LOG.debug("Updating Store snaphot version: {} with version:{}",currentSnapshot.getMetadataTree().getSubtreeVersion(),newDataTree.getSubtreeVersion()); + private void commit(final DataAndMetadataSnapshot currentSnapshot, final StoreMetadataNode newDataTree, + final ResolveDataChangeEventsTask listenerResolver) { + LOG.debug("Updating Store snaphot version: {} with version:{}", currentSnapshot.getMetadataTree() + .getSubtreeVersion(), newDataTree.getSubtreeVersion()); - if(LOG.isTraceEnabled()) { - LOG.trace("Data Tree is {}",StoreUtils.toStringTree(newDataTree)); + if (LOG.isTraceEnabled()) { + LOG.trace("Data Tree is {}", StoreUtils.toStringTree(newDataTree.getData())); } final DataAndMetadataSnapshot newSnapshot = DataAndMetadataSnapshot.builder() // @@ -162,14 +161,15 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch .build(); /* - * The commit has to occur atomically with regard to listener registrations. + * The commit has to occur atomically with regard to listener + * registrations. */ synchronized (this) { final boolean success = snapshot.compareAndSet(currentSnapshot, newSnapshot); checkState(success, "Store snapshot and transaction snapshot differ. This should never happen."); for (ChangeListenerNotifyTask task : listenerResolver.call()) { - LOG.trace("Scheduling invocation of listeners: {}",task); + LOG.trace("Scheduling invocation of listeners: {}", task); executor.submit(task); } } @@ -195,7 +195,8 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch /** * Add class-specific toString attributes. * - * @param toStringHelper ToStringHelper instance + * @param toStringHelper + * ToStringHelper instance * @return ToStringHelper instance which was passed in */ protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { @@ -203,13 +204,15 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch } } - private static class SnapshotBackedReadTransaction extends AbstractDOMStoreTransaction implements DOMStoreReadTransaction { + private static class SnapshotBackedReadTransaction extends AbstractDOMStoreTransaction implements + DOMStoreReadTransaction { private DataAndMetadataSnapshot stableSnapshot; public SnapshotBackedReadTransaction(final Object identifier, final DataAndMetadataSnapshot snapshot) { super(identifier); this.stableSnapshot = Preconditions.checkNotNull(snapshot); - LOG.debug("ReadOnly Tx: {} allocated with snapshot {}", identifier, snapshot.getMetadataTree().getSubtreeVersion()); + LOG.debug("ReadOnly Tx: {} allocated with snapshot {}", identifier, snapshot.getMetadataTree() + .getSubtreeVersion()); } @Override @@ -226,17 +229,19 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch } } - private static class SnaphostBackedWriteTransaction extends AbstractDOMStoreTransaction implements DOMStoreWriteTransaction { + private static class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction implements + DOMStoreWriteTransaction { private MutableDataTree mutableTree; private InMemoryDOMDataStore store; private boolean ready = false; - public SnaphostBackedWriteTransaction(final Object identifier, final DataAndMetadataSnapshot snapshot, + public SnapshotBackedWriteTransaction(final Object identifier, final DataAndMetadataSnapshot snapshot, final InMemoryDOMDataStore store, final ModificationApplyOperation applyOper) { super(identifier); mutableTree = MutableDataTree.from(snapshot, applyOper); this.store = store; - LOG.debug("Write Tx: {} allocated with snapshot {}",identifier,snapshot.getMetadataTree().getSubtreeVersion()); + LOG.debug("Write Tx: {} allocated with snapshot {}", identifier, snapshot.getMetadataTree() + .getSubtreeVersion()); } @Override @@ -250,11 +255,11 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch public void write(final InstanceIdentifier path, final NormalizedNode data) { checkNotReady(); try { - LOG.trace("Tx: {} Write: {}:{}",getIdentifier(),path,data); + LOG.trace("Tx: {} Write: {}:{}", getIdentifier(), path, data); mutableTree.write(path, data); - // FIXME: Add checked exception + // FIXME: Add checked exception } catch (Exception e) { - LOG.error("Tx: {}, failed to write {}:{} in {}",getIdentifier(),path,data,mutableTree,e); + LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, mutableTree, e); } } @@ -262,11 +267,11 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch public void merge(final InstanceIdentifier path, final NormalizedNode data) { checkNotReady(); try { - LOG.trace("Tx: {} Merge: {}:{}",getIdentifier(),path,data); + LOG.trace("Tx: {} Merge: {}:{}", getIdentifier(), path, data); mutableTree.merge(path, data); - // FIXME: Add checked exception + // FIXME: Add checked exception } catch (Exception e) { - LOG.error("Tx: {}, failed to write {}:{} in {}",getIdentifier(),path,data,mutableTree,e); + LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, mutableTree, e); } } @@ -274,11 +279,11 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch public void delete(final InstanceIdentifier path) { checkNotReady(); try { - LOG.trace("Tx: {} Delete: {}",getIdentifier(),path); + LOG.trace("Tx: {} Delete: {}", getIdentifier(), path); mutableTree.delete(path); - // FIXME: Add checked exception + // FIXME: Add checked exception } catch (Exception e) { - LOG.error("Tx: {}, failed to delete {} in {}",getIdentifier(),path,mutableTree,e); + LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, mutableTree, e); } } @@ -310,7 +315,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch } } - private static class SnapshotBackedReadWriteTransaction extends SnaphostBackedWriteTransaction implements + private static class SnapshotBackedReadWriteTransaction extends SnapshotBackedWriteTransaction implements DOMStoreReadWriteTransaction { protected SnapshotBackedReadWriteTransaction(final Object identifier, final DataAndMetadataSnapshot snapshot, @@ -320,11 +325,11 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch @Override public ListenableFuture>> read(final InstanceIdentifier path) { - LOG.trace("Tx: {} Read: {}",getIdentifier(),path); + LOG.trace("Tx: {} Read: {}", getIdentifier(), path); try { return Futures.immediateFuture(getMutatedView().read(path)); } catch (Exception e) { - LOG.error("Tx: {} Failed Read of {}",getIdentifier(),path,e); + LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e); throw e; } } @@ -332,14 +337,14 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch private class ThreePhaseCommitImpl implements DOMStoreThreePhaseCommitCohort { - private final SnaphostBackedWriteTransaction transaction; + private final SnapshotBackedWriteTransaction transaction; private final NodeModification modification; private DataAndMetadataSnapshot storeSnapshot; private Optional proposedSubtree; private ResolveDataChangeEventsTask listenerResolver; - public ThreePhaseCommitImpl(final SnaphostBackedWriteTransaction writeTransaction) { + public ThreePhaseCommitImpl(final SnapshotBackedWriteTransaction writeTransaction) { this.transaction = writeTransaction; this.modification = transaction.getMutatedView().getRootModification(); } @@ -353,9 +358,16 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch @Override public Boolean call() throws Exception { - boolean applicable = snapshotOperation.isApplicable(modification, + Boolean applicable = false; + try { + snapshotOperation.checkApplicable(PUBLIC_ROOT_PATH, modification, Optional.of(snapshotCapture.getMetadataTree())); - LOG.debug("Store Transcation: {} : canCommit : {}", transaction.getIdentifier(), applicable); + applicable = true; + } catch (DataPreconditionFailedException e) { + LOG.warn("Store Tx: {} Data Precondition failed for {}.",transaction.getIdentifier(),e.getPath(),e); + applicable = false; + } + LOG.debug("Store Transaction: {} : canCommit : {}", transaction.getIdentifier(), applicable); return applicable; } }); @@ -364,13 +376,11 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch @Override public ListenableFuture preCommit() { storeSnapshot = snapshot.get(); - if(modification.getModificationType() == ModificationType.UNMODIFIED) { + if (modification.getModificationType() == ModificationType.UNMODIFIED) { return Futures.immediateFuture(null); } return executor.submit(new Callable() { - - @Override public Void call() throws Exception { StoreMetadataNode metadataTree = storeSnapshot.getMetadataTree(); @@ -399,14 +409,14 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch @Override public ListenableFuture commit() { - if(modification.getModificationType() == ModificationType.UNMODIFIED) { + if (modification.getModificationType() == ModificationType.UNMODIFIED) { return Futures.immediateFuture(null); } - checkState(proposedSubtree != null,"Proposed subtree must be computed"); - checkState(storeSnapshot != null,"Proposed subtree must be computed"); + checkState(proposedSubtree != null, "Proposed subtree must be computed"); + checkState(storeSnapshot != null, "Proposed subtree must be computed"); // return ImmediateFuture<>; - InMemoryDOMDataStore.this.commit(storeSnapshot, proposedSubtree.get(),listenerResolver); + InMemoryDOMDataStore.this.commit(storeSnapshot, proposedSubtree.get(), listenerResolver); return Futures. immediateFuture(null); } @@ -421,7 +431,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch } @Override - public boolean isApplicable(final NodeModification modification, final Optional storeMetadata) { + public void checkApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional storeMetadata) { throw new IllegalStateException("Schema Context is not available."); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ModificationApplyOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ModificationApplyOperation.java index d02f1109d7..361be6800c 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ModificationApplyOperation.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ModificationApplyOperation.java @@ -10,6 +10,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import org.opendaylight.controller.md.sal.dom.store.impl.tree.NodeModification; import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreMetadataNode; import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; import com.google.common.base.Optional; @@ -59,17 +60,6 @@ public interface ModificationApplyOperation extends StoreTreeNode apply(NodeModification modification, Optional storeMeta, UnsignedLong subtreeVersion); - /** - * - * Checks if provided node modification could be applied to current metadata node. - * - * @param modification Modification - * @param current Metadata Node to which modification should be applied - * @return true if modification is applicable - * false if modification is no applicable - */ - boolean isApplicable(NodeModification modification, Optional current); - /** * * Performs structural verification of NodeModification, such as writen values / types @@ -87,8 +77,17 @@ public interface ModificationApplyOperation extends StoreTreeNode getChild(PathArgument child); - - + Optional getChild(PathArgument child); + /** + * + * Checks if provided node modification could be applied to current metadata node. + * + * @param modification Modification + * @param current Metadata Node to which modification should be applied + * @return true if modification is applicable + * false if modification is no applicable + * @throws DataPreconditionFailedException + */ + void checkApplicable(InstanceIdentifier path, NodeModification modification, Optional current) throws DataPreconditionFailedException; } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/OperationWithModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/OperationWithModification.java index 35864b6bc2..780291e70f 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/OperationWithModification.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/OperationWithModification.java @@ -1,3 +1,10 @@ +/* + * 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.dom.store.impl; import org.opendaylight.controller.md.sal.dom.store.impl.tree.NodeModification; @@ -38,10 +45,6 @@ public class OperationWithModification { return applyOperation; } - public boolean isApplicable(final Optional data) { - return applyOperation.isApplicable(modification, data); - } - public Optional apply(final Optional data, final UnsignedLong subtreeVersion) { return applyOperation.apply(modification, data, subtreeVersion); } @@ -63,4 +66,4 @@ public class OperationWithModification { Optional childOp = applyOperation.getChild(childId); return from(childOp.get(),childMod); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java index e74ba95891..44d50166af 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java @@ -327,12 +327,12 @@ public class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNode beforeData, final NormalizedNode afterData) { - if (beforeData instanceof NormalizedNodeContainer && !listeners.isEmpty()) { + if (beforeData instanceof NormalizedNodeContainer) { // Node is container (contains child) and we have interested // listeners registered for it, that means we need to do // resolution of changes on children level and can not // shortcut resolution. - + LOG.trace("Resolving subtree replace event for {} before {}, after {}",path,beforeData,afterData); @SuppressWarnings("unchecked") NormalizedNodeContainer> beforeCont = (NormalizedNodeContainer>) beforeData; @SuppressWarnings("unchecked") @@ -342,7 +342,7 @@ public class ResolveDataChangeEventsTask implements Callable listeners, final NormalizedNode node, final SimpleEventFactory eventFactory) { - final DOMImmutableDataChangeEvent event = eventFactory.create(path, node); DOMImmutableDataChangeEvent propagateEvent = event; - // We have listeners for this node or it's children, so we will try + // We have listeners for this node or it's children, so we will try // to do additional processing if (node instanceof NormalizedNodeContainer) { + LOG.trace("Resolving subtree recursive event for {}, type {}", path, eventFactory); + Builder eventBuilder = builder(DataChangeScope.BASE); eventBuilder.merge(event); eventBuilder.setBefore(event.getOriginalSubtree()); @@ -464,6 +465,7 @@ public class ResolveDataChangeEventsTask implements Callable> container = (NormalizedNodeContainer>) node; for (NormalizedNode child : container.getValue()) { PathArgument childId = child.getIdentifier(); + LOG.trace("Resolving event for child {}", childId); Collection childListeners = getListenerChildrenWildcarded(listeners, childId); eventBuilder.merge(resolveSameEventRecursivelly(append(path, childId), childListeners, child, eventFactory)); } @@ -473,7 +475,7 @@ public class ResolveDataChangeEventsTask implements Callable listeners, final DOMImmutableDataChangeEvent event) { - for (ListenerTree.Node listenerNode : listeners) { if (!listenerNode.getListeners().isEmpty()) { + LOG.trace("Adding event {} for listeners {}",event,listenerNode); events.put(listenerNode, event); } } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java index 7ea4d4e09f..afe9653394 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java @@ -1,3 +1,10 @@ +/* + * 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.dom.store.impl; import static com.google.common.base.Preconditions.checkArgument; @@ -13,6 +20,7 @@ import org.opendaylight.controller.md.sal.dom.store.impl.tree.NodeModification; import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreMetadataNode; import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreNodeCompositeBuilder; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; @@ -27,11 +35,12 @@ 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.NormalizedNodeContainer; +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.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; @@ -59,8 +68,6 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.primitives.UnsignedLong; public abstract class SchemaAwareApplyOperation implements ModificationApplyOperation { @@ -135,55 +142,61 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper protected abstract void verifyWritenStructure(NormalizedNode writenValue); @Override - public boolean isApplicable(final NodeModification modification, final Optional current) { + public void checkApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional current) throws DataPreconditionFailedException { switch (modification.getModificationType()) { case DELETE: - return isDeleteApplicable(modification, current); + checkDeleteApplicable(modification, current); case SUBTREE_MODIFIED: - return isSubtreeModificationApplicable(modification, current); + checkSubtreeModificationApplicable(path,modification, current); + return; case WRITE: - return isWriteApplicable(modification, current); + checkWriteApplicable(path,modification, current); + return; case MERGE: - return isMergeApplicable(modification,current); + checkMergeApplicable(path,modification,current); + return; case UNMODIFIED: - return true; + return; default: - return false; + throw new UnsupportedOperationException("Suplied modification type "+modification.getModificationType()+ "is not supported."); } + } - private boolean isMergeApplicable(final NodeModification modification, final Optional current) { + protected void checkMergeApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional current) throws DataPreconditionFailedException { Optional original = modification.getOriginal(); if (original.isPresent() && current.isPresent()) { - return isNotConflicting(original.get(), current.get()); - } else if (current.isPresent()) { - return true; + /* + * We need to do conflict detection only and only if the value of leaf changed + * before two transactions. If value of leaf is unchanged between two transactions + * it should not cause transaction to fail, since result of this merge + * leads to same data. + */ + if(!original.get().getData().equals(current.get().getData())) { + + checkNotConflicting(path,original.get(), current.get()); + } } - return true; } - protected boolean isWriteApplicable(final NodeModification modification, final Optional current) { + protected void checkWriteApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional current) throws DataPreconditionFailedException { Optional original = modification.getOriginal(); if (original.isPresent() && current.isPresent()) { - return isNotConflicting(original.get(), current.get()); - } else if (current.isPresent()) { - return false; + checkNotConflicting(path,original.get(), current.get()); + } else if(original.isPresent()) { + throw new DataPreconditionFailedException(path,"Node was deleted by other transaction."); } - return true; - } - protected final boolean isNotConflicting(final StoreMetadataNode original, final StoreMetadataNode current) { - return original.getNodeVersion().equals(current.getNodeVersion()) - && original.getSubtreeVersion().equals(current.getSubtreeVersion()); + protected static final void checkNotConflicting(final InstanceIdentifier path,final StoreMetadataNode original, final StoreMetadataNode current) throws DataPreconditionFailedException { + checkDataPrecondition(path, original.getNodeVersion().equals(current.getNodeVersion()),"Node was replaced by other transaction."); + checkDataPrecondition(path,original.getSubtreeVersion().equals(current.getSubtreeVersion()), "Node children was modified by other transaction"); } - protected abstract boolean isSubtreeModificationApplicable(final NodeModification modification, - final Optional current); + protected abstract void checkSubtreeModificationApplicable(InstanceIdentifier path,final NodeModification modification, + final Optional current) throws DataPreconditionFailedException; - private boolean isDeleteApplicable(final NodeModification modification, final Optional current) { - // FiXME: Add delete conflict detection. - return true; + private void checkDeleteApplicable(final NodeModification modification, final Optional current) { } @Override @@ -265,9 +278,9 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } @Override - protected boolean isSubtreeModificationApplicable(final NodeModification modification, - final Optional current) { - return false; + protected void checkSubtreeModificationApplicable(final InstanceIdentifier path,final NodeModification modification, + final Optional current) throws DataPreconditionFailedException { + throw new DataPreconditionFailedException(path, "Subtree modification is not allowed."); } } @@ -306,6 +319,14 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } } + @Override + protected void checkWriteApplicable(final InstanceIdentifier path, final NodeModification modification, + final Optional current) throws DataPreconditionFailedException { + // FIXME: Implement proper write check for replacement of node container + // prerequisite is to have transaction chain available for clients + // otherwise this will break chained writes to same node. + } + @SuppressWarnings("rawtypes") @Override protected void verifyWritenStructure(final NormalizedNode writenValue) { @@ -321,30 +342,28 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override protected StoreMetadataNode applyWrite(final NodeModification modification, final Optional currentMeta, final UnsignedLong subtreeVersion) { - // + NormalizedNode newValue = modification.getWritenValue(); - UnsignedLong nodeVersion = subtreeVersion; + final UnsignedLong nodeVersion; if (currentMeta.isPresent()) { nodeVersion = StoreUtils.increase(currentMeta.get().getNodeVersion()); + } else { + nodeVersion = subtreeVersion; } - StoreMetadataNode newValueMeta = StoreMetadataNode.createRecursively(newValue, nodeVersion, nodeVersion); + final StoreMetadataNode newValueMeta = StoreMetadataNode.createRecursively(newValue, nodeVersion, nodeVersion); if (!modification.hasAdditionalModifications()) { return newValueMeta; } + @SuppressWarnings("rawtypes") - NormalizedNodeContainerBuilder dataBuilder = createBuilder(modification.getIdentifier()); + NormalizedNodeContainerBuilder dataBuilder = createBuilder(newValue); StoreNodeCompositeBuilder builder = StoreNodeCompositeBuilder.from(dataBuilder) // .setNodeVersion(nodeVersion) // .setSubtreeVersion(subtreeVersion); - Set processedPreexisting = applyPreexistingChildren(modification, newValueMeta.getChildren(), - builder, nodeVersion); - applyNewChildren(modification, processedPreexisting, builder, nodeVersion); - - return builder.build(); - + return mutateChildren(modification.getModifications(), newValueMeta, builder, nodeVersion); } @Override @@ -357,75 +376,64 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override public StoreMetadataNode applySubtreeChange(final NodeModification modification, final StoreMetadataNode currentMeta, final UnsignedLong subtreeVersion) { + // Bump subtree version to its new target + final UnsignedLong updatedSubtreeVersion = StoreUtils.increase(currentMeta.getSubtreeVersion()); - UnsignedLong updatedSubtreeVersion = StoreUtils.increase(currentMeta.getSubtreeVersion()); @SuppressWarnings("rawtypes") - NormalizedNodeContainerBuilder dataBuilder = createBuilder(modification.getIdentifier()); - StoreNodeCompositeBuilder builder = StoreNodeCompositeBuilder.from(dataBuilder) + NormalizedNodeContainerBuilder dataBuilder = createBuilder(currentMeta.getData()); + StoreNodeCompositeBuilder builder = StoreNodeCompositeBuilder.from(dataBuilder, currentMeta) .setIdentifier(modification.getIdentifier()).setNodeVersion(currentMeta.getNodeVersion()) .setSubtreeVersion(updatedSubtreeVersion); - // We process preexisting nodes - Set processedPreexisting = applyPreexistingChildren(modification, currentMeta.getChildren(), - builder, updatedSubtreeVersion); - applyNewChildren(modification, processedPreexisting, builder, updatedSubtreeVersion); - return builder.build(); + + return mutateChildren(modification.getModifications(), currentMeta, builder, updatedSubtreeVersion); } - private void applyNewChildren(final NodeModification modification, final Set ignore, - final StoreNodeCompositeBuilder builder, final UnsignedLong subtreeVersion) { - for (NodeModification childModification : modification.getModifications()) { - PathArgument childIdentifier = childModification.getIdentifier(); - // We skip allready processed modifications - if (ignore.contains(childIdentifier)) { - continue; - } + private StoreMetadataNode mutateChildren(final Iterable modifications, final StoreMetadataNode meta, + final StoreNodeCompositeBuilder builder, final UnsignedLong nodeVersion) { - builder.addIfPresent(resolveChildOperation(childIdentifier) // - .apply(childModification, Optional. absent(), subtreeVersion)); - } - } + for (NodeModification mod : modifications) { + final PathArgument id = mod.getIdentifier(); + final Optional cm = meta.getChild(id); - private Set applyPreexistingChildren(final NodeModification modification, - final Iterable children, final StoreNodeCompositeBuilder nodeBuilder, - final UnsignedLong subtreeVersion) { - Builder processedModifications = ImmutableSet. builder(); - for (StoreMetadataNode childMeta : children) { - PathArgument childIdentifier = childMeta.getIdentifier(); - // We retrieve Child modification metadata - Optional childModification = modification.getChild(childIdentifier); - // Node is modified - if (childModification.isPresent()) { - processedModifications.add(childIdentifier); - Optional result = resolveChildOperation(childIdentifier) // - .apply(childModification.get(), Optional.of(childMeta), subtreeVersion); - nodeBuilder.addIfPresent(result); + Optional result = resolveChildOperation(id).apply(mod, cm, nodeVersion); + if (result.isPresent()) { + builder.add(result.get()); } else { - // Child is unmodified - reuse existing metadata and data - // snapshot - nodeBuilder.add(childMeta); + builder.remove(id); } } - return processedModifications.build(); + + return builder.build(); } @Override - protected boolean isSubtreeModificationApplicable(final NodeModification modification, - final Optional current) { - if (false == current.isPresent()) { - return false; - } - boolean result = true; + protected void checkSubtreeModificationApplicable(final InstanceIdentifier path,final NodeModification modification, + final Optional current) throws DataPreconditionFailedException { + checkDataPrecondition(path, current.isPresent(), "Node was deleted by other transaction."); + checkChildPreconditions(path,modification,current); + + } + + private void checkChildPreconditions(final InstanceIdentifier path, final NodeModification modification, final Optional current) throws DataPreconditionFailedException { StoreMetadataNode currentMeta = current.get(); for (NodeModification childMod : modification.getModifications()) { PathArgument childId = childMod.getIdentifier(); Optional childMeta = currentMeta.getChild(childId); - result &= resolveChildOperation(childId).isApplicable(childMod, childMeta); + InstanceIdentifier childPath = StoreUtils.append(path, childId); + resolveChildOperation(childId).checkApplicable(childPath,childMod, childMeta); + } + } + + @Override + protected void checkMergeApplicable(final InstanceIdentifier path, final NodeModification modification, + final Optional current) throws DataPreconditionFailedException { + if(current.isPresent()) { + checkChildPreconditions(path,modification,current); } - return result; } @SuppressWarnings("rawtypes") - protected abstract NormalizedNodeContainerBuilder createBuilder(PathArgument identifier); + protected abstract NormalizedNodeContainerBuilder createBuilder(NormalizedNode original); } public static abstract class DataNodeContainerModificationStrategy extends @@ -470,7 +478,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override @SuppressWarnings("rawtypes") - protected abstract DataContainerNodeBuilder createBuilder(PathArgument identifier); + protected abstract DataContainerNodeBuilder createBuilder(NormalizedNode original); @Override public String toString() { @@ -488,12 +496,10 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override @SuppressWarnings("rawtypes") - protected DataContainerNodeBuilder createBuilder(final PathArgument identifier) { - // TODO Auto-generated method stub - checkArgument(identifier instanceof NodeIdentifier); - return ImmutableContainerNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); + protected DataContainerNodeBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof ContainerNode); + return ImmutableContainerNodeBuilder.create((ContainerNode) original); } - } public static class UnkeyedListItemModificationStrategy extends @@ -505,11 +511,10 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override @SuppressWarnings("rawtypes") - protected DataContainerNodeBuilder createBuilder(final PathArgument identifier) { - checkArgument(identifier instanceof NodeIdentifier); - return ImmutableUnkeyedListEntryNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); + protected DataContainerNodeBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof UnkeyedListEntryNode); + return ImmutableUnkeyedListEntryNodeBuilder.create((UnkeyedListEntryNode) original); } - } public static class AugmentationModificationStrategy extends @@ -517,15 +522,14 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper protected AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved) { super(createAugmentProxy(schema,resolved), AugmentationNode.class); - // FIXME: Use resolved children instead of unresolved. - } @Override - protected DataContainerNodeBuilder createBuilder(final PathArgument identifier) { - return Builders.augmentationBuilder().withNodeIdentifier((AugmentationIdentifier) identifier); + @SuppressWarnings("rawtypes") + protected DataContainerNodeBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof AugmentationNode); + return ImmutableAugmentationNodeBuilder.create((AugmentationNode) original); } - } public static class ChoiceModificationStrategy extends NormalizedNodeContainerModificationStrategy { @@ -554,11 +558,10 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override @SuppressWarnings("rawtypes") - protected DataContainerNodeBuilder createBuilder(final PathArgument identifier) { - checkArgument(identifier instanceof NodeIdentifier); - return ImmutableChoiceNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); + protected DataContainerNodeBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode); + return ImmutableChoiceNodeBuilder.create((org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) original); } - } public static class ListEntryModificationStrategy extends DataNodeContainerModificationStrategy { @@ -569,10 +572,10 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @Override @SuppressWarnings("rawtypes") - protected final DataContainerNodeBuilder createBuilder(final PathArgument identifier) { - return ImmutableMapEntryNodeBuilder.create().withNodeIdentifier((NodeIdentifierWithPredicates) identifier); + protected final DataContainerNodeBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof MapEntryNode); + return ImmutableMapEntryNodeBuilder.create((MapEntryNode) original); } - } public static class UnorderedLeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy { @@ -587,8 +590,9 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @SuppressWarnings("rawtypes") @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument identifier) { - return ImmutableLeafSetNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); + protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof LeafSetNode); + return ImmutableLeafSetNodeBuilder.create((LeafSetNode) original); } @Override @@ -598,7 +602,6 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } return Optional.absent(); } - } public static class OrderedLeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy { @@ -613,8 +616,9 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @SuppressWarnings("rawtypes") @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument identifier) { - return ImmutableOrderedLeafSetNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); + protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof OrderedLeafSetNode); + return ImmutableOrderedLeafSetNodeBuilder.create((OrderedLeafSetNode) original); } @Override @@ -624,7 +628,6 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } return Optional.absent(); } - } public static class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation { @@ -667,9 +670,9 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } @Override - protected boolean isSubtreeModificationApplicable(final NodeModification modification, - final Optional current) { - return false; + protected void checkSubtreeModificationApplicable(final InstanceIdentifier path,final NodeModification modification, + final Optional current) throws DataPreconditionFailedException { + throw new DataPreconditionFailedException(path, "Subtree modification is not allowed."); } } @@ -685,8 +688,9 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @SuppressWarnings("rawtypes") @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument identifier) { - return ImmutableMapNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); + protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof MapNode); + return ImmutableMapNodeBuilder.create((MapNode) original); } @Override @@ -714,8 +718,9 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper @SuppressWarnings("rawtypes") @Override - protected NormalizedNodeContainerBuilder createBuilder(final PathArgument identifier) { - return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); + protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode original) { + checkArgument(original instanceof OrderedMapNode); + return ImmutableOrderedMapNodeBuilder.create((OrderedMapNode) original); } @Override @@ -744,4 +749,11 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper return new AugmentationSchemaProxy(schema, realChildSchemas); } + public static boolean checkDataPrecondition(final InstanceIdentifier path, final boolean condition, final String message) throws DataPreconditionFailedException { + if(!condition) { + throw new DataPreconditionFailedException(path, message); + } + return condition; + } + } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperationRoot.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperationRoot.java index e7265dedb5..8a539ff36e 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperationRoot.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperationRoot.java @@ -7,16 +7,14 @@ */ package org.opendaylight.controller.md.sal.dom.store.impl; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.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.builder.api.DataContainerNodeBuilder; 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.SchemaContext; public class SchemaAwareApplyOperationRoot extends SchemaAwareApplyOperation.DataNodeContainerModificationStrategy { - private final SchemaContext context; public SchemaAwareApplyOperationRoot(final SchemaContext context) { @@ -24,11 +22,6 @@ public class SchemaAwareApplyOperationRoot extends SchemaAwareApplyOperation.Dat this.context = context; } - @Override - protected DataContainerNodeBuilder createBuilder(final PathArgument identifier) { - return ImmutableContainerNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); - } - public SchemaContext getContext() { return context; } @@ -38,4 +31,9 @@ public class SchemaAwareApplyOperationRoot extends SchemaAwareApplyOperation.Dat return "SchemaAwareApplyOperationRoot [context=" + context + "]"; } + @Override + @SuppressWarnings("rawtypes") + protected DataContainerNodeBuilder createBuilder(NormalizedNode original) { + return ImmutableContainerNodeBuilder.create((ContainerNode) original); + } } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/StoreUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/StoreUtils.java index 830d7e3dc4..e1da9a7381 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/StoreUtils.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/StoreUtils.java @@ -1,11 +1,14 @@ +/* + * 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.dom.store.impl; -import java.util.Collections; -import java.util.Map; import java.util.Set; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreMetadataNode; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; @@ -18,10 +21,10 @@ import com.google.common.base.Function; import com.google.common.base.Strings; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.primitives.UnsignedLong; public final class StoreUtils { + private static final int STRINGTREE_INDENT = 4; private final static Function, Object> EXTRACT_IDENTIFIER = new Function, Object>() { @Override @@ -30,18 +33,8 @@ public final class StoreUtils { } }; - public static final UnsignedLong increase(final UnsignedLong original) { - return original.plus(UnsignedLong.ONE); - } - - public static final InstanceIdentifier append(final InstanceIdentifier parent, final PathArgument arg) { - - return new InstanceIdentifier(ImmutableList. builder().addAll(parent.getPath()).add(arg).build()); - } - - public static AsyncDataChangeEvent> initialChangeEvent( - final InstanceIdentifier path, final StoreMetadataNode data) { - return new InitialDataChangeEvent(path, data.getData()); + private StoreUtils() { + throw new UnsupportedOperationException("Utility class should not be instantiated"); } /* @@ -54,70 +47,39 @@ public final class StoreUtils { return (Function) EXTRACT_IDENTIFIER; } - private static final class InitialDataChangeEvent implements - AsyncDataChangeEvent> { - - private final ImmutableMap> payload; - private final NormalizedNode data; - - public InitialDataChangeEvent(final InstanceIdentifier path, final NormalizedNode data) { - payload = ImmutableMap.> of(path, data); - this.data = data; - } - - @Override - public Map> getCreatedData() { - return payload; - } - - @Override - public Map> getOriginalData() { - return Collections.emptyMap(); - } - - @Override - public NormalizedNode getOriginalSubtree() { - return null; - } - - @Override - public Set getRemovedPaths() { - return Collections.emptySet(); - } - - @Override - public Map> getUpdatedData() { - return payload; - } + public static final UnsignedLong increase(final UnsignedLong original) { + return original.plus(UnsignedLong.ONE); + } - @Override - public NormalizedNode getUpdatedSubtree() { - return data; - } + public static final InstanceIdentifier append(final InstanceIdentifier parent, final PathArgument arg) { + return new InstanceIdentifier(ImmutableList. builder().addAll(parent.getPath()).add(arg).build()); } public static Set toIdentifierSet(final Iterable> children) { return FluentIterable.from(children).transform(StoreUtils. identifierExtractor()).toSet(); } - public static String toStringTree(final StoreMetadataNode metaNode) { + public static String toStringTree(final NormalizedNode node) { StringBuilder builder = new StringBuilder(); - toStringTree(builder, metaNode, 0); + toStringTree(builder, node, 0); return builder.toString(); } - private static void toStringTree(final StringBuilder builder, final StoreMetadataNode metaNode, final int offset) { - String prefix = Strings.repeat(" ", offset); - builder.append(prefix).append(toStringTree(metaNode.getIdentifier())); - NormalizedNode dataNode = metaNode.getData(); - if (dataNode instanceof NormalizedNodeContainer) { + private static void toStringTree(final StringBuilder builder, final NormalizedNode node, final int offset) { + final String prefix = Strings.repeat(" ", offset); + + builder.append(prefix).append(toStringTree(node.getIdentifier())); + if (node instanceof NormalizedNodeContainer) { + final NormalizedNodeContainer container = (NormalizedNodeContainer) node; + builder.append(" {\n"); - for (StoreMetadataNode child : metaNode.getChildren()) { - toStringTree(builder, child, offset + 4); + for (NormalizedNode child : container.getValue()) { + toStringTree(builder, child, offset + STRINGTREE_INDENT); } + builder.append(prefix).append('}'); } else { - builder.append(' ').append(dataNode.getValue()); + builder.append(' ').append(node.getValue()); } builder.append('\n'); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java index d42f36fb90..b8ad7368b5 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java @@ -9,7 +9,8 @@ package org.opendaylight.controller.md.sal.dom.store.impl.tree; import static com.google.common.base.Preconditions.checkState; -import java.util.LinkedHashMap; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; import org.opendaylight.yangtools.concepts.Identifiable; @@ -20,7 +21,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; import com.google.common.base.Optional; import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; import com.google.common.primitives.UnsignedLong; public class StoreMetadataNode implements Immutable, Identifiable, StoreTreeNode { @@ -46,10 +46,24 @@ public class StoreMetadataNode implements Immutable, Identifiable, this.children = Preconditions.checkNotNull(children); } + public static StoreMetadataNode createEmpty(final NormalizedNode data) { + return new StoreMetadataNode(data, UnsignedLong.ZERO, UnsignedLong.ZERO, + Collections.emptyMap()); + } + + public StoreMetadataNode(final NormalizedNode data, final UnsignedLong nodeVersion, + final UnsignedLong subtreeVersion) { + this(data, nodeVersion, subtreeVersion, Collections.emptyMap()); + } + public static Builder builder() { return new Builder(); } + public static Builder builder(StoreMetadataNode node) { + return new Builder(node); + } + public UnsignedLong getNodeVersion() { return this.nodeVersion; } @@ -67,10 +81,6 @@ public class StoreMetadataNode implements Immutable, Identifiable, return this.data; } - public Iterable getChildren() { - return Iterables.unmodifiableIterable(children.values()); - } - @Override public Optional getChild(final PathArgument key) { return Optional.fromNullable(children.get(key)); @@ -118,11 +128,16 @@ public class StoreMetadataNode implements Immutable, Identifiable, private UnsignedLong nodeVersion; private UnsignedLong subtreeVersion; private NormalizedNode data; - private Map children = new LinkedHashMap<>(); + private Map children; private boolean dirty = false; - private Builder() {} + private Builder() { + children = new HashMap<>(); + } + public Builder(StoreMetadataNode node) { + children = new HashMap<>(node.children); + } public UnsignedLong getVersion() { return nodeVersion; @@ -146,13 +161,22 @@ public class StoreMetadataNode implements Immutable, Identifiable, public Builder add(final StoreMetadataNode node) { if (dirty) { - children = new LinkedHashMap<>(children); + children = new HashMap<>(children); dirty = false; } children.put(node.getIdentifier(), node); return this; } + public Builder remove(final PathArgument id) { + if (dirty) { + children = new HashMap<>(children); + dirty = false; + } + children.remove(id); + return this; + } + public StoreMetadataNode build() { checkState(data != null, "Data node should not be null."); checkState(subtreeVersion.compareTo(nodeVersion) >= 0, @@ -165,5 +189,4 @@ public class StoreMetadataNode implements Immutable, Identifiable, public static StoreMetadataNode createRecursively(final NormalizedNode node, final UnsignedLong version) { return createRecursively(node, version, version); } - } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreNodeCompositeBuilder.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreNodeCompositeBuilder.java index 41fc8239fb..a66a1d5b1c 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreNodeCompositeBuilder.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreNodeCompositeBuilder.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl.tree; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder; -import com.google.common.base.Optional; +import com.google.common.base.Preconditions; import com.google.common.primitives.UnsignedLong; /** @@ -28,7 +28,12 @@ public class StoreNodeCompositeBuilder { private StoreNodeCompositeBuilder(final NormalizedNodeContainerBuilder nodeBuilder) { this.metadata = StoreMetadataNode.builder(); - this.data = nodeBuilder; + this.data = Preconditions.checkNotNull(nodeBuilder); + } + + public StoreNodeCompositeBuilder(NormalizedNodeContainerBuilder nodeBuilder, StoreMetadataNode currentMeta) { + this.metadata = StoreMetadataNode.builder(currentMeta); + this.data = Preconditions.checkNotNull(nodeBuilder); } @SuppressWarnings("unchecked") @@ -39,12 +44,9 @@ public class StoreNodeCompositeBuilder { } @SuppressWarnings("unchecked") - public StoreNodeCompositeBuilder addIfPresent(final Optional potential) { - if (potential.isPresent()) { - StoreMetadataNode node = potential.get(); - metadata.add(node); - data.addChild(node.getData()); - } + public StoreNodeCompositeBuilder remove(PathArgument id) { + metadata.remove(id); + data.removeChild(id); return this; } @@ -56,6 +58,10 @@ public class StoreNodeCompositeBuilder { return new StoreNodeCompositeBuilder(nodeBuilder); } + public static StoreNodeCompositeBuilder from(final NormalizedNodeContainerBuilder nodeBuilder, StoreMetadataNode currentMeta) { + return new StoreNodeCompositeBuilder(nodeBuilder, currentMeta); + } + @SuppressWarnings("unchecked") public StoreNodeCompositeBuilder setIdentifier(final PathArgument identifier) { data.withNodeIdentifier(identifier); @@ -71,5 +77,4 @@ public class StoreNodeCompositeBuilder { metadata.setSubtreeVersion(updatedSubtreeVersion); return this; } - } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java index 339d9cb44e..732352dd34 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java @@ -21,7 +21,10 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; -public class TreeNodeUtils { +public final class TreeNodeUtils { + private TreeNodeUtils() { + throw new UnsupportedOperationException("Utility class should not be instantiated"); + } /** * Finds a node in tree @@ -40,7 +43,6 @@ public class TreeNodeUtils { return current; } - public static > T findNodeChecked(final T tree, final InstanceIdentifier path) { T current = tree; List nested = new ArrayList<>(path.getPath().size()); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java index 3e7b115f11..f47e1efc3f 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java @@ -457,7 +457,7 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, Ro try { listener.onRouteChange(initial); } catch (Exception e) { - LOG.error("Unhandled exception during sending initial route change event {} to {}",initial,listener); + LOG.error("Unhandled exception during sending initial route change event {} to {}",initial,listener, e); } return reg; } diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DataNormalizerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DataNormalizerTest.java index 9aa558b5ac..ac7b87a9f5 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DataNormalizerTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DataNormalizerTest.java @@ -49,12 +49,8 @@ public class DataNormalizerTest { InstanceIdentifier normalizedPath = normalizer.toNormalized(LEAF_TWO_PATH_LEGACY); - Node outerListLegacy = normalizer.toLegacy(OUTER_LIST_WITH_CHOICE); + Node outerListLegacy = DataNormalizer.toLegacy(OUTER_LIST_WITH_CHOICE); assertNotNull(outerListLegacy); - - - - } } diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java index 5a43c7b218..c0f0a35565 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.assertTrue; import java.util.concurrent.ExecutionException; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; @@ -119,6 +120,7 @@ public class InMemoryDataStoreTest { } @Test + @Ignore public void testTransactionConflict() throws InterruptedException, ExecutionException { DOMStoreReadWriteTransaction txOne = domStore.newReadWriteTransaction(); DOMStoreReadWriteTransaction txTwo = domStore.newReadWriteTransaction(); diff --git a/opendaylight/md-sal/sal-netconf-connector/pom.xml b/opendaylight/md-sal/sal-netconf-connector/pom.xml index ef485bbadf..9ad95c18d9 100644 --- a/opendaylight/md-sal/sal-netconf-connector/pom.xml +++ b/opendaylight/md-sal/sal-netconf-connector/pom.xml @@ -13,6 +13,7 @@ + ${project.groupId} netconf-client ${netconf.version} @@ -37,7 +38,6 @@ org.opendaylight.controller netconf-client - ${netconf.version} org.opendaylight.controller @@ -47,10 +47,18 @@ org.opendaylight.controller netty-threadgroup-config + + org.opendaylight.controller + sal-binding-api + org.opendaylight.controller threadpool-config-api + + org.opendaylight.controller.model + model-inventory + org.opendaylight.yangtools yang-data-impl diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java index 6e924221cf..de3c18db69 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java @@ -10,35 +10,41 @@ package org.opendaylight.controller.config.yang.md.sal.connector.netconf; import static org.opendaylight.controller.config.api.JmxAttributeValidationException.checkCondition; import static org.opendaylight.controller.config.api.JmxAttributeValidationException.checkNotNull; +import com.google.common.net.InetAddresses; import io.netty.util.HashedWheelTimer; import io.netty.util.concurrent.GlobalEventExecutor; - import java.io.File; import java.io.InputStream; import java.net.InetAddress; import java.net.InetSocketAddress; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import org.opendaylight.controller.netconf.client.NetconfClientDispatcher; import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl; import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder; +import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration; +import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder; import org.opendaylight.controller.netconf.util.handler.ssh.authentication.LoginPassword; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; import org.opendaylight.controller.sal.connect.netconf.NetconfDevice; import org.opendaylight.controller.sal.connect.netconf.NetconfDeviceListener; import org.opendaylight.protocol.framework.ReconnectStrategy; +import org.opendaylight.protocol.framework.ReconnectStrategyFactory; import org.opendaylight.protocol.framework.TimedReconnectStrategy; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.inventory.rev140108.NetconfNode; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.model.util.repo.AbstractCachingSchemaSourceProvider; import org.opendaylight.yangtools.yang.model.util.repo.FilesystemSchemaCachingProvider; import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider; import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProviders; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.net.InetAddresses; - /** * */ @@ -88,6 +94,10 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co @Override public java.lang.AutoCloseable createInstance() { + ServiceReference serviceReference = bundleContext.getServiceReference(DataProviderService.class); + + DataProviderService dataProviderService = + bundleContext.getService(serviceReference); getDomRegistryDependency(); NetconfDevice device = new NetconfDevice(getIdentifier().getInstanceName()); @@ -99,7 +109,7 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co device.setEventExecutor(getEventExecutorDependency()); device.setDispatcher(getClientDispatcher() == null ? createDispatcher() : getClientDispatcherDependency()); device.setSchemaSourceProvider(getGlobalNetconfSchemaProvider(bundleContext)); - + device.setDataProviderService(dataProviderService); getDomRegistryDependency().registerProvider(device, bundleContext); device.start(); return device; @@ -134,12 +144,12 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co this.bundleContext = bundleContext; } - public NetconfClientConfiguration getClientConfig(final NetconfDevice device) { + public NetconfReconnectingClientConfiguration getClientConfig(final NetconfDevice device) { InetSocketAddress socketAddress = getSocketAddress(); ReconnectStrategy strategy = getReconnectStrategy(); long clientConnectionTimeoutMillis = getConnectionTimeoutMillis(); - return NetconfClientConfigurationBuilder.create() + return NetconfReconnectingClientConfigurationBuilder.create() .withAddress(socketAddress) .withConnectionTimeoutMillis(clientConnectionTimeoutMillis) .withReconnectStrategy(strategy) @@ -148,6 +158,12 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co .withProtocol(getTcpOnly() ? NetconfClientConfiguration.NetconfClientProtocol.TCP : NetconfClientConfiguration.NetconfClientProtocol.SSH) + .withConnectStrategyFactory(new ReconnectStrategyFactory() { + @Override + public ReconnectStrategy createReconnectStrategy() { + return getReconnectStrategy(); + } + }) .build(); } @@ -159,7 +175,7 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co logger.trace("Setting {} on {} to infinity", maxConnectionAttemptsJmxAttribute, this); connectionAttempts = null; } - double sleepFactor = 1.0; + double sleepFactor = 1.5; int minSleep = 1000; Long maxSleep = null; Long deadline = null; diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java index 1209e88f52..94beaed0df 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.java @@ -40,6 +40,8 @@ import org.opendaylight.controller.md.sal.common.api.data.DataModification; import org.opendaylight.controller.md.sal.common.api.data.DataReader; import org.opendaylight.controller.netconf.client.NetconfClientDispatcher; import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; +import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; import org.opendaylight.controller.sal.core.api.Provider; @@ -49,6 +51,8 @@ import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; import org.opendaylight.protocol.framework.ReconnectStrategy; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.inventory.rev140108.NetconfNode; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -117,13 +121,14 @@ public class NetconfDevice implements Provider, // SchemaSourceProvider remoteSourceProvider; - DataBrokerService dataBroker; + private volatile DataBrokerService dataBroker; NetconfDeviceListener listener; private boolean rollbackSupported; - private NetconfClientConfiguration clientConfig; + private NetconfReconnectingClientConfiguration clientConfig; + private volatile DataProviderService dataProviderService; public NetconfDevice(String name) { this.name = name; @@ -142,7 +147,7 @@ public class NetconfDevice implements Provider, // logger.info("Starting NETCONF Client {} for address {}", name, socketAddress); - dispatcher.createClient(clientConfig); + dispatcher.createReconnectingClient(clientConfig); } Optional getSchemaContext() { @@ -217,6 +222,8 @@ public class NetconfDevice implements Provider, // } private void updateDeviceState(boolean up, Set capabilities) { + checkDataStoreState(); + DataModificationTransaction transaction = dataBroker.beginTransaction(); CompositeNodeBuilder it = ImmutableCompositeNode.builder(); @@ -305,6 +312,22 @@ public class NetconfDevice implements Provider, // public void onSessionInitiated(ProviderSession session) { dataBroker = session.getService(DataBrokerService.class); + processingExecutor.submit(new Runnable() { + @Override + public void run() { + updateInitialState(); + } + }); + + mountService = session.getService(MountProvisionService.class); + if (mountService != null) { + mountInstance = mountService.createOrGetMountPoint(path); + } + } + + private void updateInitialState() { + checkDataStoreState(); + DataModificationTransaction transaction = dataBroker.beginTransaction(); if (operationalNodeNotExisting(transaction)) { transaction.putOperationalData(path, getNodeWithId()); @@ -320,13 +343,13 @@ public class NetconfDevice implements Provider, // } catch (ExecutionException e) { throw new RuntimeException("Read configuration data " + path + " failed", e); } - - mountService = session.getService(MountProvisionService.class); - if (mountService != null) { - mountInstance = mountService.createOrGetMountPoint(path); - } } + private void checkDataStoreState() { + // read data from Nodes/Node in order to wait with write until schema for Nodes/Node is present in datastore + dataProviderService.readOperationalData(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.builder( + Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class).augmentation(NetconfNode.class).build()); } + CompositeNode getNodeWithId() { SimpleNodeTOImpl id = new SimpleNodeTOImpl(INVENTORY_ID, null, name); return new CompositeNodeTOImpl(INVENTORY_NODE, null, Collections.> singletonList(id)); @@ -469,10 +492,13 @@ public class NetconfDevice implements Provider, // this.dispatcher = dispatcher; } - public void setClientConfig(final NetconfClientConfiguration clientConfig) { + public void setClientConfig(final NetconfReconnectingClientConfiguration clientConfig) { this.clientConfig = clientConfig; } + public void setDataProviderService(final DataProviderService dataProviderService) { + this.dataProviderService = dataProviderService; + } } class NetconfDeviceSchemaContextProvider { diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfMapping.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfMapping.java index 55e17c56b3..f76ec28624 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfMapping.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfMapping.java @@ -99,7 +99,11 @@ public class NetconfMapping { for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument component : Lists .reverse(identifier.getPath())) { - previous = toNode(component, previous); + if (component instanceof NodeIdentifierWithPredicates) { + previous = toNode((NodeIdentifierWithPredicates)component, previous); + } else { + previous = toNode(component, previous); + } } return filter("subtree", previous); } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java index edcef83574..53fbb929bb 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.sal.connector.remoterpc; -import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import java.util.Collection; import java.util.Collections; @@ -174,7 +174,7 @@ public class RemoteRpcProvider implements Optional> routingTable = routingTableProvider.getRoutingTable(); - checkNotNull(routingTable.isPresent(), "Routing table is null"); + checkState(routingTable.isPresent(), "Routing table is null"); return routingTable.get(); } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/Message.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/Message.java index 519791a195..21d02be7d7 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/Message.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/Message.java @@ -8,11 +8,17 @@ package org.opendaylight.controller.sal.connector.remoterpc.dto; -import org.opendaylight.controller.sal.connector.api.RpcRouter; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; -import java.io.*; +import org.opendaylight.controller.sal.connector.api.RpcRouter; public class Message implements Serializable { + private static final long serialVersionUID = 1L; public static enum MessageType { PING((byte) 0), @@ -118,12 +124,13 @@ public class Message implements Serializable { } public static class Response extends Message implements RpcRouter.RpcReply { + private static final long serialVersionUID = 1L; private ResponseCode code; // response code public static enum ResponseCode { SUCCESS(200), BADREQUEST(400), TIMEOUT(408), GONE(410), SERVERERROR(500), SERVICEUNAVAILABLE(503); - private int code; + private final int code; ResponseCode(int code) { this.code = code; @@ -144,7 +151,7 @@ public class Message implements Serializable { */ public static class MessageBuilder{ - private Message message; + private final Message message; public MessageBuilder(){ message = new Message(); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/RouteIdentifierImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/RouteIdentifierImpl.java index 4ffcf3e099..53c7cc0b8d 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/RouteIdentifierImpl.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/RouteIdentifierImpl.java @@ -7,13 +7,14 @@ */ package org.opendaylight.controller.sal.connector.remoterpc.dto; +import java.io.Serializable; + import org.opendaylight.controller.sal.connector.api.RpcRouter; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import java.io.Serializable; - public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier,Serializable { + private static final long serialVersionUID = 1L; private QName context; private QName type; diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandlerTest.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandlerTest.java index a5c4d85fed..1edd004d37 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandlerTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandlerTest.java @@ -7,7 +7,14 @@ */ package org.opendaylight.controller.sal.connector.remoterpc; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; + import junit.framework.Assert; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -17,9 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.zeromq.ZMQ; -import java.io.IOException; -import java.util.concurrent.*; - /** * */ @@ -69,7 +73,7 @@ public class ClientRequestHandlerTest { serverThread.execute(MessagingUtil.startReplyServer(context, serverAddress, 1)); threadPool.execute(createEmptyMessageTaskAndHandle(handler, serverAddress)); } - Thread.currentThread().sleep(5000);//wait for all messages to get processed + Thread.sleep(5000);//wait for all messages to get processed //should be connected to 5 remote server Assert.assertEquals(5, handler.getWorkerCount()); } diff --git a/opendaylight/md-sal/sal-rest-connector/pom.xml b/opendaylight/md-sal/sal-rest-connector/pom.xml index d6ec2fd74d..fe00ab1836 100644 --- a/opendaylight/md-sal/sal-rest-connector/pom.xml +++ b/opendaylight/md-sal/sal-rest-connector/pom.xml @@ -27,10 +27,6 @@ io.netty netty-codec-http - - org.eclipse.xtend - org.eclipse.xtend.lib - org.opendaylight.controller sal-remote @@ -92,10 +88,7 @@ MD SAL Restconf Connector org.opendaylight.controller.sal.rest.*, - org.opendaylight.controller.sal.restconf.impl, - org.eclipse.xtend2.lib, - org.eclipse.xtend.lib, - org.eclipse.xtext.xbase.*, + org.opendaylight.controller.sal.restconf.impl, *, com.sun.jersey.spi.container.servlet org.opendaylight.controller.sal.rest.impl.RestconfProvider @@ -103,10 +96,6 @@ - - org.eclipse.xtend - xtend-maven-plugin - 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 new file mode 100644 index 0000000000..1cc1f783d6 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java @@ -0,0 +1,201 @@ +/** + * 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.concurrent.Future; + +import javax.ws.rs.core.Response.Status; + +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.md.sal.common.api.data.DataReader; +import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; +import org.opendaylight.controller.sal.core.api.data.DataBrokerService; +import org.opendaylight.controller.sal.core.api.data.DataChangeListener; +import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.core.api.mount.MountInstance; +import org.opendaylight.controller.sal.rest.impl.RestconfProvider; +import org.opendaylight.controller.sal.streams.listeners.ListenerAdapter; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BrokerFacade implements DataReader { + private final static Logger LOG = LoggerFactory.getLogger( BrokerFacade.class ); + + private final static BrokerFacade INSTANCE = new BrokerFacade(); + + private volatile DataBrokerService dataService; + private volatile ConsumerSession context; + + private BrokerFacade() { + } + + public void setContext( final ConsumerSession context ) { + this.context = context; + } + + public void setDataService( final DataBrokerService dataService ) { + this.dataService = dataService; + } + + public static BrokerFacade getInstance() { + return BrokerFacade.INSTANCE; + } + + private void checkPreconditions() { + if( context == null || dataService == null ) { + ResponseException _responseException = new ResponseException( Status.SERVICE_UNAVAILABLE, + RestconfProvider.NOT_INITALIZED_MSG ); + throw _responseException; + } + } + + @Override + public CompositeNode readConfigurationData( final InstanceIdentifier path ) { + this.checkPreconditions(); + + LOG.trace( "Read Configuration via Restconf: {}", path ); + + return dataService.readConfigurationData( path ); + } + + public CompositeNode readConfigurationDataBehindMountPoint( final MountInstance mountPoint, + final InstanceIdentifier path ) { + this.checkPreconditions(); + + LOG.trace( "Read Configuration via Restconf: {}", path ); + + return mountPoint.readConfigurationData( path ); + } + + @Override + public CompositeNode readOperationalData( final InstanceIdentifier path ) { + this.checkPreconditions(); + + BrokerFacade.LOG.trace( "Read Operational via Restconf: {}", path ); + + return dataService.readOperationalData( path ); + } + + public CompositeNode readOperationalDataBehindMountPoint( final MountInstance mountPoint, + final InstanceIdentifier path ) { + this.checkPreconditions(); + + BrokerFacade.LOG.trace( "Read Operational via Restconf: {}", path ); + + return mountPoint.readOperationalData( path ); + } + + public RpcResult invokeRpc( final QName type, final CompositeNode payload ) { + this.checkPreconditions(); + + final Future> future = context.rpc( type, payload ); + + try { + return future.get(); + } + catch( Exception e ) { + throw new ResponseException( e, "Error invoking RPC " + type ); + } + } + + public Future> commitConfigurationDataPut( final InstanceIdentifier path, + final CompositeNode payload ) { + this.checkPreconditions(); + + final DataModificationTransaction transaction = dataService.beginTransaction(); + BrokerFacade.LOG.trace( "Put Configuration via Restconf: {}", path ); + transaction.putConfigurationData( path, payload ); + return transaction.commit(); + } + + public Future> commitConfigurationDataPutBehindMountPoint( + final MountInstance mountPoint, final InstanceIdentifier path, final CompositeNode payload ) { + this.checkPreconditions(); + + final DataModificationTransaction transaction = mountPoint.beginTransaction(); + BrokerFacade.LOG.trace( "Put Configuration via Restconf: {}", path ); + transaction.putConfigurationData( path, payload ); + return transaction.commit(); + } + + public Future> commitConfigurationDataPost( final InstanceIdentifier path, + final CompositeNode payload) { + this.checkPreconditions(); + + final DataModificationTransaction transaction = dataService.beginTransaction(); + /* check for available Node in Configuration DataStore by path */ + CompositeNode availableNode = transaction.readConfigurationData( path ); + if (availableNode != null) { + String errMsg = "Post Configuration via Restconf was not executed because data already exists"; + BrokerFacade.LOG.warn((new StringBuilder(errMsg)).append(" : ").append(path).toString()); + // FIXME: return correct ietf-restconf:errors -> follow specification + // (http://tools.ietf.org/html/draft-bierman-netconf-restconf-03#page-48) + throw new ResponseException(Status.CONFLICT, errMsg); + } + BrokerFacade.LOG.trace( "Post Configuration via Restconf: {}", path ); + transaction.putConfigurationData( path, payload ); + return transaction.commit(); + } + + public Future> commitConfigurationDataPostBehindMountPoint( + final MountInstance mountPoint, final InstanceIdentifier path, final CompositeNode payload ) { + this.checkPreconditions(); + + final DataModificationTransaction transaction = mountPoint.beginTransaction(); + /* check for available Node in Configuration DataStore by path */ + CompositeNode availableNode = transaction.readConfigurationData( path ); + if (availableNode != null) { + String errMsg = "Post Configuration via Restconf was not executed because data already exists"; + BrokerFacade.LOG.warn((new StringBuilder(errMsg)).append(" : ").append(path).toString()); + // FIXME: return correct ietf-restconf:errors -> follow specification + // (http://tools.ietf.org/html/draft-bierman-netconf-restconf-03#page-48) + throw new ResponseException(Status.CONFLICT, errMsg); + } + BrokerFacade.LOG.trace( "Post Configuration via Restconf: {}", path ); + transaction.putConfigurationData( path, payload ); + return transaction.commit(); + } + + public Future> commitConfigurationDataDelete( final InstanceIdentifier path ) { + this.checkPreconditions(); + + final DataModificationTransaction transaction = dataService.beginTransaction(); + LOG.info( "Delete Configuration via Restconf: {}", path ); + transaction.removeConfigurationData( path ); + return transaction.commit(); + } + + public Future> commitConfigurationDataDeleteBehindMountPoint( + final MountInstance mountPoint, final InstanceIdentifier path ) { + this.checkPreconditions(); + + final DataModificationTransaction transaction = mountPoint.beginTransaction(); + LOG.info( "Delete Configuration via Restconf: {}", path ); + transaction.removeConfigurationData( path ); + return transaction.commit(); + } + + public void registerToListenDataChanges( final ListenerAdapter listener ) { + this.checkPreconditions(); + + if( listener.isListening() ) { + return; + } + + InstanceIdentifier path = listener.getPath(); + final ListenerRegistration registration = + dataService.registerDataChangeListener( path, listener ); + + listener.setRegistration( registration ); + } +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend deleted file mode 100644 index d3050061da..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend +++ /dev/null @@ -1,146 +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 javax.ws.rs.core.Response -import org.opendaylight.controller.md.sal.common.api.data.DataReader -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession -import org.opendaylight.controller.sal.core.api.data.DataBrokerService -import org.opendaylight.controller.sal.core.api.mount.MountInstance -import org.opendaylight.controller.sal.rest.impl.RestconfProvider -import org.opendaylight.controller.sal.streams.listeners.ListenerAdapter -import org.opendaylight.yangtools.yang.common.QName -import org.opendaylight.yangtools.yang.common.RpcResult -import org.opendaylight.yangtools.yang.data.api.CompositeNode -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier -import org.slf4j.LoggerFactory - -class BrokerFacade implements DataReader { - - - val static LOG = LoggerFactory.getLogger(BrokerFacade) - val static BrokerFacade INSTANCE = new BrokerFacade - - @Property - private ConsumerSession context; - - @Property - private DataBrokerService dataService; - - private new() { - if (INSTANCE !== null) { - throw new IllegalStateException("Already instantiated"); - } - } - - def static BrokerFacade getInstance() { - return INSTANCE - } - - private def void checkPreconditions() { - if (context === null || dataService === null) { - throw new ResponseException(Response.Status.SERVICE_UNAVAILABLE, RestconfProvider::NOT_INITALIZED_MSG) - } - } - - override readConfigurationData(InstanceIdentifier path) { - checkPreconditions - LOG.trace("Read Configuration via Restconf: {}", path) - return dataService.readConfigurationData(path); - } - - def readConfigurationDataBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path) { - checkPreconditions - LOG.trace("Read Configuration via Restconf: {}", path) - return mountPoint.readConfigurationData(path); - } - - override readOperationalData(InstanceIdentifier path) { - checkPreconditions - LOG.trace("Read Operational via Restconf: {}", path) - return dataService.readOperationalData(path); - } - - def readOperationalDataBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path) { - checkPreconditions - LOG.trace("Read Operational via Restconf: {}", path) - return mountPoint.readOperationalData(path); - } - - def RpcResult invokeRpc(QName type, CompositeNode payload) { - checkPreconditions - val future = context.rpc(type, payload); - return future.get; - } - - def commitConfigurationDataPut(InstanceIdentifier path, CompositeNode payload) { - checkPreconditions - val transaction = dataService.beginTransaction; - LOG.trace("Put Configuration via Restconf: {}", path) - transaction.putConfigurationData(path, payload); - return transaction.commit - } - - def commitConfigurationDataPutBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path, CompositeNode payload) { - checkPreconditions - val transaction = mountPoint.beginTransaction; - LOG.trace("Put Configuration via Restconf: {}", path) - transaction.putConfigurationData(path, payload); - return transaction.commit - } - - def commitConfigurationDataPost(InstanceIdentifier path, CompositeNode payload) { - checkPreconditions - val transaction = dataService.beginTransaction; - transaction.putConfigurationData(path, payload); - if (payload == transaction.createdConfigurationData.get(path)) { - LOG.trace("Post Configuration via Restconf: {}", path) - return transaction.commit - } - LOG.trace("Post Configuration via Restconf was not executed because data already exists: {}", path) - return null; - } - - def commitConfigurationDataPostBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path, CompositeNode payload) { - checkPreconditions - val transaction = mountPoint.beginTransaction; - transaction.putConfigurationData(path, payload); - if (payload == transaction.createdConfigurationData.get(path)) { - LOG.trace("Post Configuration via Restconf: {}", path) - return transaction.commit - } - LOG.trace("Post Configuration via Restconf was not executed because data already exists: {}", path) - return null; - } - - def commitConfigurationDataDelete(InstanceIdentifier path) { - checkPreconditions - val transaction = dataService.beginTransaction; - LOG.info("Delete Configuration via Restconf: {}", path) - transaction.removeConfigurationData(path) - return transaction.commit - } - - def commitConfigurationDataDeleteBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path) { - checkPreconditions - val transaction = mountPoint.beginTransaction; - LOG.info("Delete Configuration via Restconf: {}", path) - transaction.removeConfigurationData(path) - return transaction.commit - } - - def registerToListenDataChanges(ListenerAdapter listener) { - checkPreconditions - if (listener.listening) { - return; - } - val registration = dataService.registerDataChangeListener(listener.path, listener) - listener.setRegistration(registration) - } - -} 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 new file mode 100644 index 0000000000..1c076d1e2e --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java @@ -0,0 +1,912 @@ +/** + * 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.BiMap; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; + +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.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import javax.ws.rs.core.Response.Status; + +import org.opendaylight.controller.sal.core.api.mount.MountInstance; +import org.opendaylight.controller.sal.core.api.mount.MountService; +import org.opendaylight.controller.sal.rest.impl.RestUtil; +import org.opendaylight.controller.sal.rest.impl.RestconfProvider; +import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode; +import org.opendaylight.controller.sal.restconf.impl.ResponseException; +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.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; +import org.opendaylight.yangtools.yang.model.api.ChoiceNode; +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.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.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 final BiMap uriToModuleName = HashBiMap. create(); + + private final Map moduleNameToUri = uriToModuleName.inverse(); + + private final Map qnameToRpc = new ConcurrentHashMap<>(); + + private volatile SchemaContext globalSchema; + private volatile MountService mountService; + + public void setGlobalSchema( final SchemaContext globalSchema ) { + this.globalSchema = globalSchema; + } + + public void setMountService( final MountService mountService ) { + this.mountService = mountService; + } + + private ControllerContext() { + } + + public static ControllerContext getInstance() { + return ControllerContext.INSTANCE; + } + + private void checkPreconditions() { + if( globalSchema == null ) { + throw new ResponseException( Status.SERVICE_UNAVAILABLE, RestconfProvider.NOT_INITALIZED_MSG ); + } + } + + public void setSchemas( final SchemaContext schemas ) { + this.onGlobalContextUpdated( schemas ); + } + + public InstanceIdWithSchemaNode toInstanceIdentifier( final String restconfInstance ) { + return this.toIdentifier( restconfInstance, false ); + } + + public InstanceIdWithSchemaNode toMountPointIdentifier( final String restconfInstance ) { + return this.toIdentifier( restconfInstance, true ); + } + + private InstanceIdWithSchemaNode toIdentifier( final String restconfInstance, + final boolean toMountPointIdentifier ) { + this.checkPreconditions(); + + Iterable split = Splitter.on( "/" ).split( restconfInstance ); + final ArrayList encodedPathArgs = Lists. newArrayList( split ); + final List pathArgs = this.urlPathArgsDecode( encodedPathArgs ); + this.omitFirstAndLastEmptyString( pathArgs ); + if( pathArgs.isEmpty() ) { + return null; + } + + String first = pathArgs.iterator().next(); + final String startModule = ControllerContext.toModuleName( first ); + if( startModule == null ) { + throw new ResponseException( Status.BAD_REQUEST, + "First node in URI has to be in format \"moduleName:nodeName\"" ); + } + + InstanceIdentifierBuilder builder = InstanceIdentifier.builder(); + Module latestModule = this.getLatestModule( globalSchema, startModule ); + InstanceIdWithSchemaNode iiWithSchemaNode = this.collectPathArguments( builder, pathArgs, + latestModule, null, toMountPointIdentifier ); + + if( iiWithSchemaNode == null ) { + throw new ResponseException( Status.BAD_REQUEST, "URI has bad format" ); + } + + return iiWithSchemaNode; + } + + private List omitFirstAndLastEmptyString( final List list ) { + if( list.isEmpty() ) { + return list; + } + + String head = list.iterator().next(); + if( head.isEmpty() ) { + list.remove( 0 ); + } + + if( list.isEmpty() ) { + return list; + } + + String last = list.get( list.size() - 1 ); + if( last.isEmpty() ) { + list.remove( list.size() - 1 ); + } + + return list; + } + + private Module getLatestModule( final SchemaContext schema, final String moduleName ) { + Preconditions.checkArgument( schema != null ); + Preconditions.checkArgument( moduleName != null && !moduleName.isEmpty() ); + + Predicate filter = new Predicate() { + @Override + public boolean apply( Module m ) { + return Objects.equal( m.getName(), moduleName ); + } + }; + + Iterable modules = Iterables.filter( schema.getModules(), filter ); + return this.filterLatestModule( modules ); + } + + private Module filterLatestModule( final Iterable modules ) { + Module latestModule = modules.iterator().hasNext() ? modules.iterator().next() : null; + for( final Module module : modules ) { + if( module.getRevision().after( latestModule.getRevision() ) ) { + latestModule = module; + } + } + return latestModule; + } + + public Module findModuleByName( final String moduleName ) { + this.checkPreconditions(); + Preconditions.checkArgument( moduleName != null && !moduleName.isEmpty() ); + return this.getLatestModule( globalSchema, moduleName ); + } + + public Module findModuleByName( final MountInstance mountPoint, final String moduleName ) { + Preconditions.checkArgument( moduleName != null && mountPoint != null ); + + final SchemaContext mountPointSchema = mountPoint.getSchemaContext(); + return mountPointSchema == null ? null : this.getLatestModule( mountPointSchema, moduleName ); + } + + public Module findModuleByNamespace( final URI namespace ) { + this.checkPreconditions(); + Preconditions.checkArgument( namespace != null ); + + final Set moduleSchemas = globalSchema.findModuleByNamespace( namespace ); + return moduleSchemas == null ? null : this.filterLatestModule( moduleSchemas ); + } + + public Module findModuleByNamespace( final MountInstance mountPoint, final URI namespace ) { + Preconditions.checkArgument( namespace != null && mountPoint != null ); + + final SchemaContext mountPointSchema = mountPoint.getSchemaContext(); + Set moduleSchemas = mountPointSchema == null ? null : + mountPointSchema.findModuleByNamespace( namespace ); + return moduleSchemas == null ? null : this.filterLatestModule( moduleSchemas ); + } + + public Module findModuleByNameAndRevision( final QName module ) { + this.checkPreconditions(); + Preconditions.checkArgument( module != null && module.getLocalName() != null && + module.getRevision() != null ); + + return globalSchema.findModuleByName( module.getLocalName(), module.getRevision() ); + } + + public Module findModuleByNameAndRevision( final MountInstance mountPoint, final QName module ) { + this.checkPreconditions(); + Preconditions.checkArgument( module != null && module.getLocalName() != null && + module.getRevision() != null && mountPoint != null ); + + SchemaContext schemaContext = mountPoint.getSchemaContext(); + return schemaContext == null ? null : + schemaContext.findModuleByName( module.getLocalName(), module.getRevision() ); + } + + public DataNodeContainer getDataNodeContainerFor( final InstanceIdentifier path ) { + this.checkPreconditions(); + + final List elements = path.getPath(); + 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 ) { + QName _nodeType = element.getNodeType(); + final DataSchemaNode potentialNode = ControllerContext.childByQName( node, _nodeType ); + if( potentialNode == null || !this.isListOrContainer( potentialNode ) ) { + return null; + } + node = (DataNodeContainer) potentialNode; + } + + return node; + } + + public String toFullRestconfIdentifier( final InstanceIdentifier path ) { + this.checkPreconditions(); + + final List elements = path.getPath(); + final StringBuilder builder = new StringBuilder(); + 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 ) { + QName _nodeType = element.getNodeType(); + final DataSchemaNode potentialNode = ControllerContext.childByQName( node, _nodeType ); + if( !this.isListOrContainer( potentialNode ) ) { + return null; + } + node = ((DataNodeContainer) potentialNode); + builder.append( this.convertToRestconfIdentifier( element, node ) ); + } + + return builder.toString(); + } + + public String findModuleNameByNamespace( final URI namespace ) { + this.checkPreconditions(); + + String moduleName = this.uriToModuleName.get( namespace ); + if( moduleName == null ) { + final Module module = this.findModuleByNamespace( namespace ); + if( module != null ) { + moduleName = module.getName(); + this.uriToModuleName.put( namespace, moduleName ); + } + } + + return moduleName; + } + + public String findModuleNameByNamespace( final MountInstance mountPoint, final URI namespace ) { + final Module module = this.findModuleByNamespace( mountPoint, namespace ); + return module == null ? null : module.getName(); + } + + public URI findNamespaceByModuleName( final String moduleName ) { + URI namespace = this.moduleNameToUri.get( moduleName ); + if( namespace == null ) { + Module module = this.findModuleByName( moduleName ); + if( module != null ) { + URI _namespace = module.getNamespace(); + namespace = _namespace; + this.uriToModuleName.put( namespace, moduleName ); + } + } + return namespace; + } + + public URI findNamespaceByModuleName( final MountInstance mountPoint, final String moduleName ) { + final Module module = this.findModuleByName( mountPoint, moduleName ); + return module == null ? null : module.getNamespace(); + } + + public Set getAllModules( final MountInstance mountPoint ) { + this.checkPreconditions(); + + SchemaContext schemaContext = mountPoint == null ? null : mountPoint.getSchemaContext(); + return schemaContext == null ? null : schemaContext.getModules(); + } + + public Set getAllModules() { + this.checkPreconditions(); + return globalSchema.getModules(); + } + + public CharSequence toRestconfIdentifier( final QName qname ) { + this.checkPreconditions(); + + String module = this.uriToModuleName.get( qname.getNamespace() ); + if( module == null ) { + final Module moduleSchema = globalSchema.findModuleByNamespaceAndRevision( + qname.getNamespace(), qname.getRevision() ); + if( moduleSchema == null ) { + return null; + } + + this.uriToModuleName.put( qname.getNamespace(), moduleSchema.getName() ); + module = moduleSchema.getName(); + } + + StringBuilder builder = new StringBuilder(); + builder.append( module ); + builder.append( ":" ); + builder.append( qname.getLocalName() ); + return builder.toString(); + } + + public CharSequence toRestconfIdentifier( final MountInstance mountPoint, final QName qname ) { + if( mountPoint == null ) { + return null; + } + + SchemaContext schemaContext = mountPoint.getSchemaContext(); + + final Module moduleSchema = schemaContext.findModuleByNamespaceAndRevision( + qname.getNamespace(), qname.getRevision() ); + if( moduleSchema == null ) { + return null; + } + + StringBuilder builder = new StringBuilder(); + builder.append( moduleSchema.getName() ); + builder.append( ":" ); + builder.append( qname.getLocalName() ); + return builder.toString(); + } + + private static DataSchemaNode childByQName( final ChoiceNode 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 ) { + DataSchemaNode ret = container.getDataChildByName( name ); + if( ret == null ) { + for( final DataSchemaNode node : container.getChildNodes() ) { + if( (node instanceof ChoiceCaseNode) ) { + final ChoiceCaseNode caseNode = ((ChoiceCaseNode) node); + DataSchemaNode childByQName = ControllerContext.childByQName( caseNode, name ); + if( childByQName != null ) { + return childByQName; + } + } + } + } + return ret; + } + + private String toUriString( final Object object ) throws UnsupportedEncodingException { + return object == null ? "" : + URLEncoder.encode( object.toString(), ControllerContext.URI_ENCODING_CHAR_SET ); + } + + private InstanceIdWithSchemaNode collectPathArguments( final InstanceIdentifierBuilder builder, + final List strings, final DataNodeContainer parentNode, final MountInstance mountPoint, + final boolean returnJustMountPoint ) { + Preconditions.> checkNotNull( strings ); + + if( parentNode == null ) { + return null; + } + + if( strings.isEmpty() ) { + return new InstanceIdWithSchemaNode( builder.toInstance(), + ((DataSchemaNode) parentNode), mountPoint ); + } + + String head = strings.iterator().next(); + final String nodeName = this.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 ResponseException( Status.BAD_REQUEST, + "Restconf supports just one mount point in URI." ); + } + + if( mountService == null ) { + throw new ResponseException( Status.SERVICE_UNAVAILABLE, + "MountService was not found. Finding behind mount points does not work." ); + } + + final InstanceIdentifier partialPath = builder.toInstance(); + final MountInstance mount = mountService.getMountPoint( partialPath ); + if( mount == null ) { + LOG.debug( "Instance identifier to missing mount point: {}", partialPath ); + throw new ResponseException( Status.BAD_REQUEST, + "Mount point does not exist." ); + } + + final SchemaContext mountPointSchema = mount.getSchemaContext(); + if( mountPointSchema == null ) { + throw new ResponseException( Status.BAD_REQUEST, + "Mount point does not contain any schema with modules." ); + } + + if( returnJustMountPoint ) { + InstanceIdentifier instance = InstanceIdentifier.builder().toInstance(); + return new InstanceIdWithSchemaNode( instance, mountPointSchema, mount ); + } + + if( strings.size() == 1 ) { + InstanceIdentifier instance = InstanceIdentifier.builder().toInstance(); + return new InstanceIdWithSchemaNode( instance, mountPointSchema, mount ); + } + + final String moduleNameBehindMountPoint = toModuleName( strings.get( 1 ) ); + if( moduleNameBehindMountPoint == null ) { + throw new ResponseException( Status.BAD_REQUEST, + "First node after mount point in URI has to be in format \"moduleName:nodeName\"" ); + } + + final Module moduleBehindMountPoint = this.getLatestModule( mountPointSchema, + moduleNameBehindMountPoint ); + if( moduleBehindMountPoint == null ) { + throw new ResponseException( Status.BAD_REQUEST, + "URI has bad format. \"" + moduleName + + "\" module does not exist in mount point." ); + } + + List subList = strings.subList( 1, strings.size() ); + return this.collectPathArguments( InstanceIdentifier.builder(), subList, moduleBehindMountPoint, + mount, returnJustMountPoint ); + } + + Module module = null; + if( mountPoint == null ) { + module = this.getLatestModule( globalSchema, moduleName ); + if( module == null ) { + throw new ResponseException( Status.BAD_REQUEST, + "URI has bad format. \"" + moduleName + "\" module does not exist." ); + } + } + else { + SchemaContext schemaContext = mountPoint.getSchemaContext(); + module = schemaContext == null ? null : + this.getLatestModule( schemaContext, moduleName ); + if( module == null ) { + throw new ResponseException( Status.BAD_REQUEST, + "URI has bad format. \"" + moduleName + + "\" module does not exist in mount point." ); + } + } + + targetNode = this.findInstanceDataChildByNameAndNamespace( + parentNode, nodeName, module.getNamespace() );; + if( targetNode == null ) { + throw new ResponseException( Status.BAD_REQUEST, + "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 + "\"." ); + } + } else { + final List potentialSchemaNodes = + this.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 ResponseException( Status.BAD_REQUEST, + "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() ); + } + + if( potentialSchemaNodes.isEmpty() ) { + throw new ResponseException( Status.BAD_REQUEST, "URI has bad format. \"" + nodeName + + "\" was not found in parent data node.\n" ); + } + + targetNode = potentialSchemaNodes.iterator().next(); + } + + if( !this.isListOrContainer( targetNode ) ) { + throw new ResponseException( Status.BAD_REQUEST, + "URI has bad format. Node \"" + head + + "\" must be Container or List yang type." ); + } + + 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 ResponseException( Status.BAD_REQUEST, "Missing key for list \"" + + listNode.getQName().getLocalName() + "\"." ); + } + + 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 ResponseException( Status.BAD_REQUEST, + "URI has bad format. List \"" + listNode.getQName().getLocalName() + + "\" cannot contain \"null\" value as a key." ); + } + + this.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 this.collectPathArguments( builder, remaining, + ((DataNodeContainer) targetNode), mountPoint, returnJustMountPoint ); + } + + return new InstanceIdWithSchemaNode( builder.toInstance(), targetNode, mountPoint ); + } + + public DataSchemaNode findInstanceDataChildByNameAndNamespace( final DataNodeContainer container, + final String name, final URI namespace ) { + Preconditions. checkNotNull( namespace ); + + final List potentialSchemaNodes = this.findInstanceDataChildrenByName( container, name ); + + Predicate filter = new Predicate() { + @Override + public boolean apply( DataSchemaNode node ) { + return Objects.equal( node.getQName().getNamespace(), namespace ); + } + }; + + Iterable result = Iterables.filter( potentialSchemaNodes, filter ); + return Iterables.getFirst( result, null ); + } + + public List findInstanceDataChildrenByName( final DataNodeContainer container, + final String name ) { + Preconditions. checkNotNull( container ); + Preconditions. checkNotNull( name ); + + List instantiatedDataNodeContainers = new ArrayList(); + this.collectInstanceDataNodeContainers( instantiatedDataNodeContainers, container, name ); + return instantiatedDataNodeContainers; + } + + private void collectInstanceDataNodeContainers( final List potentialSchemaNodes, + final DataNodeContainer container, final String name ) { + + Set childNodes = container.getChildNodes(); + + Predicate filter = new Predicate() { + @Override + public boolean apply( DataSchemaNode node ) { + return Objects.equal( node.getQName().getLocalName(), name ); + } + }; + + Iterable nodes = Iterables.filter( childNodes, 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( this.isInstantiatedDataSchema( potentialNode ) ) { + potentialSchemaNodes.add( potentialNode ); + } + } + + Iterable choiceNodes = Iterables. filter( container.getChildNodes(), + ChoiceNode.class ); + + final Function> choiceFunction = + new Function>() { + @Override + public Set apply( final ChoiceNode node ) { + return node.getCases(); + } + }; + + Iterable> map = Iterables.> transform( + choiceNodes, choiceFunction ); + + final Iterable allCases = Iterables. concat( map ); + for( final ChoiceCaseNode caze : allCases ) { + this.collectInstanceDataNodeContainers( potentialSchemaNodes, caze, name ); + } + } + + public boolean isInstantiatedDataSchema( final DataSchemaNode node ) { + return node instanceof LeafSchemaNode || node instanceof LeafListSchemaNode || + node instanceof ContainerSchemaNode || node instanceof ListSchemaNode; + } + + private void addKeyValue( final HashMap map, final DataSchemaNode node, + final String uriValue, final MountInstance mountPoint ) { + Preconditions. checkNotNull( uriValue ); + Preconditions.checkArgument( (node instanceof LeafSchemaNode) ); + + final String urlDecoded = urlPathArgDecode( uriValue ); + final TypeDefinition typedef = ((LeafSchemaNode) node).getType(); + Codec codec = RestCodec.from( typedef, mountPoint ); + + Object decoded = codec == null ? null : codec.deserialize( urlDecoded ); + String additionalInfo = ""; + if( decoded == null ) { + TypeDefinition baseType = RestUtil.resolveBaseTypeFrom( typedef ); + if( (baseType instanceof IdentityrefTypeDefinition) ) { + decoded = this.toQName( urlDecoded ); + additionalInfo = "For key which is of type identityref it should be in format module_name:identity_name."; + } + } + + if( decoded == null ) { + throw new ResponseException( Status.BAD_REQUEST, uriValue + " from URI can\'t be resolved. " + + additionalInfo ); + } + + map.put( node.getQName(), decoded ); + } + + private static String toModuleName( final String str ) { + Preconditions. checkNotNull( str ); + if( str.contains( ":" ) ) { + final String[] args = str.split( ":" ); + if( args.length == 2 ) { + return args[0]; + } + } + return null; + } + + private String toNodeName( final String str ) { + if( str.contains( ":" ) ) { + final String[] args = str.split( ":" ); + if( args.length == 2 ) { + return args[1]; + } + } + return str; + } + + private QName toQName( final String name ) { + final String module = toModuleName( name ); + final String node = this.toNodeName( name ); + Set modules = globalSchema.getModules(); + + final Comparator comparator = new Comparator() { + @Override + public int compare( final Module o1, final Module o2 ) { + return o1.getRevision().compareTo( o2.getRevision() ); + } + }; + + List sorted = new ArrayList( modules ); + Collections. sort( new ArrayList( modules ), comparator ); + + final Function transform = new Function() { + @Override + public QName apply( final Module m ) { + return QName.create( m.getNamespace(), m.getRevision(), m.getName() ); + } + }; + + final Predicate findFirst = new Predicate() { + @Override + public boolean apply( final QName qn ) { + return Objects.equal( module, qn.getLocalName() ); + } + }; + + Optional namespace = FluentIterable.from( sorted ) + .transform( transform ) + .firstMatch( findFirst ); + return namespace.isPresent() ? QName.create( namespace.get(), node ) : null; + } + + private boolean isListOrContainer( final DataSchemaNode node ) { + return node instanceof ListSchemaNode || node instanceof ContainerSchemaNode; + } + + public RpcDefinition getRpcDefinition( final String name ) { + final QName validName = this.toQName( name ); + return validName == null ? null : this.qnameToRpc.get( validName ); + } + + @Override + public void onGlobalContextUpdated( final SchemaContext context ) { + if( context != null ) { + this.qnameToRpc.clear(); + this.setGlobalSchema( context ); + Set _operations = context.getOperations(); + for( final RpcDefinition operation : _operations ) { + { + this.qnameToRpc.put( operation.getQName(), operation ); + } + } + } + } + + public List urlPathArgsDecode( final List strings ) { + try { + List decodedPathArgs = new ArrayList(); + for( final String pathArg : strings ) { + String _decode = URLDecoder.decode( pathArg, URI_ENCODING_CHAR_SET ); + decodedPathArgs.add( _decode ); + } + return decodedPathArgs; + } + catch( UnsupportedEncodingException e ) { + throw new ResponseException( Status.BAD_REQUEST, + "Invalid URL path '" + strings + "': " + e.getMessage() ); + } + } + + public String urlPathArgDecode( final String pathArg ) { + if( pathArg != null ) { + try { + return URLDecoder.decode( pathArg, URI_ENCODING_CHAR_SET ); + } + catch( UnsupportedEncodingException e ) { + throw new ResponseException( Status.BAD_REQUEST, + "Invalid URL path arg '" + pathArg + "': " + e.getMessage() ); + } + } + + return null; + } + + private CharSequence convertToRestconfIdentifier( final PathArgument argument, + final DataNodeContainer node ) { + if( argument instanceof NodeIdentifier && node instanceof ContainerSchemaNode ) { + return convertToRestconfIdentifier( (NodeIdentifier) argument, (ContainerSchemaNode) node ); + } + else if( argument instanceof NodeIdentifierWithPredicates && node instanceof ListSchemaNode ) { + return convertToRestconfIdentifier( (NodeIdentifierWithPredicates) argument, (ListSchemaNode) node ); + } + 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 ContainerSchemaNode node ) { + StringBuilder builder = new StringBuilder(); + builder.append( "/" ); + QName nodeType = argument.getNodeType(); + builder.append( this.toRestconfIdentifier( nodeType ) ); + return builder.toString(); + } + + private CharSequence convertToRestconfIdentifier( final NodeIdentifierWithPredicates argument, + final ListSchemaNode node ) { + QName nodeType = argument.getNodeType(); + final CharSequence nodeIdentifier = this.toRestconfIdentifier( nodeType ); + final Map keyValues = argument.getKeyValues(); + + StringBuilder builder = new StringBuilder(); + builder.append( "/" ); + builder.append( nodeIdentifier ); + builder.append( "/" ); + + List keyDefinition = node.getKeyDefinition(); + boolean hasElements = false; + for( final QName key : keyDefinition ) { + if( !hasElements ) { + hasElements = true; + } + else { + builder.append( "/" ); + } + + try { + builder.append( this.toUriString( keyValues.get( key ) ) ); + } catch( UnsupportedEncodingException e ) { + LOG.error( "Error parsing URI: " + keyValues.get( key ), e ); + return null; + } + } + + 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 ChoiceNode ) { + return childByQName( (ChoiceNode) 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() ); + } + } +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend deleted file mode 100644 index cb02fc89bf..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend +++ /dev/null @@ -1,637 +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.Preconditions -import com.google.common.base.Splitter -import com.google.common.collect.BiMap -import com.google.common.collect.FluentIterable -import com.google.common.collect.HashBiMap -import com.google.common.collect.Lists -import java.net.URI -import java.net.URLDecoder -import java.net.URLEncoder -import java.util.ArrayList -import java.util.HashMap -import java.util.List -import java.util.Map -import java.util.concurrent.ConcurrentHashMap -import org.opendaylight.controller.sal.core.api.mount.MountInstance -import org.opendaylight.controller.sal.core.api.mount.MountService -import org.opendaylight.controller.sal.rest.impl.RestUtil -import org.opendaylight.controller.sal.rest.impl.RestconfProvider -import org.opendaylight.yangtools.yang.common.QName -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument -import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec -import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode -import org.opendaylight.yangtools.yang.model.api.ChoiceNode -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.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.type.IdentityrefTypeDefinition -import org.slf4j.LoggerFactory - -import static com.google.common.base.Preconditions.* -import static javax.ws.rs.core.Response.Status.* - -class ControllerContext implements SchemaContextListener { - val static LOG = LoggerFactory.getLogger(ControllerContext) - val static ControllerContext INSTANCE = new ControllerContext - val static NULL_VALUE = "null" - val static MOUNT_MODULE = "yang-ext" - val static MOUNT_NODE = "mount" - public val static MOUNT = "yang-ext:mount" - val static URI_ENCODING_CHAR_SET = "ISO-8859-1" - val static URI_SLASH_PLACEHOLDER = "%2F"; - - @Property - var SchemaContext globalSchema; - - @Property - var MountService mountService; - - private val BiMap uriToModuleName = HashBiMap.create(); - private val Map moduleNameToUri = uriToModuleName.inverse(); - private val Map qnameToRpc = new ConcurrentHashMap(); - - private new() { - if (INSTANCE !== null) { - throw new IllegalStateException("Already instantiated"); - } - } - - static def getInstance() { - return INSTANCE - } - - private def void checkPreconditions() { - if (globalSchema === null) { - throw new ResponseException(SERVICE_UNAVAILABLE, RestconfProvider::NOT_INITALIZED_MSG) - } - } - - def setSchemas(SchemaContext schemas) { - onGlobalContextUpdated(schemas) - } - - def InstanceIdWithSchemaNode toInstanceIdentifier(String restconfInstance) { - return restconfInstance.toIdentifier(false) - } - - def InstanceIdWithSchemaNode toMountPointIdentifier(String restconfInstance) { - return restconfInstance.toIdentifier(true) - } - - private def InstanceIdWithSchemaNode toIdentifier(String restconfInstance, boolean toMountPointIdentifier) { - checkPreconditions - val encodedPathArgs = Lists.newArrayList(Splitter.on("/").split(restconfInstance)) - val pathArgs = urlPathArgsDecode(encodedPathArgs) - pathArgs.omitFirstAndLastEmptyString - if (pathArgs.empty) { - return null; - } - val startModule = pathArgs.head.toModuleName(); - if (startModule === null) { - throw new ResponseException(BAD_REQUEST, "First node in URI has to be in format \"moduleName:nodeName\"") - } - var InstanceIdWithSchemaNode iiWithSchemaNode = null; - if (toMountPointIdentifier) { - iiWithSchemaNode = collectPathArguments(InstanceIdentifier.builder(), pathArgs, - globalSchema.getLatestModule(startModule), null, true); - } else { - iiWithSchemaNode = collectPathArguments(InstanceIdentifier.builder(), pathArgs, - globalSchema.getLatestModule(startModule), null, false); - } - if (iiWithSchemaNode === null) { - throw new ResponseException(BAD_REQUEST, "URI has bad format") - } - return iiWithSchemaNode - } - - private def omitFirstAndLastEmptyString(List list) { - if (list.empty) { - return list; - } - if (list.head.empty) { - list.remove(0) - } - if (list.empty) { - return list; - } - if (list.last.empty) { - list.remove(list.indexOf(list.last)) - } - return list; - } - - private def getLatestModule(SchemaContext schema, String moduleName) { - checkArgument(schema !== null); - checkArgument(moduleName !== null && !moduleName.empty) - val modules = schema.modules.filter[m|m.name == moduleName] - return modules.filterLatestModule - } - - private def filterLatestModule(Iterable modules) { - var latestModule = modules.head - for (module : modules) { - if (module.revision.after(latestModule.revision)) { - latestModule = module - } - } - return latestModule - } - - def findModuleByName(String moduleName) { - checkPreconditions - checkArgument(moduleName !== null && !moduleName.empty) - return globalSchema.getLatestModule(moduleName) - } - - def findModuleByName(MountInstance mountPoint, String moduleName) { - checkArgument(moduleName !== null && mountPoint !== null) - val mountPointSchema = mountPoint.schemaContext; - return mountPointSchema?.getLatestModule(moduleName); - } - - def findModuleByNamespace(URI namespace) { - checkPreconditions - checkArgument(namespace !== null) - val moduleSchemas = globalSchema.findModuleByNamespace(namespace) - return moduleSchemas?.filterLatestModule - } - - def findModuleByNamespace(MountInstance mountPoint, URI namespace) { - checkArgument(namespace !== null && mountPoint !== null) - val mountPointSchema = mountPoint.schemaContext; - val moduleSchemas = mountPointSchema?.findModuleByNamespace(namespace) - return moduleSchemas?.filterLatestModule - } - - def findModuleByNameAndRevision(QName module) { - checkPreconditions - checkArgument(module !== null && module.localName !== null && module.revision !== null) - return globalSchema.findModuleByName(module.localName, module.revision) - } - - def findModuleByNameAndRevision(MountInstance mountPoint, QName module) { - checkPreconditions - checkArgument(module !== null && module.localName !== null && module.revision !== null && mountPoint !== null) - return mountPoint.schemaContext?.findModuleByName(module.localName, module.revision) - } - - def getDataNodeContainerFor(InstanceIdentifier path) { - checkPreconditions - val elements = path.path; - val startQName = elements.head.nodeType; - val initialModule = globalSchema.findModuleByNamespaceAndRevision(startQName.namespace, startQName.revision) - var node = initialModule as DataNodeContainer; - for (element : elements) { - val potentialNode = node.childByQName(element.nodeType); - if (potentialNode === null || !potentialNode.listOrContainer) { - return null - } - node = potentialNode as DataNodeContainer - } - return node - } - - def String toFullRestconfIdentifier(InstanceIdentifier path) { - checkPreconditions - val elements = path.path; - val ret = new StringBuilder(); - val startQName = elements.head.nodeType; - val initialModule = globalSchema.findModuleByNamespaceAndRevision(startQName.namespace, startQName.revision) - var node = initialModule as DataNodeContainer; - for (element : elements) { - val potentialNode = node.childByQName(element.nodeType); - if (!potentialNode.listOrContainer) { - return null - } - node = potentialNode as DataNodeContainer - ret.append(element.convertToRestconfIdentifier(node)); - } - return ret.toString - } - - private def dispatch CharSequence convertToRestconfIdentifier(NodeIdentifier argument, ContainerSchemaNode node) { - '''/«argument.nodeType.toRestconfIdentifier()»''' - } - - private def dispatch CharSequence convertToRestconfIdentifier(NodeIdentifierWithPredicates argument, ListSchemaNode node) { - val nodeIdentifier = argument.nodeType.toRestconfIdentifier(); - val keyValues = argument.keyValues; - return '''/«nodeIdentifier»/«FOR key : node.keyDefinition SEPARATOR "/"»«keyValues.get(key).toUriString»«ENDFOR»''' - } - - private def dispatch CharSequence convertToRestconfIdentifier(PathArgument argument, DataNodeContainer node) { - throw new IllegalArgumentException("Conversion of generic path argument is not supported"); - } - - def findModuleNameByNamespace(URI namespace) { - checkPreconditions - var moduleName = uriToModuleName.get(namespace) - if (moduleName === null) { - val module = findModuleByNamespace(namespace) - if (module === null) return null - moduleName = module.name - uriToModuleName.put(namespace, moduleName) - } - return moduleName - } - - def findModuleNameByNamespace(MountInstance mountPoint, URI namespace) { - val module = mountPoint.findModuleByNamespace(namespace); - return module?.name - } - - def findNamespaceByModuleName(String moduleName) { - var namespace = moduleNameToUri.get(moduleName) - if (namespace === null) { - var module = findModuleByName(moduleName) - if(module === null) return null - namespace = module.namespace - uriToModuleName.put(namespace, moduleName) - } - return namespace - } - - def findNamespaceByModuleName(MountInstance mountPoint, String moduleName) { - val module = mountPoint.findModuleByName(moduleName) - return module?.namespace - } - - def getAllModules(MountInstance mountPoint) { - checkPreconditions - return mountPoint?.schemaContext?.modules - } - - def getAllModules() { - checkPreconditions - return globalSchema.modules - } - - def CharSequence toRestconfIdentifier(QName qname) { - checkPreconditions - var module = uriToModuleName.get(qname.namespace) - if (module === null) { - val moduleSchema = globalSchema.findModuleByNamespaceAndRevision(qname.namespace, qname.revision); - if(moduleSchema === null) return null - uriToModuleName.put(qname.namespace, moduleSchema.name) - module = moduleSchema.name; - } - return '''«module»:«qname.localName»'''; - } - - def CharSequence toRestconfIdentifier(MountInstance mountPoint, QName qname) { - val moduleSchema = mountPoint?.schemaContext.findModuleByNamespaceAndRevision(qname.namespace, qname.revision); - if(moduleSchema === null) return null - val module = moduleSchema.name; - return '''«module»:«qname.localName»'''; - } - - private static dispatch def DataSchemaNode childByQName(ChoiceNode container, QName name) { - for (caze : container.cases) { - val ret = caze.childByQName(name) - if (ret !== null) { - return ret; - } - } - return null; - } - - private static dispatch def DataSchemaNode childByQName(ChoiceCaseNode container, QName name) { - val ret = container.getDataChildByName(name); - return ret; - } - - private static dispatch def DataSchemaNode childByQName(ContainerSchemaNode container, QName name) { - return container.dataNodeChildByQName(name); - } - - private static dispatch def DataSchemaNode childByQName(ListSchemaNode container, QName name) { - return container.dataNodeChildByQName(name); - } - - private static dispatch def DataSchemaNode childByQName(Module container, QName name) { - return container.dataNodeChildByQName(name); - } - - private static dispatch def DataSchemaNode childByQName(DataSchemaNode container, QName name) { - return null; - } - - private static def DataSchemaNode dataNodeChildByQName(DataNodeContainer container, QName name) { - var ret = container.getDataChildByName(name); - if (ret === null) { - - // Find in Choice Cases - for (node : container.childNodes) { - if (node instanceof ChoiceCaseNode) { - val caseNode = (node as ChoiceCaseNode); - ret = caseNode.childByQName(name); - if (ret !== null) { - return ret; - } - } - } - } - return ret; - } - - private def toUriString(Object object) { - if(object === null) return ""; - return URLEncoder.encode(object.toString,URI_ENCODING_CHAR_SET) - } - - private def InstanceIdWithSchemaNode collectPathArguments(InstanceIdentifierBuilder builder, List strings, - DataNodeContainer parentNode, MountInstance mountPoint, boolean returnJustMountPoint) { - checkNotNull(strings) - if (parentNode === null) { - return null; - } - if (strings.empty) { - return new InstanceIdWithSchemaNode(builder.toInstance, parentNode as DataSchemaNode, mountPoint) - } - - val nodeName = strings.head.toNodeName - val moduleName = strings.head.toModuleName - var DataSchemaNode targetNode = null - if (!moduleName.nullOrEmpty) { - // if it is mount point - if (moduleName == MOUNT_MODULE && nodeName == MOUNT_NODE) { - if (mountPoint !== null) { - throw new ResponseException(BAD_REQUEST, "Restconf supports just one mount point in URI.") - } - - if (mountService === null) { - throw new ResponseException(SERVICE_UNAVAILABLE, "MountService was not found. " - + "Finding behind mount points does not work." - ) - } - - val partialPath = builder.toInstance; - val mount = mountService.getMountPoint(partialPath) - if (mount === null) { - LOG.debug("Instance identifier to missing mount point: {}", partialPath) - throw new ResponseException(BAD_REQUEST, "Mount point does not exist.") - } - - val mountPointSchema = mount.schemaContext; - if (mountPointSchema === null) { - throw new ResponseException(BAD_REQUEST, "Mount point does not contain any schema with modules.") - } - - if (returnJustMountPoint) { - return new InstanceIdWithSchemaNode(InstanceIdentifier.builder().toInstance, mountPointSchema, mount) - } - - if (strings.size == 1) { // any data node is not behind mount point - return new InstanceIdWithSchemaNode(InstanceIdentifier.builder().toInstance, mountPointSchema, mount) - } - - val moduleNameBehindMountPoint = strings.get(1).toModuleName() - if (moduleNameBehindMountPoint === null) { - throw new ResponseException(BAD_REQUEST, - "First node after mount point in URI has to be in format \"moduleName:nodeName\"") - } - - val moduleBehindMountPoint = mountPointSchema.getLatestModule(moduleNameBehindMountPoint) - if (moduleBehindMountPoint === null) { - throw new ResponseException(BAD_REQUEST, - "URI has bad format. \"" + moduleName + "\" module does not exist in mount point.") - } - - return collectPathArguments(InstanceIdentifier.builder(), strings.subList(1, strings.size), - moduleBehindMountPoint, mount, returnJustMountPoint); - } - - var Module module = null; - if (mountPoint === null) { - module = globalSchema.getLatestModule(moduleName) - if (module === null) { - throw new ResponseException(BAD_REQUEST, - "URI has bad format. \"" + moduleName + "\" module does not exist.") - } - } else { - module = mountPoint.schemaContext?.getLatestModule(moduleName) - if (module === null) { - throw new ResponseException(BAD_REQUEST, - "URI has bad format. \"" + moduleName + "\" module does not exist in mount point.") - } - } - targetNode = parentNode.findInstanceDataChildByNameAndNamespace(nodeName, module.namespace) - if (targetNode === null) { - throw new ResponseException(BAD_REQUEST, "URI has bad format. Possible reasons:\n" + - "1. \"" + strings.head + "\" was not found in parent data node.\n" + - "2. \"" + strings.head + "\" is behind mount point. Then it should be in format \"/" + MOUNT + "/" + strings.head + "\".") - } - } else { // string without module name - val potentialSchemaNodes = parentNode.findInstanceDataChildrenByName(nodeName) - if (potentialSchemaNodes.size > 1) { - val StringBuilder namespacesOfPotentialModules = new StringBuilder; - for (potentialNodeSchema : potentialSchemaNodes) { - namespacesOfPotentialModules.append(" ").append(potentialNodeSchema.QName.namespace.toString).append("\n") - } - throw new ResponseException(BAD_REQUEST, "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" + namespacesOfPotentialModules) - } - targetNode = potentialSchemaNodes.head - if (targetNode === null) { - throw new ResponseException(BAD_REQUEST, "URI has bad format. \"" + nodeName + "\" was not found in parent data node.\n") - } - } - - if (!targetNode.isListOrContainer) { - throw new ResponseException(BAD_REQUEST,"URI has bad format. Node \"" + strings.head + "\" must be Container or List yang type.") - } - // Number of consumed elements - var consumed = 1; - if (targetNode instanceof ListSchemaNode) { - val listNode = targetNode as ListSchemaNode; - val keysSize = listNode.keyDefinition.size - - // every key has to be filled - if ((strings.length - consumed) < keysSize) { - throw new ResponseException(BAD_REQUEST,"Missing key for list \"" + listNode.QName.localName + "\".") - } - val uriKeyValues = strings.subList(consumed, consumed + keysSize); - val keyValues = new HashMap(); - var i = 0; - for (key : listNode.keyDefinition) { - val uriKeyValue = uriKeyValues.get(i); - - // key value cannot be NULL - if (uriKeyValue.equals(NULL_VALUE)) { - throw new ResponseException(BAD_REQUEST, "URI has bad format. List \"" + listNode.QName.localName - + "\" cannot contain \"null\" value as a key." - ) - } - keyValues.addKeyValue(listNode.getDataChildByName(key), uriKeyValue, mountPoint); - i = i + 1; - } - consumed = consumed + i; - builder.nodeWithKey(targetNode.QName, keyValues); - } else { - - // Only one instance of node is allowed - builder.node(targetNode.QName); - } - if (targetNode instanceof DataNodeContainer) { - val remaining = strings.subList(consumed, strings.length); - val result = builder.collectPathArguments(remaining, targetNode as DataNodeContainer, mountPoint, returnJustMountPoint); - return result - } - - return new InstanceIdWithSchemaNode(builder.toInstance, targetNode, mountPoint) - } - - def DataSchemaNode findInstanceDataChildByNameAndNamespace(DataNodeContainer container, - String name, URI namespace) { - Preconditions.checkNotNull(namespace) - val potentialSchemaNodes = container.findInstanceDataChildrenByName(name) - return potentialSchemaNodes.filter[n|n.QName.namespace == namespace].head - } - - def List findInstanceDataChildrenByName(DataNodeContainer container, String name) { - Preconditions.checkNotNull(container) - Preconditions.checkNotNull(name) - val instantiatedDataNodeContainers = new ArrayList - instantiatedDataNodeContainers.collectInstanceDataNodeContainers(container, name) - return instantiatedDataNodeContainers - } - - private def void collectInstanceDataNodeContainers(List potentialSchemaNodes, DataNodeContainer container, - String name) { - val nodes = container.childNodes.filter[n|n.QName.localName == name] - for (potentialNode : nodes) { - if (potentialNode.isInstantiatedDataSchema) { - potentialSchemaNodes.add(potentialNode) - } - } - val allCases = container.childNodes.filter(ChoiceNode).map[cases].flatten - for (caze : allCases) { - collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name) - } - } - - def boolean isInstantiatedDataSchema(DataSchemaNode node) { - switch node { - LeafSchemaNode: return true - LeafListSchemaNode: return true - ContainerSchemaNode: return true - ListSchemaNode: return true - default: return false - } - } - - private def void addKeyValue(HashMap map, DataSchemaNode node, String uriValue, MountInstance mountPoint) { - checkNotNull(uriValue); - checkArgument(node instanceof LeafSchemaNode); - val urlDecoded = URLDecoder.decode(uriValue); - val typedef = (node as LeafSchemaNode).type; - - var decoded = RestCodec.from(typedef, mountPoint)?.deserialize(urlDecoded) - var additionalInfo = "" - if(decoded === null) { - var baseType = RestUtil.resolveBaseTypeFrom(typedef) - 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 ResponseException(BAD_REQUEST, uriValue + " from URI can't be resolved. "+ additionalInfo ) - } - - map.put(node.QName, decoded); - } - - private static def String toModuleName(String str) { - checkNotNull(str) - if (str.contains(":")) { - val args = str.split(":"); - if (args.size === 2) { - return args.get(0); - } - } - return null; - } - - private def String toNodeName(String str) { - if (str.contains(":")) { - val args = str.split(":"); - if (args.size === 2) { - return args.get(1); - } - } - return str; - } - - private def QName toQName(String name) { - val module = name.toModuleName; - val node = name.toNodeName; - val namespace = FluentIterable.from(globalSchema.modules.sort[o1,o2 | o1.revision.compareTo(o2.revision)]) - .transform[QName.create(namespace,revision,it.name)].findFirst[module == localName] - if (namespace === null) { - return null - } - return QName.create(namespace, node); - } - - private def boolean isListOrContainer(DataSchemaNode node) { - return ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) - } - - def getRpcDefinition(String name) { - val validName = name.toQName - if (validName === null) { - return null - } - return qnameToRpc.get(validName) - } - - override onGlobalContextUpdated(SchemaContext context) { - if (context !== null) { - qnameToRpc.clear - this.globalSchema = context; - for (operation : context.operations) { - val qname = operation.QName; - qnameToRpc.put(qname, operation); - } - } - } - - - def urlPathArgsDecode(List strings) { - val List decodedPathArgs = new ArrayList(); - for (pathArg : strings) { - decodedPathArgs.add(URLDecoder.decode(pathArg, URI_ENCODING_CHAR_SET)) - } - return decodedPathArgs - } - - def urlPathArgDecode(String pathArg) { - if (pathArg !== null) { - return URLDecoder.decode(pathArg, URI_ENCODING_CHAR_SET) - } - return null - } - -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ResponseException.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ResponseException.java index b08126b5de..007fb8eabf 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ResponseException.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ResponseException.java @@ -19,4 +19,9 @@ public class ResponseException extends WebApplicationException { public ResponseException(Status status, String msg) { super(Response.status(status).type(MediaType.TEXT_PLAIN_TYPE).entity(msg).build()); } + + public ResponseException(Throwable cause, String msg) { + super(cause, Response.status(Status.INTERNAL_SERVER_ERROR). + type(MediaType.TEXT_PLAIN_TYPE).entity(msg).build()); + } } 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 new file mode 100644 index 0000000000..0b7b693b0c --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java @@ -0,0 +1,1161 @@ +/** + * 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.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Future; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; + +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.sal.core.api.mount.MountInstance; +import org.opendaylight.controller.sal.rest.api.RestconfService; +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.concepts.Codec; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder; +import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode; +import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.data.api.SimpleNode; +import org.opendaylight.yangtools.yang.data.impl.NodeFactory; +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.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.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; +import org.opendaylight.yangtools.yang.model.util.EmptyType; +import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder; +import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder; + +import com.google.common.base.Objects; +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.Iterables; +import com.google.common.collect.Lists; + +@SuppressWarnings("all") +public class RestconfImpl implements RestconfService { + private final static RestconfImpl INSTANCE = new RestconfImpl(); + + private final static String MOUNT_POINT_MODULE_NAME = "ietf-netconf"; + + private final static SimpleDateFormat REVISION_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + + private final static String RESTCONF_MODULE_DRAFT02_REVISION = "2013-10-19"; + + private final static String RESTCONF_MODULE_DRAFT02_NAME = "ietf-restconf"; + + private final static String RESTCONF_MODULE_DRAFT02_NAMESPACE = "urn:ietf:params:xml:ns:yang:ietf-restconf"; + + private final static String RESTCONF_MODULE_DRAFT02_RESTCONF_GROUPING_SCHEMA_NODE = "restconf"; + + private final static String RESTCONF_MODULE_DRAFT02_RESTCONF_CONTAINER_SCHEMA_NODE = "restconf"; + + private final static String RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE = "modules"; + + private final static String RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE = "module"; + + private final static String RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE = "streams"; + + private final static String RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE = "stream"; + + private final static String RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE = "operations"; + + private final static String SAL_REMOTE_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote"; + + private final static String SAL_REMOTE_RPC_SUBSRCIBE = "create-data-change-event-subscription"; + + private BrokerFacade broker; + + private ControllerContext controllerContext; + + 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 StructuredData getModules() { + final Module restconfModule = this.getRestconfModule(); + + final List> modulesAsData = new ArrayList>(); + final DataSchemaNode moduleSchemaNode = + this.getSchemaNode(restconfModule, RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE); + + Set allModules = this.controllerContext.getAllModules(); + for (final Module module : allModules) { + CompositeNode moduleCompositeNode = this.toModuleCompositeNode(module, moduleSchemaNode); + modulesAsData.add(moduleCompositeNode); + } + + final DataSchemaNode modulesSchemaNode = + this.getSchemaNode(restconfModule, RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE); + QName qName = modulesSchemaNode.getQName(); + final CompositeNode modulesNode = NodeFactory.createImmutableCompositeNode(qName, null, modulesAsData); + return new StructuredData(modulesNode, modulesSchemaNode, null); + } + + @Override + public StructuredData getAvailableStreams() { + Set availableStreams = Notificator.getStreamNames(); + + final List> streamsAsData = new ArrayList>(); + Module restconfModule = this.getRestconfModule(); + final DataSchemaNode streamSchemaNode = + this.getSchemaNode(restconfModule, RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE); + for (final String streamName : availableStreams) { + streamsAsData.add(this.toStreamCompositeNode(streamName, streamSchemaNode)); + } + + final DataSchemaNode streamsSchemaNode = + this.getSchemaNode(restconfModule, RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE); + QName qName = streamsSchemaNode.getQName(); + final CompositeNode streamsNode = NodeFactory.createImmutableCompositeNode(qName, null, streamsAsData); + return new StructuredData(streamsNode, streamsSchemaNode, null); + } + + @Override + public StructuredData getModules(final String identifier) { + Set modules = null; + MountInstance mountPoint = null; + if (identifier.contains(ControllerContext.MOUNT)) { + InstanceIdWithSchemaNode mountPointIdentifier = + this.controllerContext.toMountPointIdentifier(identifier); + mountPoint = mountPointIdentifier.getMountPoint(); + modules = this.controllerContext.getAllModules(mountPoint); + } + else { + throw new ResponseException(Status.BAD_REQUEST, + "URI has bad format. If modules behind mount point should be showed, URI has to end with " + + ControllerContext.MOUNT); + } + + final List> modulesAsData = new ArrayList>(); + Module restconfModule = this.getRestconfModule(); + final DataSchemaNode moduleSchemaNode = + this.getSchemaNode(restconfModule, RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE); + + for (final Module module : modules) { + modulesAsData.add(this.toModuleCompositeNode(module, moduleSchemaNode)); + } + + final DataSchemaNode modulesSchemaNode = + this.getSchemaNode(restconfModule, RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE); + QName qName = modulesSchemaNode.getQName(); + final CompositeNode modulesNode = NodeFactory.createImmutableCompositeNode(qName, null, modulesAsData); + return new StructuredData(modulesNode, modulesSchemaNode, mountPoint); + } + + @Override + public StructuredData getModule(final String identifier) { + final QName moduleNameAndRevision = this.getModuleNameAndRevision(identifier); + Module module = null; + MountInstance mountPoint = null; + if (identifier.contains(ControllerContext.MOUNT)) { + InstanceIdWithSchemaNode mountPointIdentifier = + this.controllerContext.toMountPointIdentifier(identifier); + mountPoint = mountPointIdentifier.getMountPoint(); + module = this.controllerContext.findModuleByNameAndRevision(mountPoint, moduleNameAndRevision); + } + else { + module = this.controllerContext.findModuleByNameAndRevision(moduleNameAndRevision); + } + + if (module == null) { + throw new ResponseException(Status.BAD_REQUEST, + "Module with name '" + moduleNameAndRevision.getLocalName() + "' and revision '" + + moduleNameAndRevision.getRevision() + "' was not found."); + } + + Module restconfModule = this.getRestconfModule(); + final DataSchemaNode moduleSchemaNode = + this.getSchemaNode(restconfModule, RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE); + final CompositeNode moduleNode = this.toModuleCompositeNode(module, moduleSchemaNode); + return new StructuredData(moduleNode, moduleSchemaNode, mountPoint); + } + + @Override + public StructuredData getOperations() { + Set allModules = this.controllerContext.getAllModules(); + return this.operationsFromModulesToStructuredData(allModules, null); + } + + @Override + public StructuredData getOperations(final String identifier) { + Set modules = null; + MountInstance mountPoint = null; + if (identifier.contains(ControllerContext.MOUNT)) { + InstanceIdWithSchemaNode mountPointIdentifier = + this.controllerContext.toMountPointIdentifier(identifier); + mountPoint = mountPointIdentifier.getMountPoint(); + modules = this.controllerContext.getAllModules(mountPoint); + } + else { + throw new ResponseException(Status.BAD_REQUEST, + "URI has bad format. If operations behind mount point should be showed, URI has to end with " + + ControllerContext.MOUNT); + } + + return this.operationsFromModulesToStructuredData(modules, mountPoint); + } + + private StructuredData operationsFromModulesToStructuredData(final Set modules, + final MountInstance mountPoint) { + final List> operationsAsData = new ArrayList>(); + Module restconfModule = this.getRestconfModule(); + final DataSchemaNode operationsSchemaNode = + this.getSchemaNode(restconfModule, RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE); + QName qName = operationsSchemaNode.getQName(); + SchemaPath path = operationsSchemaNode.getPath(); + ContainerSchemaNodeBuilder containerSchemaNodeBuilder = + new ContainerSchemaNodeBuilder(RESTCONF_MODULE_DRAFT02_NAME, 0, qName, path); + final ContainerSchemaNodeBuilder fakeOperationsSchemaNode = containerSchemaNodeBuilder; + for (final Module module : modules) { + Set rpcs = module.getRpcs(); + for (final RpcDefinition rpc : rpcs) { + QName rpcQName = rpc.getQName(); + SimpleNode immutableSimpleNode = + NodeFactory.createImmutableSimpleNode(rpcQName, null, null); + operationsAsData.add(immutableSimpleNode); + + String name = module.getName(); + LeafSchemaNodeBuilder leafSchemaNodeBuilder = new LeafSchemaNodeBuilder(name, 0, rpcQName, null); + final LeafSchemaNodeBuilder fakeRpcSchemaNode = leafSchemaNodeBuilder; + fakeRpcSchemaNode.setAugmenting(true); + + EmptyType instance = EmptyType.getInstance(); + fakeRpcSchemaNode.setType(instance); + fakeOperationsSchemaNode.addChildNode(fakeRpcSchemaNode.build()); + } + } + + final CompositeNode operationsNode = + NodeFactory.createImmutableCompositeNode(qName, null, operationsAsData); + ContainerSchemaNode schemaNode = fakeOperationsSchemaNode.build(); + return new StructuredData(operationsNode, schemaNode, mountPoint); + } + + private Module getRestconfModule() { + QName qName = QName.create(RESTCONF_MODULE_DRAFT02_NAMESPACE, RESTCONF_MODULE_DRAFT02_REVISION, + RESTCONF_MODULE_DRAFT02_NAME); + final Module restconfModule = this.controllerContext.findModuleByNameAndRevision(qName); + if (restconfModule == null) { + throw new ResponseException(Status.INTERNAL_SERVER_ERROR, "Restconf module was not found."); + } + + 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; + } + + Splitter splitter = Splitter.on("/").omitEmptyStrings(); + Iterable split = splitter.split(moduleNameAndRevision); + final List pathArgs = Lists.newArrayList(split); + if (pathArgs.size() < 2) { + throw new ResponseException(Status.BAD_REQUEST, + "URI has bad format. End of URI should be in format \'moduleName/yyyy-MM-dd\'"); + } + + try { + final String moduleName = pathArgs.get( 0 ); + String revision = pathArgs.get(1); + final Date moduleRevision = REVISION_FORMAT.parse(revision); + return QName.create(null, moduleRevision, moduleName); + } + catch (ParseException e) { + throw new ResponseException(Status.BAD_REQUEST, "URI has bad format. It should be \'moduleName/yyyy-MM-dd\'"); + } + } + + private CompositeNode toStreamCompositeNode(final String streamName, final DataSchemaNode streamSchemaNode) { + final List> streamNodeValues = new ArrayList>(); + List instanceDataChildrenByName = + this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) streamSchemaNode), + "name"); + final DataSchemaNode nameSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(nameSchemaNode.getQName(), null, + streamName)); + + instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + ((DataNodeContainer) streamSchemaNode), "description"); + final DataSchemaNode descriptionSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(descriptionSchemaNode.getQName(), null, + "DESCRIPTION_PLACEHOLDER")); + + instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + ((DataNodeContainer) streamSchemaNode), "replay-support"); + final DataSchemaNode replaySupportSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(replaySupportSchemaNode.getQName(), null, + Boolean.valueOf(true))); + + instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + ((DataNodeContainer) streamSchemaNode), "replay-log-creation-time"); + final DataSchemaNode replayLogCreationTimeSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(replayLogCreationTimeSchemaNode.getQName(), + null, "")); + + instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + ((DataNodeContainer) streamSchemaNode), "events"); + final DataSchemaNode eventsSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(eventsSchemaNode.getQName(), + null, "")); + + return NodeFactory.createImmutableCompositeNode(streamSchemaNode.getQName(), null, streamNodeValues); + } + + private CompositeNode toModuleCompositeNode(final Module module, final DataSchemaNode moduleSchemaNode) { + final List> moduleNodeValues = new ArrayList>(); + List instanceDataChildrenByName = + this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) moduleSchemaNode), "name"); + final DataSchemaNode nameSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + moduleNodeValues.add(NodeFactory.createImmutableSimpleNode(nameSchemaNode.getQName(), + null, module.getName())); + + instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + ((DataNodeContainer) moduleSchemaNode), "revision"); + final DataSchemaNode revisionSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + Date _revision = module.getRevision(); + moduleNodeValues.add(NodeFactory.createImmutableSimpleNode(revisionSchemaNode.getQName(), null, + REVISION_FORMAT.format(_revision))); + + instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + ((DataNodeContainer) moduleSchemaNode), "namespace"); + final DataSchemaNode namespaceSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + moduleNodeValues.add(NodeFactory.createImmutableSimpleNode(namespaceSchemaNode.getQName(), null, + module.getNamespace().toString())); + + instanceDataChildrenByName = this.controllerContext.findInstanceDataChildrenByName( + ((DataNodeContainer) moduleSchemaNode), "feature"); + final DataSchemaNode featureSchemaNode = Iterables.getFirst(instanceDataChildrenByName, null); + for (final FeatureDefinition feature : module.getFeatures()) { + moduleNodeValues.add(NodeFactory.createImmutableSimpleNode(featureSchemaNode.getQName(), null, + feature.getQName().getLocalName())); + } + + return NodeFactory.createImmutableCompositeNode(moduleSchemaNode.getQName(), null, moduleNodeValues); + } + + private DataSchemaNode getSchemaNode(final Module restconfModule, final String schemaNodeName) { + Set groupings = restconfModule.getGroupings(); + + final Predicate filter = new Predicate() { + @Override + public boolean apply(final GroupingDefinition g) { + return Objects.equal(g.getQName().getLocalName(), + RESTCONF_MODULE_DRAFT02_RESTCONF_GROUPING_SCHEMA_NODE); + } + }; + + Iterable filteredGroups = Iterables.filter(groupings, filter); + + final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null); + + List instanceDataChildrenByName = + this.controllerContext.findInstanceDataChildrenByName(restconfGrouping, + RESTCONF_MODULE_DRAFT02_RESTCONF_CONTAINER_SCHEMA_NODE); + final DataSchemaNode restconfContainer = Iterables.getFirst(instanceDataChildrenByName, null); + + if (Objects.equal(schemaNodeName, RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE)) { + List instances = + this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) restconfContainer), + RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE); + return Iterables.getFirst(instances, null); + } + else if(Objects.equal(schemaNodeName, RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE)) { + List instances = + this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) restconfContainer), + RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE); + return Iterables.getFirst(instances, null); + } + else if(Objects.equal(schemaNodeName, RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE)) { + List instances = + this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) restconfContainer), + RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE); + final DataSchemaNode modules = Iterables.getFirst(instances, null); + instances = this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) modules), + RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE); + return Iterables.getFirst(instances, null); + } + else if(Objects.equal(schemaNodeName, RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE)) { + List instances = + this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) restconfContainer), + RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE); + return Iterables.getFirst(instances, null); + } + else if(Objects.equal(schemaNodeName, RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE)) { + List instances = + this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) restconfContainer), + RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE); + final DataSchemaNode modules = Iterables.getFirst(instances, null); + instances = this.controllerContext.findInstanceDataChildrenByName(((DataNodeContainer) modules), + RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE); + return Iterables.getFirst(instances, null); + } + + return null; + } + + @Override + public Object getRoot() { + return null; + } + + @Override + public StructuredData invokeRpc(final String identifier, final CompositeNode payload) { + final RpcDefinition rpc = this.resolveIdentifierInInvokeRpc(identifier); + if (Objects.equal(rpc.getQName().getNamespace().toString(), SAL_REMOTE_NAMESPACE) && + Objects.equal(rpc.getQName().getLocalName(), SAL_REMOTE_RPC_SUBSRCIBE)) { + + final CompositeNode value = this.normalizeNode(payload, rpc.getInput(), null); + final SimpleNode pathNode = value == null ? null : + value.getFirstSimpleByName( QName.create(rpc.getQName(), "path") ); + final Object pathValue = pathNode == null ? null : pathNode.getValue(); + + if (!(pathValue instanceof InstanceIdentifier)) { + throw new ResponseException(Status.INTERNAL_SERVER_ERROR, + "Instance identifier was not normalized correctly."); + } + + final InstanceIdentifier pathIdentifier = ((InstanceIdentifier) pathValue); + String streamName = null; + if (!Iterables.isEmpty(pathIdentifier.getPath())) { + String fullRestconfIdentifier = this.controllerContext.toFullRestconfIdentifier(pathIdentifier); + streamName = Notificator.createStreamNameFromUri(fullRestconfIdentifier); + } + + if (Strings.isNullOrEmpty(streamName)) { + throw new ResponseException(Status.BAD_REQUEST, + "Path is empty or contains data node which is not Container or List build-in type."); + } + + final SimpleNode streamNameNode = NodeFactory.createImmutableSimpleNode( + QName.create(rpc.getOutput().getQName(), "stream-name"), null, streamName); + final List> output = new ArrayList>(); + output.add(streamNameNode); + + final MutableCompositeNode responseData = NodeFactory.createMutableCompositeNode( + rpc.getOutput().getQName(), null, output, null, null); + + if (!Notificator.existListenerFor(pathIdentifier)) { + Notificator.createListener(pathIdentifier, streamName); + } + + return new StructuredData(responseData, rpc.getOutput(), null); + } + + RpcDefinition rpcDefinition = this.controllerContext.getRpcDefinition(identifier); + return this.callRpc(rpcDefinition, payload); + } + + @Override + public StructuredData invokeRpc(final String identifier, final String noPayload) { + if (!Strings.isNullOrEmpty(noPayload)) { + throw new ResponseException(Status.UNSUPPORTED_MEDIA_TYPE, + "Content-Type contains unsupported Media Type."); + } + + final RpcDefinition rpc = this.resolveIdentifierInInvokeRpc(identifier); + return this.callRpc(rpc, null); + } + + private RpcDefinition resolveIdentifierInInvokeRpc(final String identifier) { + if (identifier.indexOf("/") < 0) { + final String identifierDecoded = this.controllerContext.urlPathArgDecode(identifier); + final RpcDefinition rpc = this.controllerContext.getRpcDefinition(identifierDecoded); + if (rpc != null) { + return rpc; + } + + throw new ResponseException(Status.NOT_FOUND, "RPC does not exist."); + } + + 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); + + throw new ResponseException(Status.NOT_FOUND, slashErrorMsg); + } + + private StructuredData callRpc(final RpcDefinition rpc, final CompositeNode payload) { + if (rpc == null) { + throw new ResponseException(Status.NOT_FOUND, "RPC does not exist."); + } + + CompositeNode rpcRequest = null; + if (payload == null) { + rpcRequest = NodeFactory.createMutableCompositeNode(rpc.getQName(), null, null, null, null); + } + else { + final CompositeNode value = this.normalizeNode(payload, rpc.getInput(), null); + final List> input = new ArrayList>(); + input.add(value); + + rpcRequest = NodeFactory.createMutableCompositeNode(rpc.getQName(), null, input, null, null); + } + + final RpcResult rpcResult = broker.invokeRpc(rpc.getQName(), rpcRequest); + + if (!rpcResult.isSuccessful()) { + throw new ResponseException(Status.INTERNAL_SERVER_ERROR, "Operation failed"); + } + + CompositeNode result = rpcResult.getResult(); + if (result == null) { + return null; + } + + return new StructuredData(result, rpc.getOutput(), null); + } + + @Override + public StructuredData readConfigurationData(final String identifier) { + final InstanceIdWithSchemaNode iiWithData = this.controllerContext.toInstanceIdentifier(identifier); + CompositeNode data = null; + MountInstance mountPoint = iiWithData.getMountPoint(); + if (mountPoint != null) { + data = broker.readConfigurationDataBehindMountPoint(mountPoint, iiWithData.getInstanceIdentifier()); + } + else { + data = broker.readConfigurationData(iiWithData.getInstanceIdentifier()); + } + + return new StructuredData(data, iiWithData.getSchemaNode(), iiWithData.getMountPoint()); + } + + @Override + public StructuredData readOperationalData(final String identifier) { + final InstanceIdWithSchemaNode iiWithData = this.controllerContext.toInstanceIdentifier(identifier); + CompositeNode data = null; + MountInstance mountPoint = iiWithData.getMountPoint(); + if (mountPoint != null) { + data = broker.readOperationalDataBehindMountPoint(mountPoint, iiWithData.getInstanceIdentifier()); + } + else { + data = broker.readOperationalData(iiWithData.getInstanceIdentifier()); + } + + return new StructuredData(data, iiWithData.getSchemaNode(), mountPoint); + } + + @Override + public Response updateConfigurationData(final String identifier, final CompositeNode payload) { + final InstanceIdWithSchemaNode iiWithData = this.controllerContext.toInstanceIdentifier(identifier); + MountInstance mountPoint = iiWithData.getMountPoint(); + final CompositeNode value = this.normalizeNode(payload, iiWithData.getSchemaNode(), mountPoint); + RpcResult status = null; + + try { + if (mountPoint != null) { + status = broker.commitConfigurationDataPutBehindMountPoint( + mountPoint, iiWithData.getInstanceIdentifier(), value).get(); + } else { + status = broker.commitConfigurationDataPut(iiWithData.getInstanceIdentifier(), value).get(); + } + } + catch( Exception e ) { + throw new ResponseException( e, "Error updating data" ); + } + + if( status.getResult() == TransactionStatus.COMMITED ) + return Response.status(Status.OK).build(); + + return Response.status(Status.INTERNAL_SERVER_ERROR).build(); + } + + @Override + public Response createConfigurationData(final String identifier, final CompositeNode payload) { + URI payloadNS = this.namespace(payload); + if (payloadNS == null) { + throw new ResponseException(Status.BAD_REQUEST, + "Data has bad format. Root element node must have namespace (XML format) or module name(JSON format)"); + } + + InstanceIdWithSchemaNode iiWithData = null; + CompositeNode value = null; + if (this.representsMountPointRootData(payload)) { + // payload represents mount point data and URI represents path to the mount point + + if (this.endsWithMountPoint(identifier)) { + throw new ResponseException(Status.BAD_REQUEST, + "URI has bad format. URI should be without \"" + ControllerContext.MOUNT + + "\" for POST operation."); + } + + final String completeIdentifier = this.addMountPointIdentifier(identifier); + iiWithData = this.controllerContext.toInstanceIdentifier(completeIdentifier); + + value = this.normalizeNode(payload, iiWithData.getSchemaNode(), iiWithData.getMountPoint()); + } + else { + final InstanceIdWithSchemaNode incompleteInstIdWithData = + this.controllerContext.toInstanceIdentifier(identifier); + final DataNodeContainer parentSchema = (DataNodeContainer) incompleteInstIdWithData.getSchemaNode(); + MountInstance mountPoint = incompleteInstIdWithData.getMountPoint(); + final Module module = this.findModule(mountPoint, payload); + if (module == null) { + throw new ResponseException(Status.BAD_REQUEST, + "Module was not found for \"" + payloadNS + "\""); + } + + String payloadName = this.getName(payload); + final DataSchemaNode schemaNode = this.controllerContext.findInstanceDataChildByNameAndNamespace( + parentSchema, payloadName, module.getNamespace()); + value = this.normalizeNode(payload, schemaNode, mountPoint); + + iiWithData = this.addLastIdentifierFromData(incompleteInstIdWithData, value, schemaNode); + } + + RpcResult status = null; + MountInstance mountPoint = iiWithData.getMountPoint(); + try { + if (mountPoint != null) { + Future> future = + broker.commitConfigurationDataPostBehindMountPoint( + mountPoint, iiWithData.getInstanceIdentifier(), value); + status = future == null ? null : future.get(); + } + else { + Future> future = + broker.commitConfigurationDataPost(iiWithData.getInstanceIdentifier(), value); + status = future == null ? null : future.get(); + } + } + catch( ResponseException e) { throw e; } + catch( Exception e ) { + throw new ResponseException( e, "Error creating data" ); + } + + if (status == null) { + return Response.status(Status.ACCEPTED).build(); + } + + if( status.getResult() == TransactionStatus.COMMITED ) + return Response.status(Status.NO_CONTENT).build(); + + return Response.status(Status.INTERNAL_SERVER_ERROR).build(); + } + + @Override + public Response createConfigurationData(final CompositeNode payload) { + URI payloadNS = this.namespace(payload); + if (payloadNS == null) { + throw new ResponseException(Status.BAD_REQUEST, + "Data has bad format. Root element node must have namespace (XML format) or module name(JSON format)"); + } + + final Module module = this.findModule(null, payload); + if (module == null) { + throw new ResponseException(Status.BAD_REQUEST, + "Data has bad format. Root element node has incorrect namespace (XML format) or module name(JSON format)"); + } + + String payloadName = this.getName(payload); + final DataSchemaNode schemaNode = this.controllerContext.findInstanceDataChildByNameAndNamespace( + module, payloadName, module.getNamespace()); + final CompositeNode value = this.normalizeNode(payload, schemaNode, null); + final InstanceIdWithSchemaNode iiWithData = this.addLastIdentifierFromData(null, value, schemaNode); + RpcResult status = null; + MountInstance mountPoint = iiWithData.getMountPoint(); + + try { + if (mountPoint != null) { + Future> future = + broker.commitConfigurationDataPostBehindMountPoint( + mountPoint, iiWithData.getInstanceIdentifier(), value); + status = future == null ? null : future.get(); + } + else { + Future> future = + broker.commitConfigurationDataPost(iiWithData.getInstanceIdentifier(), value); + status = future == null ? null : future.get(); + } + } + catch( ResponseException e) { throw e; } + catch( Exception e ) { + throw new ResponseException( e, "Error creating data" ); + } + + if (status == null) { + return Response.status(Status.ACCEPTED).build(); + } + + if( status.getResult() == TransactionStatus.COMMITED ) + return Response.status(Status.NO_CONTENT).build(); + + return Response.status(Status.INTERNAL_SERVER_ERROR).build(); + } + + @Override + public Response deleteConfigurationData(final String identifier) { + final InstanceIdWithSchemaNode iiWithData = this.controllerContext.toInstanceIdentifier(identifier); + RpcResult status = null; + MountInstance mountPoint = iiWithData.getMountPoint(); + + try { + if (mountPoint != null) { + status = broker.commitConfigurationDataDeleteBehindMountPoint( + mountPoint, iiWithData.getInstanceIdentifier()).get(); + } + else { + status = broker.commitConfigurationDataDelete(iiWithData.getInstanceIdentifier()).get(); + } + } + catch( Exception e ) { + throw new ResponseException( e, "Error creating data" ); + } + + if( status.getResult() == TransactionStatus.COMMITED ) + return Response.status(Status.OK).build(); + + return Response.status(Status.INTERNAL_SERVER_ERROR).build(); + } + + @Override + public Response subscribeToStream(final String identifier, final UriInfo uriInfo) { + final String streamName = Notificator.createStreamNameFromUri(identifier); + if (Strings.isNullOrEmpty(streamName)) { + throw new ResponseException(Status.BAD_REQUEST, "Stream name is empty."); + } + + final ListenerAdapter listener = Notificator.getListenerFor(streamName); + if (listener == null) { + throw new ResponseException(Status.BAD_REQUEST, "Stream was not found."); + } + + broker.registerToListenDataChanges(listener); + + final UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder(); + UriBuilder port = uriBuilder.port(WebSocketServer.PORT); + final URI uriToWebsocketServer = port.replacePath(streamName).build(); + + return Response.status(Status.OK).location(uriToWebsocketServer).build(); + } + + private Module findModule(final MountInstance mountPoint, final CompositeNode data) { + if (data instanceof CompositeNodeWrapper) { + return findModule(mountPoint, (CompositeNodeWrapper)data); + } + else if (data != null) { + URI namespace = data.getNodeType().getNamespace(); + if (mountPoint != null) { + return this.controllerContext.findModuleByNamespace(mountPoint, namespace); + } + else { + return this.controllerContext.findModuleByNamespace(namespace); + } + } + else { + throw new IllegalArgumentException("Unhandled parameter types: " + + Arrays.asList(mountPoint, data).toString()); + } + } + + private Module findModule(final MountInstance mountPoint, final CompositeNodeWrapper data) { + URI namespace = data.getNamespace(); + Preconditions.checkNotNull(namespace); + + Module module = null; + if (mountPoint != null) { + module = this.controllerContext.findModuleByNamespace(mountPoint, namespace); + if (module == null) { + module = this.controllerContext.findModuleByName(mountPoint, namespace.toString()); + } + } + else { + module = this.controllerContext.findModuleByNamespace(namespace); + if (module == null) { + module = this.controllerContext.findModuleByName(namespace.toString()); + } + } + + return module; + } + + private InstanceIdWithSchemaNode addLastIdentifierFromData( + final InstanceIdWithSchemaNode identifierWithSchemaNode, + final CompositeNode data, final DataSchemaNode schemaOfData) { + InstanceIdentifier instanceIdentifier = null; + if (identifierWithSchemaNode != null) { + instanceIdentifier = identifierWithSchemaNode.getInstanceIdentifier(); + } + + final InstanceIdentifier iiOriginal = instanceIdentifier; + InstanceIdentifierBuilder iiBuilder = null; + if (iiOriginal == null) { + iiBuilder = InstanceIdentifier.builder(); + } + else { + iiBuilder = InstanceIdentifier.builder(iiOriginal); + } + + if ((schemaOfData instanceof ListSchemaNode)) { + HashMap keys = this.resolveKeysFromData(((ListSchemaNode) schemaOfData), data); + iiBuilder.nodeWithKey(schemaOfData.getQName(), keys); + } + else { + iiBuilder.node(schemaOfData.getQName()); + } + + InstanceIdentifier instance = iiBuilder.toInstance(); + MountInstance mountPoint = null; + if (identifierWithSchemaNode != null) { + mountPoint=identifierWithSchemaNode.getMountPoint(); + } + + return new InstanceIdWithSchemaNode(instance, schemaOfData, mountPoint); + } + + private HashMap resolveKeysFromData(final ListSchemaNode listNode, + final CompositeNode dataNode) { + final HashMap keyValues = new HashMap(); + List _keyDefinition = listNode.getKeyDefinition(); + for (final QName key : _keyDefinition) { + SimpleNode head = null; + String localName = key.getLocalName(); + List> simpleNodesByName = dataNode.getSimpleNodesByName(localName); + if (simpleNodesByName != null) { + head = Iterables.getFirst(simpleNodesByName, null); + } + + Object dataNodeKeyValueObject = null; + if (head != null) { + dataNodeKeyValueObject = head.getValue(); + } + + if (dataNodeKeyValueObject == null) { + throw new ResponseException(Status.BAD_REQUEST, + "Data contains list \"" + dataNode.getNodeType().getLocalName() + + "\" which does not contain key: \"" + key.getLocalName() + "\""); + } + + keyValues.put(key, dataNodeKeyValueObject); + } + + return keyValues; + } + + private boolean endsWithMountPoint(final String identifier) { + return identifier.endsWith(ControllerContext.MOUNT) || + identifier.endsWith(ControllerContext.MOUNT + "/"); + } + + private boolean representsMountPointRootData(final CompositeNode data) { + URI namespace = this.namespace(data); + return (SchemaContext.NAME.getNamespace().equals( namespace ) /* || + MOUNT_POINT_MODULE_NAME.equals( namespace.toString() )*/ ) && + SchemaContext.NAME.getLocalName().equals( this.localName(data) ); + } + + private String addMountPointIdentifier(final String identifier) { + boolean endsWith = identifier.endsWith("/"); + if (endsWith) { + return (identifier + ControllerContext.MOUNT); + } + + return identifier + "/" + ControllerContext.MOUNT; + } + + private CompositeNode normalizeNode(final CompositeNode node, final DataSchemaNode schema, + final MountInstance mountPoint) { + if (schema == null) { + QName nodeType = node == null ? null : node.getNodeType(); + String localName = nodeType == null ? null : nodeType.getLocalName(); + String _plus = ("Data schema node was not found for " + localName); + throw new ResponseException(Status.INTERNAL_SERVER_ERROR, + "Data schema node was not found for " + localName ); + } + + if (!(schema instanceof DataNodeContainer)) { + throw new ResponseException(Status.BAD_REQUEST, + "Root element has to be container or list yang datatype."); + } + + if ((node instanceof CompositeNodeWrapper)) { + boolean isChangeAllowed = ((CompositeNodeWrapper) node).isChangeAllowed(); + if (isChangeAllowed) { + try { + this.normalizeNode(((CompositeNodeWrapper) node), schema, null, mountPoint); + } + catch (NumberFormatException e) { + throw new ResponseException(Status.BAD_REQUEST, e.getMessage()); + } + } + + return ((CompositeNodeWrapper) node).unwrap(); + } + + return node; + } + + private void normalizeNode(final NodeWrapper nodeBuilder, + final DataSchemaNode schema, final QName previousAugment, + final MountInstance mountPoint) { + if (schema == null) { + throw new ResponseException(Status.BAD_REQUEST, + "Data has bad format.\n\"" + nodeBuilder.getLocalName() + + "\" does not exist in yang schema."); + } + + QName currentAugment = null; + if (nodeBuilder.getQname() != null) { + currentAugment = previousAugment; + } + else { + currentAugment = this.normalizeNodeName(nodeBuilder, schema, previousAugment, mountPoint); + if (nodeBuilder.getQname() == null) { + throw new ResponseException(Status.BAD_REQUEST, + "Data has bad format.\nIf data is in XML format then namespace for \"" + + nodeBuilder.getLocalName() + + "\" should be \"" + schema.getQName().getNamespace() + "\".\n" + + "If data is in JSON format then module name for \"" + nodeBuilder.getLocalName() + + "\" should be corresponding to namespace \"" + + schema.getQName().getNamespace() + "\"."); + } + } + + if ((nodeBuilder instanceof CompositeNodeWrapper)) { + final List> children = ((CompositeNodeWrapper) nodeBuilder).getValues(); + for (final NodeWrapper child : children) { + final List potentialSchemaNodes = + this.controllerContext.findInstanceDataChildrenByName( + ((DataNodeContainer) schema), child.getLocalName()); + + if (potentialSchemaNodes.size() > 1 && child.getNamespace() == null) { + StringBuilder builder = new StringBuilder(); + for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) { + builder.append(" ").append(potentialSchemaNode.getQName().getNamespace().toString()) + .append("\n"); + } + + throw new ResponseException(Status.BAD_REQUEST, + "Node \"" + child.getLocalName() + + "\" is added as augment from more than one module. " + + "Therefore node must have namespace (XML format) or module name (JSON format)." + + "\nThe node is added as augment from modules with namespaces:\n" + builder); + } + + boolean rightNodeSchemaFound = false; + for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) { + if (!rightNodeSchemaFound) { + final QName potentialCurrentAugment = + this.normalizeNodeName(child, potentialSchemaNode, currentAugment, mountPoint); + if (child.getQname() != null ) { + this.normalizeNode(child, potentialSchemaNode, potentialCurrentAugment, mountPoint); + rightNodeSchemaFound = true; + } + } + } + + if (!rightNodeSchemaFound) { + throw new ResponseException(Status.BAD_REQUEST, + "Schema node \"" + child.getLocalName() + "\" was not found in module."); + } + } + + if ((schema instanceof ListSchemaNode)) { + final List listKeys = ((ListSchemaNode) schema).getKeyDefinition(); + for (final QName listKey : listKeys) { + boolean foundKey = false; + for (final NodeWrapper child : children) { + if (Objects.equal(child.unwrap().getNodeType().getLocalName(), listKey.getLocalName())) { + foundKey = true; + } + } + + if (!foundKey) { + throw new ResponseException(Status.BAD_REQUEST, + "Missing key in URI \"" + listKey.getLocalName() + + "\" of list \"" + schema.getQName().getLocalName() + "\""); + } + } + } + } + else { + if ((nodeBuilder instanceof SimpleNodeWrapper)) { + final SimpleNodeWrapper simpleNode = ((SimpleNodeWrapper) nodeBuilder); + final Object value = simpleNode.getValue(); + Object inputValue = value; + TypeDefinition typeDefinition = this.typeDefinition(schema); + if ((typeDefinition instanceof IdentityrefTypeDefinition)) { + if ((value instanceof String)) { + inputValue = new IdentityValuesDTO( nodeBuilder.getNamespace().toString(), + (String) value, null, (String) value ); + } // else value is already instance of IdentityValuesDTO + } + + Codec codec = RestCodec.from(typeDefinition, mountPoint); + Object outputValue = codec == null ? null : codec.deserialize(inputValue); + + simpleNode.setValue(outputValue); + } + else { + if ((nodeBuilder instanceof EmptyNodeWrapper)) { + final EmptyNodeWrapper emptyNodeBuilder = ((EmptyNodeWrapper) nodeBuilder); + if ((schema instanceof LeafSchemaNode)) { + emptyNodeBuilder.setComposite(false); + } + else { + if ((schema instanceof ContainerSchemaNode)) { + // FIXME: Add presence check + emptyNodeBuilder.setComposite(true); + } + } + } + } + } + } + + private QName normalizeNodeName(final NodeWrapper nodeBuilder, + final DataSchemaNode schema, final QName previousAugment, + final MountInstance mountPoint) { + QName validQName = schema.getQName(); + QName currentAugment = previousAugment; + if (schema.isAugmenting()) { + currentAugment = schema.getQName(); + } + else if (previousAugment != null && + !Objects.equal( schema.getQName().getNamespace(), previousAugment.getNamespace())) { + validQName = QName.create(currentAugment, schema.getQName().getLocalName()); + } + + String moduleName = null; + if (mountPoint == null) { + moduleName = controllerContext.findModuleNameByNamespace(validQName.getNamespace()); + } + else { + moduleName = controllerContext.findModuleNameByNamespace(mountPoint, validQName.getNamespace()); + } + + if (nodeBuilder.getNamespace() == null || + Objects.equal(nodeBuilder.getNamespace(), validQName.getNamespace()) || + Objects.equal(nodeBuilder.getNamespace().toString(), moduleName) /*|| + Note: this check is wrong - can never be true as it compares a URI with a String + not sure what the intention is so commented out... + Objects.equal(nodeBuilder.getNamespace(), MOUNT_POINT_MODULE_NAME)*/ ) { + + nodeBuilder.setQname(validQName); + } + + return currentAugment; + } + + private URI namespace(final CompositeNode data) { + if (data instanceof CompositeNodeWrapper) { + return ((CompositeNodeWrapper)data).getNamespace(); + } + else if (data != null) { + return data.getNodeType().getNamespace(); + } + else { + throw new IllegalArgumentException("Unhandled parameter types: " + + Arrays.asList(data).toString()); + } + } + + private String localName(final CompositeNode data) { + if (data instanceof CompositeNodeWrapper) { + return ((CompositeNodeWrapper)data).getLocalName(); + } + else if (data != null) { + return data.getNodeType().getLocalName(); + } + else { + throw new IllegalArgumentException("Unhandled parameter types: " + + Arrays.asList(data).toString()); + } + } + + private String getName(final CompositeNode data) { + if (data instanceof CompositeNodeWrapper) { + return ((CompositeNodeWrapper)data).getLocalName(); + } + else if (data != null) { + return data.getNodeType().getLocalName(); + } + else { + throw new IllegalArgumentException("Unhandled parameter types: " + + Arrays.asList(data).toString()); + } + } + + private TypeDefinition _typeDefinition(final LeafSchemaNode node) { + TypeDefinition baseType = node.getType(); + while (baseType.getBaseType() != null) { + baseType = baseType.getBaseType(); + } + + return baseType; + } + + private TypeDefinition typeDefinition(final LeafListSchemaNode node) { + TypeDefinition baseType = node.getType(); + while (baseType.getBaseType() != null) { + baseType = baseType.getBaseType(); + } + + return baseType; + } + + private TypeDefinition typeDefinition(final DataSchemaNode node) { + if (node instanceof LeafListSchemaNode) { + return typeDefinition((LeafListSchemaNode)node); + } + else if (node instanceof LeafSchemaNode) { + return _typeDefinition((LeafSchemaNode)node); + } + else { + throw new IllegalArgumentException("Unhandled parameter types: " + + Arrays.asList(node).toString()); + } + } +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend deleted file mode 100644 index f1901d7112..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend +++ /dev/null @@ -1,732 +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.Preconditions -import com.google.common.base.Splitter -import com.google.common.collect.Lists -import java.net.URI -import java.text.ParseException -import java.text.SimpleDateFormat -import java.util.ArrayList -import java.util.HashMap -import java.util.List -import java.util.Set -import javax.ws.rs.core.Response -import javax.ws.rs.core.UriInfo -import org.opendaylight.controller.md.sal.common.api.TransactionStatus -import org.opendaylight.controller.sal.core.api.mount.MountInstance -import org.opendaylight.controller.sal.rest.api.RestconfService -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.RpcResult -import org.opendaylight.yangtools.yang.data.api.CompositeNode -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder -import org.opendaylight.yangtools.yang.data.api.Node -import org.opendaylight.yangtools.yang.data.impl.NodeFactory -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.Module -import org.opendaylight.yangtools.yang.model.api.RpcDefinition -import org.opendaylight.yangtools.yang.model.api.SchemaContext -import org.opendaylight.yangtools.yang.model.api.TypeDefinition -import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition -import org.opendaylight.yangtools.yang.model.util.EmptyType -import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder -import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder - -import static javax.ws.rs.core.Response.Status.* - -class RestconfImpl implements RestconfService { - - val static RestconfImpl INSTANCE = new RestconfImpl - val static MOUNT_POINT_MODULE_NAME = "ietf-netconf" - val static REVISION_FORMAT = new SimpleDateFormat("yyyy-MM-dd") - val static RESTCONF_MODULE_DRAFT02_REVISION = "2013-10-19" - val static RESTCONF_MODULE_DRAFT02_NAME = "ietf-restconf" - val static RESTCONF_MODULE_DRAFT02_NAMESPACE = "urn:ietf:params:xml:ns:yang:ietf-restconf" - val static RESTCONF_MODULE_DRAFT02_RESTCONF_GROUPING_SCHEMA_NODE = "restconf" - val static RESTCONF_MODULE_DRAFT02_RESTCONF_CONTAINER_SCHEMA_NODE = "restconf" - val static RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE = "modules" - val static RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE = "module" - val static RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE = "streams" - val static RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE = "stream" - val static RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE = "operations" - val static SAL_REMOTE_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote" - val static SAL_REMOTE_RPC_SUBSRCIBE = "create-data-change-event-subscription" - - @Property - BrokerFacade broker - - @Property - extension ControllerContext controllerContext - - private new() { - if (INSTANCE !== null) { - throw new IllegalStateException("Already instantiated"); - } - } - - static def getInstance() { - return INSTANCE - } - - override getModules() { - val restconfModule = getRestconfModule() - val List> modulesAsData = new ArrayList - val moduleSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE) - for (module : allModules) { - modulesAsData.add(module.toModuleCompositeNode(moduleSchemaNode)) - } - val modulesSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE) - val modulesNode = NodeFactory.createImmutableCompositeNode(modulesSchemaNode.QName, null, modulesAsData) - return new StructuredData(modulesNode, modulesSchemaNode, null) - } - - override getAvailableStreams(){ - var Set availableStreams = Notificator.getStreamNames(); - val List> streamsAsData = new ArrayList - val streamSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE) - for (String streamName:availableStreams){ - streamsAsData.add(streamName.toStreamCompositeNode(streamSchemaNode)) - } - val streamsSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE) - val streamsNode = NodeFactory.createImmutableCompositeNode(streamsSchemaNode.QName, null, streamsAsData) - return new StructuredData(streamsNode, streamsSchemaNode, null) - } - override getModules(String identifier) { - var Set modules = null - var MountInstance mountPoint = null - if (identifier.contains(ControllerContext.MOUNT)) { - mountPoint = identifier.toMountPointIdentifier.mountPoint - modules = mountPoint.allModules - } else { - throw new ResponseException(BAD_REQUEST, "URI has bad format. If modules behind mount point should be showed, URI has to end with " + ControllerContext.MOUNT) - } - val List> modulesAsData = new ArrayList - val moduleSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE) - for (module : modules) { - modulesAsData.add(module.toModuleCompositeNode(moduleSchemaNode)) - } - val modulesSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE) - val modulesNode = NodeFactory.createImmutableCompositeNode(modulesSchemaNode.QName, null, modulesAsData) - return new StructuredData(modulesNode, modulesSchemaNode, mountPoint) - } - - override getModule(String identifier) { - val moduleNameAndRevision = identifier.moduleNameAndRevision - var Module module = null - var MountInstance mountPoint = null - if (identifier.contains(ControllerContext.MOUNT)) { - mountPoint = identifier.toMountPointIdentifier.mountPoint - module = mountPoint.findModuleByNameAndRevision(moduleNameAndRevision) - } else { - module = findModuleByNameAndRevision(moduleNameAndRevision) - } - if (module === null) { - throw new ResponseException(BAD_REQUEST, - "Module with name '" + moduleNameAndRevision.localName + "' and revision '" + - moduleNameAndRevision.revision + "' was not found.") - } - val moduleSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE) - val moduleNode = module.toModuleCompositeNode(moduleSchemaNode) - return new StructuredData(moduleNode, moduleSchemaNode, mountPoint) - } - - override getOperations() { - return operationsFromModulesToStructuredData(allModules,null) - } - - override getOperations(String identifier) { - var Set modules = null - var MountInstance mountPoint = null - if (identifier.contains(ControllerContext.MOUNT)) { - mountPoint = identifier.toMountPointIdentifier.mountPoint - modules = mountPoint.allModules - } else { - throw new ResponseException(BAD_REQUEST, "URI has bad format. If operations behind mount point should be showed, URI has to end with " + ControllerContext.MOUNT) - } - return operationsFromModulesToStructuredData(modules,mountPoint) - } - - private def StructuredData operationsFromModulesToStructuredData(Set modules,MountInstance mountPoint) { - val List> operationsAsData = new ArrayList - val operationsSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE) - val fakeOperationsSchemaNode = new ContainerSchemaNodeBuilder(RESTCONF_MODULE_DRAFT02_NAME, 0, operationsSchemaNode.QName, operationsSchemaNode.path) - for (module : modules) { - for (rpc : module.rpcs) { - operationsAsData.add(NodeFactory.createImmutableSimpleNode(rpc.QName, null, null)) - val fakeRpcSchemaNode = new LeafSchemaNodeBuilder(module.name, 0, rpc.QName, null) - fakeRpcSchemaNode.setAugmenting(true) - fakeRpcSchemaNode.setType(EmptyType.instance) - fakeOperationsSchemaNode.addChildNode(fakeRpcSchemaNode.build) - } - } - val operationsNode = NodeFactory.createImmutableCompositeNode(operationsSchemaNode.QName, null, operationsAsData) - return new StructuredData(operationsNode, fakeOperationsSchemaNode.build, mountPoint) - } - - private def Module getRestconfModule() { - val restconfModule = findModuleByNameAndRevision( - QName.create(RESTCONF_MODULE_DRAFT02_NAMESPACE, RESTCONF_MODULE_DRAFT02_REVISION, - RESTCONF_MODULE_DRAFT02_NAME)) - if (restconfModule === null) { - throw new ResponseException(INTERNAL_SERVER_ERROR, "Restconf module was not found.") - } - return restconfModule - } - - private def QName getModuleNameAndRevision(String identifier) { - val indexOfMountPointFirstLetter = identifier.indexOf(ControllerContext.MOUNT) - var moduleNameAndRevision = ""; - if (indexOfMountPointFirstLetter !== -1) { // module and revision is behind mount point string - moduleNameAndRevision = identifier.substring(indexOfMountPointFirstLetter + ControllerContext.MOUNT.length) - } else ( - moduleNameAndRevision = identifier - ) - val pathArgs = Lists.newArrayList(Splitter.on("/").omitEmptyStrings.split(moduleNameAndRevision)) - if (pathArgs.length < 2) { - throw new ResponseException(BAD_REQUEST, - "URI has bad format. End of URI should be in format 'moduleName/yyyy-MM-dd'") - } - try { - val moduleName = pathArgs.head - val moduleRevision = REVISION_FORMAT.parse(pathArgs.get(1)) - return QName.create(null, moduleRevision, moduleName) - } catch(ParseException e) { - throw new ResponseException(BAD_REQUEST, "URI has bad format. It should be 'moduleName/yyyy-MM-dd'") - } - } - - private def CompositeNode toStreamCompositeNode(String streamName, DataSchemaNode streamSchemaNode) { - val List> streamNodeValues = new ArrayList - val nameSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("name").head - streamNodeValues.add(NodeFactory.createImmutableSimpleNode(nameSchemaNode.QName, null, streamName)) - - val descriptionSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("description").head - streamNodeValues.add(NodeFactory.createImmutableSimpleNode(descriptionSchemaNode.QName, null, "DESCRIPTION_PLACEHOLDER")) - - val replaySupportSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("replay-support").head - streamNodeValues.add(NodeFactory.createImmutableSimpleNode(replaySupportSchemaNode.QName, null, true)) - - val replayLogCreationTimeSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("replay-log-creation-time").head - streamNodeValues.add(NodeFactory.createImmutableSimpleNode(replayLogCreationTimeSchemaNode.QName, null, "")) - - val eventsSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("events").head - streamNodeValues.add(NodeFactory.createImmutableSimpleNode(eventsSchemaNode.QName, null, "")) - - return NodeFactory.createImmutableCompositeNode(streamSchemaNode.QName, null, streamNodeValues) - } - private def CompositeNode toModuleCompositeNode(Module module, DataSchemaNode moduleSchemaNode) { - val List> moduleNodeValues = new ArrayList - val nameSchemaNode = (moduleSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("name").head - moduleNodeValues.add(NodeFactory.createImmutableSimpleNode(nameSchemaNode.QName, null, module.name)) - val revisionSchemaNode = (moduleSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("revision").head - moduleNodeValues.add(NodeFactory.createImmutableSimpleNode(revisionSchemaNode.QName, null, REVISION_FORMAT.format(module.revision))) - val namespaceSchemaNode = (moduleSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("namespace").head - moduleNodeValues.add(NodeFactory.createImmutableSimpleNode(namespaceSchemaNode.QName, null, module.namespace.toString)) - val featureSchemaNode = (moduleSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("feature").head - for (feature : module.features) { - moduleNodeValues.add(NodeFactory.createImmutableSimpleNode(featureSchemaNode.QName, null, feature.QName.localName)) - } - return NodeFactory.createImmutableCompositeNode(moduleSchemaNode.QName, null, moduleNodeValues) - } - - private def DataSchemaNode getSchemaNode(Module restconfModule, String schemaNodeName) { - val restconfGrouping = restconfModule.groupings.filter[g|g.QName.localName == RESTCONF_MODULE_DRAFT02_RESTCONF_GROUPING_SCHEMA_NODE].head - val restconfContainer = restconfGrouping.findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_RESTCONF_CONTAINER_SCHEMA_NODE).head - if (schemaNodeName == RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE) { - return (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE).head - } else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE) { - return (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE).head - } else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE) { - val modules = (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE).head - return (modules as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE).head - }else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE) { - return (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE).head - } else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE) { - val modules = (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE).head - return (modules as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE).head - } - return null - } - - override getRoot() { - return null; - } - - override invokeRpc(String identifier, CompositeNode payload) { - val rpc = resolveIdentifierInInvokeRpc(identifier) - if (rpc.QName.namespace.toString == SAL_REMOTE_NAMESPACE && rpc.QName.localName == SAL_REMOTE_RPC_SUBSRCIBE) { - val value = normalizeNode(payload, rpc.input, null) - val pathNode = value?.getFirstSimpleByName(QName.create(rpc.QName, "path")) - val pathValue = pathNode?.value - if (pathValue === null && !(pathValue instanceof InstanceIdentifier)) { - throw new ResponseException(INTERNAL_SERVER_ERROR, "Instance identifier was not normalized correctly."); - } - val pathIdentifier = (pathValue as InstanceIdentifier) - var String streamName = null - if (!pathIdentifier.path.nullOrEmpty) { - streamName = Notificator.createStreamNameFromUri(pathIdentifier.toFullRestconfIdentifier) - } - if (streamName.nullOrEmpty) { - throw new ResponseException(BAD_REQUEST, "Path is empty or contains data node which is not Container or List build-in type."); - } - val streamNameNode = NodeFactory.createImmutableSimpleNode(QName.create(rpc.output.QName, "stream-name"), null, streamName) - val List> output = new ArrayList - output.add(streamNameNode) - val responseData = NodeFactory.createMutableCompositeNode(rpc.output.QName, null, output, null, null) - - if (!Notificator.existListenerFor(pathIdentifier)) { - Notificator.createListener(pathIdentifier, streamName) - } - - return new StructuredData(responseData, rpc.output, null) - } - return callRpc(identifier.rpcDefinition, payload) - } - - override invokeRpc(String identifier, String noPayload) { - if (!noPayload.nullOrEmpty) { - throw new ResponseException(UNSUPPORTED_MEDIA_TYPE, "Content-Type contains unsupported Media Type."); - } - val rpc = resolveIdentifierInInvokeRpc(identifier) - return callRpc(rpc, null) - } - - private def resolveIdentifierInInvokeRpc(String identifier) { - if (identifier.indexOf("/") === -1) { - val identifierDecoded = identifier.urlPathArgDecode - val rpc = identifierDecoded.rpcDefinition - if (rpc !== null) { - return rpc - } - throw new ResponseException(NOT_FOUND, "RPC does not exist."); - } - val slashErrorMsg = String.format( - "Identifier %n%s%ncan't contain slash character (/).%nIf slash is part of identifier name then use %%2F placeholder.", identifier) - throw new ResponseException(NOT_FOUND, slashErrorMsg); - } - - private def StructuredData callRpc(RpcDefinition rpc, CompositeNode payload) { - if (rpc === null) { - throw new ResponseException(NOT_FOUND, "RPC does not exist."); - } - var CompositeNode rpcRequest; - if (payload === null) { - rpcRequest = NodeFactory.createMutableCompositeNode(rpc.QName, null, null, null, null) - } else { - val value = normalizeNode(payload, rpc.input, null) - val List> input = new ArrayList - input.add(value) - rpcRequest = NodeFactory.createMutableCompositeNode(rpc.QName, null, input, null, null) - } - val rpcResult = broker.invokeRpc(rpc.QName, rpcRequest); - if (!rpcResult.successful) { - throw new ResponseException(INTERNAL_SERVER_ERROR, "Operation failed") - } - if (rpcResult.result === null) { - return null - } - return new StructuredData(rpcResult.result, rpc.output, null) - } - - override readConfigurationData(String identifier) { - val iiWithData = identifier.toInstanceIdentifier - var CompositeNode data = null; - if (iiWithData.mountPoint !== null) { - data = broker.readConfigurationDataBehindMountPoint(iiWithData.mountPoint, iiWithData.getInstanceIdentifier) - } else { - data = broker.readConfigurationData(iiWithData.getInstanceIdentifier); - } - return new StructuredData(data, iiWithData.schemaNode, iiWithData.mountPoint) - } - - override readOperationalData(String identifier) { - val iiWithData = identifier.toInstanceIdentifier - var CompositeNode data = null; - if (iiWithData.mountPoint !== null) { - data = broker.readOperationalDataBehindMountPoint(iiWithData.mountPoint, iiWithData.getInstanceIdentifier) - } else { - data = broker.readOperationalData(iiWithData.getInstanceIdentifier); - } - return new StructuredData(data, iiWithData.schemaNode, iiWithData.mountPoint) - } - - override updateConfigurationData(String identifier, CompositeNode payload) { - val iiWithData = identifier.toInstanceIdentifier - val value = normalizeNode(payload, iiWithData.schemaNode, iiWithData.mountPoint) - var RpcResult status = null - if (iiWithData.mountPoint !== null) { - status = broker.commitConfigurationDataPutBehindMountPoint(iiWithData.mountPoint, - iiWithData.instanceIdentifier, value).get() - } else { - status = broker.commitConfigurationDataPut(iiWithData.instanceIdentifier, value).get(); - } - switch status.result { - case TransactionStatus.COMMITED: Response.status(OK).build - default: Response.status(INTERNAL_SERVER_ERROR).build - } - } - - override createConfigurationData(String identifier, CompositeNode payload) { - if (payload.namespace === null) { - throw new ResponseException(BAD_REQUEST, - "Data has bad format. Root element node must have namespace (XML format) or module name(JSON format)"); - } - var InstanceIdWithSchemaNode iiWithData; - var CompositeNode value; - if (payload.representsMountPointRootData) { // payload represents mount point data and URI represents path to the mount point - if (identifier.endsWithMountPoint) { - throw new ResponseException(BAD_REQUEST, - "URI has bad format. URI should be without \"" + ControllerContext.MOUNT + "\" for POST operation."); - } - val completIdentifier = identifier.addMountPointIdentifier - iiWithData = completIdentifier.toInstanceIdentifier - value = normalizeNode(payload, iiWithData.schemaNode, iiWithData.mountPoint) - } else { - val uncompleteInstIdWithData = identifier.toInstanceIdentifier - val parentSchema = uncompleteInstIdWithData.schemaNode as DataNodeContainer - val module = uncompleteInstIdWithData.mountPoint.findModule(payload) - if (module === null) { - throw new ResponseException(BAD_REQUEST, "Module was not found for \"" + payload.namespace + "\"") - } - val schemaNode = parentSchema.findInstanceDataChildByNameAndNamespace(payload.name, module.namespace) - value = normalizeNode(payload, schemaNode, uncompleteInstIdWithData.mountPoint) - iiWithData = uncompleteInstIdWithData.addLastIdentifierFromData(value, schemaNode) - } - var RpcResult status = null - if (iiWithData.mountPoint !== null) { - status = broker.commitConfigurationDataPostBehindMountPoint(iiWithData.mountPoint, - iiWithData.instanceIdentifier, value)?.get(); - } else { - status = broker.commitConfigurationDataPost(iiWithData.instanceIdentifier, value)?.get(); - } - if (status === null) { - return Response.status(ACCEPTED).build - } - switch status.result { - case TransactionStatus.COMMITED: Response.status(NO_CONTENT).build - default: Response.status(INTERNAL_SERVER_ERROR).build - } - } - - override createConfigurationData(CompositeNode payload) { - if (payload.namespace === null) { - throw new ResponseException(BAD_REQUEST, - "Data has bad format. Root element node must have namespace (XML format) or module name(JSON format)"); - } - val module = findModule(null, payload) - if (module === null) { - throw new ResponseException(BAD_REQUEST, - "Data has bad format. Root element node has incorrect namespace (XML format) or module name(JSON format)"); - } - val schemaNode = module.findInstanceDataChildByNameAndNamespace(payload.name, module.namespace) - val value = normalizeNode(payload, schemaNode, null) - val iiWithData = addLastIdentifierFromData(null, value, schemaNode) - var RpcResult status = null - if (iiWithData.mountPoint !== null) { - status = broker.commitConfigurationDataPostBehindMountPoint(iiWithData.mountPoint, - iiWithData.instanceIdentifier, value)?.get(); - } else { - status = broker.commitConfigurationDataPost(iiWithData.instanceIdentifier, value)?.get(); - } - if (status === null) { - return Response.status(ACCEPTED).build - } - switch status.result { - case TransactionStatus.COMMITED: Response.status(NO_CONTENT).build - default: Response.status(INTERNAL_SERVER_ERROR).build - } - } - - override deleteConfigurationData(String identifier) { - val iiWithData = identifier.toInstanceIdentifier - var RpcResult status = null - if (iiWithData.mountPoint !== null) { - status = broker.commitConfigurationDataDeleteBehindMountPoint(iiWithData.mountPoint, - iiWithData.getInstanceIdentifier).get; - } else { - status = broker.commitConfigurationDataDelete(iiWithData.getInstanceIdentifier).get; - } - switch status.result { - case TransactionStatus.COMMITED: Response.status(OK).build - default: Response.status(INTERNAL_SERVER_ERROR).build - } - } - - override subscribeToStream(String identifier, UriInfo uriInfo) { - val streamName = Notificator.createStreamNameFromUri(identifier) - if (streamName.nullOrEmpty) { - throw new ResponseException(BAD_REQUEST, "Stream name is empty.") - } - val listener = Notificator.getListenerFor(streamName); - if (listener === null) { - throw new ResponseException(BAD_REQUEST, "Stream was not found.") - } - broker.registerToListenDataChanges(listener) - val uriBuilder = uriInfo.getAbsolutePathBuilder() - val uriToWebsocketServer = uriBuilder.port(WebSocketServer.PORT).replacePath(streamName).build() - return Response.status(OK).location(uriToWebsocketServer).build - } - - private def dispatch URI namespace(CompositeNode data) { - return data.nodeType.namespace - } - - private def dispatch URI namespace(CompositeNodeWrapper data) { - return data.namespace - } - - private def dispatch String localName(CompositeNode data) { - return data.nodeType.localName - } - - private def dispatch String localName(CompositeNodeWrapper data) { - return data.localName - } - - private def dispatch Module findModule(MountInstance mountPoint, CompositeNode data) { - if (mountPoint !== null) { - return mountPoint.findModuleByNamespace(data.nodeType.namespace) - } else { - return findModuleByNamespace(data.nodeType.namespace) - } - } - - private def dispatch Module findModule(MountInstance mountPoint, CompositeNodeWrapper data) { - Preconditions.checkNotNull(data.namespace) - var Module module = null; - if (mountPoint !== null) { - module = mountPoint.findModuleByNamespace(data.namespace) // namespace from XML - if (module === null) { - module = mountPoint.findModuleByName(data.namespace.toString) // namespace (module name) from JSON - } - } else { - module = data.namespace.findModuleByNamespace // namespace from XML - if (module === null) { - module = data.namespace.toString.findModuleByName // namespace (module name) from JSON - } - } - return module - } - - private def dispatch getName(CompositeNode data) { - return data.nodeType.localName - } - - private def dispatch getName(CompositeNodeWrapper data) { - return data.localName - } - - private def InstanceIdWithSchemaNode addLastIdentifierFromData(InstanceIdWithSchemaNode identifierWithSchemaNode, - CompositeNode data, DataSchemaNode schemaOfData) { - val iiOriginal = identifierWithSchemaNode?.instanceIdentifier - var InstanceIdentifierBuilder iiBuilder = null - if (iiOriginal === null) { - iiBuilder = InstanceIdentifier.builder - } else { - iiBuilder = InstanceIdentifier.builder(iiOriginal) - } - - if (schemaOfData instanceof ListSchemaNode) { - iiBuilder.nodeWithKey(schemaOfData.QName, (schemaOfData as ListSchemaNode).resolveKeysFromData(data)) - } else { - iiBuilder.node(schemaOfData.QName) - } - return new InstanceIdWithSchemaNode(iiBuilder.toInstance, schemaOfData, identifierWithSchemaNode?.mountPoint) - } - - private def resolveKeysFromData(ListSchemaNode listNode, CompositeNode dataNode) { - val keyValues = new HashMap(); - for (key : listNode.keyDefinition) { - val dataNodeKeyValueObject = dataNode.getSimpleNodesByName(key.localName)?.head?.value - if (dataNodeKeyValueObject === null) { - throw new ResponseException(BAD_REQUEST, - "Data contains list \"" + dataNode.nodeType.localName + "\" which does not contain key: \"" + - key.localName + "\"") - } - keyValues.put(key, dataNodeKeyValueObject); - } - return keyValues - } - - private def endsWithMountPoint(String identifier) { - return (identifier.endsWith(ControllerContext.MOUNT) || identifier.endsWith(ControllerContext.MOUNT + "/")) - } - - private def representsMountPointRootData(CompositeNode data) { - return ((data.namespace == SchemaContext.NAME.namespace || data.namespace == MOUNT_POINT_MODULE_NAME) && - data.localName == SchemaContext.NAME.localName) - } - - private def addMountPointIdentifier(String identifier) { - if (identifier.endsWith("/")) { - return identifier + ControllerContext.MOUNT - } - return identifier + "/" + ControllerContext.MOUNT - } - - private def CompositeNode normalizeNode(CompositeNode node, DataSchemaNode schema, MountInstance mountPoint) { - if (schema === null) { - throw new ResponseException(INTERNAL_SERVER_ERROR, - "Data schema node was not found for " + node?.nodeType?.localName) - } - if (!(schema instanceof DataNodeContainer)) { - throw new ResponseException(BAD_REQUEST, "Root element has to be container or list yang datatype."); - } - if (node instanceof CompositeNodeWrapper) { - if ((node as CompositeNodeWrapper).changeAllowed) { - try { - normalizeNode(node as CompositeNodeWrapper, schema, null, mountPoint) - } catch (NumberFormatException e) { - throw new ResponseException(BAD_REQUEST,e.message) - } - } - return (node as CompositeNodeWrapper).unwrap() - } - return node - } - - private def void normalizeNode(NodeWrapper nodeBuilder, DataSchemaNode schema, QName previousAugment, - MountInstance mountPoint) { - if (schema === null) { - throw new ResponseException(BAD_REQUEST, - "Data has bad format.\n\"" + nodeBuilder.localName + "\" does not exist in yang schema."); - } - - var QName currentAugment; - if (nodeBuilder.qname !== null) { - currentAugment = previousAugment - } else { - currentAugment = normalizeNodeName(nodeBuilder, schema, previousAugment, mountPoint) - if (nodeBuilder.qname === null) { - throw new ResponseException(BAD_REQUEST, - "Data has bad format.\nIf data is in XML format then namespace for \"" + nodeBuilder.localName + - "\" should be \"" + schema.QName.namespace + "\".\n" + - "If data is in JSON format then module name for \"" + nodeBuilder.localName + - "\" should be corresponding to namespace \"" + schema.QName.namespace + "\"."); - } - } - - if (nodeBuilder instanceof CompositeNodeWrapper) { - val List> children = (nodeBuilder as CompositeNodeWrapper).getValues - for (child : children) { - val potentialSchemaNodes = (schema as DataNodeContainer).findInstanceDataChildrenByName(child.localName) - if (potentialSchemaNodes.size > 1 && child.namespace === null) { - val StringBuilder namespacesOfPotentialModules = new StringBuilder; - for (potentialSchemaNode : potentialSchemaNodes) { - namespacesOfPotentialModules.append(" ").append(potentialSchemaNode.QName.namespace.toString).append("\n") - } - throw new ResponseException(BAD_REQUEST, - "Node \"" + child.localName + "\" is added as augment from more than one module. " - + "Therefore node must have namespace (XML format) or module name (JSON format)." - + "\nThe node is added as augment from modules with namespaces:\n" + namespacesOfPotentialModules) - } - var rightNodeSchemaFound = false - for (potentialSchemaNode : potentialSchemaNodes) { - if (!rightNodeSchemaFound) { - val potentialCurrentAugment = normalizeNodeName(child, potentialSchemaNode, currentAugment, - mountPoint) - if (child.qname !== null) { - normalizeNode(child, potentialSchemaNode, potentialCurrentAugment, mountPoint) - rightNodeSchemaFound = true - } - } - } - if (!rightNodeSchemaFound) { - throw new ResponseException(BAD_REQUEST, - "Schema node \"" + child.localName + "\" was not found in module.") - } - } - if (schema instanceof ListSchemaNode) { - val listKeys = (schema as ListSchemaNode).keyDefinition - for (listKey : listKeys) { - var foundKey = false - for (child : children) { - if (child.unwrap.nodeType.localName == listKey.localName) { - foundKey = true; - } - } - if (!foundKey) { - throw new ResponseException(BAD_REQUEST, - "Missing key in URI \"" + listKey.localName + "\" of list \"" + schema.QName.localName + - "\"") - } - } - } - } else if (nodeBuilder instanceof SimpleNodeWrapper) { - val simpleNode = (nodeBuilder as SimpleNodeWrapper) - val value = simpleNode.value - var inputValue = value; - - if (schema.typeDefinition instanceof IdentityrefTypeDefinition) { - if (value instanceof String) { - inputValue = new IdentityValuesDTO(nodeBuilder.namespace.toString, value as String, null,value as String); - } // else value is already instance of IdentityValuesDTO - } - - val outputValue = RestCodec.from(schema.typeDefinition, mountPoint)?.deserialize(inputValue); - simpleNode.setValue(outputValue) - } else if (nodeBuilder instanceof EmptyNodeWrapper) { - val emptyNodeBuilder = nodeBuilder as EmptyNodeWrapper - if (schema instanceof LeafSchemaNode) { - emptyNodeBuilder.setComposite(false); - } else if (schema instanceof ContainerSchemaNode) { - - // FIXME: Add presence check - emptyNodeBuilder.setComposite(true); - } - } - } - - private def dispatch TypeDefinition typeDefinition(LeafSchemaNode node) { - var baseType = node.type - while (baseType.baseType !== null) { - baseType = baseType.baseType; - } - baseType - } - - private def dispatch TypeDefinition typeDefinition(LeafListSchemaNode node) { - var TypeDefinition baseType = node.type - while (baseType.baseType !== null) { - baseType = baseType.baseType; - } - baseType - } - - private def QName normalizeNodeName(NodeWrapper nodeBuilder, DataSchemaNode schema, QName previousAugment, - MountInstance mountPoint) { - var validQName = schema.QName - var currentAugment = previousAugment; - if (schema.augmenting) { - currentAugment = schema.QName - } else if (previousAugment !== null && schema.QName.namespace !== previousAugment.namespace) { - validQName = QName.create(currentAugment, schema.QName.localName); - } - var String moduleName = null; - if (mountPoint === null) { - moduleName = controllerContext.findModuleNameByNamespace(validQName.namespace); - } else { - moduleName = controllerContext.findModuleNameByNamespace(mountPoint, validQName.namespace) - } - if (nodeBuilder.namespace === null || nodeBuilder.namespace == validQName.namespace || - nodeBuilder.namespace.toString == moduleName || nodeBuilder.namespace == MOUNT_POINT_MODULE_NAME) { - nodeBuilder.qname = validQName - } - return currentAugment - } - -} 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 new file mode 100644 index 0000000000..18199de8c6 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java @@ -0,0 +1,337 @@ +/* + * Copyright (c) ${year} 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.assertSame; +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 java.util.Map; +import java.util.concurrent.Future; + +import javax.ws.rs.core.Response.Status; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.InOrder; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; +import org.opendaylight.controller.sal.core.api.data.DataBrokerService; +import org.opendaylight.controller.sal.core.api.data.DataChangeListener; +import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.core.api.mount.MountInstance; +import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider; +import org.opendaylight.controller.sal.restconf.impl.BrokerFacade; +import org.opendaylight.controller.sal.restconf.impl.ResponseException; +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.common.RpcResult; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; + +import com.google.common.collect.ImmutableMap; +import com.google.common.util.concurrent.Futures; + +/** + * Unit tests for BrokerFacade. + * + * @author Thomas Pantelis + */ +public class BrokerFacadeTest { + + @Mock + DataBrokerService dataBroker; + + @Mock + DataModificationTransaction mockTransaction; + + @Mock + ConsumerSession mockConsumerSession; + + @Mock + MountInstance mockMountInstance; + + BrokerFacade brokerFacade = BrokerFacade.getInstance(); + + CompositeNode dataNode = TestUtils.readInputToCnSn( "/parts/ietf-interfaces_interfaces.xml", + XmlToCompositeNodeProvider.INSTANCE ); + + QName qname = QName.create( "node" ); + + InstanceIdentifier instanceID = InstanceIdentifier.builder().node( qname ).toInstance(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks( this ); + + brokerFacade.setDataService( dataBroker ); + brokerFacade.setContext( mockConsumerSession ); + } + + @Test + public void testReadConfigurationData() { + when( dataBroker.readConfigurationData( instanceID ) ).thenReturn( dataNode ); + + CompositeNode actualNode = brokerFacade.readConfigurationData( instanceID ); + + assertSame( "readConfigurationData", dataNode, actualNode ); + } + + @Test + public void testReadConfigurationDataBehindMountPoint() { + when( mockMountInstance.readConfigurationData( instanceID ) ).thenReturn( dataNode ); + + CompositeNode actualNode = brokerFacade.readConfigurationDataBehindMountPoint( + mockMountInstance, instanceID ); + + assertSame( "readConfigurationDataBehindMountPoint", dataNode, actualNode ); + } + + @Test + public void testReadOperationalData() { + when( dataBroker.readOperationalData( instanceID ) ).thenReturn( dataNode ); + + CompositeNode actualNode = brokerFacade.readOperationalData( instanceID ); + + assertSame( "readOperationalData", dataNode, actualNode ); + } + + @Test + public void testReadOperationalDataBehindMountPoint() { + when( mockMountInstance.readOperationalData( instanceID ) ).thenReturn( dataNode ); + + CompositeNode actualNode = brokerFacade.readOperationalDataBehindMountPoint( + mockMountInstance, instanceID ); + + assertSame( "readOperationalDataBehindMountPoint", dataNode, actualNode ); + } + + @Test(expected=ResponseException.class) + public void testReadOperationalDataWithNoDataBroker() { + brokerFacade.setDataService( null ); + + brokerFacade.readOperationalData( instanceID ); + } + + @SuppressWarnings("unchecked") + @Test + public void testInvokeRpc() { + RpcResult expResult = mock( RpcResult.class ); + Future> future = Futures.immediateFuture( expResult ); + when( mockConsumerSession.rpc( qname, dataNode ) ).thenReturn( future ); + + RpcResult actualResult = brokerFacade.invokeRpc( qname, dataNode ); + + assertSame( "invokeRpc", expResult, actualResult ); + } + + @Test(expected=ResponseException.class) + public void testInvokeRpcWithException() { + Exception mockEx = new Exception( "mock" ); + Future> future = Futures.immediateFailedFuture( mockEx ); + when( mockConsumerSession.rpc( qname, dataNode ) ).thenReturn( future ); + + brokerFacade.invokeRpc( qname, dataNode ); + } + + @Test(expected=ResponseException.class) + public void testInvokeRpcWithNoConsumerSession() { + brokerFacade.setContext( null ); + + brokerFacade.invokeRpc( qname, dataNode ); + } + + @Test + public void testCommitConfigurationDataPut() { + Future> expFuture = Futures.immediateFuture( null ); + + when( dataBroker.beginTransaction() ).thenReturn( mockTransaction ); + mockTransaction.putConfigurationData( instanceID, dataNode ); + when( mockTransaction.commit() ).thenReturn( expFuture ); + + Future> actualFuture = + brokerFacade.commitConfigurationDataPut( instanceID, dataNode ); + + assertSame( "invokeRpc", expFuture, actualFuture ); + + InOrder inOrder = inOrder( dataBroker, mockTransaction ); + inOrder.verify( dataBroker ).beginTransaction(); + inOrder.verify( mockTransaction ).putConfigurationData( instanceID, dataNode ); + inOrder.verify( mockTransaction ).commit(); + } + + @Test + public void testCommitConfigurationDataPutBehindMountPoint() { + Future> expFuture = Futures.immediateFuture( null ); + + when( mockMountInstance.beginTransaction() ).thenReturn( mockTransaction ); + mockTransaction.putConfigurationData( instanceID, dataNode ); + when( mockTransaction.commit() ).thenReturn( expFuture ); + + Future> actualFuture = + brokerFacade.commitConfigurationDataPutBehindMountPoint( + mockMountInstance, instanceID, dataNode ); + + assertSame( "invokeRpc", expFuture, actualFuture ); + + InOrder inOrder = inOrder( mockMountInstance, mockTransaction ); + inOrder.verify( mockMountInstance ).beginTransaction(); + inOrder.verify( mockTransaction ).putConfigurationData( instanceID, dataNode ); + inOrder.verify( mockTransaction ).commit(); + } + + @Test + public void testCommitConfigurationDataPost() { + Future> expFuture = Futures.immediateFuture( null ); + + Map nodeMap = + new ImmutableMap.Builder() + .put( instanceID, dataNode ).build(); + + when( dataBroker.beginTransaction() ).thenReturn( mockTransaction ); + mockTransaction.putConfigurationData( instanceID, dataNode ); + when( mockTransaction.getCreatedConfigurationData() ).thenReturn( nodeMap ); + when( mockTransaction.commit() ).thenReturn( expFuture ); + + Future> actualFuture = + brokerFacade.commitConfigurationDataPost( instanceID, dataNode ); + + assertSame( "commitConfigurationDataPut", expFuture, actualFuture ); + + InOrder inOrder = inOrder( dataBroker, mockTransaction ); + inOrder.verify( dataBroker ).beginTransaction(); + inOrder.verify( mockTransaction ).putConfigurationData( instanceID, dataNode ); + inOrder.verify( mockTransaction ).commit(); + } + + @Test(expected=ResponseException.class) + public void testCommitConfigurationDataPostAlreadyExists() { + when( dataBroker.beginTransaction() ).thenReturn( mockTransaction ); + mockTransaction.putConfigurationData( instanceID, dataNode ); + when ( mockTransaction.readConfigurationData( instanceID ) ) + .thenReturn( dataNode ); + try { + brokerFacade.commitConfigurationDataPost( instanceID, dataNode ); + } catch (ResponseException e) { + assertEquals("Unexpect Exception Status -> " + + "http://tools.ietf.org/html/draft-bierman-netconf-restconf-03#page-48", + (e.getResponse().getStatus()), Status.CONFLICT.getStatusCode()); + throw e; + } + } + + @Test + public void testCommitConfigurationDataPostBehindMountPoint() { + Future> expFuture = Futures.immediateFuture( null ); + + Map nodeMap = + new ImmutableMap.Builder() + .put( instanceID, dataNode ).build(); + + when( mockMountInstance.beginTransaction() ).thenReturn( mockTransaction ); + mockTransaction.putConfigurationData( instanceID, dataNode ); + when( mockTransaction.getCreatedConfigurationData() ).thenReturn( nodeMap ); + when( mockTransaction.commit() ).thenReturn( expFuture ); + + Future> actualFuture = + brokerFacade.commitConfigurationDataPostBehindMountPoint( mockMountInstance, + instanceID, dataNode ); + + assertSame( "commitConfigurationDataPostBehindMountPoint", expFuture, actualFuture ); + + InOrder inOrder = inOrder( mockMountInstance, mockTransaction ); + inOrder.verify( mockMountInstance ).beginTransaction(); + inOrder.verify( mockTransaction ).putConfigurationData( instanceID, dataNode ); + inOrder.verify( mockTransaction ).commit(); + } + + @Test(expected=ResponseException.class) + public void testCommitConfigurationDataPostBehindMountPointAlreadyExists() { + + when( mockMountInstance.beginTransaction() ).thenReturn( mockTransaction ); + mockTransaction.putConfigurationData( instanceID, dataNode ); + when ( mockTransaction.readConfigurationData( instanceID ) ) + .thenReturn( dataNode ); + try { + brokerFacade.commitConfigurationDataPostBehindMountPoint( mockMountInstance, + instanceID, dataNode ); + } catch (ResponseException e) { + assertEquals("Unexpect Exception Status -> " + + "http://tools.ietf.org/html/draft-bierman-netconf-restconf-03#page-48", + e.getResponse().getStatus(), Status.CONFLICT.getStatusCode()); + throw e; + } + } + + @Test + public void testCommitConfigurationDataDelete() { + Future> expFuture = Futures.immediateFuture( null ); + + when( dataBroker.beginTransaction() ).thenReturn( mockTransaction ); + mockTransaction.removeConfigurationData( instanceID ); + when( mockTransaction.commit() ).thenReturn( expFuture ); + + Future> actualFuture = + brokerFacade.commitConfigurationDataDelete( instanceID ); + + assertSame( "commitConfigurationDataDelete", expFuture, actualFuture ); + + InOrder inOrder = inOrder( dataBroker, mockTransaction ); + inOrder.verify( dataBroker ).beginTransaction(); + inOrder.verify( mockTransaction ).removeConfigurationData( instanceID ); + inOrder.verify( mockTransaction ).commit(); + } + + @Test + public void testCommitConfigurationDataDeleteBehindMountPoint() { + Future> expFuture = Futures.immediateFuture( null ); + + when( mockMountInstance.beginTransaction() ).thenReturn( mockTransaction ); + mockTransaction.removeConfigurationData( instanceID ); + when( mockTransaction.commit() ).thenReturn( expFuture ); + + Future> actualFuture = + brokerFacade.commitConfigurationDataDeleteBehindMountPoint( + mockMountInstance, instanceID ); + + assertSame( "commitConfigurationDataDeleteBehindMountPoint", expFuture, actualFuture ); + + InOrder inOrder = inOrder( mockMountInstance, mockTransaction ); + inOrder.verify( mockMountInstance ).beginTransaction(); + inOrder.verify( mockTransaction ).removeConfigurationData( instanceID ); + inOrder.verify( mockTransaction ).commit(); + } + + @SuppressWarnings("unchecked") + @Test + public void testRegisterToListenDataChanges() { + ListenerAdapter listener = Notificator.createListener( instanceID, "stream" ); + + ListenerRegistration mockRegistration = mock( ListenerRegistration.class ); + when( dataBroker.registerDataChangeListener( instanceID, listener ) ) + .thenReturn( mockRegistration ); + + brokerFacade.registerToListenDataChanges( listener ); + + verify( dataBroker ).registerDataChangeListener( instanceID, listener ); + + assertEquals( "isListening", true, listener.isListening() ); + + brokerFacade.registerToListenDataChanges( listener ); + verifyNoMoreInteractions( dataBroker ); + } +} 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 index 320a7f9d08..4198e20b83 100644 --- 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 @@ -234,7 +234,7 @@ public class RestGetOperationTest extends JerseyTest { response = target(uri).request("application/yang.api+xml").get(); responseBody = response.readEntity(String.class); assertNotNull(responseBody); - assertTrue(responseBody.contains("")); + assertTrue(responseBody.contains(" org.apache.felix maven-bundle-plugin - - - org.opendaylight.controller.sample.toaster.provider.api, - org.opendaylight.controller.config.yang.toaster-consumer, - * - - org.opendaylight.yangtools diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/kitchen_service/impl/KitchenServiceModule.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/kitchen_service/impl/KitchenServiceModule.java new file mode 100644 index 0000000000..4dc3645131 --- /dev/null +++ b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/kitchen_service/impl/KitchenServiceModule.java @@ -0,0 +1,76 @@ +/** +* Generated file + +* Generated from: yang module name: toaster-consumer-impl yang module local name: toaster-consumer-impl +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Wed Feb 05 11:31:30 CET 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.controller.config.yang.config.kitchen_service.impl; + +import org.opendaylight.controller.config.yang.config.kitchen_service.impl.AbstractKitchenServiceModule; +import org.opendaylight.controller.sample.kitchen.api.EggsType; +import org.opendaylight.controller.sample.kitchen.api.KitchenService; +import org.opendaylight.controller.sample.kitchen.impl.KitchenServiceImpl; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService; +import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** +* +*/ +public final class KitchenServiceModule extends AbstractKitchenServiceModule { + private static final Logger log = LoggerFactory.getLogger(KitchenServiceModule.class); + + public KitchenServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public KitchenServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + KitchenServiceModule oldModule, java.lang.AutoCloseable oldInstance) { + + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + protected void customValidation(){ + // No need to validate dependencies, since all dependencies have mandatory true flag in yang + // config-subsystem will perform the validation + } + + @Override + public java.lang.AutoCloseable createInstance() { + ToasterService toasterService = getRpcRegistryDependency().getRpcService(ToasterService.class); + + final KitchenServiceImpl kitchenService = new KitchenServiceImpl(toasterService); + + final Registration toasterListenerReg = + getNotificationServiceDependency().registerNotificationListener( kitchenService ); + + final KitchenServiceRuntimeRegistration runtimeReg = + getRootRuntimeBeanRegistratorWrapper().register( kitchenService ); + + final class AutoCloseableKitchenService implements KitchenService, AutoCloseable { + + @Override + public void close() throws Exception { + toasterListenerReg.close(); + runtimeReg.close(); + log.info("Toaster consumer (instance {}) torn down.", this); + } + + @Override + public boolean makeBreakfast( EggsType eggs, Class toast, int toastDoneness ) { + return kitchenService.makeBreakfast( eggs, toast, toastDoneness ); + } + } + + AutoCloseable ret = new AutoCloseableKitchenService(); + log.info("KitchenService (instance {}) initialized.", ret ); + return ret; + } +} diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/toaster_consumer/impl/ToasterConsumerModuleFactory.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/kitchen_service/impl/KitchenServiceModuleFactory.java similarity index 56% rename from opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/toaster_consumer/impl/ToasterConsumerModuleFactory.java rename to opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/kitchen_service/impl/KitchenServiceModuleFactory.java index f8048947b9..2d6e7f3262 100644 --- a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/toaster_consumer/impl/ToasterConsumerModuleFactory.java +++ b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/kitchen_service/impl/KitchenServiceModuleFactory.java @@ -7,12 +7,14 @@ * * Do not modify this file unless it is present under src/main directory */ -package org.opendaylight.controller.config.yang.config.toaster_consumer.impl; +package org.opendaylight.controller.config.yang.config.kitchen_service.impl; + +import org.opendaylight.controller.config.yang.config.kitchen_service.impl.AbstractKitchenServiceModuleFactory; /** * */ -public class ToasterConsumerModuleFactory extends org.opendaylight.controller.config.yang.config.toaster_consumer.impl.AbstractToasterConsumerModuleFactory +public class KitchenServiceModuleFactory extends AbstractKitchenServiceModuleFactory { diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/toaster_consumer/impl/ToasterConsumerModule.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/toaster_consumer/impl/ToasterConsumerModule.java deleted file mode 100644 index 486cdcf04e..0000000000 --- a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/config/yang/config/toaster_consumer/impl/ToasterConsumerModule.java +++ /dev/null @@ -1,75 +0,0 @@ -/** -* Generated file - -* Generated from: yang module name: toaster-consumer-impl yang module local name: toaster-consumer-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Wed Feb 05 11:31:30 CET 2014 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.config.toaster_consumer.impl; - -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.controller.sample.toaster.provider.api.ToastConsumer; -import org.opendaylight.controller.sample.toaster.provider.impl.ToastConsumerImpl; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastDone; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService; -import org.opendaylight.yangtools.concepts.Registration; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** -* -*/ -public final class ToasterConsumerModule extends org.opendaylight.controller.config.yang.config.toaster_consumer.impl.AbstractToasterConsumerModule - { - private static final Logger log = LoggerFactory.getLogger(ToasterConsumerModule.class); - - public ToasterConsumerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public ToasterConsumerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, - ToasterConsumerModule oldModule, java.lang.AutoCloseable oldInstance) { - - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - protected void customValidation(){ - // No need to validate dependencies, since all dependencies have mandatory true flag in yang - // config-subsystem will perform the validation - } - - @Override - public java.lang.AutoCloseable createInstance() { - ToasterService toasterService = getRpcRegistryDependency().getRpcService(ToasterService.class); - - final ToastConsumerImpl consumer = new ToastConsumerImpl(toasterService); - final Registration> notificationRegistration = getNotificationServiceDependency() - .registerNotificationListener(ToastDone.class, consumer); - - final ToasterConsumerRuntimeRegistration runtimeRegistration = getRootRuntimeBeanRegistratorWrapper().register(consumer); - - final class AutoCloseableToastConsumer implements AutoCloseable, ToastConsumer { - - @Override - public void close() throws Exception { - runtimeRegistration.close(); - notificationRegistration.close(); - log.info("Toaster consumer (instance {}) torn down.", this); - } - - @Override - public boolean createToast(Class type, int doneness) { - return consumer.createToast(type, doneness); - } - } - - AutoCloseable ret = new AutoCloseableToastConsumer(); - log.info("Toaster consumer (instance {}) initialized.", ret); - return ret; - } -} diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/api/EggsType.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/api/EggsType.java new file mode 100644 index 0000000000..d9c7f4578e --- /dev/null +++ b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/api/EggsType.java @@ -0,0 +1,7 @@ +package org.opendaylight.controller.sample.kitchen.api; + +public enum EggsType { + SCRAMBLED, + OVER_EASY, + POACHED +} diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/api/KitchenService.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/api/KitchenService.java new file mode 100644 index 0000000000..ef9c122ec1 --- /dev/null +++ b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/api/KitchenService.java @@ -0,0 +1,7 @@ +package org.opendaylight.controller.sample.kitchen.api; + +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType; + +public interface KitchenService { + boolean makeBreakfast( EggsType eggs, Class toast, int toastDoneness ); +} diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java new file mode 100644 index 0000000000..911a8c87d7 --- /dev/null +++ b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java @@ -0,0 +1,84 @@ +package org.opendaylight.controller.sample.kitchen.impl; + +import java.util.concurrent.ExecutionException; + +import org.opendaylight.controller.config.yang.config.kitchen_service.impl.KitchenServiceRuntimeMXBean; +import org.opendaylight.controller.sample.kitchen.api.EggsType; +import org.opendaylight.controller.sample.kitchen.api.KitchenService; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInputBuilder; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterListener; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterOutOfBread; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterRestocked; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.WheatBread; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class KitchenServiceImpl implements KitchenService, KitchenServiceRuntimeMXBean, ToasterListener { + + private static final Logger log = LoggerFactory.getLogger( KitchenServiceImpl.class ); + + private final ToasterService toaster; + + private volatile boolean toasterOutOfBread; + + public KitchenServiceImpl(ToasterService toaster) { + this.toaster = toaster; + } + + @Override + public boolean makeBreakfast( EggsType eggs, Class toast, int toastDoneness ) { + + if( toasterOutOfBread ) + { + log.info( "We're out of toast but we can make eggs" ); + return true; + } + + // Access the ToasterService to make the toast. + // We don't actually make the eggs for this example - sorry. + MakeToastInputBuilder toastInput = new MakeToastInputBuilder(); + toastInput.setToasterDoneness( (long) toastDoneness); + toastInput.setToasterToastType( toast ); + + try { + RpcResult result = toaster.makeToast( toastInput.build() ).get(); + + if( result.isSuccessful() ) { + log.info( "makeToast succeeded" ); + } else { + log.warn( "makeToast failed: " + result.getErrors() ); + } + + return result.isSuccessful(); + } catch( InterruptedException | ExecutionException e ) { + log.warn( "Error occurred during toast creation" ); + } + return false; + } + + @Override + public Boolean makeScrambledWithWheat() { + return makeBreakfast( EggsType.SCRAMBLED, WheatBread.class, 2 ); + } + + /** + * Implemented from the ToasterListener interface. + */ + @Override + public void onToasterOutOfBread( ToasterOutOfBread notification ) { + log.info( "ToasterOutOfBread notification" ); + toasterOutOfBread = true; + } + + /** + * Implemented from the ToasterListener interface. + */ + @Override + public void onToasterRestocked( ToasterRestocked notification ) { + log.info( "ToasterRestocked notification - amountOfBread: " + notification.getAmountOfBread() ); + toasterOutOfBread = false; + } +} diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/api/ToastConsumer.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/api/ToastConsumer.java deleted file mode 100644 index afc972b39e..0000000000 --- a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/api/ToastConsumer.java +++ /dev/null @@ -1,16 +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.sample.toaster.provider.api; - -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType; - -public interface ToastConsumer { - - boolean createToast(Class type,int doneness); - -} diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/impl/ToastConsumerImpl.java b/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/impl/ToastConsumerImpl.java deleted file mode 100644 index 5a4b45c71e..0000000000 --- a/opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/impl/ToastConsumerImpl.java +++ /dev/null @@ -1,63 +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.sample.toaster.provider.impl; - -import java.util.concurrent.ExecutionException; - -import org.opendaylight.controller.config.yang.config.toaster_consumer.impl.ToasterConsumerRuntimeMXBean; -import org.opendaylight.controller.sal.binding.api.NotificationListener; -import org.opendaylight.controller.sample.toaster.provider.api.ToastConsumer; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.*; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ToastConsumerImpl implements - ToastConsumer, - NotificationListener,ToasterConsumerRuntimeMXBean { - - private static final Logger log = LoggerFactory.getLogger(ToastConsumerImpl.class); - - private ToasterService toaster; - - public ToastConsumerImpl(ToasterService toaster) { - this.toaster = toaster; - } - - @Override - public boolean createToast(Class type, int doneness) { - MakeToastInputBuilder toastInput = new MakeToastInputBuilder(); - toastInput.setToasterDoneness((long) doneness); - toastInput.setToasterToastType(type); - - try { - RpcResult result = toaster.makeToast(toastInput.build()).get(); - - if (result.isSuccessful()) { - log.trace("Toast was successfully finished"); - } else { - log.warn("Toast was not successfully finished"); - } - return result.isSuccessful(); - } catch (InterruptedException | ExecutionException e) { - log.warn("Error occurred during toast creation"); - } - return false; - - } - - @Override - public void onNotification(ToastDone notification) { - log.trace("ToastDone Notification Received: {} ",notification.getToastStatus()); - } - - @Override - public Boolean makeHashBrownToast(Integer doneness) { - return createToast(HashBrown.class, doneness); - } -} diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/yang/toaster-consumer-impl.yang b/opendaylight/md-sal/samples/toaster-consumer/src/main/yang/kitchen-service-impl.yang similarity index 55% rename from opendaylight/md-sal/samples/toaster-consumer/src/main/yang/toaster-consumer-impl.yang rename to opendaylight/md-sal/samples/toaster-consumer/src/main/yang/kitchen-service-impl.yang index 8bc1a5cc22..d22dfc619a 100644 --- a/opendaylight/md-sal/samples/toaster-consumer/src/main/yang/toaster-consumer-impl.yang +++ b/opendaylight/md-sal/samples/toaster-consumer/src/main/yang/kitchen-service-impl.yang @@ -1,35 +1,40 @@ // vi: set smarttab et sw=4 tabstop=4: -module toaster-consumer-impl { +module kitchen-service-impl { yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:config:toaster-consumer:impl"; - prefix "toaster-consumer-impl"; + namespace "urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl"; + prefix "kitchen-service-impl"; import config { prefix config; revision-date 2013-04-05; } import rpc-context { prefix rpcx; revision-date 2013-06-17; } - import toaster-consumer { prefix toaster-consumer; revision-date 2014-01-31; } import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } description "This module contains the base YANG definitions for - toaster-consumer impl implementation."; + kitchen-service impl implementation."; revision "2014-01-31" { description "Initial revision."; } - // This is the definition of a service implementation - identity toaster-consumer-impl { + // This is the definition of kitchen service interface identity. + identity kitchen-service { + base "config:service-type"; + config:java-class "org.opendaylight.controller.sample.kitchen.api.KitchenService"; + } + + // This is the definition of kitchen service implementation module identity. + identity kitchen-service-impl { base config:module-type; - config:provided-service toaster-consumer:toaster-consumer; - config:java-name-prefix ToasterConsumer; + config:provided-service kitchen-service; + config:java-name-prefix KitchenService; } augment "/config:modules/config:module/config:configuration" { - case toaster-consumer-impl { - when "/config:modules/config:module/config:type = 'toaster-consumer-impl'"; + case kitchen-service-impl { + when "/config:modules/config:module/config:type = 'kitchen-service-impl'"; container rpc-registry { uses config:service-ref { @@ -48,30 +53,31 @@ module toaster-consumer-impl { } } } - } } - + augment "/config:modules/config:module/config:state" { - case toaster-consumer-impl { - when "/config:modules/config:module/config:type = 'toaster-consumer-impl'"; - rpcx:rpc-context-instance "make-hash-brown-toast-rpc"; + case kitchen-service-impl { + when "/config:modules/config:module/config:type = 'kitchen-service-impl'"; + + rpcx:rpc-context-instance "make-scrambled-with-wheat-rpc"; } } - identity make-hash-brown-toast-rpc; + identity make-scrambled-with-wheat-rpc; - rpc make-hash-brown-toast { + rpc make-scrambled-with-wheat { + description + "Shortcut JMX call to make breakfast with scrambled eggs and wheat toast for testing."; + input { uses rpcx:rpc-context-ref { refine context-instance { - rpcx:rpc-context-instance make-hash-brown-toast-rpc; + rpcx:rpc-context-instance make-scrambled-with-wheat-rpc; } } - leaf doneness { - type uint16; - } } + output { leaf result { type boolean; diff --git a/opendaylight/md-sal/samples/toaster-consumer/src/main/yang/toaster-consumer.yang b/opendaylight/md-sal/samples/toaster-consumer/src/main/yang/toaster-consumer.yang deleted file mode 100644 index c050ee86c6..0000000000 --- a/opendaylight/md-sal/samples/toaster-consumer/src/main/yang/toaster-consumer.yang +++ /dev/null @@ -1,26 +0,0 @@ -// vi: set smarttab et sw=4 tabstop=4: -module toaster-consumer { - - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:config:toaster-consumer"; - prefix "toaster-consumer"; - - import config { prefix config; revision-date 2013-04-05; } - - description - "This module contains the base YANG definitions for - toaster-consumer services."; - - revision "2014-01-31" { - description - "Initial revision."; - } - - // This is the definition of a service - identity toaster-consumer { - - base "config:service-type"; - - config:java-class "org.opendaylight.controller.sample.toaster.provider.api.ToastConsumer"; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/samples/toaster-it/pom.xml b/opendaylight/md-sal/samples/toaster-it/pom.xml index 60db8f9ba6..2fcb2f6d63 100644 --- a/opendaylight/md-sal/samples/toaster-it/pom.xml +++ b/opendaylight/md-sal/samples/toaster-it/pom.xml @@ -17,7 +17,6 @@ org.opendaylight.controller sal-binding-it - 1.1-SNAPSHOT org.opendaylight.controller.samples @@ -36,11 +35,11 @@ 1.1-SNAPSHOT - org.opendaylight.controller.thirdparty + org.openexi nagasena - org.opendaylight.controller.thirdparty + org.openexi nagasena-rta diff --git a/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java b/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java index add523157f..907b35475f 100644 --- a/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java +++ b/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java @@ -10,7 +10,8 @@ package org.opendaylight.controller.sample.toaster.it; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.opendaylight.controller.sample.toaster.provider.api.ToastConsumer; +import org.opendaylight.controller.sample.kitchen.api.EggsType; +import org.opendaylight.controller.sample.kitchen.api.KitchenService; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.HashBrown; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.WhiteBread; import org.ops4j.pax.exam.Configuration; @@ -23,6 +24,7 @@ import org.ops4j.pax.exam.util.PathUtils; import javax.inject.Inject; import javax.management.MBeanServer; import javax.management.ObjectName; + import java.lang.management.ManagementFactory; import static org.junit.Assert.assertEquals; @@ -42,7 +44,7 @@ public class ToasterTest { @Inject @Filter(timeout=60*1000) - ToastConsumer toastConsumer; + KitchenService kitchenService; @Configuration public Option[] config() { @@ -77,8 +79,8 @@ public class ToasterTest { mavenBundle("org.opendaylight.controller.samples", "sample-toaster-provider").versionAsInProject(), mavenBundle("org.opendaylight.controller.samples", "sample-toaster-consumer").versionAsInProject(), mavenBundle("org.opendaylight.controller.samples", "sample-toaster").versionAsInProject(), - mavenBundle("org.opendaylight.controller.thirdparty", "nagasena").versionAsInProject(), - mavenBundle("org.opendaylight.controller.thirdparty", "nagasena-rta").versionAsInProject() + mavenBundle("org.openexi", "nagasena").versionAsInProject(), + mavenBundle("org.openexi", "nagasena-rta").versionAsInProject() ); } @@ -86,7 +88,6 @@ public class ToasterTest { public void testToaster() throws Exception { MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); - ObjectName consumerOn = new ObjectName("org.opendaylight.controller:instanceName=toaster-consumer-impl,type=RuntimeBean,moduleFactoryName=toaster-consumer-impl"); ObjectName providerOn = new ObjectName("org.opendaylight.controller:instanceName=toaster-provider-impl,type=RuntimeBean,moduleFactoryName=toaster-provider-impl"); long toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade"); @@ -95,17 +96,14 @@ public class ToasterTest { boolean toasts = true; // Make toasts using OSGi service - toasts &= toastConsumer.createToast(HashBrown.class, 4); - toasts &= toastConsumer.createToast(WhiteBread.class, 8); - - // Make toast using JMX/config-subsystem - toasts &= (Boolean)platformMBeanServer.invoke(consumerOn, "makeHashBrownToast", new Object[]{4}, new String[]{Integer.class.getName()}); + toasts &= kitchenService.makeBreakfast( EggsType.SCRAMBLED, HashBrown.class, 4); + toasts &= kitchenService.makeBreakfast( EggsType.POACHED, WhiteBread.class, 8 ); - Assert.assertTrue("Not all toasts done by " + toastConsumer, toasts); + Assert.assertTrue("Not all toasts done by " + kitchenService, toasts); // Verify toasts made count on provider via JMX/config-subsystem toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade"); - assertEquals(3, toastsMade); + assertEquals(2, toastsMade); } } diff --git a/opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml b/opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml index 7a282db025..c5a2a0d340 100644 --- a/opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml +++ b/opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml @@ -3,7 +3,7 @@ - urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 @@ -27,15 +27,12 @@ urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28 urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16 - urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09 - + urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28 http://netconfcentral.org/ns/toaster?module=toaster&revision=2009-11-20 - urn:opendaylight:params:xml:ns:yang:controller:config:toaster-consumer?module=toaster-consumer&revision=2014-01-31 - urn:opendaylight:params:xml:ns:yang:controller:config:toaster-consumer:impl?module=toaster-consumer-impl&revision=2014-01-31 - urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider?module=toaster-provider&revision=2014-01-31 + urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl?module=kitchen-service-impl&revision=2014-01-31 urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl?module=toaster-provider-impl&revision=2014-01-31 @@ -54,6 +51,11 @@ binding-rpc-broker + + binding:binding-data-broker + ref_binding-data-broker + + binding:binding-notification-service @@ -63,10 +65,10 @@ - - prefix:toaster-consumer-impl + + prefix:kitchen-service-impl - toaster-consumer-impl + kitchen-service-impl binding:binding-rpc-registry @@ -157,6 +159,15 @@ + + + kitchen:kitchen-service + + + kitchen-service + /modules/module[type='kitchen-service-impl'][name='kitchen-service-impl'] + + dom:schema-service diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java index d9bb36eb8e..bd8e89fd7a 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java +++ b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java @@ -10,10 +10,11 @@ package org.opendaylight.controller.config.yang.config.toaster_provider.impl; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; import org.opendaylight.controller.sample.toaster.provider.OpendaylightToaster; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterData; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService; +import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +47,13 @@ public final class ToasterProviderModule extends org.opendaylight.controller.con // Register to md-sal opendaylightToaster.setNotificationProvider(getNotificationServiceDependency()); - opendaylightToaster.setDataProvider(getDataBrokerDependency()); + + DataProviderService dataBrokerService = getDataBrokerDependency(); + opendaylightToaster.setDataProvider(dataBrokerService); + + final ListenerRegistration dataChangeListenerRegistration = + dataBrokerService.registerDataChangeListener( OpendaylightToaster.TOASTER_IID, opendaylightToaster ); + final BindingAwareBroker.RpcRegistration rpcRegistration = getRpcRegistryDependency() .addRpcImplementation(ToasterService.class, opendaylightToaster); @@ -56,20 +63,16 @@ public final class ToasterProviderModule extends org.opendaylight.controller.con // Wrap toaster as AutoCloseable and close registrations to md-sal at // close() - final class AutoCloseableToaster implements AutoCloseable, ToasterData { + final class AutoCloseableToaster implements AutoCloseable { @Override public void close() throws Exception { + dataChangeListenerRegistration.close(); rpcRegistration.close(); runtimeReg.close(); opendaylightToaster.close(); log.info("Toaster provider (instance {}) torn down.", this); } - - @Override - public Toaster getToaster() { - return opendaylightToaster.getToaster(); - } } AutoCloseable ret = new AutoCloseableToaster(); diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java index 2dab924e77..b4da5a3d22 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java +++ b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.sample.toaster.provider; +import java.util.Arrays; import java.util.Collections; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -16,19 +17,24 @@ import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.controller.config.yang.config.toaster_provider.impl.ToasterProviderRuntimeMXBean; +import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.common.util.RpcErrors; import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.DisplayString; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInput; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastDone.ToastStatus; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastDoneBuilder; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster.ToasterStatus; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.RestockToasterInput; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterBuilder; -import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterData; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterOutOfBreadBuilder; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterRestocked; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterRestockedBuilder; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService; +import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; +import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -37,84 +43,179 @@ import org.slf4j.LoggerFactory; import com.google.common.util.concurrent.Futures; -public class OpendaylightToaster implements ToasterData, ToasterService, ToasterProviderRuntimeMXBean, AutoCloseable { +public class OpendaylightToaster implements ToasterService, ToasterProviderRuntimeMXBean, + DataChangeListener, AutoCloseable { - private static final Logger log = LoggerFactory.getLogger(OpendaylightToaster.class); - private static final InstanceIdentifier toasterIID = InstanceIdentifier.builder(Toaster.class).build(); + private static final Logger LOG = LoggerFactory.getLogger(OpendaylightToaster.class); - private static final DisplayString toasterManufacturer = new DisplayString("Opendaylight"); - private static final DisplayString toasterModelNumber = new DisplayString("Model 1 - Binding Aware"); + public static final InstanceIdentifier TOASTER_IID = InstanceIdentifier.builder(Toaster.class).build(); + + private static final DisplayString TOASTER_MANUFACTURER = new DisplayString("Opendaylight"); + private static final DisplayString TOASTER_MODEL_NUMBER = new DisplayString("Model 1 - Binding Aware"); private NotificationProviderService notificationProvider; private DataBrokerService dataProvider; + private final ExecutorService executor; - private Future> currentTask; + // As you will see we are using multiple threads here. Therefore we need to be careful about concurrency. + // In this case we use the taskLock to provide synchronization for the current task. + private volatile Future> currentTask; + private final Object taskLock = new Object(); + + private final AtomicLong amountOfBreadInStock = new AtomicLong( 100 ); + + private final AtomicLong toastsMade = new AtomicLong(0); + + // Thread safe holder for our darkness multiplier. + private final AtomicLong darknessFactor = new AtomicLong( 1000 ); public OpendaylightToaster() { executor = Executors.newFixedThreadPool(1); } + public void setNotificationProvider(NotificationProviderService salService) { + this.notificationProvider = salService; + } + + public void setDataProvider(DataBrokerService salDataProvider) { + this.dataProvider = salDataProvider; + updateStatus(); + } + + /** + * Implemented from the AutoCloseable interface. + */ @Override - public synchronized Toaster getToaster() { - ToasterBuilder tb = new ToasterBuilder(); - tb // - .setToasterManufacturer(toasterManufacturer) // - .setToasterModelNumber(toasterModelNumber) // - .setToasterStatus(currentTask == null ? ToasterStatus.Up : ToasterStatus.Down); + public void close() throws ExecutionException, InterruptedException { + // When we close this service we need to shutdown our executor! + executor.shutdown(); + if (dataProvider != null) { + final DataModificationTransaction t = dataProvider.beginTransaction(); + t.removeOperationalData(TOASTER_IID); + t.commit().get(); + } + } + + private Toaster buildToaster() { + // We don't need to synchronize on currentTask here b/c it's declared volatile and + // we're just doing a read. + boolean isUp = currentTask == null; + + // note - we are simulating a device whose manufacture and model are + // fixed (embedded) into the hardware. + // This is why the manufacture and model number are hardcoded. + ToasterBuilder tb = new ToasterBuilder(); + tb.setToasterManufacturer(TOASTER_MANUFACTURER).setToasterModelNumber(TOASTER_MODEL_NUMBER) + .setToasterStatus(isUp ? ToasterStatus.Up : ToasterStatus.Down); return tb.build(); } + /** + * Implemented from the DataChangeListener interface. + */ @Override - public synchronized Future> cancelToast() { - if (currentTask != null) { - cancelToastImpl(); + public void onDataChanged( DataChangeEvent, DataObject> change ) { + DataObject dataObject = change.getUpdatedConfigurationData().get( TOASTER_IID ); + if( dataObject instanceof Toaster ) + { + Toaster toaster = (Toaster) dataObject; + Long darkness = toaster.getDarknessFactor(); + if( darkness != null ) + { + darknessFactor.set( darkness ); + } } - return null; } + /** + * RestConf RPC call implemented from the ToasterService interface. + */ @Override - public synchronized Future> makeToast(MakeToastInput input) { - log.debug("makeToast - Received input for toast"); - logToastInput(input); - if (currentTask != null) { - return inProgressError(); + public Future> cancelToast() { + synchronized (taskLock) { + if (currentTask != null) { + currentTask.cancel(true); + currentTask = null; + } } - currentTask = executor.submit(new MakeToastTask(input)); - updateStatus(); - return currentTask; + // Always return success from the cancel toast call. + return Futures.immediateFuture(Rpcs. getRpcResult(true, Collections. emptySet())); } - private Future> inProgressError() { - RpcResult result = Rpcs. getRpcResult(false, null, Collections. emptySet()); - return Futures.immediateFuture(result); - } + /** + * RestConf RPC call implemented from the ToasterService interface. + */ + @Override + public Future> makeToast(MakeToastInput input) { + LOG.info("makeToast: " + input); - private void cancelToastImpl() { - currentTask.cancel(true); - ToastDoneBuilder toastDone = new ToastDoneBuilder(); - toastDone.setToastStatus(ToastStatus.Cancelled); - notificationProvider.publish(toastDone.build()); - } + synchronized (taskLock) { + if (currentTask != null) { + // return an error since we are already toasting some toast. + LOG.info( "Toaster is already making toast" ); - public void setNotificationProvider(NotificationProviderService salService) { - this.notificationProvider = salService; - } + RpcResult result = Rpcs. getRpcResult(false, null, Arrays.asList( + RpcErrors.getRpcError( null, null, null, null, + "Toaster is busy", null, null ) ) ); + return Futures.immediateFuture(result); + } + else if( outOfBread() ) { + RpcResult result = Rpcs. getRpcResult(false, null, Arrays.asList( + RpcErrors.getRpcError( null, null, null, null, + "Toaster is out of bread", null, null ) ) ); + return Futures.immediateFuture(result); + } + else { + // Notice that we are moving the actual call to another thread, + // allowing this thread to return immediately. + // The MD-SAL design encourages asynchronus programming. If the + // caller needs to block until the call is + // complete then they can leverage the blocking methods on the + // Future interface. + currentTask = executor.submit(new MakeToastTask(input)); + } + } - public void setDataProvider(DataBrokerService salDataProvider) { - this.dataProvider = salDataProvider; updateStatus(); + return currentTask; } - private void logToastInput(MakeToastInput input) { - String toastType = input.getToasterToastType().getName(); - String toastDoneness = input.getToasterDoneness().toString(); - log.trace("Toast: {} doneness: {}", toastType, toastDoneness); + /** + * RestConf RPC call implemented from the ToasterService interface. + * Restocks the bread for the toaster, resets the toastsMade counter to 0, and sends a + * ToasterRestocked notification. + */ + @Override + public Future> restockToaster(RestockToasterInput input) { + LOG.info( "restockToaster: " + input ); + + synchronized( taskLock ) { + amountOfBreadInStock.set( input.getAmountOfBreadToStock() ); + + if( amountOfBreadInStock.get() > 0 ) { + ToasterRestocked reStockedNotification = + new ToasterRestockedBuilder().setAmountOfBread( input.getAmountOfBreadToStock() ).build(); + notificationProvider.publish( reStockedNotification ); + } + } + + return Futures.immediateFuture(Rpcs. getRpcResult(true, Collections. emptySet())); } - private final AtomicLong toastsMade = new AtomicLong(0); + /** + * JMX RPC call implemented from the ToasterProviderRuntimeMXBean interface. + */ + @Override + public void clearToastsMade() { + LOG.info( "clearToastsMade" ); + toastsMade.set( 0 ); + } + /** + * Accesssor method implemented from the ToasterProviderRuntimeMXBean interface. + */ @Override public Long getToastsMade() { return toastsMade.get(); @@ -123,26 +224,22 @@ public class OpendaylightToaster implements ToasterData, ToasterService, Toaster private void updateStatus() { if (dataProvider != null) { final DataModificationTransaction t = dataProvider.beginTransaction(); - t.removeOperationalData(toasterIID); - t.putOperationalData(toasterIID, getToaster()); + t.removeOperationalData(TOASTER_IID); + t.putOperationalData(TOASTER_IID, buildToaster()); try { t.commit().get(); } catch (InterruptedException | ExecutionException e) { - log.warn("Failed to update toaster status, operational otherwise", e); + LOG.warn("Failed to update toaster status, operational otherwise", e); } } else { - log.trace("No data provider configured, not updating status"); + LOG.trace("No data provider configured, not updating status"); } } - @Override - public void close() throws ExecutionException, InterruptedException { - if (dataProvider != null) { - final DataModificationTransaction t = dataProvider.beginTransaction(); - t.removeOperationalData(toasterIID); - t.commit().get(); - } + private boolean outOfBread() + { + return amountOfBreadInStock.get() == 0; } private class MakeToastTask implements Callable> { @@ -154,19 +251,35 @@ public class OpendaylightToaster implements ToasterData, ToasterService, Toaster } @Override - public RpcResult call() throws InterruptedException { - Thread.sleep(1000 * toastRequest.getToasterDoneness()); + public RpcResult call() { + try + { + // make toast just sleeps for n secondn per doneness level. + long darknessFactor = OpendaylightToaster.this.darknessFactor.get(); + Thread.sleep(darknessFactor * toastRequest.getToasterDoneness()); - ToastDoneBuilder notifyBuilder = new ToastDoneBuilder(); - notifyBuilder.setToastStatus(ToastStatus.Done); - notificationProvider.publish(notifyBuilder.build()); - log.debug("Toast Done"); - logToastInput(toastRequest); + } + catch( InterruptedException e ) { + LOG.info( "Interrupted while making the toast" ); + } - currentTask = null; toastsMade.incrementAndGet(); + + amountOfBreadInStock.getAndDecrement(); + if( outOfBread() ) { + LOG.info( "Toaster is out of bread!" ); + + notificationProvider.publish( new ToasterOutOfBreadBuilder().build() ); + } + + synchronized (taskLock) { + currentTask = null; + } + updateStatus(); + LOG.debug("Toast done"); + return Rpcs. getRpcResult(true, null, Collections. emptySet()); } } diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/yang/toaster-provider-impl.yang b/opendaylight/md-sal/samples/toaster-provider/src/main/yang/toaster-provider-impl.yang index 17b0c8d0f0..d6de5cfd17 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/main/yang/toaster-provider-impl.yang +++ b/opendaylight/md-sal/samples/toaster-provider/src/main/yang/toaster-provider-impl.yang @@ -6,7 +6,7 @@ module toaster-provider-impl { prefix "toaster-provider-impl"; import config { prefix config; revision-date 2013-04-05; } - import toaster-provider { prefix toaster-provider; revision-date 2014-01-31; } + import rpc-context { prefix rpcx; revision-date 2013-06-17; } import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } description @@ -18,13 +18,15 @@ module toaster-provider-impl { "Initial revision."; } - // This is the definition of a service implementation + // This is the definition of the service implementation as a module identity. identity toaster-provider-impl { base config:module-type; - config:provided-service toaster-provider:toaster-provider; + + // Specifies the prefix for generated java classes. config:java-name-prefix ToasterProvider; } + // Augments the 'configuration' choice node under modules/module. augment "/config:modules/config:module/config:configuration" { case toaster-provider-impl { when "/config:modules/config:module/config:type = 'toaster-provider-impl'"; @@ -61,11 +63,27 @@ module toaster-provider-impl { augment "/config:modules/config:module/config:state" { case toaster-provider-impl { when "/config:modules/config:module/config:type = 'toaster-provider-impl'"; - + leaf toasts-made { type uint32; } + + rpcx:rpc-context-instance "clear-toasts-made-rpc"; + } + } + + identity clear-toasts-made-rpc; + rpc clear-toasts-made { + description + "JMX call to clear the toasts-made counter."; + + input { + uses rpcx:rpc-context-ref { + refine context-instance { + rpcx:rpc-context-instance clear-toasts-made-rpc; + } + } } } } diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/yang/toaster-provider.yang b/opendaylight/md-sal/samples/toaster-provider/src/main/yang/toaster-provider.yang deleted file mode 100644 index a5fba07d74..0000000000 --- a/opendaylight/md-sal/samples/toaster-provider/src/main/yang/toaster-provider.yang +++ /dev/null @@ -1,26 +0,0 @@ -// vi: set smarttab et sw=4 tabstop=4: -module toaster-provider { - - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider"; - prefix "toaster-provider"; - - import config { prefix config; revision-date 2013-04-05; } - - description - "This module contains the base YANG definitions for - toaster-provider services."; - - revision "2014-01-31" { - description - "Initial revision."; - } - - // This is the definition of a service - identity toaster-provider { - - base "config:service-type"; - - config:java-class "org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterData"; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/samples/toaster/src/main/yang/toaster.yang b/opendaylight/md-sal/samples/toaster/src/main/yang/toaster.yang index 15c0ac83ed..11b746f681 100644 --- a/opendaylight/md-sal/samples/toaster/src/main/yang/toaster.yang +++ b/opendaylight/md-sal/samples/toaster/src/main/yang/toaster.yang @@ -113,6 +113,14 @@ "This variable indicates the current state of the toaster."; } + + leaf darknessFactor { + type uint32; + config true; + default 1000; + description + "The darkness factor. Basically, the number of ms to multiple the doneness value by."; + } } // container toaster rpc make-toast { @@ -161,29 +169,32 @@ 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."; - } + rpc restock-toaster { + description + "Restocks the toaster with the amount of bread specified."; + + input { + leaf amountOfBreadToStock { + type uint32; + description + "Indicates the amount of bread to re-stock"; + } } + } + + notification toasterOutOfBread { + description + "Indicates that the toaster has run of out bread."; + } // notification toasterOutOfStock + + notification toasterRestocked { + description + "Indicates that the toaster has run of out bread."; + leaf amountOfBread { + type uint32; description - "Indicates the final toast status"; + "Indicates the amount of bread that was re-stocked"; } - } // notification toastDone + } // notification toasterOutOfStock + } // module toaster diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractStatsTracker.java index e922656d91..e23ad0acdb 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractStatsTracker.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/AbstractStatsTracker.java @@ -32,9 +32,9 @@ import com.google.common.util.concurrent.JdkFutureAdapters; abstract class AbstractStatsTracker { private static final Logger logger = LoggerFactory.getLogger(AbstractStatsTracker.class); - + private static final int WAIT_FOR_REQUEST_CYCLE = 2; - + private final FutureCallback> callback = new FutureCallback>() { @Override @@ -73,7 +73,7 @@ abstract class AbstractStatsTracker { } protected final InstanceIdentifierBuilder getNodeIdentifierBuilder() { - return InstanceIdentifier.builder(getNodeIdentifier()); + return getNodeIdentifier().builder(); } protected final NodeRef getNodeRef() { diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java index 06d6e82112..add46bd162 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java @@ -41,17 +41,17 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker flowRef = getNodeIdentifierBuilder() .augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(item.getTableId())) @@ -61,7 +61,7 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker, DataObject> change) { + public void onDataChanged(final DataChangeEvent, DataObject> change) { for (Entry, DataObject> e : change.getCreatedConfigurationData().entrySet()) { if (Flow.class.equals(e.getKey().getTargetType())) { final Flow flow = (Flow) e.getValue(); @@ -270,11 +270,8 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker flow = (InstanceIdentifier)key; - final InstanceIdentifier del = InstanceIdentifier.builder(flow) - .augmentation(FlowStatisticsData.class).build(); - logger.debug("Key {} triggered remove of augmentation {}", key, del); - - trans.removeOperationalData(del); + logger.debug("Key {} triggered remove of Flow from operational space.", key); + trans.removeOperationalData(flow); } } trans.commit(); diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupDescStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupDescStatsTracker.java index e180aaf5fc..a775b73169 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupDescStatsTracker.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupDescStatsTracker.java @@ -96,7 +96,7 @@ final class GroupDescStatsTracker extends AbstractListeningStatsTracker group = (InstanceIdentifier)key; - InstanceIdentifier del = InstanceIdentifier.builder(group).augmentation(NodeGroupDescStats.class).toInstance(); + InstanceIdentifier del = group.augmentation(NodeGroupDescStats.class); logger.debug("Key {} triggered remove of augmentation {}", key, del); trans.removeOperationalData(del); diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupStatsTracker.java index 9735fea069..c3c23c9b58 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupStatsTracker.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/GroupStatsTracker.java @@ -87,7 +87,7 @@ final class GroupStatsTracker extends AbstractListeningStatsTracker group = (InstanceIdentifier)key; - InstanceIdentifier del = InstanceIdentifier.builder(group).augmentation(NodeGroupStatistics.class).toInstance(); + InstanceIdentifier del = group.augmentation(NodeGroupStatistics.class); logger.debug("Key {} triggered remove of augmentation {}", key, del); trans.removeOperationalData(del); diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterConfigStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterConfigStatsTracker.java index e8b7fb7164..ea412a09e1 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterConfigStatsTracker.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterConfigStatsTracker.java @@ -82,7 +82,7 @@ final class MeterConfigStatsTracker extends AbstractListeningStatsTracker meter = (InstanceIdentifier)key; InstanceIdentifier nodeMeterStatisticsAugmentation = - InstanceIdentifier.builder(meter).augmentation(NodeMeterConfigStats.class).toInstance(); + meter.augmentation(NodeMeterConfigStats.class); trans.removeOperationalData(nodeMeterStatisticsAugmentation); } } diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterStatsTracker.java index b373020f1c..be53a38f18 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterStatsTracker.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MeterStatsTracker.java @@ -86,7 +86,7 @@ final class MeterStatsTracker extends AbstractListeningStatsTracker meter = (InstanceIdentifier)key; InstanceIdentifier nodeMeterStatisticsAugmentation = - InstanceIdentifier.builder(meter).augmentation(NodeMeterStatistics.class).toInstance(); + meter.augmentation(NodeMeterStatistics.class); trans.removeOperationalData(nodeMeterStatisticsAugmentation); } } diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsTracker.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsTracker.java index 6f93eeb617..03f7808c8f 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsTracker.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/QueueStatsTracker.java @@ -122,8 +122,8 @@ final class QueueStatsTracker extends AbstractListeningStatsTracker queue = (InstanceIdentifier)key; - final InstanceIdentifier del = InstanceIdentifier.builder(queue) - .augmentation(FlowCapableNodeConnectorQueueStatisticsData.class).build(); + final InstanceIdentifier del = queue + .augmentation(FlowCapableNodeConnectorQueueStatisticsData.class); logger.debug("Key {} triggered remove of augmentation {}", key, del); trans.removeOperationalData(del); diff --git a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java index 54f1fc0bb4..542e972deb 100644 --- a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java +++ b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java @@ -15,9 +15,10 @@ import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMap import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNode; import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNodeId; -import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader; +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; import org.opendaylight.controller.sal.binding.api.data.DataProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated; @@ -48,15 +49,20 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.JdkFutureAdapters; + class FlowCapableTopologyExporter implements // FlowTopologyDiscoveryListener, // OpendaylightInventoryListener // { - private final static Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyExporter.class); + protected final static Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyExporter.class); public static TopologyKey topology = new TopologyKey(new TopologyId("flow:1")); // FIXME: Flow capable topology exporter should use transaction chaining API @@ -79,7 +85,7 @@ class FlowCapableTopologyExporter implements // Topology top = tb.build(); DataModificationTransaction tx = dataService.beginTransaction(); tx.putOperationalData(topologyPath, top); - tx.commit(); + listenOnTransactionState(tx.getIdentifier(),tx.commit()); } @Override @@ -90,11 +96,7 @@ class FlowCapableTopologyExporter implements // DataModificationTransaction tx = dataService.beginTransaction(); tx.removeOperationalData(nodeInstance); removeAffectedLinks(tx, nodeId); - try { - tx.commit().get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Topology state export not successful. ",e); - } + listenOnTransactionState(tx.getIdentifier(),tx.commit()); } @Override @@ -105,11 +107,7 @@ class FlowCapableTopologyExporter implements // InstanceIdentifier path = getNodePath(toTopologyNodeId(notification.getId())); DataModificationTransaction tx = dataService.beginTransaction(); tx.putOperationalData(path, node); - try { - tx.commit().get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Topology state export not successful. ",e); - } + listenOnTransactionState(tx.getIdentifier(),tx.commit()); } } @@ -121,11 +119,7 @@ class FlowCapableTopologyExporter implements // DataModificationTransaction tx = dataService.beginTransaction(); tx.removeOperationalData(tpInstance); removeAffectedLinks(tx, tpId); - try { - tx.commit().get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Topology state export not successful. ",e); - } + listenOnTransactionState(tx.getIdentifier(),tx.commit()); } @@ -144,11 +138,7 @@ class FlowCapableTopologyExporter implements // || (fcncu.getConfiguration() != null && fcncu.getConfiguration().isPORTDOWN())) { removeAffectedLinks(tx, point.getTpId()); } - try { - tx.commit().get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Topology state export not successful. ",e); - } + listenOnTransactionState(tx.getIdentifier(),tx.commit()); } } @@ -158,11 +148,8 @@ class FlowCapableTopologyExporter implements // InstanceIdentifier path = linkPath(link); DataModificationTransaction tx = dataService.beginTransaction(); tx.putOperationalData(path, link); - try { - tx.commit().get(); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Topology state export not successful. ",e); - } + listenOnTransactionState(tx.getIdentifier(),tx.commit()); + } @Override @@ -175,7 +162,7 @@ class FlowCapableTopologyExporter implements // InstanceIdentifier path = linkPath(toTopologyLink(notification)); DataModificationTransaction tx = dataService.beginTransaction(); tx.removeOperationalData(path); - ; + listenOnTransactionState(tx.getIdentifier(),tx.commit()); } @Override @@ -206,8 +193,7 @@ class FlowCapableTopologyExporter implements // } for (Link link : topologyData.getLink()) { if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) { - InstanceIdentifier path = InstanceIdentifier.builder(topologyPath) - .child(Link.class, link.getKey()).build(); + InstanceIdentifier path = topologyPath.child(Link.class, link.getKey()); transaction.removeOperationalData(path); } } @@ -221,8 +207,7 @@ class FlowCapableTopologyExporter implements // } for (Link link : topologyData.getLink()) { if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) { - InstanceIdentifier path = InstanceIdentifier.builder(topologyPath) - .child(Link.class, link.getKey()).build(); + InstanceIdentifier path = topologyPath.child(Link.class, link.getKey()); transaction.removeOperationalData(path); } } @@ -246,4 +231,26 @@ class FlowCapableTopologyExporter implements // .child(Topology.class, topology).child(Link.class, link.getKey()).build(); return linkInstanceId; } + + /** + * @param txId transaction identificator + * @param future transaction result + */ + private static void listenOnTransactionState(final Object txId, Future> future) { + Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallback>() { + + @Override + public void onFailure(Throwable t) { + LOG.error("Topology export failed for Tx:{}", txId, t); + + } + + @Override + public void onSuccess(RpcResult result) { + if(!result.isSuccessful()) { + LOG.error("Topology export failed for Tx:{}", txId); + } + } + }); + } } diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/NetconfConfigHandlingException.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/NetconfConfigHandlingException.java index be44a71e06..f6d070b2a8 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/NetconfConfigHandlingException.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/NetconfConfigHandlingException.java @@ -7,12 +7,13 @@ */ package org.opendaylight.controller.netconf.confignetconfconnector.exception; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; - import java.util.Collections; import java.util.Map; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; + public class NetconfConfigHandlingException extends NetconfDocumentedException { + private static final long serialVersionUID = 1L; public NetconfConfigHandlingException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity) { diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/NoTransactionFoundException.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/NoTransactionFoundException.java index ebb8054c71..dea8443c29 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/NoTransactionFoundException.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/NoTransactionFoundException.java @@ -7,12 +7,13 @@ */ package org.opendaylight.controller.netconf.confignetconfconnector.exception; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; - import java.util.Collections; import java.util.Map; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; + public class NoTransactionFoundException extends NetconfDocumentedException { + private static final long serialVersionUID = 1L; public NoTransactionFoundException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity) { diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/OperationNotPermittedException.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/OperationNotPermittedException.java index e0d63c1418..49276663b8 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/OperationNotPermittedException.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/exception/OperationNotPermittedException.java @@ -7,12 +7,13 @@ */ package org.opendaylight.controller.netconf.confignetconfconnector.exception; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; - import java.util.Collections; import java.util.Map; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; + public class OperationNotPermittedException extends NetconfDocumentedException { + private static final long serialVersionUID = 1L; public OperationNotPermittedException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity) { diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java index 44e90270e7..957db50c61 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java @@ -8,10 +8,19 @@ package org.opendaylight.controller.netconf.persist.impl; -import com.google.common.base.Function; -import com.google.common.base.Preconditions; -import com.google.common.base.Stopwatch; -import com.google.common.collect.Collections2; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeMap; +import java.util.concurrent.TimeUnit; + +import javax.annotation.concurrent.Immutable; + import org.opendaylight.controller.config.api.ConflictingVersionException; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; @@ -32,17 +41,10 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; -import javax.annotation.concurrent.Immutable; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeMap; -import java.util.concurrent.TimeUnit; +import com.google.common.base.Function; +import com.google.common.base.Preconditions; +import com.google.common.base.Stopwatch; +import com.google.common.collect.Collections2; @Immutable public class ConfigPusher { @@ -110,6 +112,8 @@ public class ConfigPusher { } private static class NotEnoughCapabilitiesException extends Exception { + private static final long serialVersionUID = 1L; + private NotEnoughCapabilitiesException(String message, Throwable cause) { super(message, cause); } diff --git a/opendaylight/netconf/netconf-it/pom.xml b/opendaylight/netconf/netconf-it/pom.xml index ce52032320..66106075d3 100644 --- a/opendaylight/netconf/netconf-it/pom.xml +++ b/opendaylight/netconf/netconf-it/pom.xml @@ -15,18 +15,6 @@ - - ${project.groupId} - sal-binding-it - - - - - org.ops4j.pax.url - pax-url-aether - - - org.opendaylight.controller commons.logback_settings @@ -144,12 +132,6 @@ yang-test test - - org.ops4j.pax.tinybundles - tinybundles - ${tinybundles.version} - test - @@ -161,10 +143,6 @@ 1 false false - - com.google.collections:google-collections - org.ops4j.pax.url:pax-url-aether - diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java index e99e51e92f..cd53995bce 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java @@ -11,7 +11,8 @@ package org.opendaylight.controller.netconf.it; import static java.util.Collections.emptyList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -32,21 +33,19 @@ import java.util.concurrent.TimeoutException; import javax.management.ObjectName; import javax.xml.parsers.ParserConfigurationException; -import junit.framework.Assert; - -import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.junit.matchers.JUnitMatchers; import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver; import org.opendaylight.controller.config.spi.ModuleFactory; import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory; +import org.opendaylight.controller.config.yang.test.impl.IdentityTestModuleFactory; import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory; import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean; import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory; -import org.opendaylight.controller.netconf.StubUserManager; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl; @@ -60,11 +59,13 @@ import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFact import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshotImpl; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService; -import org.opendaylight.controller.netconf.ssh.NetconfSSHServer; -import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider; import org.opendaylight.controller.netconf.util.test.XmlFileLoader; import org.opendaylight.controller.netconf.util.xml.XmlElement; import org.opendaylight.controller.netconf.util.xml.XmlUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2; +import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry; +import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -73,9 +74,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.xml.sax.SAXException; -import ch.ethz.ssh2.Connection; -import ch.ethz.ssh2.Session; - +import com.google.common.base.Throwables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import io.netty.channel.ChannelFuture; @@ -177,7 +176,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest { static List getModuleFactoriesS() { return Lists.newArrayList(new TestImplModuleFactory(), new DepTestImplModuleFactory(), - new NetconfTestImplModuleFactory()); + new NetconfTestImplModuleFactory(), new IdentityTestModuleFactory()); } @Test @@ -376,54 +375,35 @@ public class NetconfITTest extends AbstractNetconfConfigTest { return netconfClient; } - private void startSSHServer() throws Exception { - logger.info("Creating SSH server"); - StubUserManager um = new StubUserManager(USERNAME, PASSWORD); - String pem; - try (InputStream is = getClass().getResourceAsStream("/RSA.pk")) { - pem = IOUtils.toString(is); + @Test + public void testIdRef() throws Exception { + NetconfMessage editId = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml"); + NetconfMessage commit = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/commit.xml"); + + try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) { + assertIsOK(netconfClient.sendMessage(editId).getDocument()); + assertIsOK(netconfClient.sendMessage(commit).getDocument()); + + NetconfMessage response = netconfClient.sendMessage(getConfig); + + assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("prefix:test-identity1")); + assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("prefix:test-identity2")); + assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("prefix:test-identity2")); + assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("prefix:test-identity1")); + + } catch (Exception e) { + fail(Throwables.getStackTraceAsString(e)); } - AuthProvider ap = new AuthProvider(um, pem); - Thread sshServerThread = new Thread(NetconfSSHServer.start(10830, tcpAddress, ap)); - sshServerThread.setDaemon(true); - sshServerThread.start(); - logger.info("SSH server on"); } - @Test - public void sshTest() throws Exception { - startSSHServer(); - logger.info("creating connection"); - Connection conn = new Connection(sshAddress.getHostName(), sshAddress.getPort()); - Assert.assertNotNull(conn); - logger.info("connection created"); - conn.connect(); - boolean isAuthenticated = conn.authenticateWithPassword(USERNAME, PASSWORD); - assertTrue(isAuthenticated); - logger.info("user authenticated"); - final Session sess = conn.openSession(); - sess.startSubSystem("netconf"); - logger.info("user authenticated"); - sess.getStdin().write(XmlUtil.toString(this.getConfig.getDocument()).getBytes()); - - new Thread() { - @Override - public void run() { - while (true) { - byte[] bytes = new byte[1024]; - int c = 0; - try { - c = sess.getStdout().read(bytes); - } catch (IOException e) { - throw new IllegalStateException("IO exception while reading data on ssh bridge."); - } - logger.info("got data:" + bytes); - if (c == 0) { - break; - } - } - } - }.join(); - } + @Override + protected CodecRegistry getCodecRegistry() { + final IdentityCodec codec = mock(IdentityCodec.class); + doReturn(TestIdentity1.class).when(codec).deserialize(TestIdentity1.QNAME); + doReturn(TestIdentity2.class).when(codec).deserialize(TestIdentity2.QNAME); + final CodecRegistry ret = super.getCodecRegistry(); + doReturn(codec).when(ret).getIdentityCodec(); + return ret; + } } diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java deleted file mode 100644 index ebfcff3cd4..0000000000 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java +++ /dev/null @@ -1,184 +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.netconf.it.pax; - -import static org.junit.Assert.fail; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; -import static org.ops4j.pax.exam.CoreOptions.options; -import static org.ops4j.pax.exam.CoreOptions.streamBundle; -import static org.ops4j.pax.exam.CoreOptions.systemPackages; -import static org.ops4j.pax.exam.CoreOptions.systemProperty; - -import io.netty.util.HashedWheelTimer; -import io.netty.util.Timer; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; - -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.matchers.JUnitMatchers; -import org.junit.runner.RunWith; -import org.opendaylight.controller.netconf.api.NetconfMessage; -import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl; -import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener; -import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; -import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder; -import org.opendaylight.controller.netconf.client.test.TestingNetconfClient; -import org.opendaylight.controller.netconf.util.test.XmlFileLoader; -import org.opendaylight.controller.netconf.util.xml.XmlUtil; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.protocol.framework.NeverReconnectStrategy; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.options.DefaultCompositeOption; -import org.ops4j.pax.exam.util.Filter; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; -import org.xml.sax.SAXException; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; - -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.util.concurrent.GlobalEventExecutor; - -@Ignore -@RunWith(PaxExam.class) -public class IdentityRefNetconfTest { - - public static final int CLIENT_CONNECTION_TIMEOUT_MILLIS = 15000; - - // Wait for controller to start - - // FIXME move this (pax) test to different module - // pax jars contain guava classes that clash with real guava dependencies in non-pax tests - // - //@Inject - @Filter(timeout = 60 * 1000) - BindingAwareBroker broker; - - @Configuration - public Option[] config() { - return options( - systemProperty("osgi.console").value("2401"), - systemProperty("osgi.bundles.defaultStartLevel").value("4"), - systemProperty("pax.exam.osgi.unresolved.fail").value("true"), - systemPackages("sun.nio.ch"), - - testingModules(), - loggingModules(), - mdSalCoreBundles(), - bindingAwareSalBundles(), configMinumumBundles(), baseModelBundles(), flowCapableModelBundles(), - junitAndMockitoBundles(), - - // Classes from test-jars bundled for pax-exam test - streamBundle(TinyBundles.bundle() - .add(TestingNetconfClient.class) - .add(XmlFileLoader.class) - - .add("/netconfMessages/editConfig_identities.xml", - XmlFileLoader.class.getResource("/netconfMessages/editConfig_identities.xml")) - .add("/netconfMessages/commit.xml", - XmlFileLoader.class.getResource("/netconfMessages/commit.xml")) - .add("/netconfMessages/getConfig.xml", - XmlFileLoader.class.getResource("/netconfMessages/getConfig.xml")) - - .set(Constants.BUNDLE_SYMBOLICNAME, "TestingClient_bundle") - .set(Constants.EXPORT_PACKAGE, "org.opendaylight.controller.netconf.client.test, " + - "org.opendaylight.controller.netconf.util.test") - .build(TinyBundles.withBnd()))); - } - - private Option loggingModules() { - return new DefaultCompositeOption( - mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), - mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), - mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), - mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), - mavenBundle("org.opendaylight.controller.thirdparty", "nagasena").versionAsInProject(), - mavenBundle("org.opendaylight.controller.thirdparty", "nagasena-rta").versionAsInProject()); - - - } - - private Option testingModules() { - return new DefaultCompositeOption( - mavenBundle("org.opendaylight.controller", "yang-test").versionAsInProject()); - } - - private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 18383); - - @Test - public void testIdRef() throws Exception { - Preconditions.checkNotNull(broker, "Controller not initialized"); - - - NetconfMessage edit = xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml"); - NetconfMessage commit = xmlFileToNetconfMessage("netconfMessages/commit.xml"); - NetconfMessage getConfig = xmlFileToNetconfMessage("netconfMessages/getConfig.xml"); - - NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup(); - Timer timer = new HashedWheelTimer(); - NetconfClientDispatcherImpl clientDispatcher = new NetconfClientDispatcherImpl(nettyThreadgroup, nettyThreadgroup, timer); - try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", clientDispatcher, getClientConfiguration(tcpAddress))) { - sendMessage(edit, netconfClient); - sendMessage(commit, netconfClient); - sendMessage(getConfig, netconfClient, "id-test", - "prefix:test-identity1", - "prefix:test-identity2", - "prefix:test-identity2", - "prefix:test-identity1"); - - clientDispatcher.close(); - } catch (Exception e) { - fail(Throwables.getStackTraceAsString(e)); - } finally { - nettyThreadgroup.shutdownGracefully().get(); - timer.stop(); - } - } - - private void sendMessage(NetconfMessage edit, TestingNetconfClient netconfClient, String... containingResponse) - throws ExecutionException, InterruptedException, TimeoutException { - NetconfMessage response = netconfClient.sendRequest(edit).get(); - if (containingResponse == null) { - Assert.assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("")); - } else { - for (String resp : containingResponse) { - Assert.assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString(resp)); - } - } - } - - public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException, - ParserConfigurationException { - return XmlFileLoader.xmlFileToNetconfMessage(fileName); - } - - public NetconfClientConfiguration getClientConfiguration(final InetSocketAddress tcpAddress) { - final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create(); - b.withAddress(tcpAddress); - b.withSessionListener(new SimpleNetconfClientSessionListener()); - b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, - CLIENT_CONNECTION_TIMEOUT_MILLIS)); - b.withConnectionTimeoutMillis(CLIENT_CONNECTION_TIMEOUT_MILLIS); - return b.build(); - } -} diff --git a/opendaylight/netconf/netconf-it/src/test/resources/RSA.pk b/opendaylight/netconf/netconf-it/src/test/resources/RSA.pk deleted file mode 100644 index c0266c7bd2..0000000000 --- a/opendaylight/netconf/netconf-it/src/test/resources/RSA.pk +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEAuC9hbEacpewvylI0mwFwjy3Wou2hpr/ncN9BBiFDSaG5yW2k -3Oy+SCAcFCL+ZKWb6cc6Ch4gUeCwyEHRojZguuhliKtak9YQf6qbvpPLe00842Lx -iqNAGurMpzizCDsGFq8ChaAkBZQI3TvcHuPoSUWSMJ+K8xHpRyUdVr6g2yEjezKJ -sTXBtWaeCCh6YUafFujuDJk7fvYcPW7Je5KRBBStIKvxcMW0zB+7eq04deTHwGbJ -gGjKWilQ72hsDDP3Hbp5CJMAYg1r4GlCmFx3KyHRGztgWgNgaD7nNpKCkTLjtmA6 -b4x7TA+jrzZ6Af2z5TMrI4dv5w1SrxHaZ+ziLQIDAQABAoIBAHTndeGgq/rQf8De -Do+4CTaHtK0zQSAyu/azbXUzlZ7drKuCEVs8VMY4wzmwwGEnkF+A2YDkgEUX5X0l -8aYQ97KKoS9u+43MGCrAIhyDeGrpqlT1TzRcy+qJz53v6gq2U/X/3QztiQ+VV078 -mIluxNgE9XYxPaNsYfGLSCTv1+9c8y/hjGVX2kwFK+u4ut0ZZETggNa8UxfaHVDS -fIJQX9Gm3J3GSUV30fDGMBIUW6ESLc2L8b7u8Mp9TRP39ZeQSuEUjBe8MYKv0Rel -oEpjZvcnniMTpFbLpndBYn7/AoIiEBvtCN8faVTuRRcvvLcsRm09IctzKQYnMh6M -6PLKV+ECgYEA8HFRYaKHUzxpzE/fyon82GQbzqFFY0/bbWrfWICMfNbIgshJUie6 -FmH5iUFMfeqaT7v557HFM0GB9FeIeSbvd88YmiBAcRopZ3DfMkDH+DT73yJ+/TKG -2nrQtdhyuTIs4bwHqeS2BBJYs7PK9R2rratF3l34Tf7mjlvyOgygHdUCgYEAxBo2 -8hEBlAVNcNb1hTYUxe1w1B6675/mFlmw98Xmj9dRYfICXNhahs8tX3/lsBEd+vBu -fI0oyHaff8m5bPgGzD1ZMybfeROujNrgxaKVk7Ef0FDRRCop4bm18OroFlFAt9l8 -wMp++ToACbdvQvL/mjWMPYlIxhB/YxHswICZZvkCgYAexxKYwdo6sGAGlC7cWT9x -X5cjowcjyEQZRHXkeUgCbufpvcOM7aLnXJE5nY8yCwbHsBM0MlBA2GDPKylAANjk -aDEJAZneIHAuWodngl1Wi0m2bU7+ECqs6s2uiU9eH2sZVh1RBQK7kLGkBx6ys6KX -L3ZZGYRAT6GplWFzRsx0JQKBgCeVlxPD5QqpC1nEumi6YvUVGdpnnZpzL3HBhxxs -wT612wKnZFyze4qM1X7ahVXGDsQxtkvD/sCAWW/lG13orw6ZL6FIroF1PJ3ILOkY -CZN3hJF7TtKwpCWhZB2OfWzL2AGEkE8mUP0j/Q/5DCd6f6f0OSvOw3bfq6cm3iB5 -lP2ZAoGAXsRN5TZTX4AQ2xTlrDQ8A5XgcvyWQpJOmEXMTyHV7VaJVzmNWFVAvndK -5UIq8ALDwB2t7vjmMUW6euvIwqtXiop7G79UOb3e3NhzeyWFGQyBLqCRznGaXQTT -dlFy73xhukZMhFnj006bjKCYvOPnwuGl3+0fuWil5Rq3jOuY5c8= ------END RSA PRIVATE KEY----- diff --git a/opendaylight/netconf/netconf-it/src/test/resources/controller.xml b/opendaylight/netconf/netconf-it/src/test/resources/controller.xml deleted file mode 100644 index 96efc10403..0000000000 --- a/opendaylight/netconf/netconf-it/src/test/resources/controller.xml +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - urn:opendaylight:params:xml:ns:yang:controller:config:test:types?module=test-types&revision=2013-11-27 - urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05 - urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16 - urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28 - urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 - urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28 - urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28 - urn:opendaylight:params:xml:ns:yang:controller:test:impl?module=config-test-impl&revision=2013-04-03 - urn:opendaylight:params:xml:ns:yang:controller:test?module=config-test&revision=2013-06-13 - - - - - - prefix:impl-identity-test - id-test - - prefix:test-identity2 - - - prefix:test-identity2 - prefix:test-identity1 - - - prefix:test-identity1 - prefix:test-identity2 - - prefix:test-identity1 - - - prefix:binding-broker-impl - binding-broker-impl - - prefix:binding-notification-service - ref_binding-notification-broker - - - prefix:binding-data-broker - ref_binding-data-broker - - - - prefix:runtime-generated-mapping - runtime-mapping-singleton - - - prefix:binding-notification-broker - binding-notification-broker - - - prefix:binding-data-broker - binding-data-broker - - prefix:dom-broker-osgi-registry - ref_dom-broker - - - prefix:binding-dom-mapping-service - ref_runtime-mapping-singleton - - - - prefix:logback - singleton - - DEBUG - console - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - DEBUG - ROOT - console - - - - prefix:schema-service-singleton - yang-schema-service - - - prefix:hash-map-data-store - hash-map-data-store - - - prefix:dom-broker-impl - dom-broker - - prefix:dom-data-store - ref_hash-map-data-store - - - - - - prefix:schema-service - - ref_yang-schema-service - /modules/module[type='schema-service-singleton'][name='yang-schema-service'] - - - - prefix:dom-data-store - - ref_hash-map-data-store - /modules/module[type='hash-map-data-store'][name='hash-map-data-store'] - - - - prefix:dom-broker-osgi-registry - - ref_dom-broker - /modules/module[type='dom-broker-impl'][name='dom-broker'] - - - - prefix:testing - - ref_id-test - /modules/module[type='impl-identity-test'][name='id-test'] - - - - prefix:binding-dom-mapping-service - - ref_runtime-mapping-singleton - /modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton'] - - - - prefix:binding-data-consumer-broker - - ref_binding-data-broker - /modules/module[type='binding-data-broker'][name='binding-data-broker'] - - - - prefix:binding-rpc-registry - - ref_binding-broker-impl - /modules/module[type='binding-broker-impl'][name='binding-broker-impl'] - - - - prefix:binding-notification-service - - ref_binding-notification-broker - /modules/module[type='binding-notification-broker'][name='binding-notification-broker'] - - - - prefix:binding-broker-osgi-registry - - ref_binding-broker-impl - /modules/module[type='binding-broker-impl'][name='binding-broker-impl'] - - - - prefix:binding-notification-subscription-service - - ref_binding-notification-broker - /modules/module[type='binding-notification-broker'][name='binding-notification-broker'] - - - - prefix:binding-data-broker - - ref_binding-data-broker - /modules/module[type='binding-data-broker'][name='binding-data-broker'] - - - - - - - - diff --git a/opendaylight/netconf/netconf-it/src/test/resources/keystore.jks b/opendaylight/netconf/netconf-it/src/test/resources/keystore.jks deleted file mode 100644 index 201d3758af..0000000000 Binary files a/opendaylight/netconf/netconf-it/src/test/resources/keystore.jks and /dev/null differ diff --git a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml deleted file mode 100644 index ffdf132153..0000000000 --- a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml deleted file mode 100644 index 39efb4961b..0000000000 --- a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/opendaylight/netconf/netconf-util/pom.xml b/opendaylight/netconf/netconf-util/pom.xml index 65d2954afd..14a71fd9ba 100644 --- a/opendaylight/netconf/netconf-util/pom.xml +++ b/opendaylight/netconf/netconf-util/pom.xml @@ -42,11 +42,11 @@ ganymed - org.opendaylight.controller.thirdparty + org.openexi nagasena - org.opendaylight.controller.thirdparty + org.openexi nagasena-rta diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/MissingNameSpaceException.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/MissingNameSpaceException.java index 0a3e0b3ec3..6cc5006aba 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/MissingNameSpaceException.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/MissingNameSpaceException.java @@ -7,20 +7,21 @@ */ package org.opendaylight.controller.netconf.util.exception; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; - import java.util.Collections; import java.util.Map; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; + public class MissingNameSpaceException extends NetconfDocumentedException { + private static final long serialVersionUID = 1L; public MissingNameSpaceException(final String message, final ErrorType errorType, final ErrorTag errorTag, - final ErrorSeverity errorSeverity) { + final ErrorSeverity errorSeverity) { this(message, errorType, errorTag, errorSeverity, Collections. emptyMap()); } public MissingNameSpaceException(final String message, final ErrorType errorType, final ErrorTag errorTag, - final ErrorSeverity errorSeverity, final Map errorInfo){ + final ErrorSeverity errorSeverity, final Map errorInfo){ super(message,errorType,errorTag,errorSeverity,errorInfo); } } diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/UnexpectedElementException.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/UnexpectedElementException.java index b470ce13a8..7b5f52e396 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/UnexpectedElementException.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/UnexpectedElementException.java @@ -7,20 +7,21 @@ */ package org.opendaylight.controller.netconf.util.exception; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; - import java.util.Collections; import java.util.Map; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; + public class UnexpectedElementException extends NetconfDocumentedException { + private static final long serialVersionUID = 1L; public UnexpectedElementException(final String message, final ErrorType errorType, final ErrorTag errorTag, - final ErrorSeverity errorSeverity) { + final ErrorSeverity errorSeverity) { this(message, errorType, errorTag, errorSeverity, Collections. emptyMap()); } public UnexpectedElementException(final String message, final ErrorType errorType, final ErrorTag errorTag, - final ErrorSeverity errorSeverity, final Map errorInfo){ + final ErrorSeverity errorSeverity, final Map errorInfo) { super(message,errorType,errorTag,errorSeverity,errorInfo); } } diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/UnexpectedNamespaceException.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/UnexpectedNamespaceException.java index 50d7670780..582fd23e16 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/UnexpectedNamespaceException.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/exception/UnexpectedNamespaceException.java @@ -7,12 +7,13 @@ */ package org.opendaylight.controller.netconf.util.exception; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; - import java.util.Collections; import java.util.Map; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; + public class UnexpectedNamespaceException extends NetconfDocumentedException { + private static final long serialVersionUID = 1L; public UnexpectedNamespaceException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity) { diff --git a/opendaylight/netconf/pom.xml b/opendaylight/netconf/pom.xml index 86ef75d45f..50e84463f5 100644 --- a/opendaylight/netconf/pom.xml +++ b/opendaylight/netconf/pom.xml @@ -29,7 +29,6 @@ netconf-monitoring ietf-netconf-monitoring ietf-netconf-monitoring-extension - ../../third-party/org.openexi diff --git a/opendaylight/networkconfiguration/neutron/implementation/pom.xml b/opendaylight/networkconfiguration/neutron/implementation/pom.xml index 9514ec1ed5..c8f1dd270d 100644 --- a/opendaylight/networkconfiguration/neutron/implementation/pom.xml +++ b/opendaylight/networkconfiguration/neutron/implementation/pom.xml @@ -40,7 +40,6 @@ org.apache.felix maven-bundle-plugin - 2.3.6 true diff --git a/opendaylight/networkconfiguration/neutron/pom.xml b/opendaylight/networkconfiguration/neutron/pom.xml index 4d491a51d2..998dd4488c 100644 --- a/opendaylight/networkconfiguration/neutron/pom.xml +++ b/opendaylight/networkconfiguration/neutron/pom.xml @@ -36,7 +36,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/bundlescanner/api/pom.xml b/opendaylight/northbound/bundlescanner/api/pom.xml index d861e0a7c9..ee83c93580 100644 --- a/opendaylight/northbound/bundlescanner/api/pom.xml +++ b/opendaylight/northbound/bundlescanner/api/pom.xml @@ -24,7 +24,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/bundlescanner/implementation/pom.xml b/opendaylight/northbound/bundlescanner/implementation/pom.xml index dc481ce74a..c06f8b4215 100644 --- a/opendaylight/northbound/bundlescanner/implementation/pom.xml +++ b/opendaylight/northbound/bundlescanner/implementation/pom.xml @@ -41,7 +41,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/commons/pom.xml b/opendaylight/northbound/commons/pom.xml index 83699d2b4b..09c075735a 100644 --- a/opendaylight/northbound/commons/pom.xml +++ b/opendaylight/northbound/commons/pom.xml @@ -72,7 +72,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/connectionmanager/enunciate.xml b/opendaylight/northbound/connectionmanager/enunciate.xml index 124f2d84e8..cb21d7c167 100644 --- a/opendaylight/northbound/connectionmanager/enunciate.xml +++ b/opendaylight/northbound/connectionmanager/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/connectionmanager/pom.xml b/opendaylight/northbound/connectionmanager/pom.xml index 7c17c74800..a0940e3428 100644 --- a/opendaylight/northbound/connectionmanager/pom.xml +++ b/opendaylight/northbound/connectionmanager/pom.xml @@ -42,7 +42,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/containermanager/enunciate.xml b/opendaylight/northbound/containermanager/enunciate.xml index 9dcab30900..c4e08ae897 100644 --- a/opendaylight/northbound/containermanager/enunciate.xml +++ b/opendaylight/northbound/containermanager/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> @@ -8,4 +8,4 @@ - \ No newline at end of file + diff --git a/opendaylight/northbound/containermanager/pom.xml b/opendaylight/northbound/containermanager/pom.xml index 1d91ab590e..457b1bd6a4 100644 --- a/opendaylight/northbound/containermanager/pom.xml +++ b/opendaylight/northbound/containermanager/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/controllermanager/enunciate.xml b/opendaylight/northbound/controllermanager/enunciate.xml index 13a2d27c41..5382d54138 100644 --- a/opendaylight/northbound/controllermanager/enunciate.xml +++ b/opendaylight/northbound/controllermanager/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/controllermanager/pom.xml b/opendaylight/northbound/controllermanager/pom.xml index 6c79f9d6e2..07d34cb6d4 100644 --- a/opendaylight/northbound/controllermanager/pom.xml +++ b/opendaylight/northbound/controllermanager/pom.xml @@ -51,7 +51,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerProperties.java b/opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerProperties.java index 3d45257ce2..cec5a93a9e 100644 --- a/opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerProperties.java +++ b/opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerProperties.java @@ -11,15 +11,17 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; +import org.opendaylight.controller.sal.core.Property; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import org.opendaylight.controller.sal.core.Property; /** * The class describes set of properties attached to a controller @@ -29,12 +31,12 @@ import org.opendaylight.controller.sal.core.Property; @XmlAccessorType(XmlAccessType.NONE) public class ControllerProperties { - @XmlElementRef - @XmlElementWrapper - @JsonIgnore /** * Set to store the controller properties */ + @XmlElement(name="property") + @XmlElementWrapper + @JsonIgnore private Set properties; // JAXB required constructor diff --git a/opendaylight/northbound/flowprogrammer/enunciate.xml b/opendaylight/northbound/flowprogrammer/enunciate.xml index 3ac676907b..8a87876af3 100644 --- a/opendaylight/northbound/flowprogrammer/enunciate.xml +++ b/opendaylight/northbound/flowprogrammer/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/flowprogrammer/pom.xml b/opendaylight/northbound/flowprogrammer/pom.xml index 2281aa8e3c..205b68a91c 100644 --- a/opendaylight/northbound/flowprogrammer/pom.xml +++ b/opendaylight/northbound/flowprogrammer/pom.xml @@ -46,7 +46,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/hosttracker/enunciate.xml b/opendaylight/northbound/hosttracker/enunciate.xml index df56dbae36..a8be00a3d3 100644 --- a/opendaylight/northbound/hosttracker/enunciate.xml +++ b/opendaylight/northbound/hosttracker/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/hosttracker/pom.xml b/opendaylight/northbound/hosttracker/pom.xml index d8dee6211a..bf1b082cfe 100644 --- a/opendaylight/northbound/hosttracker/pom.xml +++ b/opendaylight/northbound/hosttracker/pom.xml @@ -46,7 +46,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/httpservice-bridge/pom.xml b/opendaylight/northbound/httpservice-bridge/pom.xml index 33f204885d..c7b9cfc9a0 100644 --- a/opendaylight/northbound/httpservice-bridge/pom.xml +++ b/opendaylight/northbound/httpservice-bridge/pom.xml @@ -19,7 +19,6 @@ org.apache.felix maven-bundle-plugin - 2.4.0 true diff --git a/opendaylight/northbound/java-client/enunciate.xml b/opendaylight/northbound/java-client/enunciate.xml index ce9186eb33..c78243766e 100644 --- a/opendaylight/northbound/java-client/enunciate.xml +++ b/opendaylight/northbound/java-client/enunciate.xml @@ -1,13 +1,13 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> - + diff --git a/opendaylight/northbound/java-client/pom.xml b/opendaylight/northbound/java-client/pom.xml index 6de347fdde..ae8924feb6 100644 --- a/opendaylight/northbound/java-client/pom.xml +++ b/opendaylight/northbound/java-client/pom.xml @@ -7,12 +7,6 @@ 1.4.2-SNAPSHOT ../../commons/opendaylight - - scm:git:ssh://git.opendaylight.org:29418/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main - HEAD - northbound.client 0.0.1-SNAPSHOT @@ -22,56 +16,100 @@ ${project.build.directory}/rest-api-docs ${project.build.directory}/enunciate/build/java-client/full-client.jar ${project.build.directory}/enunciate/build/java-client/full-client-sources.jar - ${project.build.directory}/enunciate/build/java-client/full-json-client.jar - ${project.build.directory}/enunciate/build/java-client/full-json-client-sources.jar + + + org.codehaus.enunciate + enunciate-core-annotations + + + + + org.opendaylight.controller + connectionmanager.northbound + + + org.opendaylight.controller + controllermanager.northbound + + + org.opendaylight.controller + flowprogrammer.northbound + + + org.opendaylight.controller + forwarding.staticrouting.northbound + + + org.opendaylight.controller + hosttracker.northbound + + + org.opendaylight.controller + networkconfig.bridgedomain.northbound + + + org.opendaylight.controller + networkconfig.neutron.northbound + + + org.opendaylight.controller + statistics.northbound + + + org.opendaylight.controller + subnets.northbound + + + org.opendaylight.controller + switchmanager.northbound + + + org.opendaylight.controller + topology.northbound + + + org.opendaylight.controller + usermanager.northbound + + + - - org.codehaus.enunciate - maven-enunciate-plugin - org.apache.maven.plugins maven-antrun-plugin - 1.5 - - - package - - run - - - - + - - + + - + - - - + + + - + - + + + + + + + - - <![CDATA[ + <![CDATA[ <html> <head> <title> OpenDaylight REST API Documentation </title> @@ -80,39 +118,29 @@ <h2>OpenDaylight REST API Documentation</h2> <p> OpenDaylight supports the following <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">Representational State Transfer (REST)</a> APIs: </p> <h4> - ]]> - - - + ]]> + + - - - + + + - - <![CDATA[ + <![CDATA[ </h4> <i>---</i> </body> </html> - ]]> - + ]]> - + - + - - + + @@ -122,6 +150,18 @@ 20020829 + + + + run + + package + + + + + org.codehaus.enunciate + maven-enunciate-plugin @@ -130,10 +170,10 @@ attach-artifacts - package attach-artifact + package @@ -146,16 +186,6 @@ jar full-java-client-sources - - ${json-client} - jar - full-json-client - - - ${json-client-sources} - jar - full-json-client-sources - @@ -163,60 +193,10 @@ - - - org.codehaus.enunciate - enunciate-core-annotations - - - - - org.opendaylight.controller - connectionmanager.northbound - - - org.opendaylight.controller - controllermanager.northbound - - - org.opendaylight.controller - flowprogrammer.northbound - - - org.opendaylight.controller - hosttracker.northbound - - - org.opendaylight.controller - networkconfig.bridgedomain.northbound - - - org.opendaylight.controller - networkconfig.neutron.northbound - - - org.opendaylight.controller - forwarding.staticrouting.northbound - - - org.opendaylight.controller - statistics.northbound - - - org.opendaylight.controller - subnets.northbound - - - org.opendaylight.controller - switchmanager.northbound - - - org.opendaylight.controller - topology.northbound - - - org.opendaylight.controller - usermanager.northbound - - + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + HEAD + https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main + diff --git a/opendaylight/northbound/jolokia/pom.xml b/opendaylight/northbound/jolokia/pom.xml index f984d4e8ed..62af41ab46 100644 --- a/opendaylight/northbound/jolokia/pom.xml +++ b/opendaylight/northbound/jolokia/pom.xml @@ -19,7 +19,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/networkconfiguration/bridgedomain/enunciate.xml b/opendaylight/northbound/networkconfiguration/bridgedomain/enunciate.xml index f5a7ef1233..1555743ea8 100644 --- a/opendaylight/northbound/networkconfiguration/bridgedomain/enunciate.xml +++ b/opendaylight/northbound/networkconfiguration/bridgedomain/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> @@ -8,5 +8,5 @@ - + diff --git a/opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml b/opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml index e78035f00c..f112978080 100644 --- a/opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml +++ b/opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml @@ -46,7 +46,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/networkconfiguration/neutron/enunciate.xml b/opendaylight/northbound/networkconfiguration/neutron/enunciate.xml index b9e4f7ecc1..66160255f3 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/enunciate.xml +++ b/opendaylight/northbound/networkconfiguration/neutron/enunciate.xml @@ -1,12 +1,12 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/opendaylight/northbound/networkconfiguration/neutron/pom.xml b/opendaylight/northbound/networkconfiguration/neutron/pom.xml index bc0ab2b78a..728316afab 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/pom.xml +++ b/opendaylight/northbound/networkconfiguration/neutron/pom.xml @@ -10,9 +10,6 @@ networkconfig.neutron.northbound 0.4.2-SNAPSHOT bundle - - 1.26.2 - com.sun.jersey @@ -57,7 +54,6 @@ org.apache.felix maven-bundle-plugin - 2.3.6 true @@ -83,16 +79,6 @@ org.codehaus.enunciate maven-enunciate-plugin - - enunciate.xml - - - - - docs - - - diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java index d7437c831d..52c3337e40 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java @@ -9,12 +9,15 @@ package org.opendaylight.controller.networkconfig.neutron.northbound; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; @@ -22,7 +25,9 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.Response; import org.codehaus.enunciate.jaxrs.ResponseCode; @@ -60,6 +65,9 @@ import org.opendaylight.controller.sal.utils.ServiceHelper; @Path("/networks") public class NeutronNetworksNorthbound { + @Context + UriInfo uriInfo; + private NeutronNetwork extractFields(NeutronNetwork o, List fields) { return o.extractFields(fields); } @@ -72,7 +80,7 @@ public class NeutronNetworksNorthbound { //@TypeHint(OpenStackNetworks.class) @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), - @ResponseCode(code = 401, condition = "Unauthorized") }) + @ResponseCode(code = 401, condition = "Unauthorized")}) public Response listNetworks( // return fields @QueryParam("fields") List fields, @@ -88,9 +96,9 @@ public class NeutronNetworksNorthbound { @QueryParam("provider_physical_network") String queryProviderPhysicalNetwork, @QueryParam("provider_segmentation_id") String queryProviderSegmentationID, // pagination - @QueryParam("limit") String limit, + @QueryParam("limit") Integer limit, @QueryParam("marker") String marker, - @QueryParam("page_reverse") String pageReverse + @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse // sorting not supported ) { INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this); @@ -130,9 +138,94 @@ public class NeutronNetworksNorthbound { } } } - //TODO: apply pagination to results - return Response.status(200).entity( - new NeutronNetworkRequest(ans)).build(); + + Comparator neutronNetworkComparator = new Comparator() { + @Override + public int compare(NeutronNetwork o1, NeutronNetwork o2) { + return o1.getID().compareTo(o2.getID()); + } + }; + + Collections.sort(ans, neutronNetworkComparator); + + if (limit != null && ans.size() > 1) { + List links = new ArrayList<>(); + Integer startPos = null; + String startMarker; + String endMarker; + Boolean firstPage = false; + Boolean lastPage = false; + + if (marker == null) { + startPos = 0; + } + + else { + + NeutronNetwork markerNetwork = new NeutronNetwork(); + markerNetwork.setNetworkUUID(marker); + + startPos = Collections.binarySearch(ans, markerNetwork, neutronNetworkComparator); + + if (!pageReverse){ + startPos = startPos + 1; + } + else { + startPos = startPos - limit; + } + + } + + if (startPos == null) { + throw new ResourceNotFoundException("UUID for marker:" + marker + " could not be found"); + } + + if (startPos == 0){ + firstPage = true; + } + + if (startPos + limit >= ans.size()) { + ans = ans.subList(startPos, ans.size()); + startMarker = ans.get(0).getID(); + endMarker = ans.get(ans.size() - 1).getID(); + lastPage = true; + } + else if (startPos < 0) { + if (startPos + limit > 0) { + ans = ans.subList(0, startPos + limit); + startMarker = ans.get(0).getID(); + endMarker = ans.get(ans.size() - 1).getID(); + firstPage = true; + } + else { + throw new BadRequestException("Requested page is out of bounds. Please check the supplied limit and marker"); + } + } + else { + ans = ans.subList(startPos, startPos + limit); + startMarker = ans.get(0).getID(); + endMarker = ans.get(limit-1).getID(); + } + + if (!lastPage) { + NeutronPageLink next = new NeutronPageLink(); + next.setRef("next"); + next.setHref(uriInfo.getAbsolutePath().toString() + "?limit=" + limit.toString() + "&marker=" + endMarker); + links.add(next); + } + + if (!firstPage) { + NeutronPageLink previous = new NeutronPageLink(); + previous.setRef("previous"); + previous.setHref(uriInfo.getAbsolutePath().toString() + "?limit=" + limit.toString() + "&marker=" + startMarker + "&page_reverse=True"); + links.add(previous); + } + + return Response.status(200).entity(new PaginatedNeutronNetworkRequest(ans, links)).build(); + } + + return Response.status(200).entity(new NeutronNetworkRequest(ans)).build(); + } /** diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPageLink.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPageLink.java new file mode 100644 index 0000000000..f65d7f694b --- /dev/null +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPageLink.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2014 Hewlett-Packard Development Company L.P + * + * 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 + * + * Authors : Dave Tucker + */ + +package org.opendaylight.controller.networkconfig.neutron.northbound; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) + +public class NeutronPageLink { + + @XmlElement(name="ref") + String ref; + + @XmlElement (name="href") + String href; + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } +} \ No newline at end of file diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/PaginatedNeutronNetworkRequest.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/PaginatedNeutronNetworkRequest.java new file mode 100644 index 0000000000..c050661329 --- /dev/null +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/PaginatedNeutronNetworkRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2014 Hewlett-Packard Development Company L.P + * + * 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 + * + * Authors : Dave Tucker + */ + +package org.opendaylight.controller.networkconfig.neutron.northbound; + +import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) + +public class PaginatedNeutronNetworkRequest { + + @XmlElement (name="networks") + List networks; + + @XmlElement (name="network_links") + List networkLinks; + + public PaginatedNeutronNetworkRequest() { + } + + public PaginatedNeutronNetworkRequest(List networks, List networkLinks) { + this.networks = networks; + this.networkLinks = networkLinks; + } + + public List getNetworks() { + return networks; + } + + public void setNetworks(List networks) { + this.networks = networks; + } + + public List getNetworkLinks() { + return networkLinks; + } + + public void setNetworkLinks(List networkLinks) { + this.networkLinks = networkLinks; + } +} diff --git a/opendaylight/northbound/staticrouting/enunciate.xml b/opendaylight/northbound/staticrouting/enunciate.xml index 402b655371..4d2f1cb611 100644 --- a/opendaylight/northbound/staticrouting/enunciate.xml +++ b/opendaylight/northbound/staticrouting/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/staticrouting/pom.xml b/opendaylight/northbound/staticrouting/pom.xml index 0e496a420f..dd2a2e6223 100644 --- a/opendaylight/northbound/staticrouting/pom.xml +++ b/opendaylight/northbound/staticrouting/pom.xml @@ -42,7 +42,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/statistics/enunciate.xml b/opendaylight/northbound/statistics/enunciate.xml index 63ae439758..c5f9140c76 100644 --- a/opendaylight/northbound/statistics/enunciate.xml +++ b/opendaylight/northbound/statistics/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/statistics/pom.xml b/opendaylight/northbound/statistics/pom.xml index 5935db4893..76ce062424 100644 --- a/opendaylight/northbound/statistics/pom.xml +++ b/opendaylight/northbound/statistics/pom.xml @@ -42,7 +42,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/subnets/enunciate.xml b/opendaylight/northbound/subnets/enunciate.xml index abdc40a174..e75daf94ee 100644 --- a/opendaylight/northbound/subnets/enunciate.xml +++ b/opendaylight/northbound/subnets/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/subnets/pom.xml b/opendaylight/northbound/subnets/pom.xml index 7c68f41cad..5aa2f7f202 100644 --- a/opendaylight/northbound/subnets/pom.xml +++ b/opendaylight/northbound/subnets/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/switchmanager/enunciate.xml b/opendaylight/northbound/switchmanager/enunciate.xml index 6f2dd4d0e7..3db309d46f 100644 --- a/opendaylight/northbound/switchmanager/enunciate.xml +++ b/opendaylight/northbound/switchmanager/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/switchmanager/pom.xml b/opendaylight/northbound/switchmanager/pom.xml index 8f54a28bda..590f0bb533 100644 --- a/opendaylight/northbound/switchmanager/pom.xml +++ b/opendaylight/northbound/switchmanager/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeConnectorProperties.java b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeConnectorProperties.java index 00f0d4b054..bb3fc0cc03 100644 --- a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeConnectorProperties.java +++ b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeConnectorProperties.java @@ -13,18 +13,19 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.Property; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * The class describes set of properties attached to a node connector */ @@ -34,7 +35,8 @@ import org.opendaylight.controller.sal.core.Property; public class NodeConnectorProperties { @XmlElement private NodeConnector nodeconnector; - @XmlElementRef + + @XmlElement(name="property") @XmlElementWrapper @JsonIgnore private Set properties; diff --git a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeProperties.java b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeProperties.java index 51e96c49ea..380d759ab7 100644 --- a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeProperties.java +++ b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeProperties.java @@ -13,18 +13,19 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.Property; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * The class describes set of properties attached to a node */ @@ -34,7 +35,8 @@ import org.opendaylight.controller.sal.core.Property; public class NodeProperties { @XmlElement private Node node; - @XmlElementRef + + @XmlElement(name="property") @XmlElementWrapper @JsonIgnore private Set properties; diff --git a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java index 662af723ed..e30dad24ab 100644 --- a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java +++ b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java @@ -396,6 +396,85 @@ public class SwitchNorthbound { return NorthboundUtils.getResponse(status); } + /** + * Get a property of a node + * + * @param containerName + * Name of the Container (Eg. 'SliceRed') + * @param nodeType + * Type of the node being programmed (Eg. 'OF') + * @param nodeId + * Node Identifier as specified by + * {@link org.opendaylight.controller.sal.core.Node} (Eg. + * '00:00:00:00:00:03:01:02') + * @param propertyName + * Name of the Property. Properties that can be deleted are + * description, forwarding(only in default container) and tier. + * @return Property value of the property + * + *
+     *
+     * Example:
+     *
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/switchmanager/default/node/OF/00:00:00:00:00:00:00:01/property/description
+     *
+     * Response body in XML
+     * <description>
+     *       <value>switch1</value>
+     * </description>
+     *
+     * Response body in JSON
+     * {
+     *       "value": "switch1"
+     * }
+     * 
+ */ + + @Path("/{containerName}/node/{nodeType}/{nodeId}/property/{propertyName}") + @GET + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @TypeHint(String.class) + @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), + @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), + @ResponseCode(code = 404, condition = "The containerName is not found"), + @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) + public Property getNodeProperty(@PathParam("containerName") String containerName, + @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId, + @PathParam("propertyName") String propertyName) { + + if (!isValidContainer(containerName)) { + throw new ResourceNotFoundException("Container " + containerName + " does not exist."); + } + if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { + throw new UnauthorizedException("User is not authorized to perform this operation on container " + + containerName); + } + ISwitchManager switchManager = getIfSwitchManagerService(containerName); + if (switchManager == null) { + throw new ServiceUnavailableException("Switch Manager " + RestMessages.SERVICEUNAVAILABLE.toString()); + } + + handleNodeAvailability(containerName, nodeType, nodeId); + Node node = Node.fromString(nodeType, nodeId); + if (node == null) { + throw new ResourceNotFoundException(nodeId + " : " + RestMessages.NONODE.toString()); + } + SwitchConfig switchConfig = switchManager.getSwitchConfig(node.toString()); + if (switchConfig == null) { + throw new ResourceNotFoundException(nodeId + " : " + "Config Not Found" ); + } else { + Map nodeProperties = new HashMap(switchConfig.getNodeProperties()); + if (!nodeProperties.containsKey(propertyName.toLowerCase())) { + String msg = "Property " + propertyName + " does not exist or not " + + "configured for switch " + nodeId; + throw new ResourceNotFoundException(msg); + } else { + return nodeProperties.get(propertyName.toLowerCase()); + } + } + } + /** * * Retrieve a list of all the nodeconnectors and their properties in a given diff --git a/opendaylight/northbound/topology/enunciate.xml b/opendaylight/northbound/topology/enunciate.xml index fed0f68e30..b70ea74071 100644 --- a/opendaylight/northbound/topology/enunciate.xml +++ b/opendaylight/northbound/topology/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/topology/pom.xml b/opendaylight/northbound/topology/pom.xml index 838a15db98..4a1142bb18 100644 --- a/opendaylight/northbound/topology/pom.xml +++ b/opendaylight/northbound/topology/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/EdgeProperties.java b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/EdgeProperties.java index 1d4a8a66ee..d43b9bc893 100644 --- a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/EdgeProperties.java +++ b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/EdgeProperties.java @@ -13,24 +13,26 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import org.opendaylight.controller.sal.core.Edge; import org.opendaylight.controller.sal.core.Property; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) public class EdgeProperties { @XmlElement private Edge edge; - @XmlElementRef + + @XmlElement(name="property") @XmlElementWrapper @JsonIgnore private Set properties; diff --git a/opendaylight/northbound/usermanager/enunciate.xml b/opendaylight/northbound/usermanager/enunciate.xml index a0b9546539..0386c759b2 100644 --- a/opendaylight/northbound/usermanager/enunciate.xml +++ b/opendaylight/northbound/usermanager/enunciate.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"> diff --git a/opendaylight/northbound/usermanager/pom.xml b/opendaylight/northbound/usermanager/pom.xml index 01e43085b6..c7ab2fa712 100644 --- a/opendaylight/northbound/usermanager/pom.xml +++ b/opendaylight/northbound/usermanager/pom.xml @@ -39,7 +39,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/protocol_plugins/openflow/pom.xml b/opendaylight/protocol_plugins/openflow/pom.xml index e47933548a..a8fceec2bf 100644 --- a/opendaylight/protocol_plugins/openflow/pom.xml +++ b/opendaylight/protocol_plugins/openflow/pom.xml @@ -39,7 +39,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/protocol_plugins/stub/pom.xml b/opendaylight/protocol_plugins/stub/pom.xml index fc760e4919..540c9afb2c 100644 --- a/opendaylight/protocol_plugins/stub/pom.xml +++ b/opendaylight/protocol_plugins/stub/pom.xml @@ -26,7 +26,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/routing/dijkstra_implementation/pom.xml b/opendaylight/routing/dijkstra_implementation/pom.xml index d923c452e6..b691308e97 100644 --- a/opendaylight/routing/dijkstra_implementation/pom.xml +++ b/opendaylight/routing/dijkstra_implementation/pom.xml @@ -47,7 +47,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/sal/api/pom.xml b/opendaylight/sal/api/pom.xml index 070029f891..3ee239a0f4 100644 --- a/opendaylight/sal/api/pom.xml +++ b/opendaylight/sal/api/pom.xml @@ -39,7 +39,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/sal/connection/api/pom.xml b/opendaylight/sal/connection/api/pom.xml index 2340a829fd..b194f76a45 100644 --- a/opendaylight/sal/connection/api/pom.xml +++ b/opendaylight/sal/connection/api/pom.xml @@ -27,7 +27,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/sal/connection/implementation/pom.xml b/opendaylight/sal/connection/implementation/pom.xml index e771f846ae..7150683597 100644 --- a/opendaylight/sal/connection/implementation/pom.xml +++ b/opendaylight/sal/connection/implementation/pom.xml @@ -27,7 +27,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/sal/implementation/pom.xml b/opendaylight/sal/implementation/pom.xml index d8a7d7beef..88986dcdd0 100644 --- a/opendaylight/sal/implementation/pom.xml +++ b/opendaylight/sal/implementation/pom.xml @@ -32,7 +32,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/sal/networkconfiguration/api/pom.xml b/opendaylight/sal/networkconfiguration/api/pom.xml index ed3b391947..5b2269ae6d 100644 --- a/opendaylight/sal/networkconfiguration/api/pom.xml +++ b/opendaylight/sal/networkconfiguration/api/pom.xml @@ -23,7 +23,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/sal/networkconfiguration/implementation/pom.xml b/opendaylight/sal/networkconfiguration/implementation/pom.xml index 38944e6314..508c9bd3f5 100644 --- a/opendaylight/sal/networkconfiguration/implementation/pom.xml +++ b/opendaylight/sal/networkconfiguration/implementation/pom.xml @@ -27,7 +27,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/samples/loadbalancer/pom.xml b/opendaylight/samples/loadbalancer/pom.xml index 4d8212209b..7939083891 100644 --- a/opendaylight/samples/loadbalancer/pom.xml +++ b/opendaylight/samples/loadbalancer/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/samples/northbound/loadbalancer/pom.xml b/opendaylight/samples/northbound/loadbalancer/pom.xml index 9dd0f99be6..5854d5577f 100644 --- a/opendaylight/samples/northbound/loadbalancer/pom.xml +++ b/opendaylight/samples/northbound/loadbalancer/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/samples/simpleforwarding/pom.xml b/opendaylight/samples/simpleforwarding/pom.xml index d65980e26c..1208506bd5 100644 --- a/opendaylight/samples/simpleforwarding/pom.xml +++ b/opendaylight/samples/simpleforwarding/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java b/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java index 94e67247c8..a48d331773 100644 --- a/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java +++ b/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java @@ -19,7 +19,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.Timer; +import java.util.TimerTask; import org.opendaylight.controller.clustering.services.CacheConfigException; import org.opendaylight.controller.clustering.services.CacheExistException; @@ -100,6 +103,97 @@ public class SimpleForwardingImpl implements IfNewHostNotify, private ISwitchManager switchManager; private IDataPacketService dataPacketService; + /** + * Ip packets that are punted may not have their destination known by hostTracker at the time it + * is presented to SimpleForwardingImpl. Instead of dropping the packet, we will keep it around + * for a 'little' while, to accommodate any transients. See bug 590 for more details. + */ + private class PendingPacketData { + private final static byte MAX_AGE = 2; + + public final IPv4 pkt; + public final NodeConnector incomingNodeConnector; + private byte age; + + public PendingPacketData(IPv4 pkt, NodeConnector incomingNodeConnector) { + this.pkt = pkt; + this.incomingNodeConnector = incomingNodeConnector; + this.age = 0; + } + boolean bumpAgeAndCheckIfTooOld() { return ++age > MAX_AGE; } + } + private static final int MAX_PENDING_PACKET_DESTINATIONS = 64; + private ConcurrentMap pendingPacketDestinations; + private Timer pendingPacketsAgerTimer; + + private class PendingPacketsAgerTimerHandler extends TimerTask { + @Override + public void run() { + if (pendingPacketDestinations == null) { + return; + } + try { + Iterator> iterator = + pendingPacketDestinations.entrySet().iterator(); + while (iterator.hasNext()) { + ConcurrentHashMap.Entry entry = iterator.next(); + InetAddress dIP = entry.getKey(); + PendingPacketData pendingPacketData = entry.getValue(); + + if (pendingPacketData.bumpAgeAndCheckIfTooOld()) { + iterator.remove(); // safe to remove while iterating... + log.debug("Pending packet for {} has been aged out", dIP); + } else { + /** Replace the entry for a key only if currently mapped to some value. + * This will protect the concurrent map against a race where this thread + * would be re-adding an entry that just got taken out. + */ + pendingPacketDestinations.replace(dIP, pendingPacketData); + } + } + } catch (IllegalStateException e) { + log.warn("IllegalStateException Received by PendingPacketsAgerTimerHandler from: {}", + e.getMessage()); + } + } + } + + /** + * Add punted packet to pendingPackets + */ + private void addToPendingPackets(InetAddress dIP, IPv4 pkt, NodeConnector incomingNodeConnector) { + if (pendingPacketDestinations.size() >= MAX_PENDING_PACKET_DESTINATIONS) { + log.info("Will not pend packet for {}: Too many destinations", dIP); + return; + } + + /** TODO: The current implementation allows for up to 1 pending packet per InetAddress. + * This limitation is done for sake of simplicity. A potential enhancement could be to use a + * ConcurrentMultiMap instead of ConcurrentMap. + */ + if (pendingPacketDestinations.containsKey(dIP)) { + log.trace("Will not pend packet for {}: Already have a packet pending", dIP); + return; + } + + PendingPacketData pendingPacketData = new PendingPacketData(pkt, incomingNodeConnector); + pendingPacketDestinations.put(dIP, pendingPacketData); + log.debug("Pending packet for {}", dIP); + } + + /** + * Send punted packet to given destination. This is invoked when there is a certain level of + * hope that the destination is known by hostTracker. + */ + private void sendPendingPacket(InetAddress dIP) { + PendingPacketData pendingPacketData = pendingPacketDestinations.get(dIP); + if (pendingPacketData != null) { + handlePuntedIPPacket(pendingPacketData.pkt, pendingPacketData.incomingNodeConnector, false); + log.trace("Packet for {} is no longer pending", dIP); + pendingPacketDestinations.remove(dIP); + } + } + /** * Return codes from the programming of the perHost rules in HW */ @@ -170,6 +264,15 @@ public class SimpleForwardingImpl implements IfNewHostNotify, public void startUp() { allocateCaches(); retrieveCaches(); + nonClusterObjectCreate(); + } + + public void nonClusterObjectCreate() { + pendingPacketDestinations = new ConcurrentHashMap(); + + /* Pending Packets Ager Timer to go off every 6 seconds to implement pending packet aging */ + pendingPacketsAgerTimer = new Timer(); + pendingPacketsAgerTimer.schedule(new PendingPacketsAgerTimerHandler(), 6000, 6000); } /** @@ -838,6 +941,9 @@ public class SimpleForwardingImpl implements IfNewHostNotify, Set switches = preparePerHostRules(host); if (switches != null) { installPerHostRules(host, switches); + + // Green light for sending pending packet to this host. Safe to call if there are none. + sendPendingPacket(host.getNetworkAddress()); } } @@ -962,6 +1068,8 @@ public class SimpleForwardingImpl implements IfNewHostNotify, * */ void stop() { + pendingPacketsAgerTimer.cancel(); + pendingPacketDestinations.clear(); } public void setSwitchManager(ISwitchManager switchManager) { @@ -985,14 +1093,14 @@ public class SimpleForwardingImpl implements IfNewHostNotify, Object nextPak = formattedPak.getPayload(); if (nextPak instanceof IPv4) { log.trace("Handle punted IP packet: {}", formattedPak); - handlePuntedIPPacket((IPv4) nextPak, inPkt.getIncomingNodeConnector()); + handlePuntedIPPacket((IPv4) nextPak, inPkt.getIncomingNodeConnector(), true); } } return PacketResult.IGNORED; } - private void handlePuntedIPPacket(IPv4 pkt, NodeConnector incomingNodeConnector) { + private void handlePuntedIPPacket(IPv4 pkt, NodeConnector incomingNodeConnector, boolean allowAddPending) { InetAddress dIP = NetUtils.getInetAddress(pkt.getDestinationAddress()); if (dIP == null || hostTracker == null) { log.debug("Invalid param(s) in handlePuntedIPPacket.. DestIP: {}. hostTracker: {}", dIP, hostTracker); @@ -1026,7 +1134,12 @@ public class SimpleForwardingImpl implements IfNewHostNotify, rp.setOutgoingNodeConnector(nc); this.dataPacketService.transmitDataPacket(rp); } - + } else if (allowAddPending) { + // If we made it here, let's hang on to the punted packet, with hopes that its destination + // will become available soon. + addToPendingPackets(dIP, pkt, incomingNodeConnector); + } else { + log.warn("Dropping punted IP packet received at {} to Host {}", incomingNodeConnector, dIP); } } } diff --git a/opendaylight/security/pom.xml b/opendaylight/security/pom.xml index 7ac2dbbe31..896e7184b2 100644 --- a/opendaylight/security/pom.xml +++ b/opendaylight/security/pom.xml @@ -30,7 +30,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/statisticsmanager/api/pom.xml b/opendaylight/statisticsmanager/api/pom.xml index bcc4f407f0..aa9b88e1b2 100644 --- a/opendaylight/statisticsmanager/api/pom.xml +++ b/opendaylight/statisticsmanager/api/pom.xml @@ -26,7 +26,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/statisticsmanager/implementation/pom.xml b/opendaylight/statisticsmanager/implementation/pom.xml index 623c028a56..10abb3d251 100644 --- a/opendaylight/statisticsmanager/implementation/pom.xml +++ b/opendaylight/statisticsmanager/implementation/pom.xml @@ -65,7 +65,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/switchmanager/api/pom.xml b/opendaylight/switchmanager/api/pom.xml index 223bb889bc..94ba0216cc 100644 --- a/opendaylight/switchmanager/api/pom.xml +++ b/opendaylight/switchmanager/api/pom.xml @@ -47,7 +47,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/switchmanager/implementation/pom.xml b/opendaylight/switchmanager/implementation/pom.xml index 542470acf1..a0718db48a 100644 --- a/opendaylight/switchmanager/implementation/pom.xml +++ b/opendaylight/switchmanager/implementation/pom.xml @@ -66,7 +66,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java index e95ab8095d..8372f88e7d 100644 --- a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java +++ b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java @@ -54,6 +54,7 @@ import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates; import org.opendaylight.controller.sal.reader.NodeDescription; import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.IObjectReader; +import org.opendaylight.controller.sal.utils.ServiceHelper; import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.statisticsmanager.IStatisticsManager; @@ -1017,6 +1018,18 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa ForwardingMode mode = (ForwardingMode) nodeProperties.get(ForwardingMode.name); forwardingModeChanged = mode.isProactive(); } + } else if ((conf == null) && !(GlobalConstants.DEFAULT.toString().equals(containerName))) { + ISwitchManager defaultSwitchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, GlobalConstants.DEFAULT.toString(), this); + if (defaultSwitchManager != null) { + Property defaultContainerSwitchDesc = (Description) defaultSwitchManager.getNodeProp(node, Description.propertyName); + if (defaultContainerSwitchDesc != null) { + Map descPropMap = new HashMap(); + descPropMap.put(Description.propertyName, defaultContainerSwitchDesc); + conf = new SwitchConfig(nodeId, descPropMap); + updateNodeConfig(conf); + propMap.put(Description.propertyName, defaultContainerSwitchDesc); + } + } } } diff --git a/opendaylight/topologymanager/implementation/pom.xml b/opendaylight/topologymanager/implementation/pom.xml index 746135891e..196982b361 100644 --- a/opendaylight/topologymanager/implementation/pom.xml +++ b/opendaylight/topologymanager/implementation/pom.xml @@ -44,7 +44,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/usermanager/api/pom.xml b/opendaylight/usermanager/api/pom.xml index ab2bb4fa12..c932a7cb31 100644 --- a/opendaylight/usermanager/api/pom.xml +++ b/opendaylight/usermanager/api/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true @@ -67,7 +66,6 @@ org.springframework.security.core.userdetails, javax.xml.bind.annotation org.opendaylight.controller.usermanager, - ${project.basedir}/META-INF diff --git a/opendaylight/usermanager/implementation/pom.xml b/opendaylight/usermanager/implementation/pom.xml index 58539ae698..9567db0293 100644 --- a/opendaylight/usermanager/implementation/pom.xml +++ b/opendaylight/usermanager/implementation/pom.xml @@ -55,7 +55,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/web/devices/pom.xml b/opendaylight/web/devices/pom.xml index 8ec05a1102..8906946423 100644 --- a/opendaylight/web/devices/pom.xml +++ b/opendaylight/web/devices/pom.xml @@ -50,7 +50,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/web/flows/pom.xml b/opendaylight/web/flows/pom.xml index 718b6dfc50..f62c6ac4d4 100644 --- a/opendaylight/web/flows/pom.xml +++ b/opendaylight/web/flows/pom.xml @@ -42,7 +42,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/web/osgi-brandfragment/pom.xml b/opendaylight/web/osgi-brandfragment/pom.xml index fc680a5493..fc04088961 100644 --- a/opendaylight/web/osgi-brandfragment/pom.xml +++ b/opendaylight/web/osgi-brandfragment/pom.xml @@ -19,7 +19,6 @@ org.apache.felix maven-bundle-plugin - 2.4.0 true diff --git a/opendaylight/web/osgi-brandfragment/src/main/resources/META-INF/webconsole.properties b/opendaylight/web/osgi-brandfragment/src/main/resources/META-INF/webconsole.properties index 566c43b8c8..2cc8e912c1 100644 --- a/opendaylight/web/osgi-brandfragment/src/main/resources/META-INF/webconsole.properties +++ b/opendaylight/web/osgi-brandfragment/src/main/resources/META-INF/webconsole.properties @@ -3,7 +3,8 @@ webconsole.product.name = OpenDaylight Controller webconsole.product.url = http://www.opendaylight.org/ webconsole.product.image = /res/imgs/odl/logo.png webconsole.favicon = /res/imgs/odl/favicon.ico - +#To disable web console authentication clear default username +webconsole.username = # webconsole.vendor.name = Linux Foundation # webconsole.vendor.url = http://www.linuxfoundation.org/ # webconsole.vendor.image = /res/imgs/vendor.png diff --git a/opendaylight/web/root/pom.xml b/opendaylight/web/root/pom.xml index 441aab835e..6f0a0989b8 100644 --- a/opendaylight/web/root/pom.xml +++ b/opendaylight/web/root/pom.xml @@ -63,7 +63,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/web/topology/pom.xml b/opendaylight/web/topology/pom.xml index fbd07fb4fd..e65c19ff84 100644 --- a/opendaylight/web/topology/pom.xml +++ b/opendaylight/web/topology/pom.xml @@ -51,7 +51,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/opendaylight/web/troubleshoot/pom.xml b/opendaylight/web/troubleshoot/pom.xml index 1c03f30aae..b66889284d 100644 --- a/opendaylight/web/troubleshoot/pom.xml +++ b/opendaylight/web/troubleshoot/pom.xml @@ -46,7 +46,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true diff --git a/pom.xml b/pom.xml index 64ed6c7d80..3408c0513c 100644 --- a/pom.xml +++ b/pom.xml @@ -124,8 +124,8 @@ opendaylight/commons/logback_settings + feature --> + opendaylight/dummy-console opendaylight/distribution/opendaylight-karaf diff --git a/third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0038.0.jar b/third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0038.0.jar deleted file mode 100644 index 1b6a02710a..0000000000 Binary files a/third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0038.0.jar and /dev/null differ diff --git a/third-party/org.openexi/nagasena-rta/pom.xml b/third-party/org.openexi/nagasena-rta/pom.xml deleted file mode 100644 index 98da51aca8..0000000000 --- a/third-party/org.openexi/nagasena-rta/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - 4.0.0 - - - org.opendaylight.controller.thirdparty - org.openexi - 0000.0002.0038.0-SNAPSHOT - - - org.opendaylight.controller.thirdparty - nagasena-rta - bundle - - - nagasena-rta-0000.0002.0038.0.jar - - - - - - org.codehaus.mojo - truezip-maven-plugin - - - extract - - copy - - compile - - - - ${archive} - ${project.build.outputDirectory} - - ** - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.groupId}.${project.artifactId} - - - - - - - diff --git a/third-party/org.openexi/nagasena/nagasena-0000.0002.0038.0.jar b/third-party/org.openexi/nagasena/nagasena-0000.0002.0038.0.jar deleted file mode 100644 index ffc28ead4b..0000000000 Binary files a/third-party/org.openexi/nagasena/nagasena-0000.0002.0038.0.jar and /dev/null differ diff --git a/third-party/org.openexi/nagasena/pom.xml b/third-party/org.openexi/nagasena/pom.xml deleted file mode 100644 index a890431ca6..0000000000 --- a/third-party/org.openexi/nagasena/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - 4.0.0 - - - org.opendaylight.controller.thirdparty - org.openexi - 0000.0002.0038.0-SNAPSHOT - - - org.opendaylight.controller.thirdparty - nagasena - bundle - - - nagasena-0000.0002.0038.0.jar - - - - - - org.codehaus.mojo - truezip-maven-plugin - - - extract - - copy - - compile - - - - ${archive} - ${project.build.outputDirectory} - - ** - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.groupId}.${project.artifactId} - - - - - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/allclasses-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/allclasses-frame.html deleted file mode 100644 index 11f9ed5153..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/allclasses-frame.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - -All Classes - - - - - - - - - - -All Classes -
- -

- - - -
AlignmentType -
-BinaryDataHandler -
-BinaryDataSink -
-BinaryDataSource -
-CharacterBuffer -
-Characters -
-EmptySchema -
-EntityResolverEx -
-EventDescription -
-EventType -
-EXIDecoder -
-EXIOptions -
-EXIReader -
-EXISchema -
-EXISchemaFactory -
-EXISchemaFactoryErrorHandler -
-EXISchemaFactoryException -
-EXISchemaReader -
-EXISchemaResolver -
-GrammarCache -
-GrammarOptions -
-HeaderOptionsOutputType -
-QName -
-ReaderSupport -
-SAXTransmogrifier -
-Scanner -
-Transmogrifier -
-TransmogrifierException -
-
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/allclasses-noframe.html b/third-party/org.openexi/nagasena/src/main/resources/doc/allclasses-noframe.html deleted file mode 100644 index 8f32ae6587..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/allclasses-noframe.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - -All Classes - - - - - - - - - - -All Classes -
- - - - - -
AlignmentType -
-BinaryDataHandler -
-BinaryDataSink -
-BinaryDataSource -
-CharacterBuffer -
-Characters -
-EmptySchema -
-EntityResolverEx -
-EventDescription -
-EventType -
-EXIDecoder -
-EXIOptions -
-EXIReader -
-EXISchema -
-EXISchemaFactory -
-EXISchemaFactoryErrorHandler -
-EXISchemaFactoryException -
-EXISchemaReader -
-EXISchemaResolver -
-GrammarCache -
-GrammarOptions -
-HeaderOptionsOutputType -
-QName -
-ReaderSupport -
-SAXTransmogrifier -
-Scanner -
-Transmogrifier -
-TransmogrifierException -
-
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/constant-values.html b/third-party/org.openexi/nagasena/src/main/resources/doc/constant-values.html deleted file mode 100644 index 6c4e3d2837..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/constant-values.html +++ /dev/null @@ -1,553 +0,0 @@ - - - - - - - -Constant Field Values - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Constant Field Values

-
-
-Contents - - - - - - -
-org.openexi.*
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
org.openexi.proc.common.EventDescription
-public static final byteEVENT_AT3
-public static final byteEVENT_BLOB13
-public static final byteEVENT_CH6
-public static final byteEVENT_CM10
-public static final byteEVENT_DTD12
-public static final byteEVENT_ED1
-public static final byteEVENT_EE7
-public static final byteEVENT_ER11
-public static final byteEVENT_NL5
-public static final byteEVENT_NS8
-public static final byteEVENT_PI9
-public static final byteEVENT_SD0
-public static final byteEVENT_SE2
-public static final byteEVENT_TP4
- -

- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
org.openexi.proc.common.EventType
-public static final byteITEM_AT12
-public static final byteITEM_AT_WC_ANY_UNTYPED8
-public static final byteITEM_CH3
-public static final byteITEM_CM1
-public static final byteITEM_DTD10
-public static final byteITEM_ED4
-public static final byteITEM_EE9
-public static final byteITEM_ER2
-public static final byteITEM_NS7
-public static final byteITEM_PI0
-public static final byteITEM_SC6
-public static final byteITEM_SCHEMA_AT16
-public static final byteITEM_SCHEMA_AT_INVALID_VALUE23
-public static final byteITEM_SCHEMA_AT_WC_ANY17
-public static final byteITEM_SCHEMA_AT_WC_NS18
-public static final byteITEM_SCHEMA_CH19
-public static final byteITEM_SCHEMA_CH_MIXED20
-public static final byteITEM_SCHEMA_NIL21
-public static final byteITEM_SCHEMA_TYPE22
-public static final byteITEM_SCHEMA_WC_ANY14
-public static final byteITEM_SCHEMA_WC_NS15
-public static final byteITEM_SD13
-public static final byteITEM_SE11
-public static final byteITEM_SE_WC5
- -

- -

- - - - - - - - - - - - - - - - - - - - - - -
org.openexi.proc.common.GrammarOptions
-public static final shortDEFAULT_OPTIONS2
-public static final shortOPTIONS_UNUSED0
-public static final shortSTRICT_OPTIONS1
- -

- -

- - - - - - - - - - - - -
org.openexi.proc.io.CharacterBuffer
-public static final intBUFSIZE_DEFAULT4096
- -

- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
org.openexi.sax.TransmogrifierException
-public static final intPREFIX_BOUND_TO_ANOTHER_NAMESPACE11
-public static final intPREFIX_NOT_BOUND10
-public static final intSAX_ERROR6
-public static final intSCRIBER_ERROR12
-public static final intUNEXPECTED_ATTR2
-public static final intUNEXPECTED_BINARY_VALUE4
-public static final intUNEXPECTED_CHARS3
-public static final intUNEXPECTED_ED8
-public static final intUNEXPECTED_ELEM1
-public static final intUNEXPECTED_END_ELEM7
-public static final intUNEXPECTED_SD9
-public static final intUNHANDLED_SAXPARSER_FEATURE5
- -

- -

- - - - - - - - - - - - -
org.openexi.scomp.EXISchemaFactoryException
-public static final intXMLSCHEMA_ERROR1002
- -

- -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/deprecated-list.html b/third-party/org.openexi/nagasena/src/main/resources/doc/deprecated-list.html deleted file mode 100644 index 60ad3edb6c..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/deprecated-list.html +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - -Deprecated List - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Deprecated API

-
-
-Contents
    -
- -
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/help-doc.html b/third-party/org.openexi/nagasena/src/main/resources/doc/help-doc.html deleted file mode 100644 index 81850ce70b..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/help-doc.html +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - -API Help - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-How This API Document Is Organized

-
-This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

-Overview

-
- -

-The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

-

-Package

-
- -

-Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    -
  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types
-
-

-Class/Interface

-
- -

-Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    -
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description -

    -

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary -

    -

  • Field Detail
  • Constructor Detail
  • Method Detail
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
- -

-Annotation Type

-
- -

-Each annotation type has its own separate page with the following sections:

    -
  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail
-
- -

-Enum

-
- -

-Each enum has its own separate page with the following sections:

    -
  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail
-
-

-Tree (Class Hierarchy)

-
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    -
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
-
-

-Deprecated API

-
-The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-

-Index

-
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-

-Prev/Next

-These links take you to the next or previous class, interface, package, or related page.

-Frames/No Frames

-These links show and hide the HTML frames. All pages are available with or without frames. -

-

-Serialized Form

-Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. -

-

-Constant Field Values

-The Constant Field Values page lists the static final fields and their values. -

- - -This help file applies to API documentation generated using the standard doclet. - -
-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/index-all.html b/third-party/org.openexi/nagasena/src/main/resources/doc/index-all.html deleted file mode 100644 index 3fc6b297e3..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/index-all.html +++ /dev/null @@ -1,970 +0,0 @@ - - - - - - - -Index - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -A B C D E F G H I L M N O P Q R S T U V W X _
-

-A

-
-
addCM(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Sets Preserve Comments to true. -
addDTD(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Sets Preserve Document Type Definition to true. -
addNS(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Sets Preserve Namespaces to true. -
addPI(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Sets Preserve Processing Instructions to true. -
AlignmentType - Enum in org.openexi.proc.common
AlignmentType represents one of the following bit alignment - styles so as to provide an extra degree of control over the - way information is stored in EXI format.
ancestryIds - -Variable in class org.openexi.schema.EXISchema -
  -
-
-

-B

-
-
binaryData(byte[], int, int, BinaryDataSink) - -Method in interface org.openexi.sax.BinaryDataHandler -
Writes a binary value where the schema expects a binary value. -
BinaryDataHandler - Interface in org.openexi.sax
 
BinaryDataSink - Interface in org.openexi.proc.io
BinaryDataSink represents a sink that accepts successive chunks of binary data.
BinaryDataSource - Class in org.openexi.proc.common
 
BinaryDataSource() - -Constructor for class org.openexi.proc.common.BinaryDataSource -
  -
BUFSIZE_DEFAULT - -Static variable in class org.openexi.proc.io.CharacterBuffer -
  -
-
-

-C

-
-
CharacterBuffer - Class in org.openexi.proc.io
 
CharacterBuffer(int) - -Constructor for class org.openexi.proc.io.CharacterBuffer -
  -
Characters - Class in org.openexi.schema
 
Characters(char[], int, int, boolean) - -Constructor for class org.openexi.schema.Characters -
  -
characters - -Variable in class org.openexi.schema.Characters -
  -
CHARACTERS_EMPTY - -Static variable in class org.openexi.schema.Characters -
  -
closeInputStream() - -Method in class org.openexi.proc.io.Scanner -
Close the input stream. -
compile(InputSource) - -Method in class org.openexi.scomp.EXISchemaFactory -
Compile an XML Schema Document into an EXISchema. -
-
-

-D

-
-
DEFAULT_OPTIONS - -Static variable in class org.openexi.proc.common.GrammarOptions -
Indicates that undeclared elements and attributes will be - processed when the XML stream is encoded and decoded. -
-
-

-E

-
-
EmptySchema - Class in org.openexi.schema
EmptySchema provides an EXISchema that supports all datatypes inherent - in XML Schema such as xsd:int and xsd:dateTime, but with no - user-specific definitions.
encode(InputSource) - -Method in class org.openexi.sax.Transmogrifier -
Parses XML input source and converts it to an EXI stream. -
endBinaryData(BinaryDataSink) - -Method in interface org.openexi.sax.BinaryDataHandler -
Mark the end of a binary value. -
EntityResolverEx - Interface in org.openexi.scomp
Extended SAX EntityResolver interface for resolving entities and - schema documents.
equals(Object) - -Method in class org.openexi.proc.common.QName -
  -
equals(Object) - -Method in class org.openexi.schema.Characters -
  -
error(EXISchemaFactoryException) - -Method in interface org.openexi.scomp.EXISchemaFactoryErrorHandler -
Report an error found during schema processing. -
EVENT_AT - -Static variable in interface org.openexi.proc.common.EventDescription -
Attribute event. -
EVENT_BLOB - -Static variable in interface org.openexi.proc.common.EventDescription -
BLOB event (content of an element). -
EVENT_CH - -Static variable in interface org.openexi.proc.common.EventDescription -
Character event (content of an element). -
EVENT_CM - -Static variable in interface org.openexi.proc.common.EventDescription -
Comment event. -
EVENT_DTD - -Static variable in interface org.openexi.proc.common.EventDescription -
Document Type Definition event. -
EVENT_ED - -Static variable in interface org.openexi.proc.common.EventDescription -
End Document event. -
EVENT_EE - -Static variable in interface org.openexi.proc.common.EventDescription -
End Element event. -
EVENT_ER - -Static variable in interface org.openexi.proc.common.EventDescription -
Entity Reference event. -
EVENT_NL - -Static variable in interface org.openexi.proc.common.EventDescription -
Attribute xsi:nil. -
EVENT_NS - -Static variable in interface org.openexi.proc.common.EventDescription -
Namespace declaration event. -
EVENT_PI - -Static variable in interface org.openexi.proc.common.EventDescription -
Processing Instruction event. -
EVENT_SD - -Static variable in interface org.openexi.proc.common.EventDescription -
Start Document event. -
EVENT_SE - -Static variable in interface org.openexi.proc.common.EventDescription -
Start Element event. -
EVENT_TP - -Static variable in interface org.openexi.proc.common.EventDescription -
Attribute xsi:type. -
EventDescription - Interface in org.openexi.proc.common
EventDescription provides accessors to the current EXI event data - during the decode process.
EventType - Class in org.openexi.proc.common
EventType denotes terminal symbols of grammar productions - defined in the EXI 1.0 specification.
EXIDecoder - Class in org.openexi.proc
EXIDecoder provides methods to configure and - instantiate a Scanner object - you can use to parse the contents of an EXI stream.
EXIDecoder() - -Constructor for class org.openexi.proc.EXIDecoder -
Creates an instance of EXIDecoder with the default inflator - buffer size of 8192 bytes. -
EXIDecoder(int, boolean) - -Constructor for class org.openexi.proc.EXIDecoder -
Creates an instance of EXIDecoder with the specified inflator buffer - size. -
EXIOptions - Class in org.openexi.proc.common
EXIOptions provides accessors for values associated with - EXI options in the EXI header of an EXI stream.
EXIReader - Class in org.openexi.sax
EXIReader implements the SAX XMLReader to provide a convenient and - familiar interface for decoding an EXI stream.
EXIReader() - -Constructor for class org.openexi.sax.EXIReader -
  -
EXISchema - Class in org.openexi.schema
EXISchema provides methods to read and write compiled EXI schemas.
EXISchemaFactory - Class in org.openexi.scomp
EXISchemaFactory compiles XML Schema into an EXISchema instance.
EXISchemaFactory() - -Constructor for class org.openexi.scomp.EXISchemaFactory -
  -
EXISchemaFactoryErrorHandler - Interface in org.openexi.scomp
This interface reports exceptions from EXISchemaFactory during schema - processing.
EXISchemaFactoryException - Exception in org.openexi.scomp
Any errors encountered during schema compilation are communicated to - an application as EXISchemaFactoryException objects.
EXISchemaReader - Class in org.openexi.scomp
EXISchemaReader parses EXI-encoded EXI Grammar into an EXISchema.
EXISchemaReader() - -Constructor for class org.openexi.scomp.EXISchemaReader -
  -
EXISchemaResolver - Interface in org.openexi.proc
Developers have the option of implementing the EXISchemaResolver interface - to help EXIReader and EXIDecoder locate the correct grammar cache for parsing - an EXI stream.
-
-

-F

-
-
fatalError(EXISchemaFactoryException) - -Method in interface org.openexi.scomp.EXISchemaFactoryErrorHandler -
Report a fatal error found during schema processing. -
-
-

-G

-
-
getAlignmentType() - -Method in class org.openexi.proc.common.EXIOptions -
Get the bit alignment setting. -
getBinaryDataSource() - -Method in interface org.openexi.proc.common.EventDescription -
Gets the value of an EVENT_BLOB. -
getBlockSize() - -Method in class org.openexi.proc.common.EXIOptions -
Returns the number of element and attribute values that are read and processed - as a group. -
getByteArray() - -Method in class org.openexi.proc.common.BinaryDataSource -
  -
getCharacters() - -Method in interface org.openexi.proc.common.EventDescription -
Gets the value of an EVENT_CH, - Attribute (EVENT_AT, EVENT_NL, EVENT_TP), EVENT_CM, - EVENT_DTD or EVENT_PI event. -
getCode() - -Method in exception org.openexi.sax.TransmogrifierException -
Returns a code that represents the type of the exception. -
getCode() - -Method in exception org.openexi.scomp.EXISchemaFactoryException -
Returns a code that represents the type of the exception. -
getContentHandler() - -Method in class org.openexi.sax.ReaderSupport -
Get the SAX content handler currently in use. -
getDatatypeRepresentationMap() - -Method in class org.openexi.proc.common.EXIOptions -
Returns an array of qualified names that map XMLSchema datatypes to - non-standard equivalents in EXI. -
getDatatypeRepresentationMapBindingsCount() - -Method in class org.openexi.proc.common.EXIOptions -
Returns the number of Datatype Representation Map QName pairs. -
getEventKind() - -Method in interface org.openexi.proc.common.EventDescription -
Gets the event kind of which instance data this EventDescription is describing. -
getEventType() - -Method in interface org.openexi.proc.common.EventDescription -
Returns the EventType from which this event is derived. -
getException() - -Method in exception org.openexi.sax.TransmogrifierException -
Returns an Exception object. -
getException() - -Method in exception org.openexi.scomp.EXISchemaFactoryException -
Returns an Exception object. -
getEXISchema() - -Method in class org.openexi.proc.grammars.GrammarCache -
Gets the compiled EXI Schema. -
getEXISchema() - -Static method in class org.openexi.schema.EmptySchema -
Returns an EXISchema that supports all datatypes inherent in XML Schema. -
getFeature(String) - -Method in class org.openexi.sax.EXIReader -
Get features for the SAX parser. -
getGrammarCache() - -Method in interface org.openexi.sax.SAXTransmogrifier -
Returns the GrammarCache that is in use by this SAXTransmogrifier. -
getGrammarCache() - -Method in class org.openexi.sax.Transmogrifier -
Returns the GrammarCache that was previously set. -
getHeaderOptions() - -Method in class org.openexi.proc.io.Scanner -
Returns the EXI Header options from the header of the - EXI stream, if present. -
getLength() - -Method in class org.openexi.proc.common.BinaryDataSource -
  -
getLocator() - -Method in exception org.openexi.sax.TransmogrifierException -
Returns the locator that is associated with this compilation error. -
getLocator() - -Method in exception org.openexi.scomp.EXISchemaFactoryException -
Returns the locator that is associated with this compilation error. -
getMessage() - -Method in exception org.openexi.sax.TransmogrifierException -
Returns a message that describes the exception. -
getMessage() - -Method in exception org.openexi.scomp.EXISchemaFactoryException -
Returns a message that describes the exception. -
getName() - -Method in interface org.openexi.proc.common.EventDescription -
Gets the name of the EXI event. -
getPrefix() - -Method in interface org.openexi.proc.common.EventDescription -
Gets the namespace prefix of the event. -
getPreserveComments() - -Method in class org.openexi.proc.common.EXIOptions -
Returns whether comments are conserved in the EXI Stream. -
getPreserveDTD() - -Method in class org.openexi.proc.common.EXIOptions -
Returns whether the document type definition is conserved in the EXI Stream. -
getPreserveLexicalValues() - -Method in class org.openexi.proc.common.EXIOptions -
Returns whether lexical values (literal strings) are preserved rather - than the logical values of elements and attributes. -
getPreserveNS() - -Method in class org.openexi.proc.common.EXIOptions -
Returns whether the namespaces are preserved in the EXI stream. -
getPreservePIs() - -Method in class org.openexi.proc.common.EXIOptions -
Returns whether processing instructions are conserved in the EXI Stream. -
getProperty(String) - -Method in class org.openexi.sax.EXIReader -
Use to retrieve the name of the lexical handler, currently the only - property recognized by this class. -
getRemainingBytesCount() - -Method in class org.openexi.proc.common.BinaryDataSource -
  -
getSAXTransmogrifier() - -Method in class org.openexi.sax.Transmogrifier -
Returns the SAXTransmogrifier, which implements both the ContentHandler - and LexicalHandler. -
getStartIndex() - -Method in class org.openexi.proc.common.BinaryDataSource -
  -
getURI() - -Method in interface org.openexi.proc.common.EventDescription -
Gets the URI of the EXI event. -
getValueMaxLength() - -Method in class org.openexi.proc.common.EXIOptions -
Returns the maximum length in characters of strings that will be included - in the String Table. -
getValuePartitionCapacity() - -Method in class org.openexi.proc.common.EXIOptions -
Returns the maximum number of entries in the String Table. -
GrammarCache - Class in org.openexi.proc.grammars
A GrammarCache object represents a set of EXI grammars used - for processing EXI streams using specific grammar options.
GrammarCache(EXISchema) - -Constructor for class org.openexi.proc.grammars.GrammarCache -
Creates an instance of GrammarCache informed by a schema with default - grammar options. -
GrammarCache(short) - -Constructor for class org.openexi.proc.grammars.GrammarCache -
Creates an instance of GrammarCache with the specified grammar options. -
GrammarCache(EXISchema, short) - -Constructor for class org.openexi.proc.grammars.GrammarCache -
Creates an instance of GrammarCache informed by a schema with the - specified grammar options. -
GrammarOptions - Class in org.openexi.proc.common
GrammarOptions computes a short integer that represents settings in the EXI Grammar settings - that determine how an EXI file will be encoded or decoded.
grammarOptions - -Variable in class org.openexi.proc.grammars.GrammarCache -
Short integer that encapsulates GrammarOptions - for the EXI stream. -
-
-

-H

-
-
hasCM(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Returns true if Preserve Comments is true. -
hasDTD(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Returns true if Preserve Document Type Definition is true. -
hashCode() - -Method in class org.openexi.schema.Characters -
  -
hasNext() - -Method in class org.openexi.proc.common.BinaryDataSource -
  -
hasNS(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Returns true if Preserve Namespaces is true. -
hasPI(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Returns true if Preserve Processing Instructions is true. -
HeaderOptionsOutputType - Enum in org.openexi.proc
This enumeration provides three possible settings for header options output.
-
-

-I

-
-
indexOf(char) - -Method in class org.openexi.schema.Characters -
  -
isFragment() - -Method in class org.openexi.proc.common.EXIOptions -
An XML fragment is a non-compliant XML document with multiple root - elements. -
isPermitDeviation(short) - -Static method in class org.openexi.proc.common.GrammarOptions -
Returns true if DEFAULT_OPTIONS is set to true. -
isSimpleType(int) - -Method in class org.openexi.schema.EXISchema -
  -
isStrict() - -Method in class org.openexi.proc.common.EXIOptions -
The Strict option applies to streams that have an associated XML Schema - and the data in the XML stream is 100% compliant with the schema. -
isVolatile - -Variable in class org.openexi.schema.Characters -
  -
ITEM_AT - -Static variable in class org.openexi.proc.common.EventType -
Event type for an Attribute learned by built-in element grammars - from prior attribute occurrences. -
ITEM_AT_WC_ANY_UNTYPED - -Static variable in class org.openexi.proc.common.EventType -
Wildcard event type for an Attribute where the attribute's defined - datatype (if any) is disregarded. -
ITEM_CH - -Static variable in class org.openexi.proc.common.EventType -
Event type for a Character event (character events store values as strings). -
ITEM_CM - -Static variable in class org.openexi.proc.common.EventType -
Event type for a Comment. -
ITEM_DTD - -Static variable in class org.openexi.proc.common.EventType -
Event type for a Document Type Definition. -
ITEM_ED - -Static variable in class org.openexi.proc.common.EventType -
Event type for End of Document. -
ITEM_EE - -Static variable in class org.openexi.proc.common.EventType -
Event type for End of Element. -
ITEM_ER - -Static variable in class org.openexi.proc.common.EventType -
Event type for an Entity Reference. -
ITEM_NS - -Static variable in class org.openexi.proc.common.EventType -
Event type for a Namespace declaration. -
ITEM_PI - -Static variable in class org.openexi.proc.common.EventType -
Event type for a Processing Instruction. -
ITEM_SC - -Static variable in class org.openexi.proc.common.EventType -
Self-contained items are not supported in this release of OpenEXI. -
ITEM_SCHEMA_AT - -Static variable in class org.openexi.proc.common.EventType -
Event type for AttributeUse that matches an attribute event with - a valid value. -
ITEM_SCHEMA_AT_INVALID_VALUE - -Static variable in class org.openexi.proc.common.EventType -
Event type for AttributeUse that matches an attribute event with an - invalid value. -
ITEM_SCHEMA_AT_WC_ANY - -Static variable in class org.openexi.proc.common.EventType -
Attribute wildcard event type stemming from a schema, where the attribute's - defined datatype (if any) is applied. -
ITEM_SCHEMA_AT_WC_NS - -Static variable in class org.openexi.proc.common.EventType -
Attribute wildcard event type, qualified with a specific namespace, stemming - from a schema where the attribute's defined datatype (if any) is applied. -
ITEM_SCHEMA_CH - -Static variable in class org.openexi.proc.common.EventType -
Event type for a defined Character event in an EXI stream processed - using a schema. -
ITEM_SCHEMA_CH_MIXED - -Static variable in class org.openexi.proc.common.EventType -
Event type for a Character event that occurs in the context of an element - defined so as to permit mixed content (mark up and data) in an EXI - stream processed using a schema. -
ITEM_SCHEMA_NIL - -Static variable in class org.openexi.proc.common.EventType -
Special Attribute that indicates the value of the associated element is - explicitly nil rather than an empty string. -
ITEM_SCHEMA_TYPE - -Static variable in class org.openexi.proc.common.EventType -
Special Attribute that describes a data type for the associated - element. -
ITEM_SCHEMA_WC_ANY - -Static variable in class org.openexi.proc.common.EventType -
Attribute wildcard event type stemming from a schema where the - attribute's defined datatype (if any) is applied. -
ITEM_SCHEMA_WC_NS - -Static variable in class org.openexi.proc.common.EventType -
Event type for an element defined in a namespace in an EXI stream - processed using a schema. -
ITEM_SD - -Static variable in class org.openexi.proc.common.EventType -
Event type for Start Document. -
ITEM_SE - -Static variable in class org.openexi.proc.common.EventType -
Event type for Start Element. -
ITEM_SE_WC - -Static variable in class org.openexi.proc.common.EventType -
Wildcard event type for an element. -
-
-

-L

-
-
length - -Variable in class org.openexi.schema.Characters -
  -
localName - -Variable in class org.openexi.proc.common.QName -
Local name of the datatype. -
-
-

-M

-
-
makeString() - -Method in class org.openexi.schema.Characters -
  -
-
-

-N

-
-
name - -Variable in class org.openexi.proc.common.EventType -
Local name of event type definition. -
namespaceName - -Variable in class org.openexi.proc.common.QName -
If namespaceName is null, this indicates a failure of - namespace-prefix binding. -
next() - -Method in class org.openexi.proc.common.BinaryDataSource -
  -
nextEvent() - -Method in class org.openexi.proc.io.Scanner -
Gets the next event from the EXI stream. -
-
-

-O

-
-
OPTIONS_UNUSED - -Static variable in class org.openexi.proc.common.GrammarOptions -
OPTIONS_UNUSED is an internal value. -
org.openexi.proc - package org.openexi.proc
- - -The Proc (Processor) package contains the EXIDecoder, which is used to convert EXI streams to XML format.
org.openexi.proc.common - package org.openexi.proc.common
- - -The common package contains classes, interfaces, and enumerators that define the vocabulary used to describe EXI streams (events, options, alignment, and character string values).
org.openexi.proc.grammars - package org.openexi.proc.grammars
- - -The grammars package contains the GrammarCache, which combines an XML Schema Definition with EXI grammar options to create an EXI Schema.
org.openexi.proc.io - package org.openexi.proc.io
- - -The IO package contains the Scanner, which is used by EXIDecoder to read and interpret EXI streams.
org.openexi.sax - package org.openexi.sax
- - -The SAX package contains the Transmogrifier, which encodes an XML file to an EXI stream, and the EXIReader, which restores an EXI stream to its logical XML equivalent.
org.openexi.schema - package org.openexi.schema
- - -The schema package contains classes that are used to represent XML Schema Documents (XSDs).
org.openexi.scomp - package org.openexi.scomp
- - -The scomp (schema compiler) package contains the EXISchemaFactory, which is used to compile XML Schema Documents (XSDs) to EXISchemas.
-
-

-P

-
-
parse(InputStream) - -Method in class org.openexi.scomp.EXISchemaReader -
Parses EXI-encoded EXI Grammar into an EXISchema. -
PREFIX_BOUND_TO_ANOTHER_NAMESPACE - -Static variable in exception org.openexi.sax.TransmogrifierException -
Prefix is bound to another namespace. -
PREFIX_NOT_BOUND - -Static variable in exception org.openexi.sax.TransmogrifierException -
Prefix is not bound. -
processHeader() - -Method in class org.openexi.proc.EXIDecoder -
This method reads and configures any header options present - in the EXI stream, then returns a Scanner - object you can use to parse the values from the EXI stream. -
-
-

-Q

-
-
QName - Class in org.openexi.proc.common
QName is a pair comprised of a namespace name and a local name - to be used in a Datatype Representation Map (DTRM) definition - to denote an XSD datatype or an EXI datatype representation.
QName() - -Constructor for class org.openexi.proc.common.QName -
  -
QName(String, String) - -Constructor for class org.openexi.proc.common.QName -
Creates a QName based on its literal qualified name - (see http://www.w3.org/TR/xml-names/#ns-qualnames - for definition) and namespace name. -
-
-

-R

-
-
ReaderSupport - Class in org.openexi.sax
 
readIn(DataInputStream) - -Static method in class org.openexi.schema.EXISchema -
Reads an EXI Schema from a DataInputStream. -
resolveEntity(String, String, String) - -Method in interface org.openexi.scomp.EntityResolverEx -
This method will be called for resolving schema documents upon - occurrences of XML Schema directives such as "include", "import" and - "redefine" within schemas. -
resolveSchema(String, short) - -Method in interface org.openexi.proc.EXISchemaResolver -
Return a GrammarCache based on a schemaId and grammar options discovered - in the header options of an EXI stream. -
-
-

-S

-
-
SAX_ERROR - -Static variable in exception org.openexi.sax.TransmogrifierException -
SAX error reported by XML parser. -
SAXTransmogrifier - Interface in org.openexi.sax
Applications can directly feed SAX events into a transmogrifier through SAXTransmogrifier.
Scanner - Class in org.openexi.proc.io
The Scanner class provides methods for scanning events - in the body of an EXI stream.
SCRIBER_ERROR - -Static variable in exception org.openexi.sax.TransmogrifierException -
Errors reported by Scriber. -
setAlignmentType(AlignmentType) - -Method in class org.openexi.proc.EXIDecoder -
Set the bit alignment style of the stream to be decoded. -
setAlignmentType(AlignmentType) - -Method in class org.openexi.sax.EXIReader -
Set the bit alignment style used to compile the EXI input stream. -
setAlignmentType(AlignmentType) - -Method in class org.openexi.sax.Transmogrifier -
Set the bit alignment style for the encoded EXI stream. -
setBinaryChunkSize(int) - -Method in class org.openexi.proc.io.Scanner -
Binary values are read in chunks of the specified size when the - use of binary data is enabled. -
setBlockSize(int) - -Method in class org.openexi.proc.EXIDecoder -
Set the size, in number of values, of the information that will be - processed as a chunk of the entire EXI stream. -
setBlockSize(int) - -Method in class org.openexi.sax.EXIReader -
Set the size, in number of values, of the information that will be - processed as a chunk of the entire EXI stream. -
setBlockSize(int) - -Method in class org.openexi.sax.Transmogrifier -
Set the size, in number of values, of the information that will be - processed as a chunk of the entire XML stream. -
setCompilerErrorHandler(EXISchemaFactoryErrorHandler) - -Method in class org.openexi.scomp.EXISchemaFactory -
Set an error handler to report any errors encountered during - schema compilation. -
setContentHandler(ContentHandler) - -Method in class org.openexi.sax.ReaderSupport -
Set a SAX content handler to receive SAX events. -
setDatatypeRepresentationMap(QName[], int) - -Method in class org.openexi.proc.EXIDecoder -
Set a datatype representation map (DTRM). -
setDatatypeRepresentationMap(QName[], int) - -Method in class org.openexi.sax.EXIReader -
Set a datatype representation map. -
setDatatypeRepresentationMap(QName[], int) - -Method in class org.openexi.sax.Transmogrifier -
Set a datatype representation map (DTRM). -
setEnableBinaryData(boolean) - -Method in class org.openexi.proc.EXIDecoder -
Each binary value will be returned as in a EventDescription of EVENT_BLOB - instead of EVENT_CH when enabled. -
setEntityResolver(EntityResolver) - -Method in class org.openexi.sax.Transmogrifier -
Set an external SAX entity resolver. -
setEntityResolver(EntityResolverEx) - -Method in class org.openexi.scomp.EXISchemaFactory -
Set an entity resolver for use to resolve entities and schema documents. -
setEXISchemaResolver(EXISchemaResolver) - -Method in class org.openexi.sax.EXIReader -
Set the EXISchemaResolver to retrieve the schema needed to decode the - current EXI stream. -
setFeature(String, boolean) - -Method in class org.openexi.sax.EXIReader -
Set features for the SAX parser. -
setFragment(boolean) - -Method in class org.openexi.proc.EXIDecoder -
Set whether the document is a fragment. -
setFragment(boolean) - -Method in class org.openexi.sax.EXIReader -
Set to true if the EXI input stream is an XML fragment (a non-compliant - XML document with multiple root elements). -
setFragment(boolean) - -Method in class org.openexi.sax.Transmogrifier -
Set to true if the XML input stream is an XML fragment (a non-compliant - XML document with multiple root elements). -
setGrammarCache(GrammarCache) - -Method in class org.openexi.proc.EXIDecoder -
Set the GrammarCache used in decoding EXI streams. -
setGrammarCache(GrammarCache) - -Method in class org.openexi.sax.ReaderSupport -
Set the GrammarCache used in parsing EXI streams. -
setGrammarCache(GrammarCache) - -Method in class org.openexi.sax.Transmogrifier -
Set the GrammarCache used in transmogrifying XML data to EXI. -
setGrammarCache(GrammarCache, SchemaId) - -Method in class org.openexi.sax.Transmogrifier -
Set the GrammarCache to be used in encoding XML streams into EXI streams - by the transmogrifier. -
setInitialBinaryDataBufferSize(int) - -Method in class org.openexi.proc.EXIDecoder -
  -
setInputStream(InputStream) - -Method in class org.openexi.proc.EXIDecoder -
Set an input stream from which the encoded stream is read. -
setLexicalHandler(LexicalHandler) - -Method in class org.openexi.sax.EXIReader -
Set a SAX lexical handler to receive SAX lexical events. -
setOutputCookie(boolean) - -Method in class org.openexi.sax.Transmogrifier -
Tells the encoder whether to or not to start the stream by - adding an EXI cookie. -
setOutputOptions(HeaderOptionsOutputType) - -Method in class org.openexi.sax.Transmogrifier -
Set the header output options. -
setOutputStream(OutputStream) - -Method in class org.openexi.sax.Transmogrifier -
Set an output stream to which encoded streams are written. -
setPreserveLexicalValues(boolean) - -Method in class org.openexi.proc.EXIDecoder -
Set to true to preserve the original string values from the EXI - stream. -
setPreserveLexicalValues(boolean) - -Method in class org.openexi.sax.EXIReader -
Set to true if the EXI input stream was compiled with the Preserve Lexical - Values set to true. -
setPreserveLexicalValues(boolean) - -Method in class org.openexi.sax.Transmogrifier -
Set to true to preserve the original string values from the XML - stream. -
setPreserveWhitespaces(boolean) - -Method in class org.openexi.sax.Transmogrifier -
Set to true to preserve whitespace (for example, spaces, tabs, and - line breaks) in the encoded EXI stream. -
setProperty(String, Object) - -Method in class org.openexi.sax.EXIReader -
This method wraps the friendlier setLexicalHandler method to provide - syntax familiar to experienced SAX programmers. -
setResolveExternalGeneralEntities(boolean) - -Method in class org.openexi.sax.Transmogrifier -
Change the way a Transmogrifier handles external general entities. -
setSchema(EXISchema, QName[], int) - -Method in class org.openexi.proc.io.Scanner -
  -
setValueMaxLength(int) - -Method in class org.openexi.proc.EXIDecoder -
Set the maximum length of a string that will be stored for reuse in the - String Table. -
setValueMaxLength(int) - -Method in class org.openexi.sax.EXIReader -
Set the maximum length of a string that will be stored for reuse in the - String Table. -
setValueMaxLength(int) - -Method in class org.openexi.sax.Transmogrifier -
Set the maximum length of a string that will be stored for reuse in the - String Table. -
setValuePartitionCapacity(int) - -Method in class org.openexi.proc.EXIDecoder -
Set the maximum number of values in the String Table. -
setValuePartitionCapacity(int) - -Method in class org.openexi.sax.EXIReader -
Set the maximum number of values in the String Table. -
setValuePartitionCapacity(int) - -Method in class org.openexi.sax.Transmogrifier -
Set the maximum number of values in the String Table. -
startBinaryData(long) - -Method in interface org.openexi.sax.BinaryDataHandler -
Mark the start of a binary value. -
startIndex - -Variable in class org.openexi.schema.Characters -
  -
STRICT_OPTIONS - -Static variable in class org.openexi.proc.common.GrammarOptions -
Indicates that undeclared elements and attributes will throw an - exception when the XML stream is encoded and decoded. -
substring(int, int) - -Method in class org.openexi.schema.Characters -
  -
-
-

-T

-
-
Transmogrifier - Class in org.openexi.sax
The Transmogrifier converts an XML stream to an EXI stream.
Transmogrifier() - -Constructor for class org.openexi.sax.Transmogrifier -
Create an instance of the Transmogrifier with a default SAX parser. -
Transmogrifier(SAXParserFactory) - -Constructor for class org.openexi.sax.Transmogrifier -
Create an instance of the Transmogrifier, specifying the SAXParserFactory - from which to create the SAX parser. -
TransmogrifierException - Exception in org.openexi.sax
Exception handler for the Transmogrifier.
turnPermanent() - -Method in class org.openexi.schema.Characters -
  -
-
-

-U

-
-
ucsCount - -Variable in class org.openexi.schema.Characters -
  -
UNEXPECTED_ATTR - -Static variable in exception org.openexi.sax.TransmogrifierException -
Unexpected Attribute. -
UNEXPECTED_BINARY_VALUE - -Static variable in exception org.openexi.sax.TransmogrifierException -
Unexpected Binary value. -
UNEXPECTED_CHARS - -Static variable in exception org.openexi.sax.TransmogrifierException -
Unexpected Character Sequence. -
UNEXPECTED_ED - -Static variable in exception org.openexi.sax.TransmogrifierException -
Unexpected End of Document event. -
UNEXPECTED_ELEM - -Static variable in exception org.openexi.sax.TransmogrifierException -
Unexpected Element. -
UNEXPECTED_END_ELEM - -Static variable in exception org.openexi.sax.TransmogrifierException -
Unexpected End of Element event. -
UNEXPECTED_SD - -Static variable in exception org.openexi.sax.TransmogrifierException -
Unexpected Start of Document event. -
UNHANDLED_SAXPARSER_FEATURE - -Static variable in exception org.openexi.sax.TransmogrifierException -
Unhandled SAX parser feature. -
uri - -Variable in class org.openexi.proc.common.EventType -
URI of event type definition. -
-
-

-V

-
-
valueOf(String) - -Static method in enum org.openexi.proc.common.AlignmentType -
Returns the enum constant of this type with the specified name. -
valueOf(String) - -Static method in enum org.openexi.proc.HeaderOptionsOutputType -
Returns the enum constant of this type with the specified name. -
values() - -Static method in enum org.openexi.proc.common.AlignmentType -
Returns an array containing the constants of this enum type, in -the order they're declared. -
values() - -Static method in enum org.openexi.proc.HeaderOptionsOutputType -
Returns an array containing the constants of this enum type, in -the order they're declared. -
-
-

-W

-
-
warning(EXISchemaFactoryException) - -Method in interface org.openexi.scomp.EXISchemaFactoryErrorHandler -
Report a warning found during schema processing. -
writeOut(DataOutputStream) - -Method in class org.openexi.schema.EXISchema -
Writes out a serialized EXISchema. -
writeXml(OutputStream, boolean) - -Method in class org.openexi.schema.EXISchema -
  -
-
-

-X

-
-
XMLSCHEMA_ERROR - -Static variable in exception org.openexi.scomp.EXISchemaFactoryException -
The underlying XMLSchema parser found an error in the schema. -
-
-

-_

-
-
_isSimpleType(int, int[]) - -Static method in class org.openexi.schema.EXISchema -
  -
-
-A B C D E F G H I L M N O P Q R S T U V W X _ - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/index.html b/third-party/org.openexi/nagasena/src/main/resources/doc/index.html deleted file mode 100644 index f8c172cd85..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - -Generated Documentation (Untitled) - - - - - - - - - - - -<H2> -Frame Alert</H2> - -<P> -This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. -<BR> -Link to<A HREF="overview-summary.html">Non-frame version.</A> - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/EXIDecoder.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/EXIDecoder.html deleted file mode 100644 index 15bd150a78..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/EXIDecoder.html +++ /dev/null @@ -1,580 +0,0 @@ - - - - - - - -EXIDecoder - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc -
-Class EXIDecoder

-
-java.lang.Object
-  extended by org.openexi.proc.EXIDecoder
-
-
-
-
public class EXIDecoder
extends java.lang.Object
- - -

-EXIDecoder provides methods to configure and - instantiate a Scanner object - you can use to parse the contents of an EXI stream. -

- -

-

- -
-
- -

- - - - - - - - - - - - - - -
-Constructor Summary
EXIDecoder() - -
-          Creates an instance of EXIDecoder with the default inflator - buffer size of 8192 bytes.
EXIDecoder(int inflatorBufSize, - boolean useThreadedInflater) - -
-          Creates an instance of EXIDecoder with the specified inflator buffer - size.
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- ScannerprocessHeader() - -
-          This method reads and configures any header options present - in the EXI stream, then returns a Scanner - object you can use to parse the values from the EXI stream.
- voidsetAlignmentType(AlignmentType alignmentType) - -
-          Set the bit alignment style of the stream to be decoded.
- voidsetBlockSize(int blockSize) - -
-          Set the size, in number of values, of the information that will be - processed as a chunk of the entire EXI stream.
- voidsetDatatypeRepresentationMap(QName[] dtrm, - int n_bindings) - -
-          Set a datatype representation map (DTRM).
- voidsetEnableBinaryData(boolean enable) - -
-          Each binary value will be returned as in a EventDescription of EVENT_BLOB - instead of EVENT_CH when enabled.
- voidsetFragment(boolean isFragment) - -
-          Set whether the document is a fragment.
- voidsetGrammarCache(GrammarCache grammarCache) - -
-          Set the GrammarCache used in decoding EXI streams.
- voidsetInitialBinaryDataBufferSize(int initialSize) - -
-           
- voidsetInputStream(java.io.InputStream istream) - -
-          Set an input stream from which the encoded stream is read.
- voidsetPreserveLexicalValues(boolean preserveLexicalValues) - -
-          Set to true to preserve the original string values from the EXI - stream.
- voidsetValueMaxLength(int valueMaxLength) - -
-          Set the maximum length of a string that will be stored for reuse in the - String Table.
- voidsetValuePartitionCapacity(int valuePartitionCapacity) - -
-          Set the maximum number of values in the String Table.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Constructor Detail
- -

-EXIDecoder

-
-public EXIDecoder()
-
-
Creates an instance of EXIDecoder with the default inflator - buffer size of 8192 bytes. Buffer size is only used when - the EXI stream is encoded with EXI compression. -

-

-
- -

-EXIDecoder

-
-public EXIDecoder(int inflatorBufSize,
-                  boolean useThreadedInflater)
-
-
Creates an instance of EXIDecoder with the specified inflator buffer - size. When dynamic memory is limited on the target device, reducing - the buffer size can improve performance and avoid runtime errors. Buffer - size is only used when the EXI stream is encoded with EXI compression. -

-

-
Parameters:
inflatorBufSize - size of the buffer, in bytes.
useThreadedInflater - Inflater will be run in its own thread if true
-
- - - - - - - - -
-Method Detail
- -

-setInputStream

-
-public final void setInputStream(java.io.InputStream istream)
-
-
Set an input stream from which the encoded stream is read. -

-

-
Parameters:
istream - InputSream to be read.
-
-
-
- -

-setAlignmentType

-
-public final void setAlignmentType(AlignmentType alignmentType)
-                            throws org.openexi.proc.common.EXIOptionsException
-
-
Set the bit alignment style of the stream to be decoded. -

-

-
Parameters:
alignmentType - AlignmentType object -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setFragment

-
-public final void setFragment(boolean isFragment)
-
-
Set whether the document is a fragment. Fragments are nonstandard - XML documents with multiple root elements. Default is false. -

-

-
Parameters:
isFragment - true if the stream is an XML fragment
-
-
-
- -

-setGrammarCache

-
-public final void setGrammarCache(GrammarCache grammarCache)
-                           throws org.openexi.proc.common.EXIOptionsException
-
-
Set the GrammarCache used in decoding EXI streams. -

-

-
Parameters:
grammarCache - GrammarCache -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setBlockSize

-
-public final void setBlockSize(int blockSize)
-                        throws org.openexi.proc.common.EXIOptionsException
-
-
Set the size, in number of values, of the information that will be - processed as a chunk of the entire EXI stream. Reducing the block size - can improve performance for devices with limited dynamic memory. - Default is 1,000,000 items (not 1MB, but 1,000,000 complete Attribute - and Element values). Block size is only used when the EXI stream is - encoded with EXI-compression. -

-

-
Parameters:
blockSize - number of values in each processing block. Default is 1,000,000. -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setValueMaxLength

-
-public final void setValueMaxLength(int valueMaxLength)
-
-
Set the maximum length of a string that will be stored for reuse in the - String Table. By default, there is no maximum length. However, in data - sets that have long, unique strings of information, you can improve - performance by limiting the size to the length of strings that are more - likely to appear more than once. -

-

-
Parameters:
valueMaxLength - maximum length of entries in the String Table.
-
-
-
- -

-setValuePartitionCapacity

-
-public final void setValuePartitionCapacity(int valuePartitionCapacity)
-
-
Set the maximum number of values in the String Table. By default, there - is no limit. If the target device has limited dynamic memory, limiting - the number of entries in the String Table can improve performance and - reduce the likelihood that you will exceed memory capacity. -

-

-
Parameters:
valuePartitionCapacity - maximum number of entries in the String Table
-
-
-
- -

-setPreserveLexicalValues

-
-public final void setPreserveLexicalValues(boolean preserveLexicalValues)
-                                    throws org.openexi.proc.common.EXIOptionsException
-
-
Set to true to preserve the original string values from the EXI - stream. For example, a date string might be converted to a different - format when interpreted by the EXIDecoder. Preserving the lexical values - ensures that the identical strings are restored, and not just their - logical values. -

-

-
Parameters:
preserveLexicalValues - true to keep original strings intact -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setDatatypeRepresentationMap

-
-public final void setDatatypeRepresentationMap(QName[] dtrm,
-                                               int n_bindings)
-                                        throws org.openexi.proc.common.EXIOptionsException
-
-
Set a datatype representation map (DTRM). The DTRM allows you to remap - XMLSchema datatypes to EXI datatypes other than their default equivalents. - The map is created using a sequence of Qualified Name pairs that identify - a datatype definition in the XMLSchema namespace followed by the new - corresponding datatype mapping in the EXI namespace. -

- For example, the following lines map the boolean datatype from XMLSchema - to the integer datatype in EXI. -
-   QName q1 = new QName("xsd:boolean","http://www.w3.org/2001/XMLSchema");
-   QName q2 = new QName("exi:integer","http://www.w3.org/2009/exi");
-   QName[] dtrm = new QName[2];
-   dtrm = {q1, q2}; // Each mapping requires 2 qualified names.
-   decoderInstance.setDatatypeRepresentationMap(dtrm, 1); // The array, and the number of pairs (1).
- 
-

-

-
Parameters:
dtrm - a sequence of pairs of datatype QName and datatype representation QName
n_bindings - the number of QName pairs -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setEnableBinaryData

-
-public final void setEnableBinaryData(boolean enable)
-
-
Each binary value will be returned as in a EventDescription of EVENT_BLOB - instead of EVENT_CH when enabled. -

-

-
Parameters:
enable -
-
-
-
- -

-setInitialBinaryDataBufferSize

-
-public final void setInitialBinaryDataBufferSize(int initialSize)
-
-
-
-
-
-
- -

-processHeader

-
-public Scanner processHeader()
-                      throws java.io.IOException,
-                             org.openexi.proc.common.EXIOptionsException
-
-
This method reads and configures any header options present - in the EXI stream, then returns a Scanner - object you can use to parse the values from the EXI stream. -

-

- -
Returns:
Scanner parsable object with header options applied. -
Throws: -
java.io.IOException -
org.openexi.proc.common.EXIOptionsException
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/EXISchemaResolver.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/EXISchemaResolver.html deleted file mode 100644 index 7c90b7d5fb..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/EXISchemaResolver.html +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - -EXISchemaResolver - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc -
-Interface EXISchemaResolver

-
-
-
public interface EXISchemaResolver
- - -

-Developers have the option of implementing the EXISchemaResolver interface - to help EXIReader and EXIDecoder locate the correct grammar cache for parsing - an EXI stream. -

- -

-

- -
-
- -

- - - - - - - - - - - - -
-Method Summary
- GrammarCacheresolveSchema(java.lang.String schemaId, - short grammarOptions) - -
-          Return a GrammarCache based on a schemaId and grammar options discovered - in the header options of an EXI stream.
-  -

- - - - - - - - -
-Method Detail
- -

-resolveSchema

-
-GrammarCache resolveSchema(java.lang.String schemaId,
-                           short grammarOptions)
-
-
Return a GrammarCache based on a schemaId and grammar options discovered - in the header options of an EXI stream. -

-

-
Parameters:
schemaId - the specific schema used to decode an EXI stream
grammarOptions - the specific grammar options used to decode an EXI stream -
Returns:
a GrammarCache object
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/HeaderOptionsOutputType.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/HeaderOptionsOutputType.html deleted file mode 100644 index db42f8f040..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/HeaderOptionsOutputType.html +++ /dev/null @@ -1,357 +0,0 @@ - - - - - - - -HeaderOptionsOutputType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc -
-Enum HeaderOptionsOutputType

-
-java.lang.Object
-  extended by java.lang.Enum<HeaderOptionsOutputType>
-      extended by org.openexi.proc.HeaderOptionsOutputType
-
-
-
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<HeaderOptionsOutputType>
-
-
-
-
public enum HeaderOptionsOutputType
extends java.lang.Enum<HeaderOptionsOutputType>
- - -

-This enumeration provides three possible settings for header options output. -

-

    -
  • none – Header options are not included in the header. - The receiver of the document must have precise knowledge of the - settings used to encode the document.

    -
  • -
  • - lessSchemaId – Header options are present. Every - setting used is written out in the header options, except SchemaID. - The receiver of the document must know which schema is used to - encode the document.

    -
  • -
  • - all – All header options are present. Every setting - used is written to the header options, including SchemaID. -
  • -
-

- -

-

- -
-
- -

- - - - - - - - - - - - - - - - -
-Enum Constant Summary
all - -
-           
lessSchemaId - -
-           
none - -
-           
-  - - - - - - - - - - - - - - - -
-Method Summary
-static HeaderOptionsOutputTypevalueOf(java.lang.String name) - -
-          Returns the enum constant of this type with the specified name.
-static HeaderOptionsOutputType[]values() - -
-          Returns an array containing the constants of this enum type, in -the order they're declared.
- - - - - - - -
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
- - - - - - - -
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-  -

- - - - - - - - -
-Enum Constant Detail
- -

-none

-
-public static final HeaderOptionsOutputType none
-
-
-
-
-
- -

-lessSchemaId

-
-public static final HeaderOptionsOutputType lessSchemaId
-
-
-
-
-
- -

-all

-
-public static final HeaderOptionsOutputType all
-
-
-
-
- - - - - - - - -
-Method Detail
- -

-values

-
-public static final HeaderOptionsOutputType[] values()
-
-
Returns an array containing the constants of this enum type, in -the order they're declared. This method may be used to iterate -over the constants as follows: -
-for(HeaderOptionsOutputType c : HeaderOptionsOutputType.values())
-        System.out.println(c);
-
-

-

- -
Returns:
an array containing the constants of this enum type, in -the order they're declared
-
-
-
- -

-valueOf

-
-public static HeaderOptionsOutputType valueOf(java.lang.String name)
-
-
Returns the enum constant of this type with the specified name. -The string must match exactly an identifier used to declare an -enum constant in this type. (Extraneous whitespace characters are -not permitted.) -

-

-
Parameters:
name - the name of the enum constant to be returned. -
Returns:
the enum constant with the specified name -
Throws: -
java.lang.IllegalArgumentException - if this enum type has no constant -with the specified name
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/AlignmentType.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/AlignmentType.html deleted file mode 100644 index cd6ca90e7d..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/AlignmentType.html +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - -AlignmentType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.common -
-Enum AlignmentType

-
-java.lang.Object
-  extended by java.lang.Enum<AlignmentType>
-      extended by org.openexi.proc.common.AlignmentType
-
-
-
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<AlignmentType>
-
-
-
-
public enum AlignmentType
extends java.lang.Enum<AlignmentType>
- - -

-AlignmentType represents one of the following bit alignment - styles so as to provide an extra degree of control over the - way information is stored in EXI format. -
-

  • bitPacked is the default setting. Data are - stored in the fewest number of bits in sequential streams - that cross byte barriers. Conceptually, 8 boolean values - might be stored in a single byte, for example.

  • -
  • byteAligned stores data using EXI tags with - byte barriers intact. Byte-aligned files are useful for - troubleshooting, because the data are often human-readable - when the values are literally encoded as strings. It - is not meant for data transfer, as the file has not been - optimized.

  • -
  • preCompress is a byte-aligned format that arranges - the data into channels. It is intended for use cases where - file compression is part of the transfer process, so as - not to perform the compression step twice.

  • -
  • compress is not a bit alignment in and of itself, - but the Deflate algorithm requires that files be byte-aligned. - When compression is selected, byte-alignment is used, the - data are arranged in channels, and the file is compressed - at the end of processing.
  • -
-

- -

-

- -
-
- -

- - - - - - - - - - - - - - - - - - - -
-Enum Constant Summary
bitPacked - -
-           
byteAligned - -
-           
compress - -
-           
preCompress - -
-           
-  - - - - - - - - - - - - - - - -
-Method Summary
-static AlignmentTypevalueOf(java.lang.String name) - -
-          Returns the enum constant of this type with the specified name.
-static AlignmentType[]values() - -
-          Returns an array containing the constants of this enum type, in -the order they're declared.
- - - - - - - -
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
- - - - - - - -
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-  -

- - - - - - - - -
-Enum Constant Detail
- -

-bitPacked

-
-public static final AlignmentType bitPacked
-
-
-
-
-
- -

-byteAligned

-
-public static final AlignmentType byteAligned
-
-
-
-
-
- -

-preCompress

-
-public static final AlignmentType preCompress
-
-
-
-
-
- -

-compress

-
-public static final AlignmentType compress
-
-
-
-
- - - - - - - - -
-Method Detail
- -

-values

-
-public static final AlignmentType[] values()
-
-
Returns an array containing the constants of this enum type, in -the order they're declared. This method may be used to iterate -over the constants as follows: -
-for(AlignmentType c : AlignmentType.values())
-        System.out.println(c);
-
-

-

- -
Returns:
an array containing the constants of this enum type, in -the order they're declared
-
-
-
- -

-valueOf

-
-public static AlignmentType valueOf(java.lang.String name)
-
-
Returns the enum constant of this type with the specified name. -The string must match exactly an identifier used to declare an -enum constant in this type. (Extraneous whitespace characters are -not permitted.) -

-

-
Parameters:
name - the name of the enum constant to be returned. -
Returns:
the enum constant with the specified name -
Throws: -
java.lang.IllegalArgumentException - if this enum type has no constant -with the specified name
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/BinaryDataSource.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/BinaryDataSource.html deleted file mode 100644 index 27a32a0db3..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/BinaryDataSource.html +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - - -BinaryDataSource - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.common -
-Class BinaryDataSource

-
-java.lang.Object
-  extended by org.openexi.proc.common.BinaryDataSource
-
-
-
-
public final class BinaryDataSource
extends java.lang.Object
- - -

-

- -
-
- -

- - - - - - - - - - - -
-Constructor Summary
BinaryDataSource() - -
-           
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- byte[]getByteArray() - -
-           
- intgetLength() - -
-           
- longgetRemainingBytesCount() - -
-           
- intgetStartIndex() - -
-           
- booleanhasNext() - -
-           
- intnext() - -
-           
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Constructor Detail
- -

-BinaryDataSource

-
-public BinaryDataSource()
-
-
- - - - - - - - -
-Method Detail
- -

-getByteArray

-
-public final byte[] getByteArray()
-
-
-
-
-
-
- -

-getStartIndex

-
-public final int getStartIndex()
-
-
-
-
-
-
- -

-getLength

-
-public final int getLength()
-
-
-
-
-
-
- -

-getRemainingBytesCount

-
-public final long getRemainingBytesCount()
-
-
-
-
-
-
- -

-hasNext

-
-public boolean hasNext()
-
-
-
-
-
-
- -

-next

-
-public int next()
-         throws java.io.IOException
-
-
- -
Throws: -
java.io.IOException
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EXIOptions.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EXIOptions.html deleted file mode 100644 index 27d78e0a99..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EXIOptions.html +++ /dev/null @@ -1,502 +0,0 @@ - - - - - - - -EXIOptions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.common -
-Class EXIOptions

-
-java.lang.Object
-  extended by org.openexi.proc.common.EXIOptions
-
-
-
-
public final class EXIOptions
extends java.lang.Object
- - -

-EXIOptions provides accessors for values associated with - EXI options in the EXI header of an EXI stream. -

- -

-

- -
-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- AlignmentTypegetAlignmentType() - -
-          Get the bit alignment setting.
- intgetBlockSize() - -
-          Returns the number of element and attribute values that are read and processed - as a group.
- QName[]getDatatypeRepresentationMap() - -
-          Returns an array of qualified names that map XMLSchema datatypes to - non-standard equivalents in EXI.
- intgetDatatypeRepresentationMapBindingsCount() - -
-          Returns the number of Datatype Representation Map QName pairs.
- booleangetPreserveComments() - -
-          Returns whether comments are conserved in the EXI Stream.
- booleangetPreserveDTD() - -
-          Returns whether the document type definition is conserved in the EXI Stream.
- booleangetPreserveLexicalValues() - -
-          Returns whether lexical values (literal strings) are preserved rather - than the logical values of elements and attributes.
- booleangetPreserveNS() - -
-          Returns whether the namespaces are preserved in the EXI stream.
- booleangetPreservePIs() - -
-          Returns whether processing instructions are conserved in the EXI Stream.
- intgetValueMaxLength() - -
-          Returns the maximum length in characters of strings that will be included - in the String Table.
- intgetValuePartitionCapacity() - -
-          Returns the maximum number of entries in the String Table.
- booleanisFragment() - -
-          An XML fragment is a non-compliant XML document with multiple root - elements.
- booleanisStrict() - -
-          The Strict option applies to streams that have an associated XML Schema - and the data in the XML stream is 100% compliant with the schema.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Method Detail
- -

-getAlignmentType

-
-public AlignmentType getAlignmentType()
-
-
Get the bit alignment setting. -

-

- -
Returns:
AlignmentType
-
-
-
- -

-isFragment

-
-public boolean isFragment()
-
-
An XML fragment is a non-compliant XML document with multiple root - elements. -

-

- -
Returns:
true if the stream is an XML fragment.
-
-
-
- -

-isStrict

-
-public boolean isStrict()
-
-
The Strict option applies to streams that have an associated XML Schema - and the data in the XML stream is 100% compliant with the schema. -

-

- -
Returns:
true if using strict interpretation of an associated XML Schema.
-
-
-
- -

-getPreserveComments

-
-public boolean getPreserveComments()
-
-
Returns whether comments are conserved in the EXI Stream. -

-

- -
Returns:
true if comments are preserved.
-
-
-
- -

-getPreservePIs

-
-public boolean getPreservePIs()
-
-
Returns whether processing instructions are conserved in the EXI Stream. -

-

- -
Returns:
true if processing instructions are preserved.
-
-
-
- -

-getPreserveDTD

-
-public boolean getPreserveDTD()
-
-
Returns whether the document type definition is conserved in the EXI Stream. -

-

- -
Returns:
true if the document type definition is preserved.
-
-
-
- -

-getPreserveNS

-
-public boolean getPreserveNS()
-
-
Returns whether the namespaces are preserved in the EXI stream. -

-

- -
Returns:
true if namespaces are preserved.
-
-
-
- -

-getBlockSize

-
-public int getBlockSize()
-
-
Returns the number of element and attribute values that are read and processed - as a group. -

-

- -
Returns:
the current block size. Default is 1,000,000.
-
-
-
- -

-getValueMaxLength

-
-public int getValueMaxLength()
-
-
Returns the maximum length in characters of strings that will be included - in the String Table. -

-

- -
Returns:
the maximum length of values added to the String Table. Default is unbounded (-1).
-
-
-
- -

-getValuePartitionCapacity

-
-public int getValuePartitionCapacity()
-
-
Returns the maximum number of entries in the String Table. -

-

- -
Returns:
the maximum number of partitions (entries) in the String Table. Default is unbounded (-1).
-
-
-
- -

-getPreserveLexicalValues

-
-public boolean getPreserveLexicalValues()
-
-
Returns whether lexical values (literal strings) are preserved rather - than the logical values of elements and attributes. -

-

- -
Returns:
true if lexical values are preserved.
-
-
-
- -

-getDatatypeRepresentationMapBindingsCount

-
-public int getDatatypeRepresentationMapBindingsCount()
-
-
Returns the number of Datatype Representation Map QName pairs. -

-

- -
Returns:
the number of DTRM bindings.
-
-
-
- -

-getDatatypeRepresentationMap

-
-public QName[] getDatatypeRepresentationMap()
-
-
Returns an array of qualified names that map XMLSchema datatypes to - non-standard equivalents in EXI. -

-

- -
Returns:
an array of qualified names comprising a DTRM.
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EventDescription.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EventDescription.html deleted file mode 100644 index 396802fbc6..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EventDescription.html +++ /dev/null @@ -1,653 +0,0 @@ - - - - - - - -EventDescription - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.common -
-Interface EventDescription

-
-
All Known Implementing Classes:
EventType
-
-
-
-
public interface EventDescription
- - -

-

EventDescription provides accessors to the current EXI event data - during the decode process.

- -

Note that the content of EventDescription is transient, which means - its content may change when the decoder is asked for access to the - next EXI event data.

-

- -

-

- -
-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Field Summary
-static byteEVENT_AT - -
-          Attribute event.
-static byteEVENT_BLOB - -
-          BLOB event (content of an element).
-static byteEVENT_CH - -
-          Character event (content of an element).
-static byteEVENT_CM - -
-          Comment event.
-static byteEVENT_DTD - -
-          Document Type Definition event.
-static byteEVENT_ED - -
-          End Document event.
-static byteEVENT_EE - -
-          End Element event.
-static byteEVENT_ER - -
-          Entity Reference event.
-static byteEVENT_NL - -
-          Attribute xsi:nil.
-static byteEVENT_NS - -
-          Namespace declaration event.
-static byteEVENT_PI - -
-          Processing Instruction event.
-static byteEVENT_SD - -
-          Start Document event.
-static byteEVENT_SE - -
-          Start Element event.
-static byteEVENT_TP - -
-          Attribute xsi:type.
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- BinaryDataSourcegetBinaryDataSource() - -
-          Gets the value of an EVENT_BLOB.
- CharactersgetCharacters() - -
-          Gets the value of an EVENT_CH, - Attribute (EVENT_AT, EVENT_NL, EVENT_TP), EVENT_CM, - EVENT_DTD or EVENT_PI event.
- bytegetEventKind() - -
-          Gets the event kind of which instance data this EventDescription is describing.
- EventTypegetEventType() - -
-          Returns the EventType from which this event is derived.
- java.lang.StringgetName() - -
-          Gets the name of the EXI event.
- java.lang.StringgetPrefix() - -
-          Gets the namespace prefix of the event.
- java.lang.StringgetURI() - -
-          Gets the URI of the EXI event.
-  -

- - - - - - - - -
-Field Detail
- -

-EVENT_SD

-
-static final byte EVENT_SD
-
-
Start Document event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_ED

-
-static final byte EVENT_ED
-
-
End Document event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_SE

-
-static final byte EVENT_SE
-
-
Start Element event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_AT

-
-static final byte EVENT_AT
-
-
Attribute event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_TP

-
-static final byte EVENT_TP
-
-
Attribute xsi:type. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_NL

-
-static final byte EVENT_NL
-
-
Attribute xsi:nil. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_CH

-
-static final byte EVENT_CH
-
-
Character event (content of an element). -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_EE

-
-static final byte EVENT_EE
-
-
End Element event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_NS

-
-static final byte EVENT_NS
-
-
Namespace declaration event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_PI

-
-static final byte EVENT_PI
-
-
Processing Instruction event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_CM

-
-static final byte EVENT_CM
-
-
Comment event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_ER

-
-static final byte EVENT_ER
-
-
Entity Reference event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_DTD

-
-static final byte EVENT_DTD
-
-
Document Type Definition event. -

-

-
See Also:
Constant Field Values
-
-
- -

-EVENT_BLOB

-
-static final byte EVENT_BLOB
-
-
BLOB event (content of an element). -

-

-
See Also:
Constant Field Values
-
- - - - - - - - -
-Method Detail
- -

-getEventKind

-
-byte getEventKind()
-
-
Gets the event kind of which instance data this EventDescription is describing. -

-

- -
Returns:
a byte representing the event kind.
-
-
-
- -

-getURI

-
-java.lang.String getURI()
-
-
Gets the URI of the EXI event. -

-

- -
Returns:
the URI as a String.
-
-
-
- -

-getName

-
-java.lang.String getName()
-
-
Gets the name of the EXI event. -

-

- -
Returns:
the name of the event as a String.
-
-
-
- -

-getPrefix

-
-java.lang.String getPrefix()
-
-
Gets the namespace prefix of the event. -

-

- -
Returns:
the prefix as a String.
-
-
-
- -

-getCharacters

-
-Characters getCharacters()
-
-
Gets the value of an EVENT_CH, - Attribute (EVENT_AT, EVENT_NL, EVENT_TP), EVENT_CM, - EVENT_DTD or EVENT_PI event. -

-

- -
Returns:
a Characters of the corresponding value
-
-
-
- -

-getBinaryDataSource

-
-BinaryDataSource getBinaryDataSource()
-
-
Gets the value of an EVENT_BLOB. -

-

- -
Returns:
a BinaryData of the corresponding value
-
-
-
- -

-getEventType

-
-EventType getEventType()
-
-
Returns the EventType from which this event is derived. -

-

-
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EventType.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EventType.html deleted file mode 100644 index aaef0c43ed..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EventType.html +++ /dev/null @@ -1,829 +0,0 @@ - - - - - - - -EventType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.common -
-Class EventType

-
-java.lang.Object
-  extended by org.openexi.proc.common.EventCode
-      extended by org.openexi.proc.common.EventType
-
-
-
All Implemented Interfaces:
EventDescription
-
-
-
-
public class EventType
extends org.openexi.proc.common.EventCode
implements EventDescription
- - -

-EventType denotes terminal symbols of grammar productions - defined in the EXI 1.0 specification. -

- -

-

- -
-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Field Summary
-static byteITEM_AT - -
-          Event type for an Attribute learned by built-in element grammars - from prior attribute occurrences.
-static byteITEM_AT_WC_ANY_UNTYPED - -
-          Wildcard event type for an Attribute where the attribute's defined - datatype (if any) is disregarded.
-static byteITEM_CH - -
-          Event type for a Character event (character events store values as strings).
-static byteITEM_CM - -
-          Event type for a Comment.
-static byteITEM_DTD - -
-          Event type for a Document Type Definition.
-static byteITEM_ED - -
-          Event type for End of Document.
-static byteITEM_EE - -
-          Event type for End of Element.
-static byteITEM_ER - -
-          Event type for an Entity Reference.
-static byteITEM_NS - -
-          Event type for a Namespace declaration.
-static byteITEM_PI - -
-          Event type for a Processing Instruction.
-static byteITEM_SC - -
-          Self-contained items are not supported in this release of OpenEXI.
-static byteITEM_SCHEMA_AT - -
-          Event type for AttributeUse that matches an attribute event with - a valid value.
-static byteITEM_SCHEMA_AT_INVALID_VALUE - -
-          Event type for AttributeUse that matches an attribute event with an - invalid value.
-static byteITEM_SCHEMA_AT_WC_ANY - -
-          Attribute wildcard event type stemming from a schema, where the attribute's - defined datatype (if any) is applied.
-static byteITEM_SCHEMA_AT_WC_NS - -
-          Attribute wildcard event type, qualified with a specific namespace, stemming - from a schema where the attribute's defined datatype (if any) is applied.
-static byteITEM_SCHEMA_CH - -
-          Event type for a defined Character event in an EXI stream processed - using a schema.
-static byteITEM_SCHEMA_CH_MIXED - -
-          Event type for a Character event that occurs in the context of an element - defined so as to permit mixed content (mark up and data) in an EXI - stream processed using a schema.
-static byteITEM_SCHEMA_NIL - -
-          Special Attribute that indicates the value of the associated element is - explicitly nil rather than an empty string.
-static byteITEM_SCHEMA_TYPE - -
-          Special Attribute that describes a data type for the associated - element.
-static byteITEM_SCHEMA_WC_ANY - -
-          Attribute wildcard event type stemming from a schema where the - attribute's defined datatype (if any) is applied.
-static byteITEM_SCHEMA_WC_NS - -
-          Event type for an element defined in a namespace in an EXI stream - processed using a schema.
-static byteITEM_SD - -
-          Event type for Start Document.
-static byteITEM_SE - -
-          Event type for Start Element.
-static byteITEM_SE_WC - -
-          Wildcard event type for an element.
- java.lang.Stringname - -
-          Local name of event type definition.
- java.lang.Stringuri - -
-          URI of event type definition.
- - - - - - - -
Fields inherited from class org.openexi.proc.common.EventCode
EVENT_CODE_DEPTH_ONE, EVENT_CODE_DEPTH_THREE, EVENT_CODE_DEPTH_TWO, ITEM_TUPLE, itemType, parent, position
- - - - - - - -
Fields inherited from interface org.openexi.proc.common.EventDescription
EVENT_AT, EVENT_BLOB, EVENT_CH, EVENT_CM, EVENT_DTD, EVENT_ED, EVENT_EE, EVENT_ER, EVENT_NL, EVENT_NS, EVENT_PI, EVENT_SD, EVENT_SE, EVENT_TP
-  - - - - - - - -
-Method Summary
- - - - - - - -
Methods inherited from class org.openexi.proc.common.EventCode
setParentalContext
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- - - - - - - -
Methods inherited from interface org.openexi.proc.common.EventDescription
getBinaryDataSource, getCharacters, getEventKind, getEventType, getName, getPrefix, getURI
-  -

- - - - - - - - -
-Field Detail
- -

-ITEM_PI

-
-public static final byte ITEM_PI
-
-
Event type for a Processing Instruction. Value is 0. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_CM

-
-public static final byte ITEM_CM
-
-
Event type for a Comment. -
Value is 1. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_ER

-
-public static final byte ITEM_ER
-
-
Event type for an Entity Reference. -
Value is 2. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_CH

-
-public static final byte ITEM_CH
-
-
Event type for a Character event (character events store values as strings). -
Value is 3. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_ED

-
-public static final byte ITEM_ED
-
-
Event type for End of Document. -
Value is 4. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SE_WC

-
-public static final byte ITEM_SE_WC
-
-
Wildcard event type for an element. OpenEXI will first attempt - to find a corresponding element name in the schema, if present. If - no definition is available, it is given this tag. -
Value is 5. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SC

-
-public static final byte ITEM_SC
-
-
Self-contained items are not supported in this release of OpenEXI. - Event type for self-contained item. -
Value is 6. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_NS

-
-public static final byte ITEM_NS
-
-
Event type for a Namespace declaration.
-
Value is 7. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_AT_WC_ANY_UNTYPED

-
-public static final byte ITEM_AT_WC_ANY_UNTYPED
-
-
Wildcard event type for an Attribute where the attribute's defined - datatype (if any) is disregarded. - This is the "catch-all" for Attributes that do not match any of the - other Event Types in an EXI stream processed using Default options. -
Value is 8. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_EE

-
-public static final byte ITEM_EE
-
-
Event type for End of Element. -
Value is 9. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_DTD

-
-public static final byte ITEM_DTD
-
-
Event type for a Document Type Definition. -
Value is 10. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SE

-
-public static final byte ITEM_SE
-
-
Event type for Start Element. -
Value is 11. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_AT

-
-public static final byte ITEM_AT
-
-
Event type for an Attribute learned by built-in element grammars - from prior attribute occurrences. -
Value is 12. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SD

-
-public static final byte ITEM_SD
-
-
Event type for Start Document. -
Value is 13. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_WC_ANY

-
-public static final byte ITEM_SCHEMA_WC_ANY
-
-
Attribute wildcard event type stemming from a schema where the - attribute's defined datatype (if any) is applied. -
Value is 14. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_WC_NS

-
-public static final byte ITEM_SCHEMA_WC_NS
-
-
Event type for an element defined in a namespace in an EXI stream - processed using a schema. -
Value is 15. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_AT

-
-public static final byte ITEM_SCHEMA_AT
-
-
Event type for AttributeUse that matches an attribute event with - a valid value. -
Value is 16. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_AT_WC_ANY

-
-public static final byte ITEM_SCHEMA_AT_WC_ANY
-
-
Attribute wildcard event type stemming from a schema, where the attribute's - defined datatype (if any) is applied. -
Value is 17. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_AT_WC_NS

-
-public static final byte ITEM_SCHEMA_AT_WC_NS
-
-
Attribute wildcard event type, qualified with a specific namespace, stemming - from a schema where the attribute's defined datatype (if any) is applied. -
Value is 18. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_CH

-
-public static final byte ITEM_SCHEMA_CH
-
-
Event type for a defined Character event in an EXI stream processed - using a schema. -
Value is 19. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_CH_MIXED

-
-public static final byte ITEM_SCHEMA_CH_MIXED
-
-
Event type for a Character event that occurs in the context of an element - defined so as to permit mixed content (mark up and data) in an EXI - stream processed using a schema. -
Value is 20. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_NIL

-
-public static final byte ITEM_SCHEMA_NIL
-
-
Special Attribute that indicates the value of the associated element is - explicitly nil rather than an empty string. -
Value is 21. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_TYPE

-
-public static final byte ITEM_SCHEMA_TYPE
-
-
Special Attribute that describes a data type for the associated - element. For example, the schema might define a String value, but - the XML document being processed can declare that the element contains a - date-time field. -
Value is 22. -

-

-
See Also:
Constant Field Values
-
-
- -

-ITEM_SCHEMA_AT_INVALID_VALUE

-
-public static final byte ITEM_SCHEMA_AT_INVALID_VALUE
-
-
Event type for AttributeUse that matches an attribute event with an - invalid value. -
Value is 23. -

-

-
See Also:
Constant Field Values
-
-
- -

-uri

-
-public final java.lang.String uri
-
-
URI of event type definition. -

-

-
-
-
- -

-name

-
-public final java.lang.String name
-
-
Local name of event type definition. -

-

-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/GrammarOptions.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/GrammarOptions.html deleted file mode 100644 index 7ea6e13a8c..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/GrammarOptions.html +++ /dev/null @@ -1,528 +0,0 @@ - - - - - - - -GrammarOptions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.common -
-Class GrammarOptions

-
-java.lang.Object
-  extended by org.openexi.proc.common.GrammarOptions
-
-
-
-
public final class GrammarOptions
extends java.lang.Object
- - -

-GrammarOptions computes a short integer that represents settings in the EXI Grammar settings - that determine how an EXI file will be encoded or decoded. -

- Values are set using binary switch values (represented as short integers). -

- If no options have been set, the value is 0 (this is an temporary internal - value, rather than a valid setting). -

- If an XSD is available, and the file to be processed is 100% compatible with the XSD, choosing - STRICT_OPTIONS (1) provides the best performance. No other options can be set - when files are encoded or decoded in strict mode. -

- The DEFAULT_OPTIONS setting is 2. The following table lists all of the options and their values. -

- - - - - - - - -
ConstantValue
STRICT_OPTIONS1
DEFAULT_OPTIONS2
- ADD_NS4 -
- ADD_SCN/A* -
- ADD_DTD16 -
- ADD_CM32 -
- ADD_PI64 -
*The self-contained option is not supported in this release. -
-

- The value of DEFAULT_OPTIONS is 2. When you pass the options variable to an add[??] method, - the binary switch value is added to the current value of the options variable. - The sum of all additional switches becomes a concise list of the selected options. -

- For example, if you preserve comments and processing instructions, the total is - 98 (2 + 32 + 64). The bitwise options are set correctly, because there is one and only one - combination of options that sums up to 98. -

- If your application uses the same options every time, you can hard code the numeric value - as a short integer and use it to create your GrammarCache. For example: -

- GrammarCache gc = new GrammarCache((EXISchema)null,98);
- 
- Be careful to use the correct numeric value, to avoid unexpected results. -

- -

-

- -
-
- -

- - - - - - - - - - - - - - - - - - - -
-Field Summary
-static shortDEFAULT_OPTIONS - -
-          Indicates that undeclared elements and attributes will be - processed when the XML stream is encoded and decoded.
-static shortOPTIONS_UNUSED - -
-          OPTIONS_UNUSED is an internal value.
-static shortSTRICT_OPTIONS - -
-          Indicates that undeclared elements and attributes will throw an - exception when the XML stream is encoded and decoded.
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
-static shortaddCM(short options) - -
-          Sets Preserve Comments to true.
-static shortaddDTD(short options) - -
-          Sets Preserve Document Type Definition to true.
-static shortaddNS(short options) - -
-          Sets Preserve Namespaces to true.
-static shortaddPI(short options) - -
-          Sets Preserve Processing Instructions to true.
-static booleanhasCM(short options) - -
-          Returns true if Preserve Comments is true.
-static booleanhasDTD(short options) - -
-          Returns true if Preserve Document Type Definition is true.
-static booleanhasNS(short options) - -
-          Returns true if Preserve Namespaces is true.
-static booleanhasPI(short options) - -
-          Returns true if Preserve Processing Instructions is true.
-static booleanisPermitDeviation(short options) - -
-          Returns true if DEFAULT_OPTIONS is set to true.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-OPTIONS_UNUSED

-
-public static final short OPTIONS_UNUSED
-
-
OPTIONS_UNUSED is an internal value. - It indicates that the grammar options value has not yet been set. -

-

-
See Also:
Constant Field Values
-
-
- -

-DEFAULT_OPTIONS

-
-public static final short DEFAULT_OPTIONS
-
-
Indicates that undeclared elements and attributes will be - processed when the XML stream is encoded and decoded. -

-

-
See Also:
Constant Field Values
-
-
- -

-STRICT_OPTIONS

-
-public static final short STRICT_OPTIONS
-
-
Indicates that undeclared elements and attributes will throw an - exception when the XML stream is encoded and decoded. When - STRICT_OPTIONS is set, all other Grammar Options are ignored. -

-

-
See Also:
Constant Field Values
-
- - - - - - - - -
-Method Detail
- -

-isPermitDeviation

-
-public static boolean isPermitDeviation(short options)
-
-
Returns true if DEFAULT_OPTIONS is set to true. -

-

-
-
-
-
- -

-hasNS

-
-public static boolean hasNS(short options)
-
-
Returns true if Preserve Namespaces is true. -

-

-
-
-
-
- -

-hasDTD

-
-public static boolean hasDTD(short options)
-
-
Returns true if Preserve Document Type Definition is true. -

-

-
-
-
-
- -

-hasCM

-
-public static boolean hasCM(short options)
-
-
Returns true if Preserve Comments is true. -

-

-
-
-
-
- -

-hasPI

-
-public static boolean hasPI(short options)
-
-
Returns true if Preserve Processing Instructions is true. -

-

-
-
-
-
- -

-addNS

-
-public static short addNS(short options)
-
-
Sets Preserve Namespaces to true. (Adds 4 to the options value.) -

-

- -
Returns:
the new options short integer value
-
-
-
- -

-addDTD

-
-public static short addDTD(short options)
-
-
Sets Preserve Document Type Definition to true. (Adds 16 to the options value.) -

-

- -
Returns:
the new options short integer value
-
-
-
- -

-addCM

-
-public static short addCM(short options)
-
-
Sets Preserve Comments to true. (Adds 32 to the options value.) -

-

- -
Returns:
the new options short integer value
-
-
-
- -

-addPI

-
-public static short addPI(short options)
-
-
Sets Preserve Processing Instructions to true. (Adds 64 to the options value.) -

-

- -
Returns:
the new options short integer value
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/QName.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/QName.html deleted file mode 100644 index 61485ec734..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/QName.html +++ /dev/null @@ -1,346 +0,0 @@ - - - - - - - -QName - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.common -
-Class QName

-
-java.lang.Object
-  extended by org.openexi.proc.common.QName
-
-
-
-
public final class QName
extends java.lang.Object
- - -

-QName is a pair comprised of a namespace name and a local name - to be used in a Datatype Representation Map (DTRM) definition - to denote an XSD datatype or an EXI datatype representation. -

- -

-

- -
-
- -

- - - - - - - - - - - - - - - -
-Field Summary
- java.lang.StringlocalName - -
-          Local name of the datatype.
- java.lang.StringnamespaceName - -
-          If namespaceName is null, this indicates a failure of - namespace-prefix binding.
-  - - - - - - - - - - - - - -
-Constructor Summary
QName() - -
-           
QName(java.lang.String qname, - java.lang.String uri) - -
-          Creates a QName based on its literal qualified name - (see http://www.w3.org/TR/xml-names/#ns-qualnames - for definition) and namespace name.
-  - - - - - - - - - - - -
-Method Summary
- booleanequals(java.lang.Object obj) - -
-           
- - - - - - - -
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-namespaceName

-
-public java.lang.String namespaceName
-
-
If namespaceName is null, this indicates a failure of - namespace-prefix binding. No namespace binding for the - unprefixed QName is indicated by an empty namespace - name "". -

-

-
-
-
- -

-localName

-
-public java.lang.String localName
-
-
Local name of the datatype. -

-

-
-
- - - - - - - - -
-Constructor Detail
- -

-QName

-
-public QName()
-
-
-
- -

-QName

-
-public QName(java.lang.String qname,
-             java.lang.String uri)
-
-
Creates a QName based on its literal qualified name - (see http://www.w3.org/TR/xml-names/#ns-qualnames - for definition) and namespace name. -

-

-
Parameters:
qname - literal qualified name in its entirety
uri - namespace name (nullable) of the QName
See Also:
http://www.w3.org/TR/xml-names/#ns-qualnames
-
- - - - - - - - -
-Method Detail
- -

-equals

-
-public boolean equals(java.lang.Object obj)
-
-
-
Overrides:
equals in class java.lang.Object
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-frame.html deleted file mode 100644 index fcab6106d9..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-frame.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - -org.openexi.proc.common - - - - - - - - - - - -org.openexi.proc.common - - - - -
-Interfaces  - -
-EventDescription
- - - - - - -
-Classes  - -
-BinaryDataSource -
-EventType -
-EXIOptions -
-GrammarOptions -
-QName
- - - - - - -
-Enums  - -
-AlignmentType
- - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-summary.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-summary.html deleted file mode 100644 index c4f3e1c6fe..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-summary.html +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - -org.openexi.proc.common - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-

-Package org.openexi.proc.common -

- - - -The common package contains classes, interfaces, and enumerators that define the vocabulary used to describe EXI streams (events, options, alignment, and character string values). -

-See: -
-          Description -

- - - - - - - - - -
-Interface Summary
EventDescriptionEventDescription provides accessors to the current EXI event data - during the decode process.
-  - -

- - - - - - - - - - - - - - - - - - - - - - - - - -
-Class Summary
BinaryDataSource 
EventTypeEventType denotes terminal symbols of grammar productions - defined in the EXI 1.0 specification.
EXIOptionsEXIOptions provides accessors for values associated with - EXI options in the EXI header of an EXI stream.
GrammarOptionsGrammarOptions computes a short integer that represents settings in the EXI Grammar settings - that determine how an EXI file will be encoded or decoded.
QNameQName is a pair comprised of a namespace name and a local name - to be used in a Datatype Representation Map (DTRM) definition - to denote an XSD datatype or an EXI datatype representation.
-  - -

- - - - - - - - - -
-Enum Summary
AlignmentTypeAlignmentType represents one of the following bit alignment - styles so as to provide an extra degree of control over the - way information is stored in EXI format.
-  - -

-

-Package org.openexi.proc.common Description -

- -

- - - - - -
-

The common package contains classes, interfaces, and enumerators that define the vocabulary used to describe EXI streams (events, options, alignment, and character string values). -

-
- -
-

-

- -

-

- -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-tree.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-tree.html deleted file mode 100644 index 778ae7c56b..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-tree.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - -org.openexi.proc.common Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For Package org.openexi.proc.common -

-
-
-
Package Hierarchies:
All Packages
-
-

-Class Hierarchy -

- -

-Interface Hierarchy -

- -

-Enum Hierarchy -

-
    -
  • java.lang.Object
      -
    • java.lang.Enum<E> (implements java.lang.Comparable<T>, java.io.Serializable) - -
    -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/GrammarCache.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/GrammarCache.html deleted file mode 100644 index 55b03fa67b..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/GrammarCache.html +++ /dev/null @@ -1,362 +0,0 @@ - - - - - - - -GrammarCache - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.grammars -
-Class GrammarCache

-
-java.lang.Object
-  extended by org.openexi.proc.grammars.GrammarCache
-
-
-
All Implemented Interfaces:
org.openexi.proc.common.IGrammarCache
-
-
-
-
public final class GrammarCache
extends java.lang.Object
implements org.openexi.proc.common.IGrammarCache
- - -

-A GrammarCache object represents a set of EXI grammars used - for processing EXI streams using specific grammar options. - The GrammarCache is passed as an argument to - the EXIReader and Transmogrifier prior to processing an EXI stream. -

- -

-

- -
-
- -

- - - - - - - - - - - -
-Field Summary
- shortgrammarOptions - -
-          Short integer that encapsulates GrammarOptions - for the EXI stream.
-  - - - - - - - - - - - - - - - - -
-Constructor Summary
GrammarCache(EXISchema schema) - -
-          Creates an instance of GrammarCache informed by a schema with default - grammar options.
GrammarCache(EXISchema schema, - short grammarOptions) - -
-          Creates an instance of GrammarCache informed by a schema with the - specified grammar options.
GrammarCache(short grammarOptions) - -
-          Creates an instance of GrammarCache with the specified grammar options.
-  - - - - - - - - - - - -
-Method Summary
- EXISchemagetEXISchema() - -
-          Gets the compiled EXI Schema.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- - - - - - - -
Methods inherited from interface org.openexi.proc.common.IGrammarCache
getElementGrammarUse
-  -

- - - - - - - - -
-Field Detail
- -

-grammarOptions

-
-public final short grammarOptions
-
-
Short integer that encapsulates GrammarOptions - for the EXI stream. -

-

-
-
- - - - - - - - -
-Constructor Detail
- -

-GrammarCache

-
-public GrammarCache(EXISchema schema)
-
-
Creates an instance of GrammarCache informed by a schema with default - grammar options. -

-

-
Parameters:
EXISchema - compiled schema
-
-
- -

-GrammarCache

-
-public GrammarCache(short grammarOptions)
-
-
Creates an instance of GrammarCache with the specified grammar options. -

-

-
Parameters:
grammarOptions - integer value that represents a grammar option configuration
-
-
- -

-GrammarCache

-
-public GrammarCache(EXISchema schema,
-                    short grammarOptions)
-
-
Creates an instance of GrammarCache informed by a schema with the - specified grammar options. -

-

-
Parameters:
EXISchema - compiled schema
grammarOptions - integer value that represents a grammar option configuration
-
- - - - - - - - -
-Method Detail
- -

-getEXISchema

-
-public EXISchema getEXISchema()
-
-
Gets the compiled EXI Schema. -

-

-
Specified by:
getEXISchema in interface org.openexi.proc.common.IGrammarCache
-
-
- -
Returns:
an EXI schema.
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-frame.html deleted file mode 100644 index 5eb44a3df0..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-frame.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - -org.openexi.proc.grammars - - - - - - - - - - - -org.openexi.proc.grammars - - - - -
-Classes  - -
-GrammarCache
- - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-summary.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-summary.html deleted file mode 100644 index 3ae5291fc4..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-summary.html +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - -org.openexi.proc.grammars - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-

-Package org.openexi.proc.grammars -

- - - -The grammars package contains the GrammarCache, which combines an XML Schema Definition with EXI grammar options to create an EXI Schema. -

-See: -
-          Description -

- - - - - - - - - -
-Class Summary
GrammarCacheA GrammarCache object represents a set of EXI grammars used - for processing EXI streams using specific grammar options.
-  - -

-

-Package org.openexi.proc.grammars Description -

- -

- - - - - -
-

The grammars package contains the GrammarCache, which combines an XML Schema Definition with EXI grammar options to create an EXI Schema. -

-
- -
-

-

- -

-

- -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-tree.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-tree.html deleted file mode 100644 index 542514937f..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-tree.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - -org.openexi.proc.grammars Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For Package org.openexi.proc.grammars -

-
-
-
Package Hierarchies:
All Packages
-
-

-Class Hierarchy -

-
    -
  • java.lang.Object
      -
    • org.openexi.proc.grammars.GrammarCache (implements org.openexi.proc.common.IGrammarCache) -
    -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/BinaryDataSink.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/BinaryDataSink.html deleted file mode 100644 index 0f9e531c25..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/BinaryDataSink.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - -BinaryDataSink - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.io -
-Interface BinaryDataSink

-
-
-
public interface BinaryDataSink
- - -

-BinaryDataSink represents a sink that accepts successive chunks of binary data. -

- -

-

- -
-
- -

- -

- -


- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/CharacterBuffer.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/CharacterBuffer.html deleted file mode 100644 index 7b7e75e920..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/CharacterBuffer.html +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - - -CharacterBuffer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.io -
-Class CharacterBuffer

-
-java.lang.Object
-  extended by org.openexi.proc.io.CharacterBuffer
-
-
-
-
public final class CharacterBuffer
extends java.lang.Object
- - -

-

- -
-
- -

- - - - - - - - - - - -
-Field Summary
-static intBUFSIZE_DEFAULT - -
-           
-  - - - - - - - - - - -
-Constructor Summary
CharacterBuffer(int bufSize) - -
-           
-  - - - - - - - -
-Method Summary
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-BUFSIZE_DEFAULT

-
-public static final int BUFSIZE_DEFAULT
-
-
-
See Also:
Constant Field Values
-
- - - - - - - - -
-Constructor Detail
- -

-CharacterBuffer

-
-public CharacterBuffer(int bufSize)
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/Scanner.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/Scanner.html deleted file mode 100644 index 82b51284e6..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/Scanner.html +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - -Scanner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.proc.io -
-Class Scanner

-
-java.lang.Object
-  extended by org.openexi.proc.grammars.Apparatus
-      extended by org.openexi.proc.io.Scanner
-
-
-
-
public abstract class Scanner
extends org.openexi.proc.grammars.Apparatus
- - -

-The Scanner class provides methods for scanning events - in the body of an EXI stream. -

- -

-

- -
-
- -

- - - - - - - -
-Field Summary
- - - - - - - -
Fields inherited from class org.openexi.proc.grammars.Apparatus
CODEC_BASE64BINARY, CODEC_BOOLEAN, CODEC_DATE, CODEC_DATETIME, CODEC_DECIMAL, CODEC_DOUBLE, CODEC_ENUMERATION, CODEC_GDAY, CODEC_GMONTH, CODEC_GMONTHDAY, CODEC_GYEAR, CODEC_GYEARMONTH, CODEC_HEXBINARY, CODEC_INTEGER, CODEC_LEXICAL, CODEC_LIST, CODEC_STRING, CODEC_TIME, currentState, eventTypesWorkSpace, schema, stringTable
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- voidcloseInputStream() - -
-          Close the input stream.
- EXIOptionsgetHeaderOptions() - -
-          Returns the EXI Header options from the header of the - EXI stream, if present.
-abstract  EventDescriptionnextEvent() - -
-          Gets the next event from the EXI stream.
-abstract  voidsetBinaryChunkSize(int chunkSize) - -
-          Binary values are read in chunks of the specified size when the - use of binary data is enabled.
- voidsetSchema(EXISchema schema, - QName[] dtrm, - int n_bindings) - -
-           
- - - - - - - -
Methods inherited from class org.openexi.proc.grammars.Apparatus
attribute, characters, endDocument, endElement, getAlignmentType, getNextEventCodes, getNextEventTypes, getPreserveLexicalValues, miscContent, nillify, reset, setPreserveLexicalValues, setStringTable, startDocument, startElement, startWildcardElement, undeclaredCharacters, wildcardAttribute, xsitp
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Method Detail
- -

-setSchema

-
-public void setSchema(EXISchema schema,
-                      QName[] dtrm,
-                      int n_bindings)
-
-
-
Overrides:
setSchema in class org.openexi.proc.grammars.Apparatus
-
-
-
-
-
-
- -

-nextEvent

-
-public abstract EventDescription nextEvent()
-                                    throws java.io.IOException
-
-
Gets the next event from the EXI stream. -

-

- -
Returns:
EXIEvent -
Throws: -
java.io.IOException
-
-
-
- -

-closeInputStream

-
-public void closeInputStream()
-                      throws java.io.IOException
-
-
Close the input stream. -

-

- -
Throws: -
java.io.IOException
-
-
-
- -

-getHeaderOptions

-
-public final EXIOptions getHeaderOptions()
-
-
Returns the EXI Header options from the header of the - EXI stream, if present. Otherwise, returns null. -

-

- -
Returns:
EXIOptions or null if no header options are set.
-
-
-
- -

-setBinaryChunkSize

-
-public abstract void setBinaryChunkSize(int chunkSize)
-
-
Binary values are read in chunks of the specified size when the - use of binary data is enabled. -

-

-
Parameters:
chunkSize -
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-frame.html deleted file mode 100644 index fe7bf70760..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-frame.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - -org.openexi.proc.io - - - - - - - - - - - -org.openexi.proc.io - - - - -
-Interfaces  - -
-BinaryDataSink
- - - - - - -
-Classes  - -
-CharacterBuffer -
-Scanner
- - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-summary.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-summary.html deleted file mode 100644 index 42831b8609..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-summary.html +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - -org.openexi.proc.io - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-

-Package org.openexi.proc.io -

- - - -The IO package contains the Scanner, which is used by EXIDecoder to read and interpret EXI streams. -

-See: -
-          Description -

- - - - - - - - - -
-Interface Summary
BinaryDataSinkBinaryDataSink represents a sink that accepts successive chunks of binary data.
-  - -

- - - - - - - - - - - - - -
-Class Summary
CharacterBuffer 
ScannerThe Scanner class provides methods for scanning events - in the body of an EXI stream.
-  - -

-

-Package org.openexi.proc.io Description -

- -

- - - - - -
-

The IO package contains the Scanner, which is used by EXIDecoder to read and interpret EXI streams. -

-

-The IO package also contains the non-public Scriber class, which is used by the Transmogrifier to encode EXI streams (which is why this is called the IO package). Scriber settings are fully implemented in the Transmogrifier. -

-
- -
-

-

- -

-

- -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-tree.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-tree.html deleted file mode 100644 index b0cbe124ae..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-tree.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - -org.openexi.proc.io Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For Package org.openexi.proc.io -

-
-
-
Package Hierarchies:
All Packages
-
-

-Class Hierarchy -

-
    -
  • java.lang.Object -
-

-Interface Hierarchy -

- -
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-frame.html deleted file mode 100644 index 31406d379f..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-frame.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - -org.openexi.proc - - - - - - - - - - - -org.openexi.proc - - - - -
-Interfaces  - -
-EXISchemaResolver
- - - - - - -
-Classes  - -
-EXIDecoder
- - - - - - -
-Enums  - -
-HeaderOptionsOutputType
- - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-summary.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-summary.html deleted file mode 100644 index 957e54a056..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-summary.html +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - -org.openexi.proc - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-

-Package org.openexi.proc -

- - - -The Proc (Processor) package contains the EXIDecoder, which is used to convert EXI streams to XML format. -

-See: -
-          Description -

- - - - - - - - - -
-Interface Summary
EXISchemaResolverDevelopers have the option of implementing the EXISchemaResolver interface - to help EXIReader and EXIDecoder locate the correct grammar cache for parsing - an EXI stream.
-  - -

- - - - - - - - - -
-Class Summary
EXIDecoderEXIDecoder provides methods to configure and - instantiate a Scanner object - you can use to parse the contents of an EXI stream.
-  - -

- - - - - - - - - -
-Enum Summary
HeaderOptionsOutputTypeThis enumeration provides three possible settings for header options output.
-  - -

-

-Package org.openexi.proc Description -

- -

- - - - - -
-

The Proc (Processor) package contains the EXIDecoder, which is used to convert EXI streams to XML format. -EXIDecoder uses the org.openexi.proc.io.Scanner to parse EXI streams into a sequence of XML events. org.openexi.sax.EXIReader wraps EXIDecoder to provide a SAX interface for accessing the XML content. -

-

-The EXISchemaResolver interface can be implemented and used to add a hint in the EXI header to help EXIDecoder locate the EXISchema. -

-

The HeaderOptionsOutputType enumerator is used to set the header output options in the Transmogrifier.

- -
-

-

- -

-

- -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-tree.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-tree.html deleted file mode 100644 index 3bf180e361..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-tree.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - -org.openexi.proc Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For Package org.openexi.proc -

-
-
-
Package Hierarchies:
All Packages
-
-

-Class Hierarchy -

- -

-Interface Hierarchy -

- -

-Enum Hierarchy -

-
    -
  • java.lang.Object
      -
    • java.lang.Enum<E> (implements java.lang.Comparable<T>, java.io.Serializable) - -
    -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/BinaryDataHandler.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/BinaryDataHandler.html deleted file mode 100644 index b73a833559..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/BinaryDataHandler.html +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - -BinaryDataHandler - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.sax -
-Interface BinaryDataHandler

-
-
All Known Subinterfaces:
SAXTransmogrifier
-
-
-
-
public interface BinaryDataHandler
- - -

-

- -
-
- -

- - - - - - - - - - - - - - - - - - - - -
-Method Summary
- voidbinaryData(byte[] byteArray, - int offset, - int length, - BinaryDataSink binaryDataSink) - -
-          Writes a binary value where the schema expects a binary value.
- voidendBinaryData(BinaryDataSink binaryDataSink) - -
-          Mark the end of a binary value.
- BinaryDataSinkstartBinaryData(long totalSize) - -
-          Mark the start of a binary value.
-  -

- - - - - - - - -
-Method Detail
- -

-startBinaryData

-
-BinaryDataSink startBinaryData(long totalSize)
-                               throws org.xml.sax.SAXException
-
-
Mark the start of a binary value. -

-

- -
Throws: -
org.xml.sax.SAXException
-
-
-
- -

-binaryData

-
-void binaryData(byte[] byteArray,
-                int offset,
-                int length,
-                BinaryDataSink binaryDataSink)
-                throws org.xml.sax.SAXException
-
-
Writes a binary value where the schema expects a binary value. -

-

- -
Throws: -
org.xml.sax.SAXException
-
-
-
- -

-endBinaryData

-
-void endBinaryData(BinaryDataSink binaryDataSink)
-                   throws org.xml.sax.SAXException
-
-
Mark the end of a binary value. -

-

- -
Throws: -
org.xml.sax.SAXException
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/EXIReader.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/EXIReader.html deleted file mode 100644 index 228aa7506e..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/EXIReader.html +++ /dev/null @@ -1,645 +0,0 @@ - - - - - - - -EXIReader - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.sax -
-Class EXIReader

-
-java.lang.Object
-  extended by org.openexi.sax.ReaderSupport
-      extended by org.openexi.sax.EXIReader
-
-
-
All Implemented Interfaces:
org.xml.sax.Attributes, org.xml.sax.XMLReader
-
-
-
-
public final class EXIReader
extends ReaderSupport
implements org.xml.sax.XMLReader
- - -

-EXIReader implements the SAX XMLReader to provide a convenient and - familiar interface for decoding an EXI stream. -

- -

-

- -
-
- -

- - - - - - - - - - - -
-Constructor Summary
EXIReader() - -
-           
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- booleangetFeature(java.lang.String name) - -
-          Get features for the SAX parser.
- java.lang.ObjectgetProperty(java.lang.String name) - -
-          Use to retrieve the name of the lexical handler, currently the only - property recognized by this class.
- voidsetAlignmentType(AlignmentType alignmentType) - -
-          Set the bit alignment style used to compile the EXI input stream.
- voidsetBlockSize(int blockSize) - -
-          Set the size, in number of values, of the information that will be - processed as a chunk of the entire EXI stream.
- voidsetDatatypeRepresentationMap(QName[] dtrm, - int n_bindings) - -
-          Set a datatype representation map.
- voidsetEXISchemaResolver(EXISchemaResolver schemaResolver) - -
-          Set the EXISchemaResolver to retrieve the schema needed to decode the - current EXI stream.
- voidsetFeature(java.lang.String name, - boolean value) - -
-          Set features for the SAX parser.
- voidsetFragment(boolean isFragment) - -
-          Set to true if the EXI input stream is an XML fragment (a non-compliant - XML document with multiple root elements).
- voidsetLexicalHandler(org.xml.sax.ext.LexicalHandler lexicalHandler) - -
-          Set a SAX lexical handler to receive SAX lexical events.
- voidsetPreserveLexicalValues(boolean preserveLexicalValues) - -
-          Set to true if the EXI input stream was compiled with the Preserve Lexical - Values set to true.
- voidsetProperty(java.lang.String name, - java.lang.Object value) - -
-          This method wraps the friendlier setLexicalHandler method to provide - syntax familiar to experienced SAX programmers.
- voidsetValueMaxLength(int valueMaxLength) - -
-          Set the maximum length of a string that will be stored for reuse in the - String Table.
- voidsetValuePartitionCapacity(int valuePartitionCapacity) - -
-          Set the maximum number of values in the String Table.
- - - - - - - -
Methods inherited from class org.openexi.sax.ReaderSupport
getContentHandler, setContentHandler, setGrammarCache
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- - - - - - - -
Methods inherited from interface org.xml.sax.XMLReader
getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, parse, parse, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler
- - - - - - - -
Methods inherited from interface org.xml.sax.Attributes
getIndex, getIndex, getLength, getLocalName, getQName, getType, getType, getType, getURI, getValue, getValue, getValue
-  -

- - - - - - - - -
-Constructor Detail
- -

-EXIReader

-
-public EXIReader()
-
-
- - - - - - - - -
-Method Detail
- -

-setProperty

-
-public final void setProperty(java.lang.String name,
-                              java.lang.Object value)
-                       throws org.xml.sax.SAXNotRecognizedException
-
-
This method wraps the friendlier setLexicalHandler method to provide - syntax familiar to experienced SAX programmers. The only property - supported is:
http://xml.org/sax/properties/lexical-handler
-

-

-
Specified by:
setProperty in interface org.xml.sax.XMLReader
-
-
-
Parameters:
name - must equal "http://xml.org/sax/properties/lexical-handler"
value - an org.xml.sax.ext.LexicalHandler object -
Throws: -
org.xml.sax.SAXNotRecognizedException
-
-
-
- -

-getProperty

-
-public final java.lang.Object getProperty(java.lang.String name)
-                                   throws org.xml.sax.SAXNotRecognizedException
-
-
Use to retrieve the name of the lexical handler, currently the only - property recognized by this class. Pass the String - "http://xml.org/sax/properties/lexical-handler" as the name. -

-

-
Specified by:
getProperty in interface org.xml.sax.XMLReader
-
-
- -
Returns:
String name of the lexical handler -
Throws: -
org.xml.sax.SAXNotRecognizedException
-
-
-
- -

-setFeature

-
-public final void setFeature(java.lang.String name,
-                             boolean value)
-                      throws org.xml.sax.SAXNotRecognizedException,
-                             org.xml.sax.SAXNotSupportedException
-
-
Set features for the SAX parser. The only supported arguments are
- EXIReader.setFeature("http://xml.org/sax/features/namespaces", true);
and
- EXIReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
-

-

-
Specified by:
setFeature in interface org.xml.sax.XMLReader
-
-
- -
Throws: -
org.xml.sax.SAXNotRecognizedException -
org.xml.sax.SAXNotSupportedException
-
-
-
- -

-getFeature

-
-public final boolean getFeature(java.lang.String name)
-                         throws org.xml.sax.SAXNotRecognizedException
-
-
Get features for the SAX parser. -

-

-
Specified by:
getFeature in interface org.xml.sax.XMLReader
-
-
- -
Returns:
true if the feature is "http://xml.org/sax/features/namespaces" - and false if the feature is "http://xml.org/sax/features/namespace-prefixes" -
Throws: -
org.xml.sax.SAXNotRecognizedException
-
-
-
- -

-setAlignmentType

-
-public final void setAlignmentType(AlignmentType alignmentType)
-                            throws org.openexi.proc.common.EXIOptionsException
-
-
Set the bit alignment style used to compile the EXI input stream. -

-

-
-
-
-
Parameters:
alignmentType - AlignmentType -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setFragment

-
-public final void setFragment(boolean isFragment)
-
-
Set to true if the EXI input stream is an XML fragment (a non-compliant - XML document with multiple root elements). -

-

-
-
-
-
Parameters:
isFragment - true if the EXI input stream is an XML fragment.
-
-
-
- -

-setPreserveLexicalValues

-
-public final void setPreserveLexicalValues(boolean preserveLexicalValues)
-                                    throws org.openexi.proc.common.EXIOptionsException
-
-
Set to true if the EXI input stream was compiled with the Preserve Lexical - Values set to true. The original strings, rather than logical XML - equivalents, are restored in the XML output stream. -

-

-
-
-
-
Parameters:
preserveLexicalValues - set to true if the EXI input stream was compiled with - Preserve Lexical Values set to true. -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setEXISchemaResolver

-
-public final void setEXISchemaResolver(EXISchemaResolver schemaResolver)
-
-
Set the EXISchemaResolver to retrieve the schema needed to decode the - current EXI stream. -

-

-
-
-
-
Parameters:
schemaResolver - EXISchemaResolver
-
-
-
- -

-setDatatypeRepresentationMap

-
-public final void setDatatypeRepresentationMap(QName[] dtrm,
-                                               int n_bindings)
-                                        throws org.openexi.proc.common.EXIOptionsException
-
-
Set a datatype representation map. -

-

-
-
-
-
Parameters:
dtrm - a sequence of pairs of datatype qname and datatype representation qname
n_bindings - the number of qname pairs -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setBlockSize

-
-public final void setBlockSize(int blockSize)
-                        throws org.openexi.proc.common.EXIOptionsException
-
-
Set the size, in number of values, of the information that will be - processed as a chunk of the entire EXI stream. Reducing the block size - can improve performance for devices with limited dynamic memory. - Default is 1,000,000 items (not 1MB, but 1,000,000 complete Attribute - and Element values). Block size is only used when the EXI stream is - encoded with EXI-compression. -

-

-
-
-
-
Parameters:
blockSize - number of values in each processing block. Default is 1,000,000. -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setValueMaxLength

-
-public final void setValueMaxLength(int valueMaxLength)
-
-
Set the maximum length of a string that will be stored for reuse in the - String Table. By default, there is no maximum length. However, in data - sets that have long, unique strings of information, you can improve - performance by limiting the size to the length of strings that are more - likely to appear more than once. -

-

-
-
-
-
Parameters:
valueMaxLength - maximum length of entries in the String Table.
-
-
-
- -

-setValuePartitionCapacity

-
-public final void setValuePartitionCapacity(int valuePartitionCapacity)
-
-
Set the maximum number of values in the String Table. By default, there - is no limit. If the target device has limited dynamic memory, limiting - the number of entries in the String Table can improve performance and - reduce the likelihood that you will exceed memory capacity. -

-

-
-
-
-
Parameters:
valuePartitionCapacity - maximum number of entries in the String Table
-
-
-
- -

-setLexicalHandler

-
-public void setLexicalHandler(org.xml.sax.ext.LexicalHandler lexicalHandler)
-
-
Set a SAX lexical handler to receive SAX lexical events. -

-

-
-
-
-
Parameters:
lexicalHandler - SAX lexical handler
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/ReaderSupport.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/ReaderSupport.html deleted file mode 100644 index 7d392bb5b6..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/ReaderSupport.html +++ /dev/null @@ -1,290 +0,0 @@ - - - - - - - -ReaderSupport - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.sax -
-Class ReaderSupport

-
-java.lang.Object
-  extended by org.openexi.sax.ReaderSupport
-
-
-
All Implemented Interfaces:
org.xml.sax.Attributes
-
-
-
Direct Known Subclasses:
EXIReader
-
-
-
-
public abstract class ReaderSupport
extends java.lang.Object
implements org.xml.sax.Attributes
- - -

-

- -
-
- -

- - - - - - - - - - - - - - - - - - - - -
-Method Summary
- org.xml.sax.ContentHandlergetContentHandler() - -
-          Get the SAX content handler currently in use.
- voidsetContentHandler(org.xml.sax.ContentHandler contentHandler) - -
-          Set a SAX content handler to receive SAX events.
- voidsetGrammarCache(GrammarCache grammarCache) - -
-          Set the GrammarCache used in parsing EXI streams.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- - - - - - - -
Methods inherited from interface org.xml.sax.Attributes
getIndex, getIndex, getLength, getLocalName, getQName, getType, getType, getType, getURI, getValue, getValue, getValue
-  -

- - - - - - - - -
-Method Detail
- -

-setContentHandler

-
-public final void setContentHandler(org.xml.sax.ContentHandler contentHandler)
-
-
Set a SAX content handler to receive SAX events. -

-

-
-
-
-
Parameters:
contentHandler - SAX content handler
-
-
-
- -

-getContentHandler

-
-public final org.xml.sax.ContentHandler getContentHandler()
-
-
Get the SAX content handler currently in use. -

-

-
-
-
- -
Returns:
ContentHandler SAX content handler.
-
-
-
- -

-setGrammarCache

-
-public void setGrammarCache(GrammarCache grammarCache)
-                     throws org.openexi.proc.common.EXIOptionsException
-
-
Set the GrammarCache used in parsing EXI streams. -

-

-
-
-
-
Parameters:
grammarCache - GrammarCache -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/SAXTransmogrifier.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/SAXTransmogrifier.html deleted file mode 100644 index 15e2e7d77f..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/SAXTransmogrifier.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - -SAXTransmogrifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.sax -
-Interface SAXTransmogrifier

-
-
All Superinterfaces:
BinaryDataHandler, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler
-
-
-
-
public interface SAXTransmogrifier
extends org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, BinaryDataHandler
- - -

-Applications can directly feed SAX events into a transmogrifier through SAXTransmogrifier. -

- -

-

- -
-
- -

- - - - - - - - - - - - -
-Method Summary
- GrammarCachegetGrammarCache() - -
-          Returns the GrammarCache that is in use by this SAXTransmogrifier.
- - - - - - - -
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
- - - - - - - -
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
- - - - - - - -
Methods inherited from interface org.openexi.sax.BinaryDataHandler
binaryData, endBinaryData, startBinaryData
-  -

- - - - - - - - -
-Method Detail
- -

-getGrammarCache

-
-GrammarCache getGrammarCache()
-
-
Returns the GrammarCache that is in use by this SAXTransmogrifier. -

-

-
-
-
- -
Returns:
a GrammarCache
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/Transmogrifier.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/Transmogrifier.html deleted file mode 100644 index b857aab51c..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/Transmogrifier.html +++ /dev/null @@ -1,735 +0,0 @@ - - - - - - - -Transmogrifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.sax -
-Class Transmogrifier

-
-java.lang.Object
-  extended by org.openexi.sax.Transmogrifier
-
-
-
-
public final class Transmogrifier
extends java.lang.Object
- - -

-The Transmogrifier converts an XML stream to an EXI stream. -

- -

-

- -
-
- -

- - - - - - - - - - - - - - -
-Constructor Summary
Transmogrifier() - -
-          Create an instance of the Transmogrifier with a default SAX parser.
Transmogrifier(javax.xml.parsers.SAXParserFactory saxParserFactory) - -
-          Create an instance of the Transmogrifier, specifying the SAXParserFactory - from which to create the SAX parser.
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- voidencode(org.xml.sax.InputSource is) - -
-          Parses XML input source and converts it to an EXI stream.
- GrammarCachegetGrammarCache() - -
-          Returns the GrammarCache that was previously set.
- SAXTransmogrifiergetSAXTransmogrifier() - -
-          Returns the SAXTransmogrifier, which implements both the ContentHandler - and LexicalHandler.
- voidsetAlignmentType(AlignmentType alignmentType) - -
-          Set the bit alignment style for the encoded EXI stream.
- voidsetBlockSize(int blockSize) - -
-          Set the size, in number of values, of the information that will be - processed as a chunk of the entire XML stream.
- voidsetDatatypeRepresentationMap(QName[] dtrm, - int n_bindings) - -
-          Set a datatype representation map (DTRM).
- voidsetEntityResolver(org.xml.sax.EntityResolver entityResolver) - -
-          Set an external SAX entity resolver.
- voidsetFragment(boolean isFragment) - -
-          Set to true if the XML input stream is an XML fragment (a non-compliant - XML document with multiple root elements).
- voidsetGrammarCache(GrammarCache grammarCache) - -
-          Set the GrammarCache used in transmogrifying XML data to EXI.
- voidsetGrammarCache(GrammarCache grammarCache, - org.openexi.proc.common.SchemaId schemaId) - -
-          Set the GrammarCache to be used in encoding XML streams into EXI streams - by the transmogrifier.
- voidsetOutputCookie(boolean outputCookie) - -
-          Tells the encoder whether to or not to start the stream by - adding an EXI cookie.
- voidsetOutputOptions(HeaderOptionsOutputType outputOptions) - -
-          Set the header output options.
- voidsetOutputStream(java.io.OutputStream ostream) - -
-          Set an output stream to which encoded streams are written.
- voidsetPreserveLexicalValues(boolean preserveLexicalValues) - -
-          Set to true to preserve the original string values from the XML - stream.
- voidsetPreserveWhitespaces(boolean preserveWhitespaces) - -
-          Set to true to preserve whitespace (for example, spaces, tabs, and - line breaks) in the encoded EXI stream.
- voidsetResolveExternalGeneralEntities(boolean resolveExternalGeneralEntities) - -
-          Change the way a Transmogrifier handles external general entities.
- voidsetValueMaxLength(int valueMaxLength) - -
-          Set the maximum length of a string that will be stored for reuse in the - String Table.
- voidsetValuePartitionCapacity(int valuePartitionCapacity) - -
-          Set the maximum number of values in the String Table.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Constructor Detail
- -

-Transmogrifier

-
-public Transmogrifier()
-               throws org.openexi.sax.TransmogrifierRuntimeException
-
-
Create an instance of the Transmogrifier with a default SAX parser. -

-

- -
Throws: -
TransmogrifierException -
org.openexi.sax.TransmogrifierRuntimeException
-
-
- -

-Transmogrifier

-
-public Transmogrifier(javax.xml.parsers.SAXParserFactory saxParserFactory)
-               throws org.openexi.sax.TransmogrifierRuntimeException
-
-
Create an instance of the Transmogrifier, specifying the SAXParserFactory - from which to create the SAX parser. -

-

-
Parameters:
saxParserFactory - -
Throws: -
TransmogrifierException -
org.openexi.sax.TransmogrifierRuntimeException
-
- - - - - - - - -
-Method Detail
- -

-setResolveExternalGeneralEntities

-
-public void setResolveExternalGeneralEntities(boolean resolveExternalGeneralEntities)
-                                       throws TransmogrifierException
-
-
Change the way a Transmogrifier handles external general entities. When the value - of resolveExternalGeneralEntities is set to true, a Transmogrifier will try to - resolve external general entities. Otherwise, external general entities will not - be resolved. -

-

-
Parameters:
resolveExternalGeneralEntities - -
Throws: -
TransmogrifierException - Thrown when the underlying XMLReader does not - support the specified behavior.
-
-
-
- -

-setOutputStream

-
-public final void setOutputStream(java.io.OutputStream ostream)
-
-
Set an output stream to which encoded streams are written. -

-

-
Parameters:
ostream - output stream
-
-
-
- -

-setAlignmentType

-
-public final void setAlignmentType(AlignmentType alignmentType)
-                            throws org.openexi.proc.common.EXIOptionsException
-
-
Set the bit alignment style for the encoded EXI stream. -

-

-
Parameters:
alignmentType - AlignmentType. - Default is bit-packed. -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setFragment

-
-public final void setFragment(boolean isFragment)
-
-
Set to true if the XML input stream is an XML fragment (a non-compliant - XML document with multiple root elements). -

-

-
Parameters:
isFragment - true if the XML input stream is an XML fragment.
-
-
-
- -

-setBlockSize

-
-public final void setBlockSize(int blockSize)
-                        throws org.openexi.proc.common.EXIOptionsException
-
-
Set the size, in number of values, of the information that will be - processed as a chunk of the entire XML stream. Reducing the block size - can improve performance for devices with limited dynamic memory. - Default is 1,000,000 items (not 1MB, but 1,000,000 complete Attribute - and Element values). Block size is only used when the EXI stream is - encoded with EXI-compression. -

-

-
Parameters:
blockSize - number of values in each processing block. Default is 1,000,000. -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setValueMaxLength

-
-public final void setValueMaxLength(int valueMaxLength)
-
-
Set the maximum length of a string that will be stored for reuse in the - String Table. By default, there is no maximum length. However, in data - sets that have long, unique strings of information, you can improve - performance by limiting the size to the length of strings that are more - likely to appear more than once. -

-

-
Parameters:
valueMaxLength - maximum length of entries in the String Table.
-
-
-
- -

-setValuePartitionCapacity

-
-public final void setValuePartitionCapacity(int valuePartitionCapacity)
-
-
Set the maximum number of values in the String Table. By default, there - is no limit. If the target device has limited dynamic memory, limiting - the number of entries in the String Table can improve performance and - reduce the likelihood that you will exceed memory capacity. -

-

-
Parameters:
valuePartitionCapacity - maximum number of entries in the String Table
-
-
-
- -

-setPreserveLexicalValues

-
-public final void setPreserveLexicalValues(boolean preserveLexicalValues)
-                                    throws org.openexi.proc.common.EXIOptionsException
-
-
Set to true to preserve the original string values from the XML - stream. For example, a date string might be converted to a different - format when interpreted by the Transmogrifier. Preserving the lexical values - ensures that the identical strings are restored, and not just their - logical values. -

-

-
Parameters:
preserveLexicalValues - true to keep original strings intact -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setGrammarCache

-
-public final void setGrammarCache(GrammarCache grammarCache)
-                           throws org.openexi.proc.common.EXIOptionsException
-
-
Set the GrammarCache used in transmogrifying XML data to EXI. -

-

-
Parameters:
grammarCache - GrammarCache -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setGrammarCache

-
-public final void setGrammarCache(GrammarCache grammarCache,
-                                  org.openexi.proc.common.SchemaId schemaId)
-                           throws org.openexi.proc.common.EXIOptionsException
-
-
Set the GrammarCache to be used in encoding XML streams into EXI streams - by the transmogrifier. - The SchemaId contains the string that is written in the header when - HeaderOptionsOutputType.all is set. -

-

-
Parameters:
grammarCache - GrammarCache
schemaId - -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-getGrammarCache

-
-public final GrammarCache getGrammarCache()
-
-
Returns the GrammarCache that was previously set. -

-

- -
Returns:
a GrammarCache
-
-
-
- -

-setDatatypeRepresentationMap

-
-public final void setDatatypeRepresentationMap(QName[] dtrm,
-                                               int n_bindings)
-                                        throws org.openexi.proc.common.EXIOptionsException
-
-
Set a datatype representation map (DTRM). The DTRM allows you to remap - XMLSchema datatypes to EXI datatypes other than their default equivalents. - The map is created using a sequence of Qualified Name pairs that identify - a datatype definition in the XMLSchema namespace followed by the new - corresponding datatype mapping in the EXI namespace. -

- For example, the following lines map the boolean datatype from XMLSchema - to the integer datatype in EXI. -
-   QName q1 = new QName("xsd:boolean","http://www.w3.org/2001/XMLSchema");
-   QName q2 = new QName("exi:integer","http://www.w3.org/2009/exi");
-   QName[] dtrm = new QName[2];
-   dtrm = {q1, q2}; // Each mapping requires 2 qualified names.
-   transmogrifierInstance.setDatatypeRepresentationMap(dtrm, 1); // The array, and the number of pairs (1).
- 
-

-

-
Parameters:
dtrm - a sequence of pairs of datatype QName and datatype representation QName
n_bindings - the number of QName pairs -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setEntityResolver

-
-public final void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
-
-
Set an external SAX entity resolver. -

-

-
Parameters:
entityResolver - EntityResolver
-
-
-
- -

-setOutputCookie

-
-public final void setOutputCookie(boolean outputCookie)
-
-
Tells the encoder whether to or not to start the stream by - adding an EXI cookie. -

-

-
Parameters:
outputCookie - true to include the EXI cookie
-
-
-
- -

-setOutputOptions

-
-public final void setOutputOptions(HeaderOptionsOutputType outputOptions)
-                            throws org.openexi.proc.common.EXIOptionsException
-
-
Set the header output options. Choices are set using the - HeaderOptionsOutputType enumeration. - Options are all, lessSchemaID (that is, all values - except for the SchemaId), or none. -

-

-
Parameters:
outputOptions - HeaderOptionsOutputType -
Throws: -
org.openexi.proc.common.EXIOptionsException
-
-
-
- -

-setPreserveWhitespaces

-
-public final void setPreserveWhitespaces(boolean preserveWhitespaces)
-
-
Set to true to preserve whitespace (for example, spaces, tabs, and - line breaks) in the encoded EXI stream. By default, non-essential whitespace - is removed from the encoded stream. -

-

-
Parameters:
preserveWhitespaces - true to retain whitespace in the encoded EXI stream
-
-
-
- -

-encode

-
-public void encode(org.xml.sax.InputSource is)
-            throws TransmogrifierException,
-                   java.io.IOException
-
-
Parses XML input source and converts it to an EXI stream. -

-

-
Parameters:
is - XML input source -
Throws: -
TransmogrifierException -
java.io.IOException
-
-
-
- -

-getSAXTransmogrifier

-
-public SAXTransmogrifier getSAXTransmogrifier()
-
-
Returns the SAXTransmogrifier, which implements both the ContentHandler - and LexicalHandler. SAX programmers can connect the SAXTransmogrifier to - their favorite XML Parser to convert SAX events into an EXI stream. -

-

-
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/TransmogrifierException.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/TransmogrifierException.html deleted file mode 100644 index 55e1e1feaa..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/TransmogrifierException.html +++ /dev/null @@ -1,566 +0,0 @@ - - - - - - - -TransmogrifierException - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.sax -
-Class TransmogrifierException

-
-java.lang.Object
-  extended by java.lang.Throwable
-      extended by java.lang.Exception
-          extended by org.openexi.sax.TransmogrifierException
-
-
-
All Implemented Interfaces:
java.io.Serializable
-
-
-
-
public final class TransmogrifierException
extends java.lang.Exception
- - -

-Exception handler for the Transmogrifier. -

- -

-

-
See Also:
Serialized Form -
-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Field Summary
-static intPREFIX_BOUND_TO_ANOTHER_NAMESPACE - -
-          Prefix is bound to another namespace.
-static intPREFIX_NOT_BOUND - -
-          Prefix is not bound.
-static intSAX_ERROR - -
-          SAX error reported by XML parser.
-static intSCRIBER_ERROR - -
-          Errors reported by Scriber.
-static intUNEXPECTED_ATTR - -
-          Unexpected Attribute.
-static intUNEXPECTED_BINARY_VALUE - -
-          Unexpected Binary value.
-static intUNEXPECTED_CHARS - -
-          Unexpected Character Sequence.
-static intUNEXPECTED_ED - -
-          Unexpected End of Document event.
-static intUNEXPECTED_ELEM - -
-          Unexpected Element.
-static intUNEXPECTED_END_ELEM - -
-          Unexpected End of Element event.
-static intUNEXPECTED_SD - -
-          Unexpected Start of Document event.
-static intUNHANDLED_SAXPARSER_FEATURE - -
-          Unhandled SAX parser feature.
-  - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- intgetCode() - -
-          Returns a code that represents the type of the exception.
- java.lang.ExceptiongetException() - -
-          Returns an Exception object.
- org.xml.sax.LocatorgetLocator() - -
-          Returns the locator that is associated with this compilation error.
- java.lang.StringgetMessage() - -
-          Returns a message that describes the exception.
- - - - - - - -
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-UNEXPECTED_ELEM

-
-public static final int UNEXPECTED_ELEM
-
-
Unexpected Element. -

-

-
See Also:
Constant Field Values
-
-
- -

-UNEXPECTED_ATTR

-
-public static final int UNEXPECTED_ATTR
-
-
Unexpected Attribute. -

-

-
See Also:
Constant Field Values
-
-
- -

-UNEXPECTED_CHARS

-
-public static final int UNEXPECTED_CHARS
-
-
Unexpected Character Sequence. -

-

-
See Also:
Constant Field Values
-
-
- -

-UNEXPECTED_BINARY_VALUE

-
-public static final int UNEXPECTED_BINARY_VALUE
-
-
Unexpected Binary value. -

-

-
See Also:
Constant Field Values
-
-
- -

-UNHANDLED_SAXPARSER_FEATURE

-
-public static final int UNHANDLED_SAXPARSER_FEATURE
-
-
Unhandled SAX parser feature. -

-

-
See Also:
Constant Field Values
-
-
- -

-SAX_ERROR

-
-public static final int SAX_ERROR
-
-
SAX error reported by XML parser. -

-

-
See Also:
Constant Field Values
-
-
- -

-UNEXPECTED_END_ELEM

-
-public static final int UNEXPECTED_END_ELEM
-
-
Unexpected End of Element event. -

-

-
See Also:
Constant Field Values
-
-
- -

-UNEXPECTED_ED

-
-public static final int UNEXPECTED_ED
-
-
Unexpected End of Document event. -

-

-
See Also:
Constant Field Values
-
-
- -

-UNEXPECTED_SD

-
-public static final int UNEXPECTED_SD
-
-
Unexpected Start of Document event. -

-

-
See Also:
Constant Field Values
-
-
- -

-PREFIX_NOT_BOUND

-
-public static final int PREFIX_NOT_BOUND
-
-
Prefix is not bound. -

-

-
See Also:
Constant Field Values
-
-
- -

-PREFIX_BOUND_TO_ANOTHER_NAMESPACE

-
-public static final int PREFIX_BOUND_TO_ANOTHER_NAMESPACE
-
-
Prefix is bound to another namespace. -

-

-
See Also:
Constant Field Values
-
-
- -

-SCRIBER_ERROR

-
-public static final int SCRIBER_ERROR
-
-
Errors reported by Scriber. -

-

-
See Also:
Constant Field Values
-
- - - - - - - - -
-Method Detail
- -

-getCode

-
-public int getCode()
-
-
Returns a code that represents the type of the exception. -

-

- -
Returns:
error code
-
-
-
- -

-getMessage

-
-public java.lang.String getMessage()
-
-
Returns a message that describes the exception. -

-

-
Overrides:
getMessage in class java.lang.Throwable
-
-
- -
Returns:
error message
-
-
-
- -

-getException

-
-public java.lang.Exception getException()
-
-
Returns an Exception object. -

-

- -
Returns:
the error as an Exception instance
-
-
-
- -

-getLocator

-
-public org.xml.sax.Locator getLocator()
-
-
Returns the locator that is associated with this compilation error. -

-

- -
Returns:
a Locator if available, otherwise null
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-frame.html deleted file mode 100644 index 22e45d692b..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-frame.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - -org.openexi.sax - - - - - - - - - - - -org.openexi.sax - - - - -
-Interfaces  - -
-BinaryDataHandler -
-SAXTransmogrifier
- - - - - - -
-Classes  - -
-EXIReader -
-ReaderSupport -
-Transmogrifier
- - - - - - -
-Exceptions  - -
-TransmogrifierException
- - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-summary.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-summary.html deleted file mode 100644 index b0e720814c..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-summary.html +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - - -org.openexi.sax - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-

-Package org.openexi.sax -

- - - -The SAX package contains the Transmogrifier, which encodes an XML file to an EXI stream, and the EXIReader, which restores an EXI stream to its logical XML equivalent. -

-See: -
-          Description -

- - - - - - - - - - - - - -
-Interface Summary
BinaryDataHandler 
SAXTransmogrifierApplications can directly feed SAX events into a transmogrifier through SAXTransmogrifier.
-  - -

- - - - - - - - - - - - - - - - - -
-Class Summary
EXIReaderEXIReader implements the SAX XMLReader to provide a convenient and - familiar interface for decoding an EXI stream.
ReaderSupport 
TransmogrifierThe Transmogrifier converts an XML stream to an EXI stream.
-  - -

- - - - - - - - - -
-Exception Summary
TransmogrifierExceptionException handler for the Transmogrifier.
-  - -

-

-Package org.openexi.sax Description -

- -

- - - - - -
-

The SAX package contains the Transmogrifier, which encodes an XML file to an EXI stream, and the EXIReader, which restores an EXI stream to its logical XML equivalent. These classes are wrappers for the Scriber and EXIDecoder, respectively, and are primarily meant to provide access to EXI using familiar SAX syntax. -

-
- -
-

-

- -

-

- -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-tree.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-tree.html deleted file mode 100644 index f4184bf934..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-tree.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - -org.openexi.sax Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For Package org.openexi.sax -

-
-
-
Package Hierarchies:
All Packages
-
-

-Class Hierarchy -

-
    -
  • java.lang.Object -
-

-Interface Hierarchy -

- -
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/Characters.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/Characters.html deleted file mode 100644 index 022f5be35a..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/Characters.html +++ /dev/null @@ -1,486 +0,0 @@ - - - - - - - -Characters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.schema -
-Class Characters

-
-java.lang.Object
-  extended by org.openexi.schema.Characters
-
-
-
-
public final class Characters
extends java.lang.Object
- - -

-

- -
-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Field Summary
- char[]characters - -
-           
-static CharactersCHARACTERS_EMPTY - -
-           
- booleanisVolatile - -
-           
- intlength - -
-           
- intstartIndex - -
-           
- intucsCount - -
-           
-  - - - - - - - - - - -
-Constructor Summary
Characters(char[] characters, - int startIndex, - int length, - boolean isVolatile) - -
-           
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- booleanequals(java.lang.Object object) - -
-           
- inthashCode() - -
-           
- intindexOf(char c) - -
-           
- java.lang.StringmakeString() - -
-           
- java.lang.Stringsubstring(int beginIndex, - int endIndex) - -
-           
- voidturnPermanent() - -
-           
- - - - - - - -
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-isVolatile

-
-public boolean isVolatile
-
-
-
-
-
- -

-characters

-
-public char[] characters
-
-
-
-
-
- -

-startIndex

-
-public int startIndex
-
-
-
-
-
- -

-length

-
-public final int length
-
-
-
-
-
- -

-ucsCount

-
-public final int ucsCount
-
-
-
-
-
- -

-CHARACTERS_EMPTY

-
-public static final Characters CHARACTERS_EMPTY
-
-
-
-
- - - - - - - - -
-Constructor Detail
- -

-Characters

-
-public Characters(char[] characters,
-                  int startIndex,
-                  int length,
-                  boolean isVolatile)
-
-
- - - - - - - - -
-Method Detail
- -

-turnPermanent

-
-public void turnPermanent()
-
-
-
-
-
-
- -

-indexOf

-
-public int indexOf(char c)
-
-
-
-
-
-
- -

-substring

-
-public java.lang.String substring(int beginIndex,
-                                  int endIndex)
-
-
-
-
-
-
- -

-hashCode

-
-public int hashCode()
-
-
-
Overrides:
hashCode in class java.lang.Object
-
-
-
-
-
-
- -

-equals

-
-public boolean equals(java.lang.Object object)
-
-
-
Overrides:
equals in class java.lang.Object
-
-
-
-
-
-
- -

-makeString

-
-public java.lang.String makeString()
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/EXISchema.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/EXISchema.html deleted file mode 100644 index f3c472ec5e..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/EXISchema.html +++ /dev/null @@ -1,355 +0,0 @@ - - - - - - - -EXISchema - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.schema -
-Class EXISchema

-
-java.lang.Object
-  extended by org.openexi.schema.EXISchema
-
-
-
-
public final class EXISchema
extends java.lang.Object
- - -

-EXISchema provides methods to read and write compiled EXI schemas. -

- -

-

- -
-
- -

- - - - - - - - - - - -
-Field Summary
- byte[]ancestryIds - -
-           
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
-static boolean_isSimpleType(int tp, - int[] types) - -
-           
- booleanisSimpleType(int tp) - -
-           
-static EXISchemareadIn(java.io.DataInputStream in) - -
-          Reads an EXI Schema from a DataInputStream.
- voidwriteOut(java.io.DataOutputStream out) - -
-          Writes out a serialized EXISchema.
- voidwriteXml(java.io.OutputStream out, - boolean whole) - -
-           
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-ancestryIds

-
-public transient byte[] ancestryIds
-
-
-
-
- - - - - - - - -
-Method Detail
- -

-isSimpleType

-
-public boolean isSimpleType(int tp)
-
-
-
-
-
-
- -

-_isSimpleType

-
-public static boolean _isSimpleType(int tp,
-                                    int[] types)
-
-
-
-
-
-
- -

-readIn

-
-public static EXISchema readIn(java.io.DataInputStream in)
-                        throws java.io.IOException,
-                               java.lang.ClassNotFoundException
-
-
Reads an EXI Schema from a DataInputStream. -

-

-
Parameters:
in - DataInputStream containing a serialized EXISchema -
Returns:
EXISchema -
Throws: -
IOException, - ClassNotFoundException -
java.io.IOException -
java.lang.ClassNotFoundException
-
-
-
- -

-writeOut

-
-public void writeOut(java.io.DataOutputStream out)
-              throws java.io.IOException
-
-
Writes out a serialized EXISchema. -

-

-
Parameters:
out - DataOutputStream to receive the serialized EXISchema -
Throws: -
java.io.IOException
-
-
-
- -

-writeXml

-
-public void writeXml(java.io.OutputStream out,
-                     boolean whole)
-              throws java.io.IOException
-
-
- -
Throws: -
java.io.IOException
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/EmptySchema.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/EmptySchema.html deleted file mode 100644 index 2a932cc5fb..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/EmptySchema.html +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - -EmptySchema - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.schema -
-Class EmptySchema

-
-java.lang.Object
-  extended by org.openexi.schema.EmptySchema
-
-
-
-
public final class EmptySchema
extends java.lang.Object
- - -

-EmptySchema provides an EXISchema that supports all datatypes inherent - in XML Schema such as xsd:int and xsd:dateTime, but with no - user-specific definitions. This is to support the use of dynamic - datatype associations discovered within elements during processing. -

- -

-

- -
-
- -

- - - - - - - - - - - - -
-Method Summary
-static EXISchemagetEXISchema() - -
-          Returns an EXISchema that supports all datatypes inherent in XML Schema.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Method Detail
- -

-getEXISchema

-
-public static EXISchema getEXISchema()
-
-
Returns an EXISchema that supports all datatypes inherent in XML Schema. - Calls to this method always return the same object. -

-

- -
Returns:
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-frame.html deleted file mode 100644 index 4fdd831792..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-frame.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - -org.openexi.schema - - - - - - - - - - - -org.openexi.schema - - - - -
-Classes  - -
-Characters -
-EmptySchema -
-EXISchema
- - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-summary.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-summary.html deleted file mode 100644 index 53242f2e32..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-summary.html +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - -org.openexi.schema - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-

-Package org.openexi.schema -

- - - -The schema package contains classes that are used to represent XML Schema Documents (XSDs). -

-See: -
-          Description -

- - - - - - - - - - - - - - - - - -
-Class Summary
Characters 
EmptySchemaEmptySchema provides an EXISchema that supports all datatypes inherent - in XML Schema such as xsd:int and xsd:dateTime, but with no - user-specific definitions.
EXISchemaEXISchema provides methods to read and write compiled EXI schemas.
-  - -

-

-Package org.openexi.schema Description -

- -

- - - - - -
-

The schema package contains classes that are used to represent XML Schema Documents (XSDs). EXISchema.writeOut writes an EXISchema to a DataOutputStream (which is typically saved to disk). EXISchema.readIn returns an EXISchema from a DataInputStream (typically from a file on disk), saving the step of processing the schema at runtime. -

-

-EmptySchema is used to create an explicit schema object with default settings. This is to enable the EXIDecoder and Transmogrifier to process element tags that have embedded datatype overrides. -

- -
-

-

- -

-

- -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-tree.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-tree.html deleted file mode 100644 index dda7f6246f..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-tree.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - -org.openexi.schema Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For Package org.openexi.schema -

-
-
-
Package Hierarchies:
All Packages
-
-

-Class Hierarchy -

- -
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactory.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactory.html deleted file mode 100644 index 7a95df8e6d..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactory.html +++ /dev/null @@ -1,308 +0,0 @@ - - - - - - - -EXISchemaFactory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.scomp -
-Class EXISchemaFactory

-
-java.lang.Object
-  extended by EXISchemaStruct
-      extended by org.openexi.scomp.EXISchemaFactory
-
-
-
-
public class EXISchemaFactory
extends EXISchemaStruct
- - -

-EXISchemaFactory compiles XML Schema into an EXISchema instance. -

- -

-

- -
-
- -

- - - - - - - - - - - -
-Constructor Summary
EXISchemaFactory() - -
-           
-  - - - - - - - - - - - - - - - - - - - -
-Method Summary
- EXISchemacompile(org.xml.sax.InputSource inputSource) - -
-          Compile an XML Schema Document into an EXISchema.
- voidsetCompilerErrorHandler(EXISchemaFactoryErrorHandler errorHandler) - -
-          Set an error handler to report any errors encountered during - schema compilation.
- voidsetEntityResolver(EntityResolverEx entityResolver) - -
-          Set an entity resolver for use to resolve entities and schema documents.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Constructor Detail
- -

-EXISchemaFactory

-
-public EXISchemaFactory()
-
-
- - - - - - - - -
-Method Detail
- -

-setCompilerErrorHandler

-
-public void setCompilerErrorHandler(EXISchemaFactoryErrorHandler errorHandler)
-
-
Set an error handler to report any errors encountered during - schema compilation. -

-

-
Parameters:
errorHandler - Error handler
-
-
-
- -

-setEntityResolver

-
-public void setEntityResolver(EntityResolverEx entityResolver)
-
-
Set an entity resolver for use to resolve entities and schema documents. -

-

-
Parameters:
entityResolverEx - extended SAX entity resolver
-
-
-
- -

-compile

-
-public final EXISchema compile(org.xml.sax.InputSource inputSource)
-                        throws java.io.IOException,
-                               EXISchemaFactoryException
-
-
Compile an XML Schema Document into an EXISchema. -

-

-
Parameters:
is - XML Schema Document stream from an InputSource -
Returns:
an EXISchema instance -
Throws: -
java.io.IOException -
EXISchemaFactoryException
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactoryErrorHandler.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactoryErrorHandler.html deleted file mode 100644 index 48648e4635..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactoryErrorHandler.html +++ /dev/null @@ -1,268 +0,0 @@ - - - - - - - -EXISchemaFactoryErrorHandler - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.scomp -
-Interface EXISchemaFactoryErrorHandler

-
-
-
public interface EXISchemaFactoryErrorHandler
- - -

-This interface reports exceptions from EXISchemaFactory during schema - processing. Users of EXISchemaFactory need to provide an - implementation of this interface to receive errors from EXISchemaFactory. -

- -

-

-
Author:
-
Dennis Dawson
- -
-
- -

- - - - - - - - - - - - - - - - - - - - -
-Method Summary
- voiderror(EXISchemaFactoryException exc) - -
-          Report an error found during schema processing.
- voidfatalError(EXISchemaFactoryException exc) - -
-          Report a fatal error found during schema processing.
- voidwarning(EXISchemaFactoryException exc) - -
-          Report a warning found during schema processing.
-  -

- - - - - - - - -
-Method Detail
- -

-warning

-
-void warning(EXISchemaFactoryException exc)
-             throws EXISchemaFactoryException
-
-
Report a warning found during schema processing. -

-

-
Parameters:
exc - warning found -
Throws: -
EXISchemaFactoryException - at the discretion of the application
-
-
-
- -

-error

-
-void error(EXISchemaFactoryException exc)
-           throws EXISchemaFactoryException
-
-
Report an error found during schema processing. Note that errors are - recoverable only as far as the schema processor is concerned. They might - be fatal at the application level. -

-

-
Parameters:
exc - error found -
Throws: -
EXISchemaFactoryException - at the discretion of the application
-
-
-
- -

-fatalError

-
-void fatalError(EXISchemaFactoryException exc)
-                throws EXISchemaFactoryException
-
-
Report a fatal error found during schema processing. -

-

-
Parameters:
exc - fatal error found -
Throws: -
EXISchemaFactoryException - at the discretion of the application
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactoryException.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactoryException.html deleted file mode 100644 index 598f7db597..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactoryException.html +++ /dev/null @@ -1,350 +0,0 @@ - - - - - - - -EXISchemaFactoryException - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.scomp -
-Class EXISchemaFactoryException

-
-java.lang.Object
-  extended by java.lang.Throwable
-      extended by java.lang.Exception
-          extended by org.openexi.scomp.EXISchemaFactoryException
-
-
-
All Implemented Interfaces:
java.io.Serializable
-
-
-
-
public class EXISchemaFactoryException
extends java.lang.Exception
- - -

-Any errors encountered during schema compilation are communicated to - an application as EXISchemaFactoryException objects. -

- -

-

-
See Also:
EXISchemaFactoryErrorHandler, -Serialized Form
Author:
-
Dennis Dawson
- -
-
- -

- - - - - - - - - - - -
-Field Summary
-static intXMLSCHEMA_ERROR - -
-          The underlying XMLSchema parser found an error in the schema.
-  - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- intgetCode() - -
-          Returns a code that represents the type of the exception.
- java.lang.ExceptiongetException() - -
-          Returns an Exception object.
- org.xml.sax.LocatorgetLocator() - -
-          Returns the locator that is associated with this compilation error.
- java.lang.StringgetMessage() - -
-          Returns a message that describes the exception.
- - - - - - - -
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-  -

- - - - - - - - -
-Field Detail
- -

-XMLSCHEMA_ERROR

-
-public static final int XMLSCHEMA_ERROR
-
-
The underlying XMLSchema parser found an error in the schema. -

-

-
See Also:
Constant Field Values
-
- - - - - - - - -
-Method Detail
- -

-getCode

-
-public int getCode()
-
-
Returns a code that represents the type of the exception. -

-

- -
Returns:
error code
-
-
-
- -

-getMessage

-
-public java.lang.String getMessage()
-
-
Returns a message that describes the exception. -

-

-
Overrides:
getMessage in class java.lang.Throwable
-
-
- -
Returns:
error message
-
-
-
- -

-getException

-
-public java.lang.Exception getException()
-
-
Returns an Exception object. -

-

- -
Returns:
an Exception instance for the current exception.
-
-
-
- -

-getLocator

-
-public org.xml.sax.Locator getLocator()
-
-
Returns the locator that is associated with this compilation error. -

-

- -
Returns:
a Locator if available, otherwise null
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaReader.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaReader.html deleted file mode 100644 index 6249b50feb..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaReader.html +++ /dev/null @@ -1,264 +0,0 @@ - - - - - - - -EXISchemaReader - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.scomp -
-Class EXISchemaReader

-
-java.lang.Object
-  extended by EXISchemaStruct
-      extended by org.openexi.scomp.EXISchemaReader
-
-
-
-
public final class EXISchemaReader
extends EXISchemaStruct
- - -

-EXISchemaReader parses EXI-encoded EXI Grammar into an EXISchema. -

- -

-

- -
-
- -

- - - - - - - - - - - -
-Constructor Summary
EXISchemaReader() - -
-           
-  - - - - - - - - - - - -
-Method Summary
- EXISchemaparse(java.io.InputStream inputStream) - -
-          Parses EXI-encoded EXI Grammar into an EXISchema.
- - - - - - - -
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-  -

- - - - - - - - -
-Constructor Detail
- -

-EXISchemaReader

-
-public EXISchemaReader()
-
-
- - - - - - - - -
-Method Detail
- -

-parse

-
-public EXISchema parse(java.io.InputStream inputStream)
-                throws java.io.IOException,
-                       org.openexi.proc.common.EXIOptionsException
-
-
Parses EXI-encoded EXI Grammar into an EXISchema. -

-

-
Parameters:
inputStream - EXI-encoded EXI Grammar -
Returns:
EXISchema -
Throws: -
java.io.IOException -
org.openexi.proc.common.EXIOptionsException
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EntityResolverEx.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EntityResolverEx.html deleted file mode 100644 index cd12bdddb1..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EntityResolverEx.html +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - - -EntityResolverEx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -

- -org.openexi.scomp -
-Interface EntityResolverEx

-
-
All Superinterfaces:
org.xml.sax.EntityResolver
-
-
-
-
public interface EntityResolverEx
extends org.xml.sax.EntityResolver
- - -

-Extended SAX EntityResolver interface for resolving entities and - schema documents. -

- -

-

- -
-
- -

- - - - - - - - - - - - -
-Method Summary
- org.xml.sax.InputSourceresolveEntity(java.lang.String publicId, - java.lang.String systemId, - java.lang.String namespaceURI) - -
-          This method will be called for resolving schema documents upon - occurrences of XML Schema directives such as "include", "import" and - "redefine" within schemas.
- - - - - - - -
Methods inherited from interface org.xml.sax.EntityResolver
resolveEntity
-  -

- - - - - - - - -
-Method Detail
- -

-resolveEntity

-
-org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
-                                      java.lang.String systemId,
-                                      java.lang.String namespaceURI)
-                                      throws org.xml.sax.SAXException,
-                                             java.io.IOException
-
-
This method will be called for resolving schema documents upon - occurrences of XML Schema directives such as "include", "import" and - "redefine" within schemas. -

-

-
-
-
-
Parameters:
publicId - Public identifier of the schema document that is being resolved
systemId - System identifier of the schema document that is being resolved
namespaceURI - Target namespace name of the schema document that is being resolved -
Returns:
InputSource that represents the schema document if resolved otherwise null -
Throws: -
org.xml.sax.SAXException -
java.io.IOException
-
-
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-frame.html deleted file mode 100644 index 65600a98d7..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-frame.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - -org.openexi.scomp - - - - - - - - - - - -org.openexi.scomp - - - - -
-Interfaces  - -
-EntityResolverEx -
-EXISchemaFactoryErrorHandler
- - - - - - -
-Classes  - -
-EXISchemaFactory -
-EXISchemaReader
- - - - - - -
-Exceptions  - -
-EXISchemaFactoryException
- - - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-summary.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-summary.html deleted file mode 100644 index a35b92a223..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-summary.html +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - -org.openexi.scomp - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-

-Package org.openexi.scomp -

- - - -The scomp (schema compiler) package contains the EXISchemaFactory, which is used to compile XML Schema Documents (XSDs) to EXISchemas. -

-See: -
-          Description -

- - - - - - - - - - - - - -
-Interface Summary
EntityResolverExExtended SAX EntityResolver interface for resolving entities and - schema documents.
EXISchemaFactoryErrorHandlerThis interface reports exceptions from EXISchemaFactory during schema - processing.
-  - -

- - - - - - - - - - - - - -
-Class Summary
EXISchemaFactoryEXISchemaFactory compiles XML Schema into an EXISchema instance.
EXISchemaReaderEXISchemaReader parses EXI-encoded EXI Grammar into an EXISchema.
-  - -

- - - - - - - - - -
-Exception Summary
EXISchemaFactoryExceptionAny errors encountered during schema compilation are communicated to - an application as EXISchemaFactoryException objects.
-  - -

-

-Package org.openexi.scomp Description -

- -

- - - - - -
-

The scomp (schema compiler) package contains the EXISchemaFactory, which is used to compile XML Schema Documents (XSDs) to EXISchemas. Developers can implement the interface EXISchemaFactoryErrorHandler to capture and report runtime exceptions from EXISchemaFactory. -

-
- -
-

-

- -

-

- -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-tree.html b/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-tree.html deleted file mode 100644 index 93d1752d5a..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-tree.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - -org.openexi.scomp Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For Package org.openexi.scomp -

-
-
-
Package Hierarchies:
All Packages
-
-

-Class Hierarchy -

- -

-Interface Hierarchy -

- -
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/overview-frame.html b/third-party/org.openexi/nagasena/src/main/resources/doc/overview-frame.html deleted file mode 100644 index 045191d7df..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/overview-frame.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - -Overview - - - - - - - - - - - - - - - -
-
- - - - - -
All Classes -

- -Packages -
-org.openexi.proc -
-org.openexi.proc.common -
-org.openexi.proc.grammars -
-org.openexi.proc.io -
-org.openexi.sax -
-org.openexi.schema -
-org.openexi.scomp -
-

- -

-  - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/overview-summary.html b/third-party/org.openexi/nagasena/src/main/resources/doc/overview-summary.html deleted file mode 100644 index 1a299fd622..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/overview-summary.html +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - - -Overview - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -


-
-

-OpenEXI Nagasena -

-
- - - -OpenEXI is a W3C open source API for converting XML files to the Efficient XML Interchange format (EXI). -

-See: -
-          Description -

- - - - - - - - - -The Proc (Processor) package contains the EXIDecoder, which is used to convert EXI streams to XML format. - - - - - -The common package contains classes, interfaces, and enumerators that define the vocabulary used to describe EXI streams (events, options, alignment, and character string values). - - - - - -The grammars package contains the GrammarCache, which combines an XML Schema Definition with EXI grammar options to create an EXI Schema. - - - - - -The IO package contains the Scanner, which is used by EXIDecoder to read and interpret EXI streams. - - - - - -The SAX package contains the Transmogrifier, which encodes an XML file to an EXI stream, and the EXIReader, which restores an EXI stream to its logical XML equivalent. - - - - - -The schema package contains classes that are used to represent XML Schema Documents (XSDs). - - - - - -The scomp (schema compiler) package contains the EXISchemaFactory, which is used to compile XML Schema Documents (XSDs) to EXISchemas. - -
-Packages
org.openexi.proc -
org.openexi.proc.common -
org.openexi.proc.grammars -
org.openexi.proc.io -
org.openexi.sax -
org.openexi.schema -
org.openexi.scomp -
- -

-

- - - - - -
-

OpenEXI is a W3C open source API for converting XML files to the Efficient XML Interchange format (EXI). -

-

You can learn more about OpenEXI by visiting the OpenEXI homepage at openexi.sourceforge.net. -

- -
-

-

- -

-

- -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/overview-tree.html b/third-party/org.openexi/nagasena/src/main/resources/doc/overview-tree.html deleted file mode 100644 index 8409fdb317..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/overview-tree.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - -Class Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Hierarchy For All Packages

-
-
-
Package Hierarchies:
org.openexi.proc, org.openexi.proc.common, org.openexi.proc.grammars, org.openexi.proc.io, org.openexi.sax, org.openexi.schema, org.openexi.scomp
-
-

-Class Hierarchy -

- -

-Interface Hierarchy -

- -

-Enum Hierarchy -

-
    -
  • java.lang.Object -
-
- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/package-list b/third-party/org.openexi/nagasena/src/main/resources/doc/package-list deleted file mode 100644 index 746aadc8bd..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/package-list +++ /dev/null @@ -1,7 +0,0 @@ -org.openexi.proc -org.openexi.proc.common -org.openexi.proc.grammars -org.openexi.proc.io -org.openexi.sax -org.openexi.schema -org.openexi.scomp diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/resources/inherit.gif b/third-party/org.openexi/nagasena/src/main/resources/doc/resources/inherit.gif deleted file mode 100644 index c814867a13..0000000000 Binary files a/third-party/org.openexi/nagasena/src/main/resources/doc/resources/inherit.gif and /dev/null differ diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/serialized-form.html b/third-party/org.openexi/nagasena/src/main/resources/doc/serialized-form.html deleted file mode 100644 index c3688f526d..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/serialized-form.html +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - -Serialized Form - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
-
-

-Serialized Form

-
-
- - - - - -
-Package org.openexi.sax
- -

- - - - - -
-Class org.openexi.sax.TransmogrifierException extends java.lang.Exception implements Serializable
- -

-serialVersionUID: -4536662596727577640L - -

- - - - - -
-Serialized Fields
- -

-m_code

-
-int m_code
-
-
-
-
-
-

-m_message

-
-java.lang.String m_message
-
-
-
-
-
-

-m_exception

-
-java.lang.Exception m_exception
-
-
-
-
-
-

-m_locator

-
-org.xml.sax.Locator m_locator
-
-
-
-
-
- - - - - -
-Package org.openexi.scomp
- -

- - - - - -
-Class org.openexi.scomp.EXISchemaFactoryException extends java.lang.Exception implements Serializable
- -

-serialVersionUID: 3816521974819647026L - -

- - - - - -
-Serialized Fields
- -

-m_code

-
-int m_code
-
-
-
-
-
-

-m_message

-
-java.lang.String m_message
-
-
-
-
-
-

-m_exception

-
-java.lang.Exception m_exception
-
-
-
-
-
-

-m_locator

-
-org.xml.sax.Locator m_locator
-
-
-
-
- -

-


- - - - - - - - - - - - - - - -
- -
- - - -
- - - diff --git a/third-party/org.openexi/nagasena/src/main/resources/doc/stylesheet.css b/third-party/org.openexi/nagasena/src/main/resources/doc/stylesheet.css deleted file mode 100644 index 14c3737e8a..0000000000 --- a/third-party/org.openexi/nagasena/src/main/resources/doc/stylesheet.css +++ /dev/null @@ -1,29 +0,0 @@ -/* Javadoc style sheet */ - -/* Define colors, fonts and other style attributes here to override the defaults */ - -/* Page background color */ -body { background-color: #FFFFFF } - -/* Headings */ -h1 { font-size: 145% } - -/* Table colors */ -.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ -.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ -.TableRowColor { background: #FFFFFF } /* White */ - -/* Font used in left-hand frame lists */ -.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } -.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } -.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } - -/* Navigation bar fonts and colors */ -.NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ -.NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ -.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} -.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} - -.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} -.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} - diff --git a/third-party/org.openexi/pom.xml b/third-party/org.openexi/pom.xml deleted file mode 100644 index 6369b294ba..0000000000 --- a/third-party/org.openexi/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - 4.0.0 - - - org.opendaylight.controller - commons.thirdparty - 1.1.2-SNAPSHOT - ../commons/thirdparty - - - org.opendaylight.controller.thirdparty - org.openexi - 0000.0002.0038.0-SNAPSHOT - pom - - 3.0.4 - - - - nagasena - nagasena-rta - - - - - - - org.codehaus.mojo - truezip-maven-plugin - 1.1 - - - org.apache.felix - maven-bundle-plugin - 2.4.0 - - - - - -