<artifactId>sal.implementation</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>clustering.services-implementation</artifactId>
<version>0.4.0-SNAPSHOT</version>
<!--
Used to register JMX statistics in any available MBean server
-->
- <jmxStatistics enabled="true"/>
+ <jmxStatistics enabled="true"/>
</default>
<!-- transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" -->
<namedCache name="transactional-type">
<version>0.8.0.v201110170705</version>
</dependency>
</dependencies>
-
+
<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>maven-paxexam-plugin</artifactId>
<configuration scan="true">
-
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
-
+
<root level="error">
<appender-ref ref="STDOUT" />
</root>
<projectinfo>2.6</projectinfo>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>2.3.2</compiler.version>
- <surefire.version>2.13</surefire.version>
+ <surefire.version>2.15</surefire.version>
+ <failsafe.version>2.15</failsafe.version>
<exam.version>3.0.0</exam.version>
<url.version>1.5.0</url.version>
<enunciate.version>1.26.2</enunciate.version>
<configLocation>${project.parent.basedir}/space_and_tabs_checks.xml</configLocation>
<consoleOutput>true</consoleOutput>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <sourceDirectory>${project.basedir}</sourceDirectory>
+ <includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>2.14.1</version>
+ <version>${failsafe.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
- <goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<configuration scan="true">
-
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
-
+
<root level="error">
<appender-ref ref="STDOUT" />
</root>
--- /dev/null
+configuration
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+<parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.integrationtest</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath>../../commons/integrationtest</relativePath>
+ </parent>
+ <artifactId>configuration.integrationtest</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>protocol_plugins.stub</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>forwardingrulesmanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services-implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.stub</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>containermanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>containermanager.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topologymanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package org.opendaylight.controller.configuration.internal;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.File;
+
+import javax.inject.Inject;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.configuration.IConfigurationService;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.PathUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(PaxExam.class)
+public class ConfigurationIT {
+ private Logger logger = LoggerFactory
+ .getLogger(ConfigurationIT.class);
+ // get the OSGI bundle context
+ @Inject
+ private BundleContext bc;
+ private IClusterServices clusterService = null;
+ private IConfigurationService configService = null;
+
+ // Configure the OSGi container
+ @Configuration
+ public Option[] config() {
+ return options(
+ systemProperty("logback.configurationFile").value(
+ "file:" + PathUtils.getBaseDir()
+ + "/src/test/resources/logback.xml"),
+ // To start OSGi console for inspection remotely
+ systemProperty("osgi.console").value("2401"),
+ // Set the systemPackages (used by clustering)
+ systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
+ // List framework bundles
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
+ "1.0.0.v20120522-1841"),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
+ "1.0.400.v20120522-2049"),
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
+ "3.3.100.v20120522-1822"),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
+ "1.4.0.v20120522-1841"),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
+ "0.8.0.v201108120515"),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
+ "0.8.0.v201108120515"),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
+ "0.8.0.v201110170705"),
+ // List logger bundles
+ mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
+ mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
+ mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
+ mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
+ mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
+ mavenBundle("org.jboss.spec.javax.transaction",
+ "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
+ mavenBundle("org.apache.felix",
+ "org.apache.felix.dependencymanager", "3.1.0"),
+ // List all the bundles on which the test case depends
+ mavenBundle("org.opendaylight.controller", "sal",
+ "0.5.0-SNAPSHOT"), // SAL connects the protocols
+ // plug-ins to other stuff
+ mavenBundle("org.opendaylight.controller",
+ "sal.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
+ // needed bundles by switchmanager
+ mavenBundle("org.opendaylight.controller", "containermanager",
+ "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "containermanager.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "switchmanager",
+ "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "switchmanager.implementation", "0.4.0-SNAPSHOT"),
+ // needed bundles by configuration
+ mavenBundle("org.opendaylight.controller",
+ "clustering.services", "0.4.0-SNAPSHOT"), // what are
+ // the
+ // clustering
+ // services
+ // for
+ mavenBundle("org.opendaylight.controller", "clustering.stub",
+ "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "clustering.services-implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "configuration",
+ "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "configuration.implementation", "0.4.0-SNAPSHOT"),
+ junitBundles());
+ }
+
+ private String stateToString(int state) {
+ switch (state) {
+ case Bundle.ACTIVE:
+ return "ACTIVE";
+ case Bundle.INSTALLED:
+ return "INSTALLED";
+ case Bundle.RESOLVED:
+ return "RESOLVED";
+ case Bundle.UNINSTALLED:
+ return "UNINSTALLED";
+ default:
+ return "Not CONVERTED";
+ }
+ }
+
+ @Before
+ public void areWeReadyForClustering() {
+ assertNotNull(bc);
+ boolean debugit = false;
+ Bundle b[] = bc.getBundles();
+ for (int i = 0; i < b.length; i++) {
+ int state = b[i].getState();
+ if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
+ logger.debug("Bundle:" + b[i].getSymbolicName() + " state:"
+ + stateToString(state));
+ debugit = true;
+ }
+ }
+ if (debugit) {
+ logger.debug("Do some debugging because some bundle is unresolved");
+ }
+
+ // Assert if true, if false we are good to go!
+ assertFalse(debugit);
+ ServiceReference r = bc.getServiceReference(IClusterServices.class
+ .getName());
+ if (r != null) {
+ this.clusterService = (IClusterServices) bc.getService(r);
+ }
+ // If StatisticsManager is null, cannot run tests.
+ assertNotNull(this.clusterService);
+
+ }
+
+ @Before
+ public void areWeReadyForConfiguration() {
+ assertNotNull(bc);
+ boolean debugit = false;
+ Bundle b[] = bc.getBundles();
+ for (int i = 0; i < b.length; i++) {
+ int state = b[i].getState();
+ if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
+ logger.debug("Bundle:" + b[i].getSymbolicName() + " state:"
+ + stateToString(state));
+ debugit = true;
+ }
+ }
+ if (debugit) {
+ logger.debug("Do some debugging because some bundle is unresolved");
+ }
+
+ // Assert if true, if false we are good to go!
+ assertFalse(debugit);
+ ServiceReference r = bc.getServiceReference(IConfigurationService.class
+ .getName());
+ if (r != null) {
+ this.configService = (IConfigurationService) bc.getService(r);
+ }
+ // If StatisticsManager is null, cannot run tests.
+ assertNotNull(this.configService);
+
+ }
+
+ @Test
+ public void saveConfiguration() {
+ File f = new File(GlobalConstants.STARTUPHOME.toString());
+ boolean success = f.exists();
+ if (!success) {
+ success = f.mkdirs();
+ }
+ if(success){
+ Status status = new Status(StatusCode.SUCCESS, null);
+ if (this.configService != null) {
+ status = this.configService.saveConfigurations();
+ }
+ if (status.getCode().equals(StatusCode.SUCCESS)) {
+ Assert.assertTrue("Successfully saved config for "
+ + configService.getClass().getSimpleName(), status
+ .getCode().equals(StatusCode.SUCCESS));
+ } else {
+ Assert.assertFalse("Failed to save config for "
+ + configService.getClass().getSimpleName(), status
+ .getCode().equals(StatusCode.INTERNALERROR));
+ }
+ }
+ }
+
+}
--- /dev/null
+<configuration scan="true">
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <root level="error">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
<artifactId>containermanager</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal</artifactId>
<version>0.5.0-SNAPSHOT</version>
- </dependency>
+ </dependency>
</dependencies>
</project>
<module>../../clustering/test</module>
<module>../../configuration/api</module>
<module>../../configuration/implementation</module>
+ <module>../../configuration/integrationtest</module>
<module>../../routing/dijkstra_implementation</module>
<module>../../arphandler</module>
<module>../../forwardingrulesmanager/api</module>
<module>../../statisticsmanager/implementation</module>
<module>../../statisticsmanager/integrationtest</module>
<module>../../topologymanager</module>
- <module>../../usermanager</module>
+ <module>../../usermanager/api</module>
+ <module>../../usermanager/implementation</module>
<module>../../security</module>
<module>../../samples/northbound/loadbalancer</module>
<module>../../commons/concepts</module>
<module>../../commons/integrationtest</module>
-
+
</modules>
<build>
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>osgipackage</id>
<formats>
<format>dir</format>
<excludes>
<exclude>org.opendaylight.controller.thirdparty:org.openflow.openflowj</exclude>
<exclude>org.opendaylight.controller:clustering.stub</exclude>
- <exclude>org.opendaylight.controller:logging.bridge</exclude>
- <exclude>org.opendaylight.controller:protocol_plugins.stub</exclude>
- <exclude>org.opendaylight.controller:*.integrationtest</exclude>
+ <exclude>org.opendaylight.controller:logging.bridge</exclude>
+ <exclude>org.opendaylight.controller:protocol_plugins.stub</exclude>
+ <exclude>org.opendaylight.controller:*.integrationtest</exclude>
<exclude>org.opendaylight.controller:hosttracker_new</exclude>
<exclude>org.opendaylight.controller:hosttracker_new.implementation</exclude>
</excludes>
<includeDependencies>false</includeDependencies>
</binaries>
</moduleSet>
- <moduleSet>
- <includes>
- <include>org.opendaylight.controller:logging.bridge</include>
- </includes>
- <binaries>
- <outputDirectory>opendaylight/lib</outputDirectory>
- <outputFileNameMapping>
- ${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
- </outputFileNameMapping>
- <unpack>false</unpack>
- <includeDependencies>false</includeDependencies>
- </binaries>
- </moduleSet>
+ <moduleSet>
+ <includes>
+ <include>org.opendaylight.controller:logging.bridge</include>
+ </includes>
+ <binaries>
+ <outputDirectory>opendaylight/lib</outputDirectory>
+ <outputFileNameMapping>
+ ${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
+ </outputFileNameMapping>
+ <unpack>false</unpack>
+ <includeDependencies>false</includeDependencies>
+ </binaries>
+ </moduleSet>
</moduleSets>
<dependencySets>
<dependencySet>
<exclude>virgomirror:org.eclipse.jdt.core.compiler.batch</exclude>
<exclude>org.apache.felix:org.apache.felix.fileinstall</exclude>
<exclude>geminiweb:org.eclipse.virgo.kernel.equinox.extensions</exclude>
- <exclude>org.slf4j:slf4j-api</exclude>
- <exclude>ch.qos.logback:logback-core</exclude>
- <exclude>ch.qos.logback:logback-classic</exclude>
- <exclude>com.sun.jersey:jersey-core</exclude>
- <exclude>com.sun.jersey:jersey-json</exclude>
- <exclude>com.sun.jersey:jersey-server</exclude>
+ <exclude>org.slf4j:slf4j-api</exclude>
+ <exclude>ch.qos.logback:logback-core</exclude>
+ <exclude>ch.qos.logback:logback-classic</exclude>
+ <exclude>com.sun.jersey:jersey-core</exclude>
+ <exclude>com.sun.jersey:jersey-json</exclude>
+ <exclude>com.sun.jersey:jersey-server</exclude>
</excludes>
<outputFileNameMapping>
- ${artifact.groupId}.${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
+ ${artifact.groupId}.${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
</outputFileNameMapping>
<unpack>false</unpack>
<scope>runtime</scope>
<include>virgomirror:org.eclipse.jdt.core.compiler.batch</include>
<include>org.apache.felix:org.apache.felix.fileinstall</include>
<include>geminiweb:org.eclipse.virgo.kernel.equinox.extensions</include>
- <include>org.slf4j:slf4j-api</include>
- <include>ch.qos.logback:logback-core</include>
- <include>ch.qos.logback:logback-classic</include>
- <include>com.sun.jersey:jersey-core</include>
- <include>com.sun.jersey:jersey-json</include>
- <include>com.sun.jersey:jersey-server</include>
+ <include>org.slf4j:slf4j-api</include>
+ <include>ch.qos.logback:logback-core</include>
+ <include>ch.qos.logback:logback-classic</include>
+ <include>com.sun.jersey:jersey-core</include>
+ <include>com.sun.jersey:jersey-json</include>
+ <include>com.sun.jersey:jersey-server</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputFileNameMapping>
- ${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
+ ${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
</outputFileNameMapping>
<unpack>false</unpack>
<scope>runtime</scope>
osgi.bundles=\
- reference\:file\:../lib/org.apache.felix.fileinstall-3.1.6.jar@1:start,\
- reference\:file\:../lib/org.eclipse.jdt.core.compiler.batch-3.8.0.I20120518-2145.jar@1:start,\
- reference\:file\:../lib/org.eclipse.equinox.ds-1.4.0.v20120522-1841.jar@2:start,\
- reference\:file\:../lib/org.eclipse.equinox.util-1.0.400.v20120522-2049.jar@2:start,\
- reference\:file\:../lib/org.eclipse.osgi.services-3.3.100.v20120522-1822@2:start,\
- reference\:file\:../lib/org.eclipse.equinox.console-1.0.0.v20120522-1841.jar@start,\
- reference\:file\:../lib/slf4j-api-1.7.2.jar@1:start,\
- reference\:file\:../lib/logback-classic-1.0.9.jar@1:start,\
- reference\:file\:../lib/logback-core-1.0.9.jar@1:start,\
+ reference\:file\:../lib/org.apache.felix.fileinstall-3.1.6.jar@1:start,\
+ reference\:file\:../lib/org.eclipse.jdt.core.compiler.batch-3.8.0.I20120518-2145.jar@1:start,\
+ reference\:file\:../lib/org.eclipse.equinox.ds-1.4.0.v20120522-1841.jar@2:start,\
+ reference\:file\:../lib/org.eclipse.equinox.util-1.0.400.v20120522-2049.jar@2:start,\
+ reference\:file\:../lib/org.eclipse.osgi.services-3.3.100.v20120522-1822@2:start,\
+ reference\:file\:../lib/org.eclipse.equinox.console-1.0.0.v20120522-1841.jar@start,\
+ reference\:file\:../lib/slf4j-api-1.7.2.jar@1:start,\
+ reference\:file\:../lib/logback-classic-1.0.9.jar@1:start,\
+ reference\:file\:../lib/logback-core-1.0.9.jar@1:start,\
reference\:file\:../lib/logging.bridge-0.4.0-SNAPSHOT@1:start,\
reference\:file\:../lib/jersey-core-1.17.jar@2:start,\
reference\:file\:../lib/jersey-json-1.17.jar@2:start,\
org.osgi.framework.system.packages.extra=sun.reflect,sun.reflect.misc,sun.misc
# This is not Eclipse App
eclipse.ignoreApp=true
-# Don't shutdown equinox if the eclipse App has ended,
+# Don't shutdown equinox if the eclipse App has ended,
# which is our case because we are not running any eclipse application
osgi.noShutdown=true
# Clean any cached data on restart of the framework
felix.fileinstall.noInitialDelay=true
# Auto start the bundles at level 4
felix.fileinstall.start.level=4
-# Avoid to auto-install following bundles, that means those need
+# Avoid to auto-install following bundles, that means those need
# to be started manually or in other way like osgi.bundles
felix.fileinstall.filter=^(?!org.apache.felix.fileinstall).*
# TLS configuration
# To enable TLS, set secureChannelEnabled=true and specify the location of controller Java KeyStore and TrustStore files.
-# The Java KeyStore contains controller's private key and certificate. The Java TrustStore contains the trusted certificate
+# The Java KeyStore contains controller's private key and certificate. The Java TrustStore contains the trusted certificate
# entries, including switches' Certification Authority (CA) certificates. For example,
# secureChannelEnabled=true
# controllerKeyStore=./configuration/ctlKeyStore
<logger name="org.opendaylight.controller.topologymanager" level="INFO"/>
<logger name="org.opendaylight.controller.usermanager" level="INFO"/>
<!-- Web modules -->
- <logger name="org.opendaylight.controller.web" level="INFO"/>
+ <logger name="org.opendaylight.controller.web" level="INFO"/>
</configuration>
connectionTimeout="20000"
redirectPort="8443" />
-<!--
- Please remove the comments around the following Connector tag to enable HTTPS Authentication support.
- Remember to add a valid keystore in the configuration folder.
- More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+<!--
+ Please remove the comments around the following Connector tag to enable HTTPS Authentication support.
+ Remember to add a valid keystore in the configuration folder.
+ More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
-->
-
- <!--
+
+ <!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
unpackWARs="false" autoDeploy="false"
deployOnStartup="false" createDirs="false">
<Realm className="org.opendaylight.controller.security.ControllerCustomRealm" />
- <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="web_access_log_" suffix=".txt" resolveHosts="false"
- rotatable="true" fileDateFormat="yyyy-MM"
- pattern="%{yyyy-MM-dd HH:mm:ss.SSS z}t - [%a] - %r"/>
-
+ prefix="web_access_log_" suffix=".txt" resolveHosts="false"
+ rotatable="true" fileDateFormat="yyyy-MM"
+ pattern="%{yyyy-MM-dd HH:mm:ss.SSS z}t - [%a] - %r"/>
+
</Host>
</Engine>
</Service>
SETLOCAL
SETLOCAL ENABLEDELAYEDEXPANSION
IF EXIST "%JAVA_HOME%" (
- set basedir=%~dp0
+ set basedir=%~dp0
REM Now set the classpath:
set cp="!basedir!lib\org.eclipse.osgi-3.8.1.v20120830-144521.jar;!basedir!lib\org.eclipse.virgo.kernel.equinox.extensions-3.6.0.RELEASE.jar;!basedir!lib\org.eclipse.equinox.launcher-1.3.0.v20120522-1813.jar"
ECHO JAVA_HOME environment variable is not set
PAUSE
)
-ENDLOCAL
\ No newline at end of file
+ENDLOCAL
<artifactId>distribution.p2site</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
-
+
<build>
<plugins>
<plugin>
--- /dev/null
+OVERVIEW
+========
+This distribution is built to allow to deploy all the commons parents
+in one shot. This is needed because the way how maven works when a
+"mvn deploy" is called on a multi-module project, only the modules
+that are listed in there are deployed. All the opendaylight modules
+has a parent, those parents module will not be deployed when deploying
+a distribution hence if someone tries to compile a module without
+compiling the whole system it will run in missing parent errors.
+To address the issue this distribution will collect all the known
+parents and deploy them in one shot.
+
+The user of this distribution is one of the Jenkins jobs and not
+developers.
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+ <artifactId>distribution.parents</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>../../commons/concepts</module>
+ <module>../../commons/integrationtest</module>
+ <module>../../commons/opendaylight</module>
+ <module>../../../third-party/commons/thirdparty</module>
+ </modules>
+</project>
<!-- Northbound common hooks -->
<module>../../northbound/commons</module>
</modules>
-
+
<build>
<plugins>
<plugin>
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>package</id>
<groupId>org.opendaylight.controller</groupId>
<artifactId>configuration</artifactId>
<version>0.4.0-SNAPSHOT</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.core.Host;
import org.opendaylight.controller.sal.core.Node;
return !Arrays.equals(emptyArray, macaddr);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
- return "HostNodeConnector[" + ReflectionToStringBuilder.toString(this)
- + "]";
+ return "HostNodeConnector [nodeConnector=" + nodeConnector + ", vlan="
+ + vlan + ", staticHost=" + staticHost + "]";
}
public boolean isV4Host() {
org.opendaylight.controller.sal.authorization,
org.opendaylight.controller.containermanager,
org.opendaylight.controller.usermanager,
- javax.servlet.http,
+ javax.servlet.http,
org.slf4j
</Import-Package>
</instructions>
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/flow"/>
</services>
<version>0.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
org.opendaylight.controller.northbound.commons.utils,
org.opendaylight.controller.sal.authorization,
org.opendaylight.controller.usermanager,
- com.sun.jersey.spi.container.servlet,
+ com.sun.jersey.spi.container.servlet,
javax.ws.rs,
javax.ws.rs.core,
javax.xml.bind.annotation,
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager</artifactId>
<version>0.4.0-SNAPSHOT</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>forwardingrulesmanager</artifactId>
<version>${enunciate.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.northbound</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.northbound</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>com.sun.jersey.jersey-servlet</artifactId>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
-
- <servlet>
- <servlet-name>JAXRSFlowProgrammer</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>org.opendaylight.controller.flowprogrammer.northbound.FlowProgrammerNorthboundRSApplication</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAXRSFlowProgrammer</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+
+ <servlet>
+ <servlet-name>JAXRSFlowProgrammer</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.opendaylight.controller.flowprogrammer.northbound.FlowProgrammerNorthboundRSApplication</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JAXRSFlowProgrammer</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
-
<security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
-
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/host"/>
</services>
<version>0.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSHostTracker</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
- <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId>
+ <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version> </dependency> -->
<dependency>
<groupId>com.sun.jersey</groupId>
</dependencies>
</project>
-
import org.opendaylight.controller.switchmanager.IInventoryListener;
import org.opendaylight.controller.usermanager.IUserManager;
-
@RunWith(PaxExam.class)
public class NorthboundIT {
- private Logger log = LoggerFactory
- .getLogger(NorthboundIT.class);
+ private Logger log = LoggerFactory.getLogger(NorthboundIT.class);
// get the OSGI bundle context
@Inject
private BundleContext bc;
}
@Test
- public void testSwitchManager() {
+ public void testSubnetsNorthbound() throws JSONException {
+ String baseURL = "http://127.0.0.1:8080/controller/nb/v2/subnet/";
+
+ String name1 = "testSubnet1";
+ String subnet1 = "1.1.1.1/24";
+ String name2 = "testSubnet2";
+ String subnet2 = "2.2.2.2/24";
+
+ // Test GET subnets in default container
+ String result = getJsonResult(baseURL + "default");
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ Assert.assertEquals("{}", result);
+
+ // Test GET subnet1 expecting 404
+ result = getJsonResult(baseURL + "default/" + name1);
+ Assert.assertEquals(404, httpResponseCode.intValue());
+
+ // Test POST subnet1
+ String queryParameter = new QueryParameter("subnetName", name1).add(
+ "subnet", subnet1).getString();
+ result = getJsonResult(baseURL + "default/" + name1 + queryParameter,
+ "POST");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ // Test GET subnet1
+ result = getJsonResult(baseURL + "default/" + name1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertEquals(200, httpResponseCode.intValue());
+ Assert.assertEquals(name1, json.getString("@name"));
+ Assert.assertEquals(subnet1, json.getString("@subnet"));
+
+ // Test POST subnet2
+ queryParameter = new QueryParameter("subnetName", name2).add("subnet",
+ subnet2).getString();
+ result = getJsonResult(baseURL + "default/" + name2 + queryParameter,
+ "POST");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ // Test GET all subnets in default container
+ result = getJsonResult(baseURL + "default");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONArray subnetConfigArray = json.getJSONArray("subnetConfig");
+ JSONObject subnetConfig;
+ Assert.assertEquals(2, subnetConfigArray.length());
+ for (int i = 0; i < subnetConfigArray.length(); i++) {
+ subnetConfig = subnetConfigArray.getJSONObject(i);
+ if (subnetConfig.getString("@name").equals(name1)) {
+ Assert.assertEquals(subnet1, subnetConfig.getString("@subnet"));
+ } else if (subnetConfig.getString("@name").equals(name2)) {
+ Assert.assertEquals(subnet2, subnetConfig.getString("@subnet"));
+ } else {
+ // Unexpected config name
+ Assert.assertTrue(false);
+ }
+ }
+
+ // Test DELETE subnet1
+ result = getJsonResult(baseURL + "default/" + name1, "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ // Test GET deleted subnet1
+ result = getJsonResult(baseURL + "default/" + name1);
+ Assert.assertEquals(404, httpResponseCode.intValue());
+
+ }
+
+ @Test
+ public void testStaticRoutingNorthbound() throws JSONException {
+ String baseURL = "http://127.0.0.1:8080/controller/nb/v2/staticroute/";
+
+ String name1 = "testRoute1";
+ String prefix1 = "192.168.1.1/24";
+ String nextHop1 = "0.0.0.0";
+ String name2 = "testRoute2";
+ String prefix2 = "192.168.1.1/16";
+ String nextHop2 = "1.1.1.1";
+
+ // Test GET static routes in default container, expecting no results
+ String result = getJsonResult(baseURL + "default");
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ Assert.assertEquals("{}", result);
+
+ // Test insert static route
+ String requestBody = "{\"name\":\"" + name1 + "\", \"prefix\":\""
+ + prefix1 + "\", \"nextHop\":\"" + nextHop1 + "\"}";
+ result = getJsonResult(baseURL + "default/" + name1, "POST",
+ requestBody);
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ requestBody = "{\"name\":\"" + name2 + "\", \"prefix\":\"" + prefix2
+ + "\", \"nextHop\":\"" + nextHop2 + "\"}";
+ result = getJsonResult(baseURL + "default/" + name2, "POST",
+ requestBody);
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ // Test Get all static routes
+ result = getJsonResult(baseURL + "default");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONArray staticRoutes = json.getJSONArray("staticRoute");
+ Assert.assertEquals(2, staticRoutes.length());
+ JSONObject route;
+ for (int i = 0; i < staticRoutes.length(); i++) {
+ route = staticRoutes.getJSONObject(i);
+ if (route.getString("name").equals(name1)) {
+ Assert.assertEquals(prefix1, route.getString("prefix"));
+ Assert.assertEquals(nextHop1, route.getString("nextHop"));
+ } else if (route.getString("name").equals(name2)) {
+ Assert.assertEquals(prefix2, route.getString("prefix"));
+ Assert.assertEquals(nextHop2, route.getString("nextHop"));
+ } else {
+ // static route has unknown name
+ Assert.assertTrue(false);
+ }
+ }
+
+ // Test get specific static route
+ result = getJsonResult(baseURL + "default/" + name1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ Assert.assertEquals(name1, json.getString("name"));
+ Assert.assertEquals(prefix1, json.getString("prefix"));
+ Assert.assertEquals(nextHop1, json.getString("nextHop"));
+
+ result = getJsonResult(baseURL + "default/" + name2);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ Assert.assertEquals(name2, json.getString("name"));
+ Assert.assertEquals(prefix2, json.getString("prefix"));
+ Assert.assertEquals(nextHop2, json.getString("nextHop"));
+
+ // Test delete static route
+ result = getJsonResult(baseURL + "default/" + name1, "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ result = getJsonResult(baseURL + "default");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONObject singleStaticRoute = json.getJSONObject("staticRoute");
+ Assert.assertEquals(name2, singleStaticRoute.getString("name"));
+
+ }
+
+ @Test
+ public void testSwitchManager() throws JSONException {
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switch/default/";
// define Node/NodeConnector attributes for test
int ncBandwidth = 1000000000;
// Test GET all nodes
- try {
- String result = getJsonResult(baseURL + "nodes");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
-
- // Test for first node
- JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_1, nodeType, timestamp_1,
- timestampName_1, actionsValue_1, capabilitiesValue_1,
- tablesValue_1, buffersValue_1);
-
- // Test 2nd node, properties of 2nd node same as first node
- node = getJsonInstance(json, "nodeProperties", nodeId_2);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
- timestampName_1, actionsValue_1, capabilitiesValue_1,
- tablesValue_1, buffersValue_1);
-
- // Test 3rd node, properties of 3rd node same as first node
- node = getJsonInstance(json, "nodeProperties", nodeId_3);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_3, nodeType, timestamp_1,
- timestampName_1, actionsValue_1, capabilitiesValue_1,
- tablesValue_1, buffersValue_1);
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ String result = getJsonResult(baseURL + "nodes");
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+
+ // Test for first node
+ JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_1, nodeType, timestamp_1,
+ timestampName_1, actionsValue_1, capabilitiesValue_1,
+ tablesValue_1, buffersValue_1);
+
+ // Test 2nd node, properties of 2nd node same as first node
+ node = getJsonInstance(json, "nodeProperties", nodeId_2);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
+ timestampName_1, actionsValue_1, capabilitiesValue_1,
+ tablesValue_1, buffersValue_1);
+
+ // Test 3rd node, properties of 3rd node same as first node
+ node = getJsonInstance(json, "nodeProperties", nodeId_3);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_3, nodeType, timestamp_1,
+ timestampName_1, actionsValue_1, capabilitiesValue_1,
+ tablesValue_1, buffersValue_1);
// Test GET nodeConnectors of a node
- try {
- //Test first node
- String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_1, ncType, nodeId_1, nodeType, ncState,
- ncCapabilities, ncBandwidth);
-
- //Test second node
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState,
- ncCapabilities, ncBandwidth);
-
- //Test third node
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_3);
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
-
- nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_3, ncType, nodeId_3, nodeType, ncState,
- ncCapabilities, ncBandwidth);
-
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ // Test first node
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONObject nodeConnectorProperties = json
+ .getJSONObject("nodeConnectorProperties");
+
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1,
+ ncType, nodeId_1, nodeType, ncState, ncCapabilities,
+ ncBandwidth);
+
+ // Test second node
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_2,
+ ncType, nodeId_2, nodeType, ncState, ncCapabilities,
+ ncBandwidth);
+
+ // Test third node
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_3);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_3,
+ ncType, nodeId_3, nodeType, ncState, ncCapabilities,
+ ncBandwidth);
// Test delete node property
- try {
- // Delete timestamp property from node1
- String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
- + "/property/timeStamp", "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- // Check node1
- result = getJsonResult(baseURL + "nodes");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_1, nodeType, null, null,
- actionsValue_1, capabilitiesValue_1, tablesValue_1,
- buffersValue_1);
-
- // Delete actions property from node2
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_2
- + "/property/actions", "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- // Check node2
- result = getJsonResult(baseURL + "nodes");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- node = getJsonInstance(json, "nodeProperties", nodeId_2);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
- timestampName_1, null, capabilitiesValue_1, tablesValue_1,
- buffersValue_1);
-
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ // Delete timestamp property from node1
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
+ + "/property/timeStamp", "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ // Check node1
+ result = getJsonResult(baseURL + "nodes");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node = getJsonInstance(json, "nodeProperties", nodeId_1);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_1, nodeType, null, null,
+ actionsValue_1, capabilitiesValue_1, tablesValue_1,
+ buffersValue_1);
+
+ // Delete actions property from node2
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_2
+ + "/property/actions", "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ // Check node2
+ result = getJsonResult(baseURL + "nodes");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node = getJsonInstance(json, "nodeProperties", nodeId_2);
+ Assert.assertNotNull(node);
+ testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
+ timestampName_1, null, capabilitiesValue_1, tablesValue_1,
+ buffersValue_1);
// Test add property to node
- try {
- // Add Tier and Bandwidth property to node1
- String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
- + "/property/tier/1001", "PUT");
- Assert.assertEquals(201, httpResponseCode.intValue());
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
- + "/property/bandwidth/1002", "PUT");
- Assert.assertEquals(201, httpResponseCode.intValue());
-
- // Test for first node
- result = getJsonResult(baseURL + "nodes");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
- Assert.assertNotNull(node);
- Assert.assertEquals(1001, node.getJSONObject("properties")
- .getJSONObject("tier").getInt("tierValue"));
- Assert.assertEquals(1002, node.getJSONObject("properties")
- .getJSONObject("bandwidth").getInt("bandwidthValue"));
-
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ // Add Tier and Bandwidth property to node1
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
+ + "/property/tier/1001", "PUT");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
+ + "/property/bandwidth/1002", "PUT");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ // Test for first node
+ result = getJsonResult(baseURL + "nodes");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node = getJsonInstance(json, "nodeProperties", nodeId_1);
+ Assert.assertNotNull(node);
+ Assert.assertEquals(1001, node.getJSONObject("properties")
+ .getJSONObject("tier").getInt("tierValue"));
+ Assert.assertEquals(1002, node.getJSONObject("properties")
+ .getJSONObject("bandwidth").getInt("bandwidthValue"));
// Test delete nodeConnector property
- try {
- // Delete state property of nodeconnector1
- String result = getJsonResult(baseURL + "nodeconnector/STUB/"
- + nodeId_1 + "/STUB/" + nodeConnectorId_1
- + "/property/state", "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_1, ncType, nodeId_1, nodeType, null,
- ncCapabilities, ncBandwidth);
-
- // Delete capabilities property of nodeconnector2
- result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_2
- + "/STUB/" + nodeConnectorId_2 + "/property/capabilities",
- "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState,
- null, ncBandwidth);
+ // Delete state property of nodeconnector1
+ result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_1
+ + "/STUB/" + nodeConnectorId_1 + "/property/state", "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1,
+ ncType, nodeId_1, nodeType, null, ncCapabilities, ncBandwidth);
+
+ // Delete capabilities property of nodeconnector2
+ result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_2
+ + "/STUB/" + nodeConnectorId_2 + "/property/capabilities",
+ "DELETE");
+ Assert.assertEquals(200, httpResponseCode.intValue());
+
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_2,
+ ncType, nodeId_2, nodeType, ncState, null, ncBandwidth);
// Test PUT nodeConnector property
- try {
- int newBandwidth = 1001;
-
- // Add Name/Bandwidth property to nodeConnector1
- String result = getJsonResult(baseURL + "nodeconnector/STUB/"
- + nodeId_1 + "/STUB/" + nodeConnectorId_1
- + "/property/bandwidth/" + newBandwidth, "PUT");
- Assert.assertEquals(201, httpResponseCode.intValue());
-
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject nodeConnectorProperties = json
- .getJSONObject("nodeConnectorProperties");
-
- // Check for new bandwidth value, state value removed from previous
- // test
- testNodeConnectorProperties(nodeConnectorProperties,
- nodeConnectorId_1, ncType, nodeId_1, nodeType, null,
- ncCapabilities, newBandwidth);
+ int newBandwidth = 1001;
+
+ // Add Name/Bandwidth property to nodeConnector1
+ result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_1
+ + "/STUB/" + nodeConnectorId_1 + "/property/bandwidth/"
+ + newBandwidth, "PUT");
+ Assert.assertEquals(201, httpResponseCode.intValue());
+
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties");
+
+ // Check for new bandwidth value, state value removed from previous
+ // test
+ testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1,
+ ncType, nodeId_1, nodeType, null, ncCapabilities, newBandwidth);
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
}
@Test
- public void testStatistics() {
+ public void testStatistics() throws JSONException {
String actionTypes[] = { "drop", "loopback", "flood", "floodAll",
"controller", "swPath", "hwPath", "output", "setDlSrc",
"setDlDst", "setDlType", "setVlanId", "setVlanPcp",
System.out.println("Starting Statistics JAXB client.");
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/statistics/default/";
- try {
- String result = getJsonResult(baseURL + "flowstats");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- JSONObject flowStatistics = getJsonInstance(json, "flowStatistics",
- 0xCAFE);
- JSONObject node = flowStatistics.getJSONObject("node");
- // test that node was returned properly
- Assert.assertTrue(node.getInt("@id") == 0xCAFE);
- Assert.assertTrue(node.getString("@type").equals("STUB"));
-
- // test that flow statistics results are correct
- JSONArray flowStats = flowStatistics.getJSONArray("flowStat");
- for (int i = 0; i < flowStats.length(); i++) {
-
- JSONObject flowStat = flowStats.getJSONObject(i);
- testFlowStat(flowStat, actionTypes[i]);
- }
+ String result = getJsonResult(baseURL + "flowstats");
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ JSONObject flowStatistics = getJsonInstance(json, "flowStatistics",
+ 0xCAFE);
+ JSONObject node = flowStatistics.getJSONObject("node");
+ // test that node was returned properly
+ Assert.assertTrue(node.getInt("@id") == 0xCAFE);
+ Assert.assertTrue(node.getString("@type").equals("STUB"));
- // for /controller/nb/v2/statistics/default/portstats
- result = getJsonResult(baseURL + "portstats");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- JSONObject portStatistics = getJsonInstance(json, "portStatistics",
- 0xCAFE);
- JSONObject node2 = portStatistics.getJSONObject("node");
- // test that node was returned properly
- Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
- Assert.assertTrue(node2.getString("@type").equals("STUB"));
-
- // test that port statistic results are correct
- JSONObject portStat = portStatistics.getJSONObject("portStat");
- Assert.assertTrue(portStat.getInt("receivePackets") == 250);
- Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
- Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
- Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
- Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
- Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
- Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
- Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
- Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
- Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
- Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
- Assert.assertTrue(portStat.getInt("collisionCount") == 4);
-
- // test for getting one specific node's stats
- result = getJsonResult(baseURL + "flowstats/STUB/51966");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- node = json.getJSONObject("node");
- // test that node was returned properly
- Assert.assertTrue(node.getInt("@id") == 0xCAFE);
- Assert.assertTrue(node.getString("@type").equals("STUB"));
-
- // test that flow statistics results are correct
- flowStats = json.getJSONArray("flowStat");
- for (int i = 0; i < flowStats.length(); i++) {
- JSONObject flowStat = flowStats.getJSONObject(i);
- testFlowStat(flowStat, actionTypes[i]);
- }
+ // test that flow statistics results are correct
+ JSONArray flowStats = flowStatistics.getJSONArray("flowStat");
+ for (int i = 0; i < flowStats.length(); i++) {
- result = getJsonResult(baseURL + "portstats/STUB/51966");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- node2 = json.getJSONObject("node");
- // test that node was returned properly
- Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
- Assert.assertTrue(node2.getString("@type").equals("STUB"));
-
- // test that port statistic results are correct
- portStat = json.getJSONObject("portStat");
- Assert.assertTrue(portStat.getInt("receivePackets") == 250);
- Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
- Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
- Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
- Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
- Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
- Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
- Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
- Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
- Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
- Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
- Assert.assertTrue(portStat.getInt("collisionCount") == 4);
+ JSONObject flowStat = flowStats.getJSONObject(i);
+ testFlowStat(flowStat, actionTypes[i]);
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
+ }
+ // for /controller/nb/v2/statistics/default/portstats
+ result = getJsonResult(baseURL + "portstats");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ JSONObject portStatistics = getJsonInstance(json, "portStatistics",
+ 0xCAFE);
+ JSONObject node2 = portStatistics.getJSONObject("node");
+ // test that node was returned properly
+ Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
+ Assert.assertTrue(node2.getString("@type").equals("STUB"));
+
+ // test that port statistic results are correct
+ JSONObject portStat = portStatistics.getJSONObject("portStat");
+ Assert.assertTrue(portStat.getInt("receivePackets") == 250);
+ Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
+ Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
+ Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
+ Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
+ Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
+ Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
+ Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
+ Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
+ Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
+ Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
+ Assert.assertTrue(portStat.getInt("collisionCount") == 4);
+
+ // test for getting one specific node's stats
+ result = getJsonResult(baseURL + "flowstats/STUB/51966");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node = json.getJSONObject("node");
+ // test that node was returned properly
+ Assert.assertTrue(node.getInt("@id") == 0xCAFE);
+ Assert.assertTrue(node.getString("@type").equals("STUB"));
+
+ // test that flow statistics results are correct
+ flowStats = json.getJSONArray("flowStat");
+ for (int i = 0; i < flowStats.length(); i++) {
+ JSONObject flowStat = flowStats.getJSONObject(i);
+ testFlowStat(flowStat, actionTypes[i]);
}
+
+ result = getJsonResult(baseURL + "portstats/STUB/51966");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ node2 = json.getJSONObject("node");
+ // test that node was returned properly
+ Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
+ Assert.assertTrue(node2.getString("@type").equals("STUB"));
+
+ // test that port statistic results are correct
+ portStat = json.getJSONObject("portStat");
+ Assert.assertTrue(portStat.getInt("receivePackets") == 250);
+ Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
+ Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
+ Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
+ Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
+ Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
+ Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
+ Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
+ Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
+ Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
+ Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
+ Assert.assertTrue(portStat.getInt("collisionCount") == 4);
}
- private void testFlowStat(JSONObject flowStat, String actionType) {
- try {
- Assert.assertTrue(flowStat.getInt("tableId") == 1);
- Assert.assertTrue(flowStat.getInt("durationSeconds") == 40);
- Assert.assertTrue(flowStat.getInt("durationNanoseconds") == 400);
- Assert.assertTrue(flowStat.getInt("packetCount") == 200);
- Assert.assertTrue(flowStat.getInt("byteCount") == 100);
-
- // test that flow information is correct
- JSONObject flow = flowStat.getJSONObject("flow");
- Assert.assertTrue(flow.getInt("priority") == 3500);
- Assert.assertTrue(flow.getInt("idleTimeout") == 1000);
- Assert.assertTrue(flow.getInt("hardTimeout") == 2000);
- Assert.assertTrue(flow.getInt("id") == 12345);
-
- JSONObject match = (flow.getJSONObject("match")
- .getJSONObject("matchField"));
- Assert.assertTrue(match.getString("type").equals("NW_DST"));
- Assert.assertTrue(match.getString("value").equals("1.1.1.1"));
-
- JSONObject act = flow.getJSONObject("actions");
- Assert.assertTrue(act.getString("@type").equals(actionType));
-
- if (act.getString("@type").equals("output")) {
- JSONObject port = act.getJSONObject("port");
- JSONObject port_node = port.getJSONObject("node");
- Assert.assertTrue(port.getInt("@id") == 51966);
- Assert.assertTrue(port.getString("@type").equals("STUB"));
- Assert.assertTrue(port_node.getInt("@id") == 51966);
- Assert.assertTrue(port_node.getString("@type").equals("STUB"));
- }
+ private void testFlowStat(JSONObject flowStat, String actionType)
+ throws JSONException {
+ Assert.assertTrue(flowStat.getInt("tableId") == 1);
+ Assert.assertTrue(flowStat.getInt("durationSeconds") == 40);
+ Assert.assertTrue(flowStat.getInt("durationNanoseconds") == 400);
+ Assert.assertTrue(flowStat.getInt("packetCount") == 200);
+ Assert.assertTrue(flowStat.getInt("byteCount") == 100);
+
+ // test that flow information is correct
+ JSONObject flow = flowStat.getJSONObject("flow");
+ Assert.assertTrue(flow.getInt("priority") == 3500);
+ Assert.assertTrue(flow.getInt("idleTimeout") == 1000);
+ Assert.assertTrue(flow.getInt("hardTimeout") == 2000);
+ Assert.assertTrue(flow.getInt("id") == 12345);
+
+ JSONObject match = (flow.getJSONObject("match")
+ .getJSONObject("matchField"));
+ Assert.assertTrue(match.getString("type").equals("NW_DST"));
+ Assert.assertTrue(match.getString("value").equals("1.1.1.1"));
+
+ JSONObject act = flow.getJSONObject("actions");
+ Assert.assertTrue(act.getString("@type").equals(actionType));
+
+ if (act.getString("@type").equals("output")) {
+ JSONObject port = act.getJSONObject("port");
+ JSONObject port_node = port.getJSONObject("node");
+ Assert.assertTrue(port.getInt("@id") == 51966);
+ Assert.assertTrue(port.getString("@type").equals("STUB"));
+ Assert.assertTrue(port_node.getInt("@id") == 51966);
+ Assert.assertTrue(port_node.getString("@type").equals("STUB"));
+ }
- if (act.getString("@type").equals("setDlSrc")) {
- byte srcMatch[] = { (byte) 5, (byte) 4, (byte) 3, (byte) 2,
- (byte) 1 };
- String src = act.getString("address");
- byte srcBytes[] = new byte[5];
- srcBytes[0] = Byte.parseByte(src.substring(0, 2));
- srcBytes[1] = Byte.parseByte(src.substring(2, 4));
- srcBytes[2] = Byte.parseByte(src.substring(4, 6));
- srcBytes[3] = Byte.parseByte(src.substring(6, 8));
- srcBytes[4] = Byte.parseByte(src.substring(8, 10));
- Assert.assertTrue(Arrays.equals(srcBytes, srcMatch));
- }
+ if (act.getString("@type").equals("setDlSrc")) {
+ byte srcMatch[] = { (byte) 5, (byte) 4, (byte) 3, (byte) 2,
+ (byte) 1 };
+ String src = act.getString("address");
+ byte srcBytes[] = new byte[5];
+ srcBytes[0] = Byte.parseByte(src.substring(0, 2));
+ srcBytes[1] = Byte.parseByte(src.substring(2, 4));
+ srcBytes[2] = Byte.parseByte(src.substring(4, 6));
+ srcBytes[3] = Byte.parseByte(src.substring(6, 8));
+ srcBytes[4] = Byte.parseByte(src.substring(8, 10));
+ Assert.assertTrue(Arrays.equals(srcBytes, srcMatch));
+ }
- if (act.getString("@type").equals("setDlDst")) {
- byte dstMatch[] = { (byte) 1, (byte) 2, (byte) 3, (byte) 4,
- (byte) 5 };
- String dst = act.getString("address");
- byte dstBytes[] = new byte[5];
- dstBytes[0] = Byte.parseByte(dst.substring(0, 2));
- dstBytes[1] = Byte.parseByte(dst.substring(2, 4));
- dstBytes[2] = Byte.parseByte(dst.substring(4, 6));
- dstBytes[3] = Byte.parseByte(dst.substring(6, 8));
- dstBytes[4] = Byte.parseByte(dst.substring(8, 10));
- Assert.assertTrue(Arrays.equals(dstBytes, dstMatch));
- }
- if (act.getString("@type").equals("setDlType"))
- Assert.assertTrue(act.getInt("dlType") == 10);
- if (act.getString("@type").equals("setVlanId"))
- Assert.assertTrue(act.getInt("vlanId") == 2);
- if (act.getString("@type").equals("setVlanPcp"))
- Assert.assertTrue(act.getInt("pcp") == 3);
- if (act.getString("@type").equals("setVlanCfi"))
- Assert.assertTrue(act.getInt("cfi") == 1);
-
- if (act.getString("@type").equals("setNwSrc"))
- Assert.assertTrue(act.getString("address").equals("2.2.2.2"));
- if (act.getString("@type").equals("setNwDst"))
- Assert.assertTrue(act.getString("address").equals("1.1.1.1"));
-
- if (act.getString("@type").equals("pushVlan")) {
- int head = act.getInt("VlanHeader");
- // parsing vlan header
- int id = head & 0xfff;
- int cfi = (head >> 12) & 0x1;
- int pcp = (head >> 13) & 0x7;
- int tag = (head >> 16) & 0xffff;
- Assert.assertTrue(id == 1234);
- Assert.assertTrue(cfi == 1);
- Assert.assertTrue(pcp == 1);
- Assert.assertTrue(tag == 0x8100);
- }
- if (act.getString("@type").equals("setNwTos"))
- Assert.assertTrue(act.getInt("tos") == 16);
- if (act.getString("@type").equals("setTpSrc"))
- Assert.assertTrue(act.getInt("port") == 4201);
- if (act.getString("@type").equals("setTpDst"))
- Assert.assertTrue(act.getInt("port") == 8080);
- } catch (Exception e) {
- Assert.assertTrue(false);
+ if (act.getString("@type").equals("setDlDst")) {
+ byte dstMatch[] = { (byte) 1, (byte) 2, (byte) 3, (byte) 4,
+ (byte) 5 };
+ String dst = act.getString("address");
+ byte dstBytes[] = new byte[5];
+ dstBytes[0] = Byte.parseByte(dst.substring(0, 2));
+ dstBytes[1] = Byte.parseByte(dst.substring(2, 4));
+ dstBytes[2] = Byte.parseByte(dst.substring(4, 6));
+ dstBytes[3] = Byte.parseByte(dst.substring(6, 8));
+ dstBytes[4] = Byte.parseByte(dst.substring(8, 10));
+ Assert.assertTrue(Arrays.equals(dstBytes, dstMatch));
+ }
+ if (act.getString("@type").equals("setDlType"))
+ Assert.assertTrue(act.getInt("dlType") == 10);
+ if (act.getString("@type").equals("setVlanId"))
+ Assert.assertTrue(act.getInt("vlanId") == 2);
+ if (act.getString("@type").equals("setVlanPcp"))
+ Assert.assertTrue(act.getInt("pcp") == 3);
+ if (act.getString("@type").equals("setVlanCfi"))
+ Assert.assertTrue(act.getInt("cfi") == 1);
+
+ if (act.getString("@type").equals("setNwSrc"))
+ Assert.assertTrue(act.getString("address").equals("2.2.2.2"));
+ if (act.getString("@type").equals("setNwDst"))
+ Assert.assertTrue(act.getString("address").equals("1.1.1.1"));
+
+ if (act.getString("@type").equals("pushVlan")) {
+ int head = act.getInt("VlanHeader");
+ // parsing vlan header
+ int id = head & 0xfff;
+ int cfi = (head >> 12) & 0x1;
+ int pcp = (head >> 13) & 0x7;
+ int tag = (head >> 16) & 0xffff;
+ Assert.assertTrue(id == 1234);
+ Assert.assertTrue(cfi == 1);
+ Assert.assertTrue(pcp == 1);
+ Assert.assertTrue(tag == 0x8100);
}
+ if (act.getString("@type").equals("setNwTos"))
+ Assert.assertTrue(act.getInt("tos") == 16);
+ if (act.getString("@type").equals("setTpSrc"))
+ Assert.assertTrue(act.getInt("port") == 4201);
+ if (act.getString("@type").equals("setTpDst"))
+ Assert.assertTrue(act.getInt("port") == 8080);
}
@Test
- public void testFlowProgrammer() {
- try {
- String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/";
- // Attempt to get a flow that doesn't exit. Should return 404
- // status.
- String result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
- Assert.assertTrue(result.equals("404"));
-
- // test add flow1
- String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
- Assert.assertTrue(httpResponseCode == 201);
-
- // test get returns flow that was added.
- result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
- // check that result came out fine.
- Assert.assertTrue(httpResponseCode == 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- Assert.assertTrue(json.getString("name").equals("test1"));
- Assert.assertTrue(json.getString("actions").equals("DROP"));
- Assert.assertTrue(json.getString("installInHw").equals("true"));
- JSONObject node = json.getJSONObject("node");
- Assert.assertTrue(node.getString("@type").equals("STUB"));
- Assert.assertTrue(node.getString("@id").equals("51966"));
- // test adding same flow again fails due to repeat name..return 409
- // code
- result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
- Assert.assertTrue(result.equals("409"));
-
- fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
- // test should return 500 for error due to same flow being added.
- Assert.assertTrue(result.equals("500"));
-
- // add second flow that's different
- fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
- Assert.assertTrue(httpResponseCode == 201);
-
- // check that request returns both flows given node.
- result = getJsonResult(baseURL + "STUB/51966/", "GET");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
- JSONArray ja = json.getJSONArray("flowConfig");
- Integer count = ja.length();
- Assert.assertTrue(count == 2);
-
- // check that request returns both flows given just container.
- result = getJsonResult(baseURL);
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
- ja = json.getJSONArray("flowConfig");
- count = ja.length();
- Assert.assertTrue(count == 2);
-
- // delete a flow, check that it's no longer in list.
- result = getJsonResult(baseURL + "STUB/51966/test2", "DELETE");
- Assert.assertTrue(httpResponseCode == 200);
-
- result = getJsonResult(baseURL + "STUB/51966/test2", "GET");
- Assert.assertTrue(result.equals("404"));
-
- } catch (Exception e) {
- Assert.assertTrue(false);
- }
-
+ public void testFlowProgrammer() throws JSONException {
+ String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/";
+ // Attempt to get a flow that doesn't exit. Should return 404
+ // status.
+ String result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
+ Assert.assertTrue(result.equals("404"));
+
+ // test add flow1
+ String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
+ Assert.assertTrue(httpResponseCode == 201);
+
+ // test get returns flow that was added.
+ result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
+ // check that result came out fine.
+ Assert.assertTrue(httpResponseCode == 200);
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ Assert.assertTrue(json.getString("name").equals("test1"));
+ Assert.assertTrue(json.getString("actions").equals("DROP"));
+ Assert.assertTrue(json.getString("installInHw").equals("true"));
+ JSONObject node = json.getJSONObject("node");
+ Assert.assertTrue(node.getString("@type").equals("STUB"));
+ Assert.assertTrue(node.getString("@id").equals("51966"));
+ // test adding same flow again fails due to repeat name..return 409
+ // code
+ result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
+ Assert.assertTrue(result.equals("409"));
+
+ fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
+ // test should return 500 for error due to same flow being added.
+ Assert.assertTrue(result.equals("500"));
+
+ // add second flow that's different
+ fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
+ Assert.assertTrue(httpResponseCode == 201);
+
+ // check that request returns both flows given node.
+ result = getJsonResult(baseURL + "STUB/51966/", "GET");
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
+ JSONArray ja = json.getJSONArray("flowConfig");
+ Integer count = ja.length();
+ Assert.assertTrue(count == 2);
+
+ // check that request returns both flows given just container.
+ result = getJsonResult(baseURL);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
+ ja = json.getJSONArray("flowConfig");
+ count = ja.length();
+ Assert.assertTrue(count == 2);
+
+ // delete a flow, check that it's no longer in list.
+ result = getJsonResult(baseURL + "STUB/51966/test2", "DELETE");
+ Assert.assertTrue(httpResponseCode == 200);
+
+ result = getJsonResult(baseURL + "STUB/51966/test2", "GET");
+ Assert.assertTrue(result.equals("404"));
}
// method to extract a JSONObject with specified node ID from a JSONObject
}
@Test
- public void testHostTracker() {
+ public void testHostTracker() throws JSONException {
System.out.println("Starting HostTracker JAXB client.");
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default";
// test POST method: addHost()
- try {
- String queryParameter = new QueryParameter("dataLayerAddress",
- dataLayerAddress_1).add("nodeType", nodeType_1)
- .add("nodeId", nodeId_1.toString())
- .add("nodeConnectorType", nodeConnectorType_1)
- .add("nodeConnectorId", nodeConnectorId_1.toString())
- .add("vlan", vlan_1).getString();
-
- String result = getJsonResult(baseURL + "/" + networkAddress_1
- + queryParameter, "POST");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
-
- // vlan is not passed through query parameter but should be
- // defaulted to "0"
- queryParameter = new QueryParameter("dataLayerAddress",
- dataLayerAddress_2).add("nodeType", nodeType_2)
- .add("nodeId", nodeId_2.toString())
- .add("nodeConnectorType", nodeConnectorType_2)
- .add("nodeConnectorId", nodeConnectorId_2.toString())
- .getString();
-
- result = getJsonResult(baseURL + "/" + networkAddress_2
- + queryParameter, "POST");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ String queryParameter = new QueryParameter("dataLayerAddress",
+ dataLayerAddress_1).add("nodeType", nodeType_1)
+ .add("nodeId", nodeId_1.toString())
+ .add("nodeConnectorType", nodeConnectorType_1)
+ .add("nodeConnectorId", nodeConnectorId_1.toString())
+ .add("vlan", vlan_1).getString();
+
+ String result = getJsonResult(baseURL + "/" + networkAddress_1
+ + queryParameter, "POST");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
+
+ // vlan is not passed through query parameter but should be
+ // defaulted to "0"
+ queryParameter = new QueryParameter("dataLayerAddress",
+ dataLayerAddress_2).add("nodeType", nodeType_2)
+ .add("nodeId", nodeId_2.toString())
+ .add("nodeConnectorType", nodeConnectorType_2)
+ .add("nodeConnectorId", nodeConnectorId_2.toString())
+ .getString();
+
+ result = getJsonResult(baseURL + "/" + networkAddress_2
+ + queryParameter, "POST");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
// define variables for decoding returned strings
String networkAddress;
// the two hosts should be in inactive host DB
// test GET method: getInactiveHosts()
- try {
- String result = getJsonResult(baseURL + "/inactive", "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+ result = getJsonResult(baseURL + "/inactive", "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
+ JSONTokener jt = new JSONTokener(result);
+ JSONObject json = new JSONObject(jt);
+ // there should be at least two hosts in the DB
+ Assert.assertTrue(json.get("host") instanceof JSONArray);
+ JSONArray ja = json.getJSONArray("host");
+ Integer count = ja.length();
+ Assert.assertTrue(count == 2);
+
+ for (int i = 0; i < count; i++) {
+ host_jo = ja.getJSONObject(i);
+ dl_jo = host_jo.getJSONObject("dataLayerAddress");
+ nc_jo = host_jo.getJSONObject("nodeConnector");
+ node_jo = nc_jo.getJSONObject("node");
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- // there should be at least two hosts in the DB
- Assert.assertTrue(json.get("host") instanceof JSONArray);
- JSONArray ja = json.getJSONArray("host");
- Integer count = ja.length();
- Assert.assertTrue(count == 2);
-
- for (int i = 0; i < count; i++) {
- host_jo = ja.getJSONObject(i);
- dl_jo = host_jo.getJSONObject("dataLayerAddress");
- nc_jo = host_jo.getJSONObject("nodeConnector");
- node_jo = nc_jo.getJSONObject("node");
-
- networkAddress = host_jo.getString("networkAddress");
- if (networkAddress.equalsIgnoreCase(networkAddress_1)) {
- Assert.assertTrue(dl_jo.getString("macAddress")
- .equalsIgnoreCase(dataLayerAddress_1));
- Assert.assertTrue(nc_jo.getString("@type")
- .equalsIgnoreCase(nodeConnectorType_1));
- Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
- Assert.assertTrue(node_jo.getString("@type")
- .equalsIgnoreCase(nodeType_1));
- Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
- Assert.assertTrue(host_jo.getString("vlan")
- .equalsIgnoreCase(vlan_1));
- } else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
- Assert.assertTrue(dl_jo.getString("macAddress")
- .equalsIgnoreCase(dataLayerAddress_2));
- Assert.assertTrue(nc_jo.getString("@type")
- .equalsIgnoreCase(nodeConnectorType_2));
- Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_2);
- Assert.assertTrue(node_jo.getString("@type")
- .equalsIgnoreCase(nodeType_2));
- Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_2);
- Assert.assertTrue(host_jo.getString("vlan")
- .equalsIgnoreCase(vlan_2));
- } else {
- Assert.assertTrue(false);
- }
+ networkAddress = host_jo.getString("networkAddress");
+ if (networkAddress.equalsIgnoreCase(networkAddress_1)) {
+ Assert.assertTrue(dl_jo.getString("macAddress")
+ .equalsIgnoreCase(dataLayerAddress_1));
+ Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
+ nodeConnectorType_1));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
+ Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
+ nodeType_1));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
+ Assert.assertTrue(host_jo.getString("vlan").equalsIgnoreCase(
+ vlan_1));
+ } else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
+ Assert.assertTrue(dl_jo.getString("macAddress")
+ .equalsIgnoreCase(dataLayerAddress_2));
+ Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
+ nodeConnectorType_2));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_2);
+ Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
+ nodeType_2));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_2);
+ Assert.assertTrue(host_jo.getString("vlan").equalsIgnoreCase(
+ vlan_2));
+ } else {
+ Assert.assertTrue(false);
}
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
}
// test GET method: getActiveHosts() - no host expected
- try {
- String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+ result = getJsonResult(baseURL, "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
- Assert.assertFalse(hostInJson(json, networkAddress_1));
- Assert.assertFalse(hostInJson(json, networkAddress_2));
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+ Assert.assertFalse(hostInJson(json, networkAddress_1));
+ Assert.assertFalse(hostInJson(json, networkAddress_2));
// put the 1st host into active host DB
Node nd;
}
// verify the host shows up in active host DB
- try {
- String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
+ result = getJsonResult(baseURL, "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- Assert.assertTrue(hostInJson(json, networkAddress_1));
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ Assert.assertTrue(hostInJson(json, networkAddress_1));
// test GET method for getHostDetails()
- try {
- String result = getJsonResult(baseURL + "/" + networkAddress_1,
- "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
+ result = getJsonResult(baseURL + "/" + networkAddress_1, "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- Assert.assertFalse(json.length() == 0);
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
- dl_jo = json.getJSONObject("dataLayerAddress");
- nc_jo = json.getJSONObject("nodeConnector");
- node_jo = nc_jo.getJSONObject("node");
+ Assert.assertFalse(json.length() == 0);
- Assert.assertTrue(json.getString("networkAddress")
- .equalsIgnoreCase(networkAddress_1));
- Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(
- dataLayerAddress_1));
- Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
- nodeConnectorType_1));
- Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
- Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
- nodeType_1));
- Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
- Assert.assertTrue(json.getString("vlan").equalsIgnoreCase(vlan_1));
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ dl_jo = json.getJSONObject("dataLayerAddress");
+ nc_jo = json.getJSONObject("nodeConnector");
+ node_jo = nc_jo.getJSONObject("node");
+
+ Assert.assertTrue(json.getString("networkAddress").equalsIgnoreCase(
+ networkAddress_1));
+ Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(
+ dataLayerAddress_1));
+ Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
+ nodeConnectorType_1));
+ Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
+ Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
+ nodeType_1));
+ Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
+ Assert.assertTrue(json.getString("vlan").equalsIgnoreCase(vlan_1));
// test DELETE method for deleteFlow()
- try {
- String result = getJsonResult(baseURL + "/" + networkAddress_1,
- "DELETE");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
+ result = getJsonResult(baseURL + "/" + networkAddress_1, "DELETE");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
// verify host_1 removed from active host DB
// test GET method: getActiveHosts() - no host expected
- try {
- String result = getJsonResult(baseURL, "GET");
- Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
- JSONTokener jt = new JSONTokener(result);
- JSONObject json = new JSONObject(jt);
+ result = getJsonResult(baseURL, "GET");
+ Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
+
+ jt = new JSONTokener(result);
+ json = new JSONObject(jt);
+
+ Assert.assertFalse(hostInJson(json, networkAddress_1));
- Assert.assertFalse(hostInJson(json, networkAddress_1));
- } catch (Exception e) {
- // Got an unexpected exception
- Assert.assertTrue(false);
- }
}
private Boolean hostInJson(JSONObject json, String hostIp)
mavenBundle("org.opendaylight.controller", "usermanager",
"0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller",
+ "usermanager.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "logging.bridge",
"0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "clustering.test",
mavenBundle("com.sun.jersey", "jersey-json", "1.17")
.startLevel(2), junitBundles());
}
-}
\ No newline at end of file
+}
connectionTimeout="20000"
redirectPort="8443" />
-<!--
- Please remove the comments around the following Connector tag to enable HTTPS Authentication support.
- Remember to add a valid keystore in the configuration folder.
- More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+<!--
+ Please remove the comments around the following Connector tag to enable HTTPS Authentication support.
+ Remember to add a valid keystore in the configuration folder.
+ More info : http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
-->
-
- <!--
+
+ <!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
unpackWARs="false" autoDeploy="false"
deployOnStartup="false" createDirs="false">
<Realm className="org.opendaylight.controller.security.ControllerCustomRealm" />
- <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="web_access_log_" suffix=".txt" resolveHosts="false"
- rotatable="true" fileDateFormat="yyyy-MM"
- pattern="%{yyyy-MM-dd HH:mm:ss.SSS z}t - [%a] - %r"/>
-
+ prefix="web_access_log_" suffix=".txt" resolveHosts="false"
+ rotatable="true" fileDateFormat="yyyy-MM"
+ pattern="%{yyyy-MM-dd HH:mm:ss.SSS z}t - [%a] - %r"/>
+
</Host>
</Engine>
</Service>
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/staticroute"/>
</services>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>com.sun.jersey.jersey-servlet</artifactId>
<version>1.17-SNAPSHOT</version>
- </dependency>
+ </dependency>
</dependencies>
</project>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSStaticRouting</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
- <servlet-mapping>
- <servlet-name>JAXRSStaticRouting</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>JAXRSStaticRouting</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/statistics"/>
</services>
<version>0.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSStatistics</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSSubnets</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<servlet-name>JAXRSSubnets</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/switch"/>
</services>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSSwitchManager</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
\ No newline at end of file
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/controller/nb/v2/topology"/>
</services>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSTopology</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../../../opendaylight/commons/opendaylight</relativePath>
</parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>northboundtest</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>2.3.6</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.opendaylight.controller.sal.core,
- org.eclipse.osgi.framework.console,
- org.osgi.framework,
- org.apache.felix.dm
- </Import-Package>
- <Export-Package>
- </Export-Package>
- <Bundle-Activator>
- org.opendaylight.controller.northboundtest.unittestsuite.internal.Activator
- </Bundle-Activator>
- <Service-Component>
- </Service-Component>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>northboundtest</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.6</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.opendaylight.controller.sal.core,
+ org.eclipse.osgi.framework.console,
+ org.osgi.framework,
+ org.apache.felix.dm
+ </Import-Package>
+ <Export-Package>
+ </Export-Package>
+ <Bundle-Activator>
+ org.opendaylight.controller.northboundtest.unittestsuite.internal.Activator
+ </Bundle-Activator>
+ <Service-Component>
+ </Service-Component>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
</project>
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.openflow.protocol.OFMessage;
/**
import java.util.LinkedList;
import java.util.List;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.openflow.protocol.OFPacketOut;
import org.openflow.protocol.OFPort;
import org.openflow.protocol.OFVendor;
}
}
- /**
- * Prints the contents of V6FlowMod in a string format.
- */
@Override
public String toString() {
- return "V6FlowMod[" + ReflectionToStringBuilder.toString(this) + "]";
+ return "V6FlowMod [match=" + match + ", cookie=" + cookie
+ + ", command=" + command + ", idleTimeout=" + idleTimeout
+ + ", hardTimeout=" + hardTimeout + ", priority=" + priority
+ + ", bufferId=" + bufferId + ", outPort=" + outPort
+ + ", flags=" + flags + ", actions=" + actions + ", match_len="
+ + match_len + ", actions_len=" + actions_len + ", pad_size="
+ + pad_size + "]";
}
}
package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.openflow.protocol.OFMatch;
-import org.openflow.util.U16;
-import org.openflow.util.U8;
-
import java.net.Inet6Address;
-import org.opendaylight.controller.sal.utils.HexEncode;
-
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.opendaylight.controller.sal.utils.HexEncode;
+import org.openflow.protocol.OFMatch;
+import org.openflow.util.U16;
+import org.openflow.util.U8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public String toString() {
- return "V6Match[" + ReflectionToStringBuilder.toString(this) + "]";
+ return "V6Match [nwSrc=" + nwSrc + ", nwDst=" + nwDst
+ + ", inputPortMask=" + inputPortMask + ", dataLayerSourceMask="
+ + HexEncode.bytesToHexStringFormat(dataLayerSourceMask)
+ + ", dataLayerDestinationMask="
+ + HexEncode.bytesToHexStringFormat(dataLayerDestinationMask)
+ + ", dataLayerVirtualLanMask=" + dataLayerVirtualLanMask
+ + ", dataLayerVirtualLanPriorityCodePointMask="
+ + dataLayerVirtualLanPriorityCodePointMask
+ + ", dataLayerTypeMask=" + dataLayerTypeMask
+ + ", networkTypeOfServiceMask=" + networkTypeOfServiceMask
+ + ", networkProtocolMask=" + networkProtocolMask
+ + ", networkSourceMask=" + networkSourceMask
+ + ", networkDestinationMask=" + networkDestinationMask
+ + ", transportSourceMask=" + transportSourceMask
+ + ", transportDestinationMask=" + transportDestinationMask
+ + ", srcIPv6SubnetMaskbits=" + srcIPv6SubnetMaskbits
+ + ", dstIPv6SubnetMaskbits=" + dstIPv6SubnetMaskbits
+ + ", inputPortState=" + inputPortState + ", dlSourceState="
+ + dlSourceState + ", dlDestState=" + dlDestState
+ + ", dlVlanState=" + dlVlanState + ", ethTypeState="
+ + ethTypeState + ", nwTosState=" + nwTosState
+ + ", nwProtoState=" + nwProtoState + ", nwSrcState="
+ + nwSrcState + ", nwDstState=" + nwDstState + ", tpSrcState="
+ + tpSrcState + ", tpDstState=" + tpDstState + ", match_len="
+ + match_len + ", pad_size=" + pad_size + "]";
}
/**
import java.nio.ByteBuffer;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.openflow.protocol.statistics.OFVendorStatistics;
@Override
public String toString() {
- return "V6StatsRequest[" + ReflectionToStringBuilder.toString(this)
+ return "V6StatsRequest [msgsubtype=" + msgsubtype + ", outPort="
+ + outPort + ", match_len=" + match_len + ", tableId=" + tableId
+ "]";
}
org.opendaylight.controller.protocol_plugins.stub.internal
</Export-Package>
<Bundle-Activator>
- org.opendaylight.controller.protocol_plugins.stub.internal.Activator
+ org.opendaylight.controller.protocol_plugins.stub.internal.Activator
</Bundle-Activator>
</instructions>
<manifestLocation>${project.basedir}/META-INF</manifestLocation>
<scope>test</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-
+import org.opendaylight.controller.sal.utils.HexEncode;
/**
* The class contains MAC address property.
*/
@Override
public String toString() {
- return "MacAddress[" + ReflectionToStringBuilder.toString(this) + "]";
+ return "MacAddress [address=" +
+ HexEncode.bytesToHexStringFormat(address) + "]";
}
}
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-
/**
* @file DataLinkAddress.java
*
@Override
public String toString() {
- return "DataLinkAddress[" + ReflectionToStringBuilder.toString(this)
- + "]";
+ return "DataLinkAddress [name=" + name + "]";
}
}
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.utils.HexEncode;
@Override
public String toString() {
- return "EthernetAddress[" + ReflectionToStringBuilder.toString(this)
+ return "EthernetAddress [macAddress=" + HexEncode.bytesToHexStringFormat(macAddress)
+ "]";
}
import java.util.Set;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.opendaylight.controller.sal.core.Edge;
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.core.UpdateType;
@Override
public String toString() {
- return "TopoEdgeUpdate[" + ReflectionToStringBuilder.toString(this)
- + "]";
+ return "TopoEdgeUpdate [edge=" + edge + ", props=" + props + ", type="
+ + type + "]";
}
@Override
import org.opendaylight.controller.binding.generator.util.ReferencedTypeImpl;
import org.opendaylight.controller.binding.generator.util.Types;
+import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
import org.opendaylight.controller.sal.binding.model.api.*;
import org.opendaylight.controller.sal.binding.model.api.type.builder.*;
import org.opendaylight.controller.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.controller.yang.binding.Notification;
import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.common.RpcResult;
import org.opendaylight.controller.yang.model.api.*;
import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
import org.opendaylight.controller.yang.model.util.DataNodeIterator;
import org.opendaylight.controller.yang.model.util.ExtendedType;
+import org.opendaylight.controller.yang.model.util.SchemaContextUtil;
import java.util.*;
+import java.util.concurrent.Future;
import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.*;
import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNode;
@Override
public List<Type> generateTypes(final SchemaContext context) {
if (context == null) {
- throw new IllegalArgumentException("Schema Context reference " +
- "cannot be NULL!");
+ throw new IllegalArgumentException("Schema Context reference "
+ + "cannot be NULL!");
}
if (context.getModules() == null) {
- throw new IllegalStateException("Schema Context does not contain " +
- "defined modules!");
+ throw new IllegalStateException("Schema Context does not contain "
+ + "defined modules!");
}
final List<Type> generatedTypes = new ArrayList<>();
generatedTypes.addAll(allListsToGenTypes(module));
generatedTypes.addAll(allAugmentsToGenTypes(module));
generatedTypes.addAll(allRPCMethodsToGenType(module));
- generatedTypes.addAll(allNotifycationsToGenType(module));
+ generatedTypes.addAll(allNotificationsToGenType(module));
+ generatedTypes.addAll(allIdentitiesToGenTypes(module, context));
+ generatedTypes.addAll(allGroupingsToGenTypes(module));
}
return generatedTypes;
}
@Override
public List<Type> generateTypes(final SchemaContext context,
- final Set<Module> modules) {
+ final Set<Module> modules) {
if (context == null) {
- throw new IllegalArgumentException("Schema Context reference " +
- "cannot be NULL!");
+ throw new IllegalArgumentException("Schema Context reference "
+ + "cannot be NULL!");
}
if (context.getModules() == null) {
- throw new IllegalStateException("Schema Context does not contain " +
- "defined modules!");
+ throw new IllegalStateException("Schema Context does not contain "
+ + "defined modules!");
}
if (modules == null) {
- throw new IllegalArgumentException("Sef of Modules cannot be " +
- "NULL!");
+ throw new IllegalArgumentException("Sef of Modules cannot be "
+ + "NULL!");
}
final List<Type> filteredGenTypes = new ArrayList<>();
generatedTypes.addAll(allListsToGenTypes(contextModule));
generatedTypes.addAll(allAugmentsToGenTypes(contextModule));
generatedTypes.addAll(allRPCMethodsToGenType(contextModule));
- generatedTypes.addAll(allNotifycationsToGenType(contextModule));
+ generatedTypes.addAll(allNotificationsToGenType(contextModule));
+ generatedTypes.addAll(allIdentitiesToGenTypes(contextModule,
+ context));
+ generatedTypes.addAll(allGroupingsToGenTypes(contextModule));
if (modules.contains(contextModule)) {
filteredGenTypes.addAll(generatedTypes);
private List<Type> allTypeDefinitionsToGenTypes(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
throw new IllegalArgumentException("Module name cannot be NULL!");
}
if (module.getTypeDefinitions() == null) {
- throw new IllegalArgumentException("Type Definitions for module " +
- module.getName() + " cannot be NULL!");
+ throw new IllegalArgumentException("Type Definitions for module "
+ + module.getName() + " cannot be NULL!");
}
final Set<TypeDefinition<?>> typeDefinitions = module
final List<Type> generatedTypes = new ArrayList<>();
for (final TypeDefinition<?> typedef : typeDefinitions) {
if (typedef != null) {
- final Type type = ((TypeProviderImpl)typeProvider)
+ final Type type = ((TypeProviderImpl) typeProvider)
.generatedTypeForExtendedDefinitionType(typedef);
if ((type != null) && !generatedTypes.contains(type)) {
generatedTypes.add(type);
private List<Type> allContainersToGenTypes(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of Child " +
- "Nodes in module " + module.getName() + " cannot be " +
- "NULL!");
+ throw new IllegalArgumentException("Reference to Set of Child "
+ + "Nodes in module " + module.getName() + " cannot be "
+ + "NULL!");
}
final List<Type> generatedTypes = new ArrayList<>();
- final DataNodeIterator it = new DataNodeIterator(
- module);
+ final DataNodeIterator it = new DataNodeIterator(module);
final List<ContainerSchemaNode> schemaContainers = it.allContainers();
final String basePackageName = moduleNamespaceToPackageName(module);
for (final ContainerSchemaNode container : schemaContainers) {
- generatedTypes.add(containerToGenType(basePackageName,
- container));
+ generatedTypes.add(containerToGenType(basePackageName, container));
}
return generatedTypes;
}
private List<Type> allListsToGenTypes(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of Child " +
- "Nodes in module " + module.getName() + " cannot be " +
- "NULL!");
+ throw new IllegalArgumentException("Reference to Set of Child "
+ + "Nodes in module " + module.getName() + " cannot be "
+ + "NULL!");
}
final List<Type> generatedTypes = new ArrayList<>();
- final DataNodeIterator it = new DataNodeIterator(
- module);
+ final DataNodeIterator it = new DataNodeIterator(module);
final List<ListSchemaNode> schemaLists = it.allLists();
final String basePackageName = moduleNamespaceToPackageName(module);
if (schemaLists != null) {
private List<Type> allAugmentsToGenTypes(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of " +
- "Augmentation Definitions in module " + module.getName()
+ throw new IllegalArgumentException("Reference to Set of "
+ + "Augmentation Definitions in module " + module.getName()
+ " cannot be NULL!");
}
final String basePackageName = moduleNamespaceToPackageName(module);
final List<AugmentationSchema> augmentations = resolveAugmentations(module);
for (final AugmentationSchema augment : augmentations) {
- generatedTypes.addAll(augmentationToGenTypes(basePackageName, augment));
+ generatedTypes.addAll(augmentationToGenTypes(basePackageName,
+ augment));
}
return generatedTypes;
}
private List<AugmentationSchema> resolveAugmentations(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getAugmentations() == null) {
throw new IllegalStateException("Augmentations Set cannot be NULL!");
}
- final Set<AugmentationSchema> augmentations = module
- .getAugmentations();
+ final Set<AugmentationSchema> augmentations = module.getAugmentations();
final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(
augmentations);
Collections.sort(sortedAugmentations,
new Comparator<AugmentationSchema>() {
@Override
- public int compare(
- AugmentationSchema augSchema1,
+ public int compare(AugmentationSchema augSchema1,
AugmentationSchema augSchema2) {
- if (augSchema1.getTargetPath().getPath()
- .size() > augSchema2
+ if (augSchema1.getTargetPath().getPath().size() > augSchema2
.getTargetPath().getPath().size()) {
return 1;
- } else if (augSchema1.getTargetPath()
- .getPath().size() < augSchema2
+ } else if (augSchema1.getTargetPath().getPath().size() < augSchema2
.getTargetPath().getPath().size()) {
return -1;
}
private GeneratedType moduleToDataType(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(
final String basePackageName = moduleNamespaceToPackageName(module);
if (moduleDataTypeBuilder != null) {
final Set<DataSchemaNode> dataNodes = module.getChildNodes();
- resolveDataSchemaNodes(basePackageName, moduleDataTypeBuilder, dataNodes);
+ resolveDataSchemaNodes(basePackageName, moduleDataTypeBuilder,
+ dataNodes);
}
return moduleDataTypeBuilder.toInstance();
}
- private List<GeneratedType> allRPCMethodsToGenType(final Module module) {
+ private List<Type> allRPCMethodsToGenType(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of " +
- "RPC Method Definitions in module " + module.getName()
+ throw new IllegalArgumentException("Reference to Set of "
+ + "RPC Method Definitions in module " + module.getName()
+ " cannot be NULL!");
}
final String basePackageName = moduleNamespaceToPackageName(module);
final Set<RpcDefinition> rpcDefinitions = module.getRpcs();
- final List<GeneratedType> genRPCTypes = new ArrayList<>();
-
+ final List<Type> genRPCTypes = new ArrayList<>();
+ final GeneratedTypeBuilder interfaceBuilder = moduleTypeBuilder(module,
+ "Service");
+ final Type future = Types.typeForClass(Future.class);
for (final RpcDefinition rpc : rpcDefinitions) {
if (rpc != null) {
+
+ String rpcName = parseToClassName(rpc.getQName()
+ .getLocalName());
+ MethodSignatureBuilder method = interfaceBuilder
+ .addMethod(rpcName);
+
final List<DataNodeIterator> rpcInOut = new ArrayList<>();
- rpcInOut.add(new DataNodeIterator(rpc.getInput()));
- rpcInOut.add(new DataNodeIterator(rpc.getOutput()));
+ ContainerSchemaNode input = rpc.getInput();
+ ContainerSchemaNode output = rpc.getOutput();
+
+ if (input != null) {
+ rpcInOut.add(new DataNodeIterator(input));
+ GeneratedTypeBuilder inType = addRawInterfaceDefinition(
+ basePackageName, input, rpcName);
+ resolveDataSchemaNodes(basePackageName, inType, input.getChildNodes());
+ Type inTypeInstance = inType.toInstance();
+ genRPCTypes.add(inTypeInstance);
+ method.addParameter(inTypeInstance, "input");
+ }
+
+ Type outTypeInstance = Types.typeForClass(Void.class);
+ if (output != null) {
+ rpcInOut.add(new DataNodeIterator(output));
+
+ GeneratedTypeBuilder outType = addRawInterfaceDefinition(
+ basePackageName, output, rpcName);
+ resolveDataSchemaNodes(basePackageName, outType, output.getChildNodes());
+ outTypeInstance = outType.toInstance();
+ genRPCTypes.add(outTypeInstance);
+
+ }
+
+ final Type rpcRes = Types.parameterizedTypeFor(
+ Types.typeForClass(RpcResult.class), outTypeInstance);
+ method.addReturnType(Types.parameterizedTypeFor(future, rpcRes));
for (DataNodeIterator it : rpcInOut) {
List<ContainerSchemaNode> nContainers = it.allContainers();
if ((nContainers != null) && !nContainers.isEmpty()) {
for (final ContainerSchemaNode container : nContainers) {
- genRPCTypes.add(containerToGenType(basePackageName, container));
+ genRPCTypes.add(containerToGenType(basePackageName,
+ container));
+ }
+ }
+ List<ListSchemaNode> nLists = it.allLists();
+ if ((nLists != null) && !nLists.isEmpty()) {
+ for (final ListSchemaNode list : nLists) {
+ genRPCTypes.addAll(listToGenType(basePackageName,
+ list));
}
}
}
}
}
+ genRPCTypes.add(interfaceBuilder.toInstance());
return genRPCTypes;
}
- private List<Type> allNotifycationsToGenType(final Module module) {
+ private List<Type> allNotificationsToGenType(final Module module) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
if (module.getName() == null) {
}
if (module.getChildNodes() == null) {
- throw new IllegalArgumentException("Reference to Set of " +
- "Notification Definitions in module " + module.getName()
+ throw new IllegalArgumentException("Reference to Set of "
+ + "Notification Definitions in module " + module.getName()
+ " cannot be NULL!");
}
for (final NotificationDefinition notification : notifications) {
if (notification != null) {
- final List<DataNodeIterator> notifyChildren = new ArrayList<>();
+ DataNodeIterator it = new DataNodeIterator(notification);
- for (DataSchemaNode childNode : notification.getChildNodes()) {
- if (childNode instanceof DataNodeContainer) {
- notifyChildren.add(new DataNodeIterator((DataNodeContainer) childNode));
- }
+ // Containers
+ for (ContainerSchemaNode node : it.allContainers()) {
+ genNotifyTypes
+ .add(containerToGenType(basePackageName, node));
}
-
- for (DataNodeIterator it : notifyChildren) {
- List<ContainerSchemaNode> nContainers = it.allContainers();
- List<ListSchemaNode> nLists = it.allLists();
- if ((nContainers != null) && !nContainers.isEmpty()) {
- for (final ContainerSchemaNode container : nContainers) {
- genNotifyTypes.add(containerToGenType(basePackageName, container));
- }
- }
- if ((nLists != null) && !nLists.isEmpty()) {
- for (final ListSchemaNode list : nLists) {
- genNotifyTypes.addAll(listToGenType(basePackageName, list));
- }
- }
+ // Lists
+ for (ListSchemaNode node : it.allLists()) {
+ genNotifyTypes.addAll(listToGenType(basePackageName, node));
}
+ final GeneratedTypeBuilder notificationTypeBuilder = addRawInterfaceDefinition(
+ basePackageName, notification);
+ notificationTypeBuilder.addImplementsType(Types
+ .typeForClass(Notification.class));
+ // Notification object
+ resolveDataSchemaNodes(basePackageName,
+ notificationTypeBuilder, notification.getChildNodes());
+ genNotifyTypes.add(notificationTypeBuilder.toInstance());
}
}
return genNotifyTypes;
}
+ private List<Type> allIdentitiesToGenTypes(final Module module,
+ final SchemaContext context) {
+ List<Type> genTypes = new ArrayList<Type>();
+
+ final Set<IdentitySchemaNode> schemaIdentities = module.getIdentities();
+
+ final String basePackageName = moduleNamespaceToPackageName(module);
+
+ if (schemaIdentities != null && !schemaIdentities.isEmpty()) {
+ for (final IdentitySchemaNode identity : schemaIdentities) {
+ genTypes.add(identityToGenType(basePackageName, identity,
+ context));
+ }
+ }
+ return genTypes;
+ }
+
+ private GeneratedType identityToGenType(final String basePackageName,
+ IdentitySchemaNode identity, SchemaContext context) {
+ if (identity == null) {
+ return null;
+ }
+
+ final String packageName = packageNameForGeneratedType(basePackageName,
+ identity.getPath());
+
+ final String genTypeName = parseToClassName(identity.getQName()
+ .getLocalName());
+ final GeneratedTOBuilderImpl newType = new GeneratedTOBuilderImpl(
+ packageName, genTypeName);
+
+ IdentitySchemaNode baseIdentity = identity.getBaseIdentity();
+ if (baseIdentity != null) {
+ Module baseIdentityParentModule = SchemaContextUtil.findParentModule(
+ context, baseIdentity);
+
+ final String returnTypePkgName = moduleNamespaceToPackageName(baseIdentityParentModule);
+ final String returnTypeName = parseToClassName(baseIdentity
+ .getQName().getLocalName());
+
+ GeneratedTransferObject gto = new GeneratedTOBuilderImpl(
+ returnTypePkgName, returnTypeName).toInstance();
+ newType.addExtendsType(gto);
+ } else {
+ newType.addExtendsType(Types.getBaseIdentityTO());
+ }
+
+ return newType.toIdentityInstance();
+ }
+
+ private List<Type> allGroupingsToGenTypes(Module module) {
+ final List<Type> genTypes = new ArrayList<Type>();
+ final String basePackageName = moduleNamespaceToPackageName(module);
+ Set<GroupingDefinition> groupings = module.getGroupings();
+ if (groupings != null && !groupings.isEmpty()) {
+ for (final GroupingDefinition grouping : groupings) {
+ genTypes.add(groupingToGenType(basePackageName, grouping));
+ }
+ }
+ return genTypes;
+ }
+
+ private GeneratedType groupingToGenType(final String basePackageName,
+ GroupingDefinition grouping) {
+ if (grouping == null) {
+ return null;
+ }
+
+ final String packageName = packageNameForGeneratedType(basePackageName,
+ grouping.getPath());
+ final Set<DataSchemaNode> schemaNodes = grouping.getChildNodes();
+ final GeneratedTypeBuilder typeBuilder = addRawInterfaceDefinition(
+ packageName, grouping);
+
+ resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);
+ return typeBuilder.toInstance();
+ }
+
private EnumTypeDefinition enumTypeDefFromExtendedType(
final TypeDefinition<?> typeDefinition) {
if (typeDefinition != null) {
}
private GeneratedTypeBuilder moduleTypeBuilder(final Module module,
- final String postfix) {
+ final String postfix) {
if (module == null) {
- throw new IllegalArgumentException("Module reference cannot be NULL!");
+ throw new IllegalArgumentException(
+ "Module reference cannot be NULL!");
}
String packageName = moduleNamespaceToPackageName(module);
- final String moduleName = parseToClassName(module.getName())
- + postfix;
+ final String moduleName = parseToClassName(module.getName()) + postfix;
return new GeneratedTypeBuilderImpl(packageName, moduleName);
}
private List<Type> augmentationToGenTypes(final String augmentPackageName,
- final AugmentationSchema augSchema) {
+ final AugmentationSchema augSchema) {
if (augmentPackageName == null) {
throw new IllegalArgumentException("Package Name cannot be NULL!");
}
// EVERY augmented interface will extends Augmentation<T> interface
// and DataObject interface!!!
final SchemaPath targetPath = augSchema.getTargetPath();
- final DataSchemaNode targetSchemaNode = findDataSchemaNode(schemaContext,
- targetPath);
- if ((targetSchemaNode != null) &&
- (targetSchemaNode.getQName() != null) &&
- (targetSchemaNode.getQName().getLocalName() != null)) {
+ final DataSchemaNode targetSchemaNode = findDataSchemaNode(
+ schemaContext, targetPath);
+ if ((targetSchemaNode != null) && (targetSchemaNode.getQName() != null)
+ && (targetSchemaNode.getQName().getLocalName() != null)) {
final Module targetModule = findParentModule(schemaContext,
targetSchemaNode);
final String targetBasePackage = moduleNamespaceToPackageName(targetModule);
- final String targetPackageName = packageNameForGeneratedType(targetBasePackage,
- targetSchemaNode.getPath());
+ final String targetPackageName = packageNameForGeneratedType(
+ targetBasePackage, targetSchemaNode.getPath());
- final String targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();
- final Set<DataSchemaNode> augChildNodes = augSchema
- .getChildNodes();
+ final String targetSchemaNodeName = targetSchemaNode.getQName()
+ .getLocalName();
+ final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();
final GeneratedTypeBuilder augTypeBuilder = addRawAugmentGenTypeDefinition(
- augmentPackageName, targetPackageName, targetSchemaNodeName, augSchema);
+ augmentPackageName, targetPackageName,
+ targetSchemaNodeName, augSchema);
if (augTypeBuilder != null) {
genTypes.add(augTypeBuilder.toInstance());
}
genTypeBuilders.put(augmentPackageName, augmentBuilders);
}
- final String augTypeName = augGenTypeName(augmentBuilders, targetTypeName);
- final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName, targetTypeName);
- final Set<DataSchemaNode> augChildNodes = augSchema
- .getChildNodes();
+ final String augTypeName = augGenTypeName(augmentBuilders,
+ targetTypeName);
+ final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName,
+ targetTypeName);
+ final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();
final GeneratedTypeBuilder augTypeBuilder = new GeneratedTypeBuilderImpl(
augmentPackageName, augTypeName);
augTypeBuilder.addImplementsType(Types
.augmentationTypeFor(targetTypeRef));
- augSchemaNodeToMethods(augmentPackageName, augTypeBuilder, augChildNodes);
+ augSchemaNodeToMethods(augmentPackageName, augTypeBuilder,
+ augChildNodes);
augmentBuilders.put(augTypeName, augTypeBuilder);
return augTypeBuilder;
}
- private List<Type> augmentationBodyToGenTypes(final String augBasePackageName,
- final Set<DataSchemaNode> augChildNodes) {
+ private List<Type> augmentationBodyToGenTypes(
+ final String augBasePackageName,
+ final Set<DataSchemaNode> augChildNodes) {
final List<Type> genTypes = new ArrayList<>();
final List<DataNodeIterator> augSchemaIts = new ArrayList<>();
for (final DataSchemaNode childNode : augChildNodes) {
if ((augContainers != null) && !augContainers.isEmpty()) {
for (final ContainerSchemaNode container : augContainers) {
- genTypes.add(containerToGenType(augBasePackageName, container));
+ genTypes.add(containerToGenType(augBasePackageName,
+ container));
}
}
if ((augLists != null) && !augLists.isEmpty()) {
}
private GeneratedType containerToGenType(final String basePackageName,
- ContainerSchemaNode containerNode) {
+ ContainerSchemaNode containerNode) {
if (containerNode == null) {
return null;
}
- final String packageName = packageNameForGeneratedType(
- basePackageName, containerNode.getPath());
+ final String packageName = packageNameForGeneratedType(basePackageName,
+ containerNode.getPath());
final Set<DataSchemaNode> schemaNodes = containerNode.getChildNodes();
final GeneratedTypeBuilder typeBuilder = addRawInterfaceDefinition(
packageName, containerNode);
if (schemaNode.isAugmenting()) {
continue;
}
- addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
+ addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode,
+ typeBuilder);
}
}
return typeBuilder;
if ((schemaNodes != null) && (typeBuilder != null)) {
for (final DataSchemaNode schemaNode : schemaNodes) {
if (schemaNode.isAugmenting()) {
- addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
+ addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode,
+ typeBuilder);
}
}
}
return typeBuilder;
}
- private void addSchemaNodeToBuilderAsMethod(
- final String basePackageName,
+ private void addSchemaNodeToBuilderAsMethod(final String basePackageName,
final DataSchemaNode schemaNode,
final GeneratedTypeBuilder typeBuilder) {
if (schemaNode != null && typeBuilder != null) {
enumBuilder.getPackageName(),
enumBuilder.getName());
}
- ((TypeProviderImpl)typeProvider).putReferencedType(leaf
- .getPath(), returnType);
+ ((TypeProviderImpl) typeProvider).putReferencedType(
+ leaf.getPath(), returnType);
}
if (returnType != null) {
constructGetter(typeBuilder, leafName, leafDesc, returnType);
if (!leaf.isConfiguration()) {
- constructSetter(typeBuilder, leafName, leafDesc, returnType);
+ constructSetter(typeBuilder, leafName, leafDesc,
+ returnType);
}
return true;
}
}
private boolean resolveContainerSchemaNode(final String basePackageName,
- final GeneratedTypeBuilder typeBuilder,
- final ContainerSchemaNode containerNode) {
+ final GeneratedTypeBuilder typeBuilder,
+ final ContainerSchemaNode containerNode) {
if ((containerNode != null) && (typeBuilder != null)) {
final String nodeName = containerNode.getQName().getLocalName();
}
private boolean resolveListSchemaNode(final String basePackageName,
- final GeneratedTypeBuilder typeBuilder,
- final ListSchemaNode schemaNode) {
+ final GeneratedTypeBuilder typeBuilder,
+ final ListSchemaNode schemaNode) {
if ((schemaNode != null) && (typeBuilder != null)) {
final String listName = schemaNode.getQName().getLocalName();
}
private GeneratedTypeBuilder addRawInterfaceDefinition(
- final String packageName, final DataSchemaNode schemaNode) {
+ final String packageName, final SchemaNode schemaNode) {
+ return addRawInterfaceDefinition(packageName, schemaNode, "");
+ }
+
+ private GeneratedTypeBuilder addRawInterfaceDefinition(
+ final String packageName, final SchemaNode schemaNode,
+ final String prefix) {
if (schemaNode == null) {
return null;
}
final String schemaNodeName = schemaNode.getQName().getLocalName();
if ((packageName != null) && (schemaNodeName != null)) {
- final String genTypeName = parseToClassName(schemaNodeName);
+ final String genTypeName = prefix + parseToClassName(schemaNodeName)
+ ;
final GeneratedTypeBuilder newType = new GeneratedTypeBuilderImpl(
packageName, genTypeName);
return setMethod;
}
-
private List<Type> listToGenType(final String basePackageName,
- final ListSchemaNode list) {
+ final ListSchemaNode list) {
if (basePackageName == null) {
throw new IllegalArgumentException(
"Package Name for Generated Type cannot be NULL!");
"List Schema Node cannot be NULL!");
}
- final String packageName = packageNameForGeneratedType(
- basePackageName, list.getPath());
+ final String packageName = packageNameForGeneratedType(basePackageName,
+ list.getPath());
final GeneratedTypeBuilder typeBuilder = resolveListTypeBuilder(
packageName, list);
final List<String> listKeys = listKeys(list);
if (schemaNode.isAugmenting()) {
continue;
}
- addSchemaNodeToListBuilders(basePackageName, schemaNode, typeBuilder,
- genTOBuilder, listKeys);
+ addSchemaNodeToListBuilders(basePackageName, schemaNode,
+ typeBuilder, genTOBuilder, listKeys);
}
return typeBuildersToGenTypes(typeBuilder, genTOBuilder);
}
private void addSchemaNodeToListBuilders(final String basePackageName,
- final DataSchemaNode schemaNode,
- final GeneratedTypeBuilder typeBuilder,
- final GeneratedTOBuilder genTOBuilder,
- final List<String> listKeys) {
+ final DataSchemaNode schemaNode,
+ final GeneratedTypeBuilder typeBuilder,
+ final GeneratedTOBuilder genTOBuilder, final List<String> listKeys) {
if (schemaNode == null) {
throw new IllegalArgumentException(
"Data Schema Node cannot be NULL!");
resolveContainerSchemaNode(basePackageName, typeBuilder,
(ContainerSchemaNode) schemaNode);
} else if (schemaNode instanceof ListSchemaNode) {
- resolveListSchemaNode(basePackageName, typeBuilder, (ListSchemaNode) schemaNode);
+ resolveListSchemaNode(basePackageName, typeBuilder,
+ (ListSchemaNode) schemaNode);
}
}
* @return
*/
private GeneratedTOBuilder resolveListKey(final String packageName,
- final ListSchemaNode list) {
+ final ListSchemaNode list) {
final String listName = list.getQName().getLocalName() + "Key";
return schemaNodeToTransferObjectBuilder(packageName, list, listName);
}
private boolean isPartOfListKey(final LeafSchemaNode leaf,
- final List<String> keys) {
+ final List<String> keys) {
if ((leaf != null) && (keys != null) && (leaf.getQName() != null)) {
final String leafName = leaf.getQName().getLocalName();
if (keys.contains(leafName)) {
final String genTypeName = parseToClassName(schemaNodeName);
GeneratedTypeBuilder typeBuilder = null;
- final Map<String, GeneratedTypeBuilder> builders = genTypeBuilders.get(packageName);
+ final Map<String, GeneratedTypeBuilder> builders = genTypeBuilders
+ .get(packageName);
if (builders != null) {
typeBuilder = builders.get(genTypeName);
}
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.*;
import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
final LeafrefTypeDefinition leafref = (LeafrefTypeDefinition) baseTypeDef;
returnType = provideTypeForLeafref(leafref);
} else if (baseTypeDef instanceof IdentityrefTypeDefinition) {
-
+ final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition)typeDefinition;
+ returnType = returnTypeForIdentityref(idref);
} else if (baseTypeDef instanceof EnumTypeDefinition) {
final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) baseTypeDef;
returnType = resolveEnumFromTypeDefinition(enumTypeDef,
final LeafrefTypeDefinition leafref = (LeafrefTypeDefinition) typeDefinition;
returnType = provideTypeForLeafref(leafref);
} else if (typeDefinition instanceof IdentityrefTypeDefinition) {
-
+ final IdentityrefTypeDefinition idref = (IdentityrefTypeDefinition)typeDefinition;
+ returnType = returnTypeForIdentityref(idref);
} else {
returnType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
.javaTypeForSchemaDefinitionType(typeDefinition);
// }
return returnType;
}
+
+ private Type returnTypeForIdentityref(IdentityrefTypeDefinition idref) {
+ QName baseIdQName = idref.getIdentity();
+ Module module = schemaContext.findModuleByNamespace(baseIdQName.getNamespace());
+ IdentitySchemaNode identity = null;
+ for(IdentitySchemaNode id : module.getIdentities()) {
+ if(id.getQName().equals(baseIdQName)) {
+ identity = id;
+ }
+ }
+ if(identity == null) {
+ throw new IllegalArgumentException("Target identity '" + baseIdQName + "' do not exists");
+ }
+
+ final String basePackageName = moduleNamespaceToPackageName(module);
+ final String packageName = packageNameForGeneratedType(basePackageName, identity.getPath());
+ final String genTypeName = parseToClassName(identity.getQName().getLocalName());
+
+ Type baseType = Types.typeForClass(Class.class);
+ Type paramType = Types.wildcardTypeFor(packageName, genTypeName);
+ Type returnType = Types.parameterizedTypeFor(baseType, paramType);
+ return returnType;
+ }
public Type generatedTypeForExtendedDefinitionType(
final TypeDefinition<?> typeDefinition) {
assertTrue(genTypes != null);
assertEquals("Expected count of all Generated Types from yang models " +
- "is 22", 22, genTypes.size());
+ "is 22", 25, genTypes.size());
GeneratedType genInterface = null;
for (final Type type : genTypes) {
final BindingGenerator bindingGen = new BindingGeneratorImpl();
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(2, genTypes.size());
+ assertEquals(3, genTypes.size());
final Type type = genTypes.get(1);
assertTrue(type instanceof Enumeration);
assertNotNull("genTypes is null", genTypes);
assertFalse("genTypes is empty", genTypes.isEmpty());
assertEquals("Expected Generated Types from provided sub set of " +
- "modules should be 23!", 23,
+ "modules should be 23!", 25,
genTypes.size());
}
assertNotNull("genTypes is null", genTypes);
assertFalse("genTypes is empty", genTypes.isEmpty());
assertEquals("Expected Generated Types from provided sub set of " +
- "modules should be 25!", 25, genTypes.size());
+ "modules should be 25!", 28, genTypes.size());
}
}
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(27, genTypes.size());
+ assertEquals(29, genTypes.size());
}
@Test
final BindingGenerator bindingGen = new BindingGeneratorImpl();
final List<Type> genTypes = bindingGen.generateTypes(context);
- assertEquals(53, genTypes.size());
+ assertEquals(57, genTypes.size());
assertTrue(genTypes != null);
GeneratedTransferObject gtIfcKey = null;
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(3, genTypes.size());
+ assertEquals(4, genTypes.size());
final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(3, genTypes.size());
+ assertEquals(4, genTypes.size());
final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(5, genTypes.size());
+ assertEquals(6, genTypes.size());
int genTypesCount = 0;
int genTOsCount = 0;
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(7, genTypes.size());
+ assertEquals(8, genTypes.size());
int genTypesCount = 0;
int genTOsCount = 0;
}
}
- assertEquals(5, genTypesCount);
+ assertEquals(6, genTypesCount);
assertEquals(2, genTOsCount);
}
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(14, genTypes.size());
+ assertEquals(15, genTypes.size());
int genTypesCount = 0;
int genTOsCount = 0;
}
}
- assertEquals(11, genTypesCount);
+ assertEquals(12, genTypesCount);
assertEquals(3, genTOsCount);
}
}
import java.util.Map;\r
import java.util.Set;\r
\r
+import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;\r
import org.opendaylight.controller.sal.binding.model.api.ConcreteType;\r
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;\r
import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;\r
import org.opendaylight.controller.sal.binding.model.api.Type;\r
+import org.opendaylight.controller.sal.binding.model.api.WildcardType;\r
import org.opendaylight.controller.yang.binding.Augmentable;\r
import org.opendaylight.controller.yang.binding.Augmentation;\r
+import org.opendaylight.controller.yang.binding.BaseIdentity;\r
import org.opendaylight.controller.yang.binding.DataObject;\r
\r
public final class Types {\r
\r
/**\r
* Returns an instance of {@link ConcreteType} describing the class\r
- * \r
+ *\r
* @param cls\r
* Class to describe\r
* @return Description of class\r
/**\r
* Returns an instance of {@link ParameterizedType} describing the typed\r
* {@link Map}<K,V>\r
- * \r
+ *\r
* @param keyType\r
* Key Type\r
* @param valueType\r
/**\r
* Returns an instance of {@link ParameterizedType} describing the typed\r
* {@link Set}<V> with concrete type of value.\r
- * \r
+ *\r
* @param valueType\r
* Value Type\r
* @return Description of generic type instance of Set\r
/**\r
* Returns an instance of {@link ParameterizedType} describing the typed\r
* {@link List}<V> with concrete type of value.\r
- * \r
+ *\r
* @param valueType\r
* Value Type\r
* @return Description of type instance of List\r
return parameterizedTypeFor(LIST_TYPE, valueType);\r
}\r
\r
+ public static GeneratedTransferObject getBaseIdentityTO() {\r
+ Class<BaseIdentity> cls = BaseIdentity.class;\r
+ GeneratedTOBuilderImpl gto = new GeneratedTOBuilderImpl(cls.getPackage().getName(),\r
+ cls.getSimpleName());\r
+ return gto.toInstance();\r
+ }\r
+\r
/**\r
- * \r
+ *\r
* @param type\r
* @param parameters\r
* @return\r
Type... parameters) {\r
return new ParametrizedTypeImpl(type, parameters);\r
}\r
- \r
+\r
+ public static WildcardType wildcardTypeFor(String packageName, String typeName) {\r
+ return new WildcardTypeImpl(packageName, typeName);\r
+ }\r
+\r
public static ParameterizedType augmentableTypeFor(Type valueType) {\r
final Type augmentable = typeForClass(Augmentable.class);\r
return parameterizedTypeFor(augmentable, valueType);\r
}\r
- \r
+\r
public static ParameterizedType augmentationTypeFor(Type valueType) {\r
final Type augmentation = typeForClass(Augmentation.class);\r
return parameterizedTypeFor(augmentation, valueType);\r
}\r
- \r
+\r
private static class ConcreteTypeImpl extends AbstractBaseType implements\r
ConcreteType {\r
private ConcreteTypeImpl(String pkName, String name) {\r
}\r
\r
}\r
+\r
+ private static class WildcardTypeImpl extends AbstractBaseType\r
+ implements WildcardType {\r
+ public WildcardTypeImpl(String packageName, String typeName) {\r
+ super(packageName, typeName);\r
+ }\r
+ }\r
+\r
}\r
import org.opendaylight.controller.sal.binding.model.api.Constant;
import org.opendaylight.controller.sal.binding.model.api.Enumeration;
import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferIdentityObject;
import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
import org.opendaylight.controller.sal.binding.model.api.Type;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder;
-public final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
+public class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
private String packageName;
private final String name;
private String comment = "";
-
+
private GeneratedTransferObject extendsType;
private final List<Type> implementsTypes = new ArrayList<Type>();
private final List<EnumBuilder> enumerations = new ArrayList<EnumBuilder>();
}
return null;
}
-
+
@Override
public boolean addImplementsType(final Type genType) {
if (genType != null) {
}
return false;
}
-
+
@Override
public EnumBuilder addEnumeration(String name) {
final String innerPackageName = packageName + "." + this.name;
@Override
public GeneratedTransferObject toInstance() {
- return new GeneratedTransferObjectImpl(packageName, name, comment,
- annotationBuilders, extendsType, implementsTypes, constantDefintions, enumerations,
- methodDefinitions, properties, equalsProperties,
- hashProperties, toStringProperties);
+ return new GeneratedTransferObjectImpl(packageName, name, comment,
+ annotationBuilders, extendsType, implementsTypes,
+ constantDefintions, enumerations, methodDefinitions,
+ properties, equalsProperties, hashProperties,
+ toStringProperties);
+ }
+
+ @Override
+ public GeneratedTransferObject toIdentityInstance() {
+ return new GeneratedTransferIdentityObjectImpl(packageName, name, comment,
+ annotationBuilders, extendsType, implementsTypes,
+ constantDefintions, enumerations, methodDefinitions,
+ properties, equalsProperties, hashProperties,
+ toStringProperties);
}
private static final class GeneratedPropertyBuilderImpl implements
@Override
public GeneratedProperty toInstance(final Type definingType) {
- return new GeneratedPropertyImpl(name, comment, annotationBuilders, definingType,
- returnType, isFinal, isReadOnly, parameters, accessModifier);
+ return new GeneratedPropertyImpl(name, comment, annotationBuilders,
+ definingType, returnType, isFinal, isReadOnly, parameters,
+ accessModifier);
}
}
private final boolean isReadOnly;
private final List<MethodSignature.Parameter> parameters;
private final AccessModifier modifier;
-
+
public GeneratedPropertyImpl(final String name, final String comment,
- final List<AnnotationTypeBuilder> annotationBuilders, final Type parent, final Type returnType,
+ final List<AnnotationTypeBuilder> annotationBuilders,
+ final Type parent, final Type returnType,
final boolean isFinal, final boolean isReadOnly,
final List<Parameter> parameters, final AccessModifier modifier) {
super();
public List<AnnotationType> getAnnotations() {
return annotations;
}
-
+
@Override
public Type getReturnType() {
return returnType;
return isFinal;
}
-
-
@Override
public int hashCode() {
final int prime = 31;
if (other.returnType != null) {
return false;
}
- } else if (!returnType.getPackageName().equals(other.returnType.getPackageName())) {
+ } else if (!returnType.getPackageName().equals(
+ other.returnType.getPackageName())) {
return false;
} else if (!returnType.getName().equals(other.returnType.getName())) {
return false;
}
}
- private static final class GeneratedTransferObjectImpl implements
+ private static class GeneratedTransferObjectImpl implements
GeneratedTransferObject {
private final String packageName;
private final List<Type> implementsTypes;
public GeneratedTransferObjectImpl(final String packageName,
- final String name,
- final String comment,
+ final String name, final String comment,
final List<AnnotationTypeBuilder> annotationBuilders,
final GeneratedTransferObject extendsType,
final List<Type> implementsTypes,
this.comment = comment;
this.annotations = toUnmodifiableAnnotations(annotationBuilders);
this.extendsType = extendsType;
- this.implementsTypes = Collections.unmodifiableList(implementsTypes);
+ this.implementsTypes = Collections
+ .unmodifiableList(implementsTypes);
this.constants = toUnmodifiableConstant(constantBuilders);
this.enumerations = toUnmodifiableEnumerations(enumBuilders);
this.properties = toUnmodifiableProperties(propBuilers);
public Type getParentType() {
return null;
}
-
+
@Override
public String getComment() {
return comment;
}
-
+
@Override
public List<AnnotationType> getAnnotations() {
return annotations;
}
-
+
@Override
public List<Type> getImplements() {
return implementsTypes;
public GeneratedTransferObject getExtends() {
return extendsType;
}
-
+
@Override
public List<Enumeration> getEnumDefintions() {
return enumerations;
return builder.toString();
}
}
+
+ private static final class GeneratedTransferIdentityObjectImpl extends
+ GeneratedTransferObjectImpl implements
+ GeneratedTransferIdentityObject {
+ public GeneratedTransferIdentityObjectImpl(final String packageName,
+ final String name, final String comment,
+ final List<AnnotationTypeBuilder> annotationBuilders,
+ final GeneratedTransferObject extendsType,
+ final List<Type> implementsTypes,
+ final List<ConstantBuilder> constantBuilders,
+ final List<EnumBuilder> enumBuilders,
+ final List<MethodSignatureBuilder> methodBuilders,
+ final List<GeneratedPropertyBuilder> propBuilers,
+ final List<GeneratedPropertyBuilder> equalsBuilers,
+ final List<GeneratedPropertyBuilder> hashCodeBuilers,
+ final List<GeneratedPropertyBuilder> stringBuilers) {
+ super(packageName, name, comment, annotationBuilders, extendsType,
+ implementsTypes, constantBuilders, enumBuilders,
+ methodBuilders, propBuilers, equalsBuilers,
+ hashCodeBuilers, stringBuilers);
+ }
+ }
}
import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
import org.opendaylight.controller.sal.binding.model.api.Enumeration;
import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferIdentityObject;
import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.controller.sal.binding.model.api.Type;
@Override
public Writer generate(Type type) throws IOException {
final Writer writer = new StringWriter();
+ boolean isIdentity = type instanceof GeneratedTransferIdentityObject;
+
if (type instanceof GeneratedTransferObject) {
GeneratedTransferObject genTO = (GeneratedTransferObject) type;
imports = GeneratorUtil.createImports(genTO);
writer.write(NL);
writer.write(GeneratorUtil.createClassDeclaration(genTO, "",
- imports));
+ imports, isIdentity));
writer.write(NL);
writer.write(NL);
}
writer.write(NL);
writer.write(GeneratorUtil.createConstructor(genTO, TAB,
- imports) + NL);
+ imports, isIdentity) + NL);
writer.write(NL);
for (GeneratedProperty field : fields) {
writer.write(GeneratorUtil.createGetter(field, TAB,
package org.opendaylight.controller.sal.java.api.generator;
final class Constants {
-
public static final String IFC = "interface";
public static final String CLASS = "class";
public static final String PKG = "package";
public static final String COMMA = ",";
public static final String NL = "\n";
public static final String SC = ";";
- public static final String TAB = "\t";
+ public static final String TAB = " ";
public static final String PUBLIC = "public";
public static final String PRIVATE = "private";
+ public static final String PROTECTED = "protected";
public static final String STATIC = "static";
+ public static final String ABSTRACT = "abstract";
public static final String FINAL = "final";
public static final String EXTENDS = "extends";
public static final String IMPLEMENTS = "implements";
import org.opendaylight.controller.sal.binding.model.api.MethodSignature.Parameter;
import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.WildcardType;
public final class GeneratorUtil {
- private GeneratorUtil() {
- }
-
- public static String createIfcDeclaration(final GeneratedType genType,
- final String indent,
- final Map<String, LinkedHashMap<String, Integer>> availableImports) {
- return createFileDeclaration(IFC, genType, indent, availableImports);
- }
-
- public static String createClassDeclaration(
- final GeneratedTransferObject genTransferObject,
- final String indent,
- final Map<String, LinkedHashMap<String, Integer>> availableImports) {
- return createFileDeclaration(CLASS, genTransferObject, indent,
- availableImports);
- }
-
- public static String createPackageDeclaration(final String packageName) {
- return PKG + GAP + packageName + SC;
- }
-
- private static String createFileDeclaration(final String type,
- final GeneratedType genType, final String indent,
- final Map<String, LinkedHashMap<String, Integer>> availableImports) {
- final StringBuilder builder = new StringBuilder();
- final String currentPkg = genType.getPackageName();
-
- createComment(builder, genType.getComment(), indent);
-
- if (!genType.getAnnotations().isEmpty()) {
- final List<AnnotationType> annotations = genType.getAnnotations();
- appendAnnotations(builder, annotations);
- builder.append(NL);
- }
- builder.append(PUBLIC + GAP + type + GAP + genType.getName() + GAP);
-
- if (genType instanceof GeneratedTransferObject) {
- GeneratedTransferObject genTO = (GeneratedTransferObject) genType;
-
- if (genTO.getExtends() != null) {
- builder.append(EXTENDS + GAP);
- builder.append(genTO.getExtends() + GAP);
- }
- }
-
- final List<Type> genImplements = genType.getImplements();
- if (!genImplements.isEmpty()) {
- if (genType instanceof GeneratedTransferObject) {
- builder.append(IMPLEMENTS + GAP);
- } else {
- builder.append(EXTENDS + GAP);
- }
- builder.append(getExplicitType(genImplements.get(0),
- availableImports, currentPkg));
-
- for (int i = 1; i < genImplements.size(); ++i) {
- builder.append(", ");
- builder.append(getExplicitType(genImplements.get(i),
- availableImports, currentPkg));
- }
- }
-
- builder.append(GAP + LCB);
- return builder.toString();
- }
-
- private static StringBuilder appendAnnotations(final StringBuilder builder,
- final List<AnnotationType> annotations) {
- if ((builder != null) && (annotations != null)) {
- for (final AnnotationType annotation : annotations) {
- builder.append("@");
- builder.append(annotation.getPackageName());
- builder.append(".");
- builder.append(annotation.getName());
-
- if (annotation.containsParameters()) {
- builder.append("(");
- final List<AnnotationType.Parameter> parameters = annotation
- .getParameters();
- appendAnnotationParams(builder, parameters);
- builder.append(")");
- }
- }
- }
- return builder;
- }
-
- private static StringBuilder appendAnnotationParams(
- final StringBuilder builder,
- final List<AnnotationType.Parameter> parameters) {
- if (parameters != null) {
- int i = 0;
- for (final AnnotationType.Parameter param : parameters) {
- if (param == null) {
- continue;
- }
- if (i > 0) {
- builder.append(", ");
- }
- final String paramName = param.getName();
- if (param.getValue() != null) {
- builder.append(paramName);
- builder.append(" = ");
- builder.append(param.getValue());
- } else {
- builder.append(paramName);
- builder.append(" = {");
- final List<String> values = param.getValues();
- builder.append(values.get(0));
- for (int j = 1; j < values.size(); ++j) {
- builder.append(", ");
- builder.append(values.get(j));
- }
- builder.append("}");
- }
- i++;
- }
- }
- return builder;
- }
-
- public static String createConstant(final Constant constant,
- final String indent,
- final Map<String, LinkedHashMap<String, Integer>> availableImports,
- final String currentPkg) {
- final StringBuilder builder = new StringBuilder();
- builder.append(indent + PUBLIC + GAP + STATIC + GAP + FINAL + GAP);
- builder.append(getExplicitType(constant.getType(), availableImports,
- currentPkg) + GAP + constant.getName());
- builder.append(GAP + "=" + GAP);
- builder.append(constant.getValue() + SC);
- return builder.toString();
- }
-
- public static String createField(final GeneratedProperty property,
- final String indent,
- Map<String, LinkedHashMap<String, Integer>> availableImports,
- final String currentPkg) {
- final StringBuilder builder = new StringBuilder();
- builder.append(indent);
- if (!property.getAnnotations().isEmpty()) {
- final List<AnnotationType> annotations = property.getAnnotations();
- appendAnnotations(builder, annotations);
- builder.append(NL);
- }
- builder.append(indent + PRIVATE + GAP);
- builder.append(getExplicitType(property.getReturnType(),
- availableImports, currentPkg) + GAP + property.getName());
- builder.append(SC);
- return builder.toString();
- }
-
- /**
- * Create method declaration in interface.
- *
- * @param method
- * @param indent
- * @return
- */
- public static String createMethodDeclaration(final MethodSignature method,
- final String indent,
- Map<String, LinkedHashMap<String, Integer>> availableImports,
- final String currentPkg) {
- final StringBuilder builder = new StringBuilder();
-
- if (method == null) {
- throw new IllegalArgumentException(
- "Method Signature parameter MUST be specified and cannot be NULL!");
- }
-
- final String comment = method.getComment();
- final String name = method.getName();
- if (name == null) {
- throw new IllegalStateException("Method Name cannot be NULL!");
- }
-
- final Type type = method.getReturnType();
- if (type == null) {
- throw new IllegalStateException(
- "Method Return type cannot be NULL!");
- }
-
- final List<Parameter> parameters = method.getParameters();
-
- createComment(builder, comment, indent);
- builder.append(NL);
- builder.append(indent);
-
- if (!method.getAnnotations().isEmpty()) {
- final List<AnnotationType> annotations = method.getAnnotations();
- appendAnnotations(builder, annotations);
- builder.append(NL);
- }
-
- builder.append(indent
- + getExplicitType(type, availableImports, currentPkg) + GAP
- + name);
- builder.append(LB);
- for (int i = 0; i < parameters.size(); i++) {
- Parameter p = parameters.get(i);
- String separator = COMMA;
- if (i + 1 == parameters.size()) {
- separator = "";
- }
- builder.append(getExplicitType(p.getType(), availableImports,
- currentPkg) + GAP + p.getName() + separator);
- }
- builder.append(RB);
- builder.append(SC);
-
- return builder.toString();
- }
-
- public static String createConstructor(
- GeneratedTransferObject genTransferObject, final String indent,
- Map<String, LinkedHashMap<String, Integer>> availableImports) {
- final StringBuilder builder = new StringBuilder();
-
- final String currentPkg = genTransferObject.getPackageName();
- final List<GeneratedProperty> properties = genTransferObject
- .getProperties();
- final List<GeneratedProperty> ctorParams = new ArrayList<GeneratedProperty>();
- for (final GeneratedProperty property : properties) {
- if (property.isReadOnly()) {
- ctorParams.add(property);
- }
- }
-
- builder.append(indent);
- builder.append(PUBLIC);
- builder.append(GAP);
- builder.append(genTransferObject.getName());
- builder.append(LB);
-
- if (!ctorParams.isEmpty()) {
- builder.append(getExplicitType(ctorParams.get(0).getReturnType(),
- availableImports, currentPkg));
- builder.append(" ");
- builder.append(ctorParams.get(0).getName());
- for (int i = 1; i < ctorParams.size(); ++i) {
- final GeneratedProperty param = ctorParams.get(i);
- builder.append(", ");
- builder.append(getExplicitType(param.getReturnType(),
- availableImports, currentPkg));
- builder.append(GAP);
- builder.append(param.getName());
- }
- }
- builder.append(RB + GAP + LCB + NL + indent + TAB + "super();" + NL);
- if (!ctorParams.isEmpty()) {
- for (final GeneratedProperty property : ctorParams) {
- builder.append(indent);
- builder.append(TAB);
- builder.append("this.");
- builder.append(property.getName());
- builder.append(" = ");
- builder.append(property.getName());
- builder.append(SC);
- builder.append(NL);
- }
- }
- builder.append(indent);
- builder.append(RCB);
- return builder.toString();
- }
-
- public static String createGetter(final GeneratedProperty property,
- final String indent,
- Map<String, LinkedHashMap<String, Integer>> availableImports,
- final String currentPkg) {
- final StringBuilder builder = new StringBuilder();
-
- final Type type = property.getReturnType();
- final String varName = property.getName();
- final char first = Character.toUpperCase(varName.charAt(0));
- final String methodName = "get" + first + varName.substring(1);
-
- builder.append(indent + PUBLIC + GAP
- + getExplicitType(type, availableImports, currentPkg) + GAP
- + methodName);
- builder.append(LB + RB + LCB + NL);
-
- String currentIndent = indent + TAB;
-
- builder.append(currentIndent + "return " + varName + SC + NL);
-
- builder.append(indent + RCB);
- return builder.toString();
- }
-
- public static String createSetter(final GeneratedProperty property,
- final String indent,
- Map<String, LinkedHashMap<String, Integer>> availableImports,
- String currentPkg) {
- final StringBuilder builder = new StringBuilder();
-
- final Type type = property.getReturnType();
- final String varName = property.getName();
- final char first = Character.toUpperCase(varName.charAt(0));
- final String methodName = "set" + first + varName.substring(1);
-
- builder.append(indent + PUBLIC + GAP + "void" + GAP + methodName);
- builder.append(LB + getExplicitType(type, availableImports, currentPkg)
- + GAP + varName + RB + LCB + NL);
- String currentIndent = indent + TAB;
- builder.append(currentIndent + "this." + varName + " = " + varName + SC
- + NL);
- builder.append(indent + RCB);
- return builder.toString();
- }
-
- public static String createHashCode(
- final List<GeneratedProperty> properties, final String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(indent + "public int hashCode() {" + NL);
- builder.append(indent + TAB + "final int prime = 31;" + NL);
- builder.append(indent + TAB + "int result = 1;" + NL);
-
- for (GeneratedProperty property : properties) {
- String fieldName = property.getName();
- builder.append(indent + TAB + "result = prime * result + (("
- + fieldName + " == null) ? 0 : " + fieldName
- + ".hashCode());" + NL);
- }
-
- builder.append(indent + TAB + "return result;" + NL);
- builder.append(indent + RCB + NL);
- return builder.toString();
- }
-
- public static String createEquals(final GeneratedTransferObject type,
- final List<GeneratedProperty> properties, final String indent) {
- StringBuilder builder = new StringBuilder();
- final String indent1 = indent + TAB;
- final String indent2 = indent1 + TAB;
- final String indent3 = indent2 + TAB;
-
- builder.append(indent + "public boolean equals(Object obj) {" + NL);
- builder.append(indent1 + "if (this == obj) {" + NL);
- builder.append(indent2 + "return true;" + NL);
- builder.append(indent1 + "}" + NL);
- builder.append(indent1 + "if (obj == null) {" + NL);
- builder.append(indent2 + "return false;" + NL);
- builder.append(indent1 + "}" + NL);
- builder.append(indent1 + "if (getClass() != obj.getClass()) {" + NL);
- builder.append(indent2 + "return false;" + NL);
- builder.append(indent1 + "}" + NL);
-
- String typeStr = type.getName();
- builder.append(indent1 + typeStr + " other = (" + typeStr + ") obj;"
- + NL);
-
- for (GeneratedProperty property : properties) {
- String fieldName = property.getName();
- builder.append(indent1 + "if (" + fieldName + " == null) {" + NL);
- builder.append(indent2 + "if (other." + fieldName + " != null) {"
- + NL);
- builder.append(indent3 + "return false;" + NL);
- builder.append(indent2 + "}" + NL);
- builder.append(indent1 + "} else if (!" + fieldName
- + ".equals(other." + fieldName + ")) {" + NL);
- builder.append(indent2 + "return false;" + NL);
- builder.append(indent1 + "}" + NL);
- }
-
- builder.append(indent1 + "return true;" + NL);
-
- builder.append(indent + RCB + NL);
- return builder.toString();
- }
-
- public static String createToString(final GeneratedTransferObject type,
- final List<GeneratedProperty> properties, final String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(indent);
- builder.append("public String toString() {");
- builder.append(NL);
- builder.append(indent);
- builder.append(TAB);
- builder.append("StringBuilder builder = new StringBuilder();");
- builder.append(NL);
- builder.append(indent);
- builder.append(TAB);
- builder.append("builder.append(\"");
- builder.append(type.getName());
- builder.append(" [");
-
- boolean first = true;
- for (GeneratedProperty property : properties) {
- if (first) {
- builder.append(property.getName());
- builder.append("=\");");
- builder.append(NL);
- builder.append(indent);
- builder.append(TAB);
- builder.append("builder.append(");
- builder.append(property.getName());
- builder.append(");");
- first = false;
- } else {
- builder.append(NL);
- builder.append(indent);
- builder.append(TAB);
- builder.append("builder.append(\", ");
- builder.append(property.getName());
- builder.append("=\");");
- builder.append(NL);
- builder.append(indent);
- builder.append(TAB);
- builder.append("builder.append(");
- builder.append(property.getName());
- builder.append(");");
- }
- }
- builder.append(NL);
- builder.append(indent);
- builder.append(TAB);
- builder.append("builder.append(\"]\");");
- builder.append(NL);
- builder.append(indent);
- builder.append(TAB);
- builder.append("return builder.toString();");
-
- builder.append(NL);
- builder.append(indent);
- builder.append(RCB);
- builder.append(NL);
- return builder.toString();
- }
-
- public static String createEnum(final Enumeration enumeration,
- final String indent) {
- if (enumeration == null || indent == null)
- throw new IllegalArgumentException();
- final StringBuilder builder = new StringBuilder(indent + PUBLIC + GAP
- + ENUM + GAP + enumeration.getName() + GAP + LCB + NL);
-
- String separator = COMMA + NL;
- final List<Pair> values = enumeration.getValues();
-
- for (int i = 0; i < values.size(); i++) {
- if (i + 1 == values.size()) {
- separator = SC;
- }
- builder.append(indent + TAB + values.get(i).getName() + LB
- + values.get(i).getValue() + RB + separator);
- }
- builder.append(NL);
- builder.append(NL);
- final String ENUMERATION_NAME = "value";
- final String ENUMERATION_TYPE = "int";
- builder.append(indent + TAB + ENUMERATION_TYPE + GAP + ENUMERATION_NAME
- + SC);
- builder.append(NL);
- builder.append(indent + TAB + PRIVATE + GAP + enumeration.getName()
- + LB + ENUMERATION_TYPE + GAP + ENUMERATION_NAME + RB + GAP
- + LCB + NL);
- builder.append(indent + TAB + TAB + "this." + ENUMERATION_NAME + GAP
- + "=" + GAP + ENUMERATION_NAME + SC + NL);
- builder.append(indent + TAB + RCB + NL);
-
- builder.append(indent + RCB);
- builder.append(NL);
- return builder.toString();
- }
-
- private static String getExplicitType(final Type type,
- Map<String, LinkedHashMap<String, Integer>> availableImports,
- final String currentPkg) {
- if (type == null) {
- throw new IllegalArgumentException(
- "Type parameter MUST be specified and cannot be NULL!");
- }
- String packageName = type.getPackageName();
-
- LinkedHashMap<String, Integer> imports = availableImports.get(type
- .getName());
-
- if ((imports != null && packageName
- .equals(findMaxValue(imports).get(0)))
- || packageName.equals(currentPkg)) {
- final StringBuilder builder = new StringBuilder(type.getName());
- if (type instanceof ParameterizedType) {
- ParameterizedType pType = (ParameterizedType) type;
- Type[] pTypes = pType.getActualTypeArguments();
- builder.append("<");
- builder.append(getParameters(pTypes, availableImports,
- currentPkg));
- builder.append(">");
- }
- if (builder.toString().equals("Void")) {
- return "void";
- }
- return builder.toString();
- } else {
- final StringBuilder builder = new StringBuilder();
- if (packageName.startsWith("java.lang")) {
- builder.append(type.getName());
- } else {
+ private GeneratorUtil() {
+ }
+
+ public static String createIfcDeclaration(final GeneratedType genType,
+ final String indent,
+ final Map<String, LinkedHashMap<String, Integer>> availableImports) {
+ return createFileDeclaration(IFC, genType, indent, availableImports,
+ false);
+ }
+
+ public static String createClassDeclaration(
+ final GeneratedTransferObject genTransferObject,
+ final String indent,
+ final Map<String, LinkedHashMap<String, Integer>> availableImports,
+ boolean isIdentity) {
+ return createFileDeclaration(CLASS, genTransferObject, indent,
+ availableImports, isIdentity);
+ }
+
+ public static String createPackageDeclaration(final String packageName) {
+ return PKG + GAP + packageName + SC;
+ }
+
+ private static String createFileDeclaration(final String type,
+ final GeneratedType genType, final String indent,
+ final Map<String, LinkedHashMap<String, Integer>> availableImports,
+ boolean isIdentity) {
+ final StringBuilder builder = new StringBuilder();
+ final String currentPkg = genType.getPackageName();
+
+ createComment(builder, genType.getComment(), indent);
+
+ if (!genType.getAnnotations().isEmpty()) {
+ final List<AnnotationType> annotations = genType.getAnnotations();
+ appendAnnotations(builder, annotations);
+ builder.append(NL);
+ }
+
+ if (isIdentity) {
+ if (!(CLASS.equals(type))) {
+ throw new IllegalArgumentException(
+ "'identity' has to be generated as a class");
+ }
+ builder.append(PUBLIC + GAP + ABSTRACT + GAP + type + GAP
+ + genType.getName() + GAP);
+ } else {
+ builder.append(PUBLIC + GAP + type + GAP + genType.getName() + GAP);
+ }
+
+ if (genType instanceof GeneratedTransferObject) {
+ GeneratedTransferObject genTO = (GeneratedTransferObject) genType;
+
+ if (genTO.getExtends() != null) {
+ builder.append(EXTENDS + GAP);
+ String gtoString = getExplicitType(genTO.getExtends(), availableImports, currentPkg);
+ builder.append(gtoString + GAP);
+ }
+ }
+
+ final List<Type> genImplements = genType.getImplements();
+ if (!genImplements.isEmpty()) {
+ if (genType instanceof GeneratedTransferObject) {
+ builder.append(IMPLEMENTS + GAP);
+ } else {
+ builder.append(EXTENDS + GAP);
+ }
+ builder.append(getExplicitType(genImplements.get(0),
+ availableImports, currentPkg));
+
+ for (int i = 1; i < genImplements.size(); ++i) {
+ builder.append(", ");
+ builder.append(getExplicitType(genImplements.get(i),
+ availableImports, currentPkg));
+ }
+ }
+
+ builder.append(GAP + LCB);
+ return builder.toString();
+ }
+
+ private static StringBuilder appendAnnotations(final StringBuilder builder,
+ final List<AnnotationType> annotations) {
+ if ((builder != null) && (annotations != null)) {
+ for (final AnnotationType annotation : annotations) {
+ builder.append("@");
+ builder.append(annotation.getPackageName());
+ builder.append(".");
+ builder.append(annotation.getName());
+
+ if (annotation.containsParameters()) {
+ builder.append("(");
+ final List<AnnotationType.Parameter> parameters = annotation
+ .getParameters();
+ appendAnnotationParams(builder, parameters);
+ builder.append(")");
+ }
+ }
+ }
+ return builder;
+ }
+
+ private static StringBuilder appendAnnotationParams(
+ final StringBuilder builder,
+ final List<AnnotationType.Parameter> parameters) {
+ if (parameters != null) {
+ int i = 0;
+ for (final AnnotationType.Parameter param : parameters) {
+ if (param == null) {
+ continue;
+ }
+ if (i > 0) {
+ builder.append(", ");
+ }
+ final String paramName = param.getName();
+ if (param.getValue() != null) {
+ builder.append(paramName);
+ builder.append(" = ");
+ builder.append(param.getValue());
+ } else {
+ builder.append(paramName);
+ builder.append(" = {");
+ final List<String> values = param.getValues();
+ builder.append(values.get(0));
+ for (int j = 1; j < values.size(); ++j) {
+ builder.append(", ");
+ builder.append(values.get(j));
+ }
+ builder.append("}");
+ }
+ i++;
+ }
+ }
+ return builder;
+ }
+
+ public static String createConstant(final Constant constant,
+ final String indent,
+ final Map<String, LinkedHashMap<String, Integer>> availableImports,
+ final String currentPkg) {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(indent + PUBLIC + GAP + STATIC + GAP + FINAL + GAP);
+ builder.append(getExplicitType(constant.getType(), availableImports,
+ currentPkg) + GAP + constant.getName());
+ builder.append(GAP + "=" + GAP);
+ builder.append(constant.getValue() + SC);
+ return builder.toString();
+ }
+
+ public static String createField(final GeneratedProperty property,
+ final String indent,
+ Map<String, LinkedHashMap<String, Integer>> availableImports,
+ final String currentPkg) {
+ final StringBuilder builder = new StringBuilder();
+ if (!property.getAnnotations().isEmpty()) {
+ final List<AnnotationType> annotations = property.getAnnotations();
+ appendAnnotations(builder, annotations);
+ builder.append(NL);
+ }
+ builder.append(indent + PRIVATE + GAP);
+ builder.append(getExplicitType(property.getReturnType(),
+ availableImports, currentPkg) + GAP + property.getName());
+ builder.append(SC);
+ return builder.toString();
+ }
+
+ /**
+ * Create method declaration in interface.
+ *
+ * @param method
+ * @param indent
+ * @return
+ */
+ public static String createMethodDeclaration(final MethodSignature method,
+ final String indent,
+ Map<String, LinkedHashMap<String, Integer>> availableImports,
+ final String currentPkg) {
+ final StringBuilder builder = new StringBuilder();
+
+ if (method == null) {
+ throw new IllegalArgumentException(
+ "Method Signature parameter MUST be specified and cannot be NULL!");
+ }
+
+ final String comment = method.getComment();
+ final String name = method.getName();
+ if (name == null) {
+ throw new IllegalStateException("Method Name cannot be NULL!");
+ }
+
+ final Type type = method.getReturnType();
+ if (type == null) {
+ throw new IllegalStateException(
+ "Method Return type cannot be NULL!");
+ }
+
+ final List<Parameter> parameters = method.getParameters();
+
+ createComment(builder, comment, indent);
+ builder.append(NL);
+ builder.append(indent);
+
+ if (!method.getAnnotations().isEmpty()) {
+ final List<AnnotationType> annotations = method.getAnnotations();
+ appendAnnotations(builder, annotations);
+ builder.append(NL);
+ }
+
+ builder.append(indent
+ + getExplicitType(type, availableImports, currentPkg) + GAP
+ + name);
+ builder.append(LB);
+ for (int i = 0; i < parameters.size(); i++) {
+ Parameter p = parameters.get(i);
+ String separator = COMMA;
+ if (i + 1 == parameters.size()) {
+ separator = "";
+ }
+ builder.append(getExplicitType(p.getType(), availableImports,
+ currentPkg) + GAP + p.getName() + separator);
+ }
+ builder.append(RB);
+ builder.append(SC);
+
+ return builder.toString();
+ }
+
+ public static String createConstructor(
+ GeneratedTransferObject genTransferObject, final String indent,
+ Map<String, LinkedHashMap<String, Integer>> availableImports,
+ boolean isIdentity) {
+ final StringBuilder builder = new StringBuilder();
+
+ final String currentPkg = genTransferObject.getPackageName();
+ final List<GeneratedProperty> properties = genTransferObject
+ .getProperties();
+ final List<GeneratedProperty> ctorParams = new ArrayList<GeneratedProperty>();
+ for (final GeneratedProperty property : properties) {
+ if (property.isReadOnly()) {
+ ctorParams.add(property);
+ }
+ }
+
+ builder.append(indent);
+ builder.append(isIdentity ? PROTECTED : PUBLIC);
+ builder.append(GAP);
+ builder.append(genTransferObject.getName());
+ builder.append(LB);
+
+ if (!ctorParams.isEmpty()) {
+ builder.append(getExplicitType(ctorParams.get(0).getReturnType(),
+ availableImports, currentPkg));
+ builder.append(" ");
+ builder.append(ctorParams.get(0).getName());
+ for (int i = 1; i < ctorParams.size(); ++i) {
+ final GeneratedProperty param = ctorParams.get(i);
+ builder.append(", ");
+ builder.append(getExplicitType(param.getReturnType(),
+ availableImports, currentPkg));
+ builder.append(GAP);
+ builder.append(param.getName());
+ }
+ }
+ builder.append(RB + GAP + LCB + NL + indent + TAB + "super();" + NL);
+ if (!ctorParams.isEmpty()) {
+ for (final GeneratedProperty property : ctorParams) {
+ builder.append(indent);
+ builder.append(TAB);
+ builder.append("this.");
+ builder.append(property.getName());
+ builder.append(" = ");
+ builder.append(property.getName());
+ builder.append(SC);
+ builder.append(NL);
+ }
+ }
+ builder.append(indent);
+ builder.append(RCB);
+ return builder.toString();
+ }
+
+ public static String createGetter(final GeneratedProperty property,
+ final String indent,
+ Map<String, LinkedHashMap<String, Integer>> availableImports,
+ final String currentPkg) {
+ final StringBuilder builder = new StringBuilder();
+
+ final Type type = property.getReturnType();
+ final String varName = property.getName();
+ final char first = Character.toUpperCase(varName.charAt(0));
+ final String methodName = "get" + first + varName.substring(1);
+
+ builder.append(indent + PUBLIC + GAP
+ + getExplicitType(type, availableImports, currentPkg) + GAP
+ + methodName);
+ builder.append(LB + RB + LCB + NL);
+
+ String currentIndent = indent + TAB;
+
+ builder.append(currentIndent + "return " + varName + SC + NL);
+
+ builder.append(indent + RCB);
+ return builder.toString();
+ }
+
+ public static String createSetter(final GeneratedProperty property,
+ final String indent,
+ Map<String, LinkedHashMap<String, Integer>> availableImports,
+ String currentPkg) {
+ final StringBuilder builder = new StringBuilder();
+
+ final Type type = property.getReturnType();
+ final String varName = property.getName();
+ final char first = Character.toUpperCase(varName.charAt(0));
+ final String methodName = "set" + first + varName.substring(1);
+
+ builder.append(indent + PUBLIC + GAP + "void" + GAP + methodName);
+ builder.append(LB + getExplicitType(type, availableImports, currentPkg)
+ + GAP + varName + RB + LCB + NL);
+ String currentIndent = indent + TAB;
+ builder.append(currentIndent + "this." + varName + " = " + varName + SC
+ + NL);
+ builder.append(indent + RCB);
+ return builder.toString();
+ }
+
+ public static String createHashCode(
+ final List<GeneratedProperty> properties, final String indent) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(indent + "public int hashCode() {" + NL);
+ builder.append(indent + TAB + "final int prime = 31;" + NL);
+ builder.append(indent + TAB + "int result = 1;" + NL);
+
+ for (GeneratedProperty property : properties) {
+ String fieldName = property.getName();
+ builder.append(indent + TAB + "result = prime * result + (("
+ + fieldName + " == null) ? 0 : " + fieldName
+ + ".hashCode());" + NL);
+ }
+
+ builder.append(indent + TAB + "return result;" + NL);
+ builder.append(indent + RCB + NL);
+ return builder.toString();
+ }
+
+ public static String createEquals(final GeneratedTransferObject type,
+ final List<GeneratedProperty> properties, final String indent) {
+ StringBuilder builder = new StringBuilder();
+ final String indent1 = indent + TAB;
+ final String indent2 = indent1 + TAB;
+ final String indent3 = indent2 + TAB;
+
+ builder.append(indent + "public boolean equals(Object obj) {" + NL);
+ builder.append(indent1 + "if (this == obj) {" + NL);
+ builder.append(indent2 + "return true;" + NL);
+ builder.append(indent1 + "}" + NL);
+ builder.append(indent1 + "if (obj == null) {" + NL);
+ builder.append(indent2 + "return false;" + NL);
+ builder.append(indent1 + "}" + NL);
+ builder.append(indent1 + "if (getClass() != obj.getClass()) {" + NL);
+ builder.append(indent2 + "return false;" + NL);
+ builder.append(indent1 + "}" + NL);
+
+ String typeStr = type.getName();
+ builder.append(indent1 + typeStr + " other = (" + typeStr + ") obj;"
+ + NL);
+
+ for (GeneratedProperty property : properties) {
+ String fieldName = property.getName();
+ builder.append(indent1 + "if (" + fieldName + " == null) {" + NL);
+ builder.append(indent2 + "if (other." + fieldName + " != null) {"
+ + NL);
+ builder.append(indent3 + "return false;" + NL);
+ builder.append(indent2 + "}" + NL);
+ builder.append(indent1 + "} else if (!" + fieldName
+ + ".equals(other." + fieldName + ")) {" + NL);
+ builder.append(indent2 + "return false;" + NL);
+ builder.append(indent1 + "}" + NL);
+ }
+
+ builder.append(indent1 + "return true;" + NL);
+
+ builder.append(indent + RCB + NL);
+ return builder.toString();
+ }
+
+ public static String createToString(final GeneratedTransferObject type,
+ final List<GeneratedProperty> properties, final String indent) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(indent);
+ builder.append("public String toString() {");
+ builder.append(NL);
+ builder.append(indent);
+ builder.append(TAB);
+ builder.append("StringBuilder builder = new StringBuilder();");
+ builder.append(NL);
+ builder.append(indent);
+ builder.append(TAB);
+ builder.append("builder.append(\"");
+ builder.append(type.getName());
+ builder.append(" [");
+
+ boolean first = true;
+ for (GeneratedProperty property : properties) {
+ if (first) {
+ builder.append(property.getName());
+ builder.append("=\");");
+ builder.append(NL);
+ builder.append(indent);
+ builder.append(TAB);
+ builder.append("builder.append(");
+ builder.append(property.getName());
+ builder.append(");");
+ first = false;
+ } else {
+ builder.append(NL);
+ builder.append(indent);
+ builder.append(TAB);
+ builder.append("builder.append(\", ");
+ builder.append(property.getName());
+ builder.append("=\");");
+ builder.append(NL);
+ builder.append(indent);
+ builder.append(TAB);
+ builder.append("builder.append(");
+ builder.append(property.getName());
+ builder.append(");");
+ }
+ }
+ builder.append(NL);
+ builder.append(indent);
+ builder.append(TAB);
+ builder.append("builder.append(\"]\");");
+ builder.append(NL);
+ builder.append(indent);
+ builder.append(TAB);
+ builder.append("return builder.toString();");
+
+ builder.append(NL);
+ builder.append(indent);
+ builder.append(RCB);
+ builder.append(NL);
+ return builder.toString();
+ }
+
+ public static String createEnum(final Enumeration enumeration,
+ final String indent) {
+ if (enumeration == null || indent == null)
+ throw new IllegalArgumentException();
+ final StringBuilder builder = new StringBuilder(indent + PUBLIC + GAP
+ + ENUM + GAP + enumeration.getName() + GAP + LCB + NL);
+
+ String separator = COMMA + NL;
+ final List<Pair> values = enumeration.getValues();
+
+ for (int i = 0; i < values.size(); i++) {
+ if (i + 1 == values.size()) {
+ separator = SC;
+ }
+ builder.append(indent + TAB + values.get(i).getName() + LB
+ + values.get(i).getValue() + RB + separator);
+ }
+ builder.append(NL);
+ builder.append(NL);
+ final String ENUMERATION_NAME = "value";
+ final String ENUMERATION_TYPE = "int";
+ builder.append(indent + TAB + ENUMERATION_TYPE + GAP + ENUMERATION_NAME
+ + SC);
+ builder.append(NL);
+ builder.append(indent + TAB + PRIVATE + GAP + enumeration.getName()
+ + LB + ENUMERATION_TYPE + GAP + ENUMERATION_NAME + RB + GAP
+ + LCB + NL);
+ builder.append(indent + TAB + TAB + "this." + ENUMERATION_NAME + GAP
+ + "=" + GAP + ENUMERATION_NAME + SC + NL);
+ builder.append(indent + TAB + RCB + NL);
+
+ builder.append(indent + RCB);
+ builder.append(NL);
+ return builder.toString();
+ }
+
+ private static String getExplicitType(final Type type,
+ Map<String, LinkedHashMap<String, Integer>> availableImports,
+ final String currentPkg) {
+ if (type == null) {
+ throw new IllegalArgumentException(
+ "Type parameter MUST be specified and cannot be NULL!");
+ }
+ String packageName = type.getPackageName();
+
+ LinkedHashMap<String, Integer> imports = availableImports.get(type
+ .getName());
+
+ if ((imports != null && packageName
+ .equals(findMaxValue(imports).get(0)))
+ || packageName.equals(currentPkg)) {
+ final StringBuilder builder = new StringBuilder(type.getName());
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType) type;
+ Type[] pTypes = pType.getActualTypeArguments();
+ builder.append("<");
+ builder.append(getParameters(pTypes, availableImports,
+ currentPkg));
+ builder.append(">");
+ }
+ if (builder.toString().equals("Void")) {
+ return "void";
+ }
+ return builder.toString();
+ } else {
+ final StringBuilder builder = new StringBuilder();
+ if (packageName.startsWith("java.lang")) {
+ builder.append(type.getName());
+ } else {
if (!packageName.isEmpty()) {
builder.append(packageName + "." + type.getName());
} else {
builder.append(type.getName());
}
- }
- if (type instanceof ParameterizedType) {
- ParameterizedType pType = (ParameterizedType) type;
- Type[] pTypes = pType.getActualTypeArguments();
- builder.append("<");
- builder.append(getParameters(pTypes, availableImports,
- currentPkg));
- builder.append(">");
- }
- if (builder.toString().equals("Void")) {
- return "void";
- }
- return builder.toString();
- }
- }
-
- private static String getParameters(final Type[] pTypes,
- Map<String, LinkedHashMap<String, Integer>> availableImports,
- String currentPkg) {
- final StringBuilder builder = new StringBuilder();
- for (int i = 0; i < pTypes.length; i++) {
- Type t = pTypes[i];
-
- String separator = COMMA;
- if (i + 1 == pTypes.length) {
- separator = "";
- }
- builder.append(getExplicitType(t, availableImports, currentPkg)
- + separator);
- }
- return builder.toString();
- }
-
- private static List<String> findMaxValue(
- LinkedHashMap<String, Integer> imports) {
- final List<String> result = new ArrayList<String>();
-
- int maxValue = 0;
- int currentValue = 0;
- for (Map.Entry<String, Integer> entry : imports.entrySet()) {
- currentValue = entry.getValue();
- if (currentValue > maxValue) {
- result.clear();
- result.add(entry.getKey());
- } else if (currentValue == maxValue) {
- result.add(entry.getKey());
- }
- }
- return result;
- }
-
- private static void createComment(final StringBuilder builder,
- final String comment, final String indent) {
- if (comment != null && comment.length() > 0) {
- builder.append(indent + "/*" + NL);
- builder.append(indent + comment + NL);
- builder.append(indent + "*/" + NL);
- }
- }
-
- public static Map<String, LinkedHashMap<String, Integer>> createImports(
- GeneratedType genType) {
- final Map<String, LinkedHashMap<String, Integer>> imports = new HashMap<String, LinkedHashMap<String, Integer>>();
- final String genTypePkg = genType.getPackageName();
-
- final List<Constant> constants = genType.getConstantDefinitions();
- final List<MethodSignature> methods = genType.getMethodDefinitions();
- List<Type> impl = genType.getImplements();
-
- // IMPLEMENTATIONS
- if (impl != null) {
- for (Type t : impl) {
- addTypeToImports(t, imports, genTypePkg);
- }
- }
-
- // CONSTANTS
- if (constants != null) {
- for (Constant c : constants) {
- Type ct = c.getType();
- addTypeToImports(ct, imports, genTypePkg);
- }
- }
-
- // METHODS
- if (methods != null) {
- for (MethodSignature m : methods) {
- Type ct = m.getReturnType();
- addTypeToImports(ct, imports, genTypePkg);
- for (MethodSignature.Parameter p : m.getParameters()) {
- addTypeToImports(p.getType(), imports, genTypePkg);
- }
- }
- }
-
- // PROPERTIES
- if (genType instanceof GeneratedTransferObject) {
- GeneratedTransferObject genTO = (GeneratedTransferObject) genType;
-
- List<GeneratedProperty> props = genTO.getProperties();
- if (props != null) {
- for (GeneratedProperty prop : props) {
- Type pt = prop.getReturnType();
- addTypeToImports(pt, imports, genTypePkg);
- }
- }
- }
-
- return imports;
- }
-
- private static void addTypeToImports(Type type,
- Map<String, LinkedHashMap<String, Integer>> importedTypes,
- String genTypePkg) {
- String typeName = type.getName();
- String typePkg = type.getPackageName();
+ }
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType) type;
+ Type[] pTypes = pType.getActualTypeArguments();
+ builder.append("<");
+ builder.append(getParameters(pTypes, availableImports,
+ currentPkg));
+ builder.append(">");
+ }
+ if (builder.toString().equals("Void")) {
+ return "void";
+ }
+ return builder.toString();
+ }
+ }
+
+ private static String getParameters(final Type[] pTypes,
+ Map<String, LinkedHashMap<String, Integer>> availableImports,
+ String currentPkg) {
+ final StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < pTypes.length; i++) {
+ Type t = pTypes[i];
+
+ String separator = COMMA;
+ if (i + 1 == pTypes.length) {
+ separator = "";
+ }
+
+ String wildcardParam = "";
+ if(t instanceof WildcardType) {
+ wildcardParam = "? extends ";
+ }
+
+ builder.append(wildcardParam + getExplicitType(t, availableImports, currentPkg)
+ + separator);
+ }
+ return builder.toString();
+ }
+
+ private static List<String> findMaxValue(
+ LinkedHashMap<String, Integer> imports) {
+ final List<String> result = new ArrayList<String>();
+
+ int maxValue = 0;
+ int currentValue = 0;
+ for (Map.Entry<String, Integer> entry : imports.entrySet()) {
+ currentValue = entry.getValue();
+ if (currentValue > maxValue) {
+ result.clear();
+ result.add(entry.getKey());
+ maxValue = currentValue;
+ } else if (currentValue == maxValue) {
+ result.add(entry.getKey());
+ }
+ }
+ return result;
+ }
+
+ private static void createComment(final StringBuilder builder,
+ final String comment, final String indent) {
+ if (comment != null && comment.length() > 0) {
+ builder.append(indent + "/*" + NL);
+ builder.append(indent + comment + NL);
+ builder.append(indent + "*/" + NL);
+ }
+ }
+
+ public static Map<String, LinkedHashMap<String, Integer>> createImports(
+ GeneratedType genType) {
+ final Map<String, LinkedHashMap<String, Integer>> imports = new HashMap<String, LinkedHashMap<String, Integer>>();
+ final String genTypePkg = genType.getPackageName();
+
+ final List<Constant> constants = genType.getConstantDefinitions();
+ final List<MethodSignature> methods = genType.getMethodDefinitions();
+ List<Type> impl = genType.getImplements();
+
+ // IMPLEMENTATIONS
+ if (impl != null) {
+ for (Type t : impl) {
+ addTypeToImports(t, imports, genTypePkg);
+ }
+ }
+
+ // CONSTANTS
+ if (constants != null) {
+ for (Constant c : constants) {
+ Type ct = c.getType();
+ addTypeToImports(ct, imports, genTypePkg);
+ }
+ }
+
+ // METHODS
+ if (methods != null) {
+ for (MethodSignature m : methods) {
+ Type ct = m.getReturnType();
+ addTypeToImports(ct, imports, genTypePkg);
+ for (MethodSignature.Parameter p : m.getParameters()) {
+ addTypeToImports(p.getType(), imports, genTypePkg);
+ }
+ }
+ }
+
+ // PROPERTIES
+ if (genType instanceof GeneratedTransferObject) {
+ GeneratedTransferObject genTO = (GeneratedTransferObject) genType;
+
+ List<GeneratedProperty> props = genTO.getProperties();
+ if (props != null) {
+ for (GeneratedProperty prop : props) {
+ Type pt = prop.getReturnType();
+ addTypeToImports(pt, imports, genTypePkg);
+ }
+ }
+ }
+
+ return imports;
+ }
+
+ private static void addTypeToImports(Type type,
+ Map<String, LinkedHashMap<String, Integer>> importedTypes,
+ String genTypePkg) {
+ String typeName = type.getName();
+ String typePkg = type.getPackageName();
if (typePkg.startsWith("java.lang") || typePkg.equals(genTypePkg) ||
typePkg.isEmpty()) {
- return;
- }
- LinkedHashMap<String, Integer> packages = importedTypes.get(typeName);
- if (packages == null) {
- packages = new LinkedHashMap<String, Integer>();
- packages.put(typePkg, 1);
- importedTypes.put(typeName, packages);
- } else {
- Integer occurrence = packages.get(typePkg);
- if (occurrence == null) {
- packages.put(typePkg, 1);
- } else {
- occurrence++;
- packages.put(typePkg, occurrence);
- }
- }
-
- if (type instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) type;
- Type[] params = pt.getActualTypeArguments();
- for (Type param : params) {
- addTypeToImports(param, importedTypes, genTypePkg);
- }
- }
- }
-
- public static List<String> createImportLines(
- Map<String, LinkedHashMap<String, Integer>> imports) {
- List<String> importLines = new ArrayList<String>();
-
- for (Map.Entry<String, LinkedHashMap<String, Integer>> entry : imports
- .entrySet()) {
- String typeName = entry.getKey();
- LinkedHashMap<String, Integer> typePkgMap = entry.getValue();
- String typePkg = typePkgMap.keySet().iterator().next();
- importLines.add("import " + typePkg + "." + typeName + SC);
- }
- return importLines;
- }
+ return;
+ }
+ LinkedHashMap<String, Integer> packages = importedTypes.get(typeName);
+ if (packages == null) {
+ packages = new LinkedHashMap<String, Integer>();
+ packages.put(typePkg, 1);
+ importedTypes.put(typeName, packages);
+ } else {
+ Integer occurrence = packages.get(typePkg);
+ if (occurrence == null) {
+ packages.put(typePkg, 1);
+ } else {
+ occurrence++;
+ packages.put(typePkg, occurrence);
+ }
+ }
+
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
+ Type[] params = pt.getActualTypeArguments();
+ for (Type param : params) {
+ addTypeToImports(param, importedTypes, genTypePkg);
+ }
+ }
+ }
+
+ public static List<String> createImportLines(
+ Map<String, LinkedHashMap<String, Integer>> imports) {
+ List<String> importLines = new ArrayList<String>();
+
+ for (Map.Entry<String, LinkedHashMap<String, Integer>> entry : imports
+ .entrySet()) {
+ String typeName = entry.getKey();
+ LinkedHashMap<String, Integer> typePkgMap = entry.getValue();
+ String typePkg = typePkgMap.keySet().iterator().next();
+ importLines.add("import " + typePkg + "." + typeName + SC);
+ }
+ return importLines;
+ }
}
final List<Type> genTypes = bindingGen.generateTypes(context);
assertTrue(genTypes != null);
- assertEquals(7, genTypes.size());
+ assertEquals(8, genTypes.size());
int genTypesCount = 0;
int genTOsCount = 0;
}
}
- assertEquals(5, genTypesCount);
+ assertEquals(6, genTypesCount);
assertEquals(2, genTOsCount);
}
}
}
}
-}
\ No newline at end of file
+
+ identity crypto-base {
+ description "crypto-base description";
+ }
+
+ identity crypto-alg {
+ base crypto-base;
+ description "crypto-alg description";
+ }
+
+ grouping target {
+ container nodes {
+ leaf source {
+ type int8;
+ }
+ leaf target {
+ type int16;
+ }
+ }
+ leaf id {
+ type string;
+ }
+ }
+
+ leaf idreftest {
+ type identityref {
+ base crypto-alg;
+ }
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.sal.binding.model.api;
+
+public interface GeneratedTransferIdentityObject extends
+ GeneratedTransferObject {
+
+}
--- /dev/null
+package org.opendaylight.controller.sal.binding.model.api;
+
+public interface WildcardType extends Type {
+
+}
*/
public interface GeneratedTOBuilder extends GeneratedTypeBuilder {
-
+
public boolean addExtendsType(final GeneratedTransferObject genTransObj);
-
+
public GeneratedPropertyBuilder addProperty(final String name);
public boolean addEqualsIdentity(final GeneratedPropertyBuilder property);
@Override
public GeneratedTransferObject toInstance();
+
+ public GeneratedTransferObject toIdentityInstance();
+
}
<parent>
<artifactId>yang</artifactId>
<groupId>org.opendaylight.controller</groupId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<relativePath>../../yang/pom.xml</relativePath>
</parent>
<artifactId>yang-maven-plugin-it</artifactId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>generator-test1</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/../GenerateTest1/target/generator-test1-0.5.1-SNAPSHOT.jar</systemPath>
</dependency>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<plugin>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<parent>
<artifactId>yang</artifactId>
<groupId>org.opendaylight.controller</groupId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<relativePath>../../yang/pom.xml</relativePath>
</parent>
<parent>
<artifactId>yang</artifactId>
<groupId>org.opendaylight.controller</groupId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<relativePath>../../yang/pom.xml</relativePath>
</parent>
<artifactId>yang-maven-plugin-spi</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- version of YANG tools dependencies -->
- <yang.version>0.5.1-SNAPSHOT</yang.version>
+ <yang.version>0.5.2-SNAPSHOT</yang.version>
</properties>
<modules>
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>binding-generator</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <version>0.5.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>modeling-sample</artifactId>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <version>0.5.1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-sources</goal>
+ </goals>
+ <configuration>
+ <yangFilesRootDir>src/main/yang</yangFilesRootDir>
+ <codeGenerators>
+ <generator>
+ <codeGeneratorClass>
+ org.opendaylight.controller.maven.sal.api.gen.plugin.CodeGeneratorImpl
+ </codeGeneratorClass>
+ <outputBaseDir>
+ target/generated-sources/sal
+ </outputBaseDir>
+ </generator>
+ </codeGenerators>
+ <inspectDependencies>false</inspectDependencies>
+ </configuration>
+ </execution>
+ </executions>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>maven-sal-api-gen-plugin</artifactId>
+ <version>0.5.1-SNAPSHOT</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/generated-sources/sal</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.opendaylight.controller
+ </groupId>
+ <artifactId>
+ yang-maven-plugin
+ </artifactId>
+ <versionRange>
+ [0.5,)
+ </versionRange>
+ <goals>
+ <goal>
+ generate-sources
+ </goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-binding</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
--- /dev/null
+module sample {
+ yang-version 1;
+ namespace "sample";
+ prefix "s";
+
+ revision 2013-06-13 {
+ description "Initial demo";
+ }
+
+
+
+ // Simple Type definition
+
+ typedef foo-name {
+ type string;
+ }
+
+ // Storage / data structure
+
+ container topologies {
+ list topology {
+ leaf foo-name {
+ type string;
+ }
+ }
+ }
+
+
+ // Notification / Event
+
+ notification packet-in {
+ leaf node {
+ type string;
+ }
+ leaf port {
+ type uint16;
+ }
+ leaf content {
+ type binary;
+ }
+ }
+
+ // RPC
+
+ rpc packet-out {
+ input {
+ leaf node {
+ type string;
+ }
+ leaf port {
+ type uint16;
+ }
+ leaf content {
+ type binary;
+ }
+ }
+ output {
+
+ }
+ }
+
+}
\ No newline at end of file
<parent>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<relativePath>../../yang/pom.xml</relativePath>
</parent>
<artifactId>yang-model-parser-api</artifactId>
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>yang</artifactId>\r
- <version>0.5.1-SNAPSHOT</version>\r
+ <version>0.5.2-SNAPSHOT</version>\r
<relativePath>../../yang/pom.xml</relativePath>\r
</parent>\r
<artifactId>yang-model-parser-impl</artifactId>\r
void addChildNode(DataSchemaNodeBuilder childNode);
+ Set<GroupingBuilder> getGroupings();
+
void addGrouping(GroupingBuilder groupingBuilder);
void addUsesNode(UsesNodeBuilder usesBuilder);
*/
public interface UsesNodeBuilder extends Builder {
- String getGroupingPathString();
+ String getGroupingName();
- SchemaPath getGroupingPath();
+ void setGroupingPath(SchemaPath groupingPath);
+
+ SchemaPath getPath();
+
+ void setPath(SchemaPath path);
Set<AugmentationSchemaBuilder> getAugmentations();
return childNodes;
}
+ @Override
+ public Set<GroupingBuilder> getGroupings() {
+ return groupings;
+ }
+
@Override
public void addGrouping(GroupingBuilder grouping) {
groupings.add(grouping);
}
}
+ @Override
public String getDefault() {
return defaultStr;
}
this.defaultStr = defaultStr;
}
+ @Override
public String getUnits() {
return unitsStr;
}
return typedefs;
}
+ public Set<GroupingBuilder> getModuleGroupings() {
+ final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
+ for (Map.Entry<List<String>, GroupingBuilder> entry : addedGroupings
+ .entrySet()) {
+ if (entry.getKey().size() == 2) {
+ groupings.add(entry.getValue());
+ }
+ }
+ return groupings;
+ }
+
public String getName() {
return name;
}
addedTypedefs.add(type);
}
+ public Set<GroupingBuilder> getGroupings() {
+ return addedGroupings;
+ }
+
public void addGrouping(GroupingBuilder grouping) {
addedGroupings.add(grouping);
}
import java.util.Map;\r
import java.util.Set;\r
\r
-import org.opendaylight.controller.yang.common.QName;\r
import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
import org.opendaylight.controller.yang.model.api.SchemaNode;\r
import org.opendaylight.controller.yang.model.api.SchemaPath;\r
\r
public final class UsesNodeBuilderImpl implements UsesNodeBuilder {\r
private boolean isBuilt;\r
- private final UsesNodeImpl instance;\r
+ private UsesNodeImpl instance;\r
private final int line;\r
- private final String groupingPathStr;\r
- private final SchemaPath groupingPath;\r
+ private SchemaPath schemaPath;\r
+ private final String groupingName;\r
+ private SchemaPath groupingPath;\r
private boolean augmenting;\r
private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();\r
private List<SchemaNodeBuilder> refineBuilders = new ArrayList<SchemaNodeBuilder>();\r
private List<RefineHolder> refines = new ArrayList<RefineHolder>();\r
\r
- public UsesNodeBuilderImpl(final String groupingPathStr, final int line) {\r
- this.groupingPathStr = groupingPathStr;\r
- this.groupingPath = parseUsesPath(groupingPathStr);\r
+ public UsesNodeBuilderImpl(final String groupingName, final int line) {\r
+ this.groupingName = groupingName;\r
this.line = line;\r
- instance = new UsesNodeImpl(groupingPath);\r
}\r
\r
@Override\r
public UsesNode build() {\r
if (!isBuilt) {\r
+ instance = new UsesNodeImpl(groupingPath);\r
instance.setAugmenting(augmenting);\r
\r
// AUGMENTATIONS\r
}\r
\r
@Override\r
- public String getGroupingPathString() {\r
- return groupingPathStr;\r
+ public void setGroupingPath(SchemaPath groupingPath) {\r
+ this.groupingPath = groupingPath;\r
}\r
\r
@Override\r
- public SchemaPath getGroupingPath() {\r
- return groupingPath;\r
+ public SchemaPath getPath() {\r
+ return schemaPath;\r
+ }\r
+\r
+ @Override\r
+ public void setPath(SchemaPath path) {\r
+ this.schemaPath = path;\r
+ }\r
+\r
+ @Override\r
+ public String getGroupingName() {\r
+ return groupingName;\r
}\r
\r
@Override\r
refines.add(refine);\r
}\r
\r
- private SchemaPath parseUsesPath(final String groupingPathStr) {\r
- final String[] splittedPath = groupingPathStr.split("/");\r
- final List<QName> path = new ArrayList<QName>();\r
- QName name;\r
- for (String pathElement : splittedPath) {\r
- final String[] splittedElement = pathElement.split(":");\r
- if (splittedElement.length == 1) {\r
- name = new QName(null, null, null, splittedElement[0]);\r
- } else {\r
- name = new QName(null, null, splittedElement[0],\r
- splittedElement[1]);\r
- }\r
- path.add(name);\r
- }\r
- final boolean absolute = groupingPathStr.startsWith("/");\r
- return new SchemaPath(path, absolute);\r
- }\r
\r
private final class UsesNodeImpl implements UsesNode {\r
private final SchemaPath groupingPath;\r
.getUsesNodes();
for (Map.Entry<List<String>, UsesNodeBuilder> entry : moduleUses
.entrySet()) {
- final List<String> key = entry.getKey();
final UsesNodeBuilder usesNode = entry.getValue();
final int line = usesNode.getLine();
- final String groupingName = key.get(key.size() - 1);
+ GroupingBuilder targetGrouping = getTargetGrouping(usesNode, modules, module);
+ usesNode.setGroupingPath(targetGrouping.getPath());
for (RefineHolder refine : usesNode.getRefines()) {
SchemaNodeBuilder refineTarget = getRefineNodeBuilderCopy(
- groupingName, refine, modules, module);
+ targetGrouping, refine, modules, module);
ParserUtils.checkRefine(refineTarget, refine);
ParserUtils.refineDefault(refineTarget, refine, line);
if (refineTarget instanceof LeafSchemaNodeBuilder) {
}
}
+ private GroupingBuilder getTargetGrouping(
+ final UsesNodeBuilder usesBuilder,
+ final Map<String, TreeMap<Date, ModuleBuilder>> modules,
+ final ModuleBuilder module) {
+ final int line = usesBuilder.getLine();
+ String groupingString = usesBuilder.getGroupingName();
+ String groupingPrefix;
+ String groupingName;
+
+ if(groupingString.contains(":")) {
+ String[] splitted = groupingString.split(":");
+ if(splitted.length != 2 || groupingString.contains("/")) {
+ throw new YangParseException(module.getName(), line, "Invalid name of target grouping");
+ }
+ groupingPrefix = splitted[0];
+ groupingName = splitted[1];
+ } else {
+ groupingPrefix = module.getPrefix();
+ groupingName = groupingString;
+ }
+
+ ModuleBuilder dependentModule = null;
+ if(groupingPrefix.equals(module.getPrefix())) {
+ dependentModule = module;
+ } else {
+ dependentModule = findDependentModule(modules, module, groupingPrefix, line);
+ }
+
+
+ List<QName> path = usesBuilder.getPath().getPath();
+ GroupingBuilder result = null;
+ Set<GroupingBuilder> groupings = dependentModule.getModuleGroupings();
+ result = findGrouping(groupings, groupingName);
+
+ if (result == null) {
+ Builder currentNode = null;
+ final List<String> currentPath = new ArrayList<String>();
+ currentPath.add(dependentModule.getName());
+
+ for (int i = 0; i < path.size(); i++) {
+ QName qname = path.get(i);
+ currentPath.add(qname.getLocalName());
+ currentNode = dependentModule.getModuleNode(currentPath);
+
+ if (currentNode instanceof RpcDefinitionBuilder) {
+ groupings = ((RpcDefinitionBuilder) currentNode).getGroupings();
+ } else if (currentNode instanceof DataNodeContainerBuilder) {
+ groupings = ((DataNodeContainerBuilder) currentNode).getGroupings();
+ } else {
+ groupings = Collections.emptySet();
+ }
+
+ result = findGrouping(groupings, groupingName);
+ if (result != null) {
+ break;
+ }
+ }
+ }
+
+ if (result != null) {
+ return result;
+ }
+ throw new YangParseException(module.getName(), line,
+ "Referenced grouping '" + groupingName + "' not found.");
+ }
+
+ private GroupingBuilder findGrouping(Set<GroupingBuilder> groupings,
+ String name) {
+ for (GroupingBuilder grouping : groupings) {
+ if (grouping.getQName().getLocalName().equals(name)) {
+ return grouping;
+ }
+ }
+ return null;
+ }
+
/**
* Find original builder of node to refine and return copy of this builder.
* <p>
* otherwise
*/
private SchemaNodeBuilder getRefineNodeBuilderCopy(
- final String groupingPath, final RefineHolder refine,
+ final GroupingBuilder targetGrouping, final RefineHolder refine,
final Map<String, TreeMap<Date, ModuleBuilder>> modules,
final ModuleBuilder module) {
Builder result = null;
- final Builder lookedUpBuilder = findRefineTargetBuilder(groupingPath,
+ final Builder lookedUpBuilder = findRefineTargetBuilder(targetGrouping,
refine, modules, module);
if (lookedUpBuilder instanceof LeafSchemaNodeBuilder) {
result = ParserUtils
* @return Builder object of refine node if it is present in grouping, null
* otherwise
*/
- private Builder findRefineTargetBuilder(final String groupingPath,
+ private Builder findRefineTargetBuilder(final GroupingBuilder builder,
final RefineHolder refine,
final Map<String, TreeMap<Date, ModuleBuilder>> modules,
final ModuleBuilder module) {
final String refineNodeName = refine.getName();
- final SchemaPath path = ParserUtils.parseUsesPath(groupingPath);
- final List<String> builderPath = new ArrayList<String>();
- String prefix = null;
- for (QName qname : path.getPath()) {
- builderPath.add(qname.getLocalName());
- prefix = qname.getPrefix();
- }
- if (prefix == null) {
- prefix = module.getPrefix();
- }
-
- final ModuleBuilder dependentModule = findDependentModule(modules,
- module, prefix, refine.getLine());
- builderPath.add(0, dependentModule.getName());
- final GroupingBuilder builder = dependentModule
- .getGrouping(builderPath);
-
Builder result = builder.getChildNode(refineNodeName);
if (result == null) {
Set<GroupingBuilder> grps = builder.getGroupings();
GroupingBuilder builder = moduleBuilder.addGrouping(groupQName,
actualPath, ctx.getStart().getLine());
moduleBuilder.enterNode(builder);
- updatePath("grouping");
updatePath(groupName);
+ builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
+ yangModelPrefix));
parseSchemaNodeArgs(ctx, builder);
}
@Override
public void exitGrouping_stmt(YangParser.Grouping_stmtContext ctx) {
String actContainer = actualPath.pop();
- actContainer += "-" + actualPath.pop();
logger.debug("exiting " + actContainer);
moduleBuilder.exitNode();
}
final String groupingPathStr = stringFromNode(ctx);
UsesNodeBuilder builder = moduleBuilder.addUsesNode(groupingPathStr,
actualPath, ctx.getStart().getLine());
+
moduleBuilder.enterNode(builder);
updatePath(groupingPathStr);
+ builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
+ yangModelPrefix));
}
@Override
public static UsesNodeBuilder copyUsesNodeBuilder(UsesNodeBuilder old) {
final UsesNodeBuilder copy = new UsesNodeBuilderImpl(
- old.getGroupingPathString(), old.getLine());
+ old.getGroupingName(), old.getLine());
for (AugmentationSchemaBuilder augment : old.getAugmentations()) {
copy.addAugment(augment);
}
<artifactId>yang-prototype</artifactId>
<version>0.5-SNAPSHOT</version>
</parent>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
<artifactId>yang</artifactId>
<packaging>pom</packaging>
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>yang</artifactId>\r
- <version>0.5.1-SNAPSHOT</version>\r
+ <version>0.5.2-SNAPSHOT</version>\r
</parent>\r
<artifactId>yang-binding</artifactId>\r
</project>
\ No newline at end of file
--- /dev/null
+/*
+ * 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.yang.binding;
+
+public abstract class BaseIdentity {
+
+ protected BaseIdentity() {
+ }
+
+}
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>yang</artifactId>\r
- <version>0.5.1-SNAPSHOT</version>\r
+ <version>0.5.2-SNAPSHOT</version>\r
</parent>\r
<artifactId>yang-common</artifactId>\r
<dependencies>\r
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>yang</artifactId>\r
- <version>0.5.1-SNAPSHOT</version>\r
+ <version>0.5.2-SNAPSHOT</version>\r
</parent>\r
<artifactId>yang-data-api</artifactId>\r
\r
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>yang</artifactId>\r
- <version>0.5.1-SNAPSHOT</version>\r
+ <version>0.5.2-SNAPSHOT</version>\r
</parent>\r
<artifactId>yang-data-util</artifactId>\r
<dependencies>\r
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>yang</artifactId>\r
- <version>0.5.1-SNAPSHOT</version>\r
+ <version>0.5.2-SNAPSHOT</version>\r
</parent>\r
<artifactId>yang-model-api</artifactId>\r
<dependencies>\r
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>yang</artifactId>\r
- <version>0.5.1-SNAPSHOT</version>\r
+ <version>0.5.2-SNAPSHOT</version>\r
</parent>\r
<artifactId>yang-model-util</artifactId>\r
<dependencies>\r
import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
import org.opendaylight.controller.yang.model.api.DataNodeContainer;
import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
import org.opendaylight.controller.yang.model.api.ListSchemaNode;
public class DataNodeIterator implements Iterator<DataSchemaNode> {
-
+
private final DataNodeContainer container;
private List<ListSchemaNode> allLists;
private List<ContainerSchemaNode> allContainers;
private List<LeafSchemaNode> allLeafs;
private List<LeafListSchemaNode> allLeafLists;
private List<DataSchemaNode> allChilds;
-
+
public DataNodeIterator(final DataNodeContainer container) {
if (container == null) {
throw new IllegalArgumentException("Data Node Container MUST be specified and cannot be NULL!");
}
-
+
init();
this.container = container;
traverse(this.container);
}
-
+
private void init() {
this.allContainers = new ArrayList<ContainerSchemaNode>();
this.allLists = new ArrayList<ListSchemaNode>();
this.allLeafLists = new ArrayList<LeafListSchemaNode>();
this.allChilds = new ArrayList<DataSchemaNode>();
}
-
+
public List<ContainerSchemaNode> allContainers() {
return allContainers;
}
-
+
public List<ListSchemaNode> allLists() {
return allLists;
}
-
+
public List<LeafSchemaNode> allLeafs() {
return allLeafs;
}
-
+
public List<LeafListSchemaNode> allLeafLists() {
return allLeafLists;
}
-
+
private void traverse(final DataNodeContainer dataNode) {
if (dataNode == null) {
return;
}
-
+
final Set<DataSchemaNode> childs = dataNode.getChildNodes();
if (childs != null) {
for (DataSchemaNode childNode : childs) {
allLeafLists.add(leafList);
}
}
- return;
+ }
+
+ final Set<GroupingDefinition> groupings = dataNode.getGroupings();
+ if(groupings != null) {
+ for(GroupingDefinition grouping : groupings) {
+ traverse(grouping);
+ }
}
}
-
+
@Override
public boolean hasNext() {
if (container.getChildNodes() != null) {
Set<DataSchemaNode> childs = container.getChildNodes();
-
+
if ((childs != null) && !childs.isEmpty()) {
return childs.iterator().hasNext();
}
<?xml version="1.0"?>
<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
+
<services>
<rest defaultRestSubcontext="/one/nb/v2/lb"/>
</services>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<servlet>
<servlet-name>JAXRSLoadBalancer</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>NB api</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
</web-app>
org.apache.felix.dm
</Import-Package>
<Export-Package>
- org.opendaylight.controller.statisticsmanager
+ org.opendaylight.controller.statisticsmanager
</Export-Package>
</instructions>
<manifestLocation>${project.basedir}/META-INF</manifestLocation>
import java.util.List;
import java.util.Set;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.utils.HexEncode;
/**
* The class describes switch related information including L2 address, ports,
@Override
public String toString() {
- return "Switch[" + ReflectionToStringBuilder.toString(this) + "]";
+ return "Switch [dataLayerAddress=" + HexEncode.bytesToHexStringFormat(dataLayerAddress)
+ + ", nodeConnectors=" + nodeConnectors + ", spanPorts="
+ + spanPorts + ", node=" + node + "]";
}
}
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>switchmanager.implementation</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
NodeConnector tailnc1 = NodeConnectorCreator
.createOFNodeConnector((short) (i + 10),
NodeCreator.createOFNode((long) (i + 10)));
- Edge e1 = new Edge(headnc1, tailnc1);
+ Edge e1 = new Edge(tailnc1, headnc1);
TopoEdgeUpdate teu1 = new TopoEdgeUpdate(e1, props,
UpdateType.ADDED);
topoedgeupdateList.add(teu1);
- NodeConnector headnc2 = NodeConnectorCreator.createOFNodeConnector(
- (short) (i + 1), headnc1.getNode());
NodeConnector tailnc2 = NodeConnectorCreator.createOFNodeConnector(
+ (short) (i + 1), headnc1.getNode());
+ NodeConnector headnc2 = NodeConnectorCreator.createOFNodeConnector(
(short) (i + 11), tailnc1.getNode());
- Edge e2 = new Edge(headnc2, tailnc2);
+ Edge e2 = new Edge(tailnc2, headnc2);
TopoEdgeUpdate teu2 = new TopoEdgeUpdate(e2, props,
UpdateType.ADDED);
topoedgeupdateList.add(teu2);
.longValue();
Long tailNcId = ((Short) edge.getTailNodeConnector().getID())
.longValue();
- if (nodeId == 1 || nodeId == 3 || nodeId == 5) {
- Assert.assertTrue((headNcId.equals(nodeId) && tailNcId
- .equals(nodeId + 10))
- || (headNcId.equals(nodeId + 10) && tailNcId
- .equals(nodeId))
- || (headNcId.equals(nodeId + 1) && tailNcId
- .equals(nodeId + 11))
- || (headNcId.equals(nodeId + 11) && tailNcId
- .equals(nodeId + 1)));
- } else if (nodeId == 11 || nodeId == 13 || nodeId == 15) {
- Assert.assertTrue((headNcId.equals(nodeId) && tailNcId
- .equals(nodeId - 10))
- || (headNcId.equals(nodeId) && tailNcId
- .equals(nodeId - 10))
- || (headNcId.equals(nodeId - 9) && tailNcId
- .equals(nodeId + 1))
- || (headNcId.equals(nodeId + 1) && tailNcId
- .equals(nodeId - 9)));
- }
+ Assert.assertTrue(
+ (headNcId.equals(nodeId) && tailNcId.equals(nodeId + 10))
+ || (headNcId.equals(nodeId + 11) && tailNcId.equals(nodeId + 1))
+ || (headNcId.equals(nodeId + 1) && tailNcId.equals(nodeId - 9))
+ || (headNcId.equals(nodeId - 10) && tailNcId.equals(nodeId))
+ );
}
i.remove();
}
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.4.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
+ <relativePath>../../commons/opendaylight</relativePath>
</parent>
<artifactId>usermanager</artifactId>
</Import-Package>
<Export-Package>
org.opendaylight.controller.usermanager,
+<!--
org.opendaylight.controller.usermanager.internal
- </Export-Package>
+ -->
+ </Export-Package>
<Bundle-Activator>
+<!--
org.opendaylight.controller.usermanager.internal.Activator
- </Bundle-Activator>
+ -->
+ </Bundle-Activator>
</instructions>
<manifestLocation>${project.basedir}/META-INF</manifestLocation>
</configuration>
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.usermanager.internal;
+package org.opendaylight.controller.usermanager;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.opendaylight.controller.sal.utils.Status;
public String toString() {
return "AuthorizationConfig=[user: " + user + ", roles: " + roles + "]";
}
+
+ public String getRolesString() {
+ return super.getRolesString();
+ }
+
}
import org.opendaylight.controller.sal.authorization.AuthResultEnum;
import org.opendaylight.controller.sal.authorization.UserLevel;
import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.usermanager.internal.AuthorizationConfig;
-import org.opendaylight.controller.usermanager.internal.ServerConfig;
-import org.opendaylight.controller.usermanager.internal.UserConfig;
+import org.opendaylight.controller.usermanager.AuthorizationConfig;
+import org.opendaylight.controller.usermanager.ServerConfig;
+import org.opendaylight.controller.usermanager.UserConfig;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.context.SecurityContextRepository;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.usermanager.internal;
+package org.opendaylight.controller.usermanager;
import java.io.Serializable;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.usermanager.internal;
+package org.opendaylight.controller.usermanager;
import java.io.Serializable;
import java.util.ArrayList;
* 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.usermanager.internal;
+package org.opendaylight.controller.usermanager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.opendaylight.controller.sal.authorization.AuthResultEnum;
import org.opendaylight.controller.sal.authorization.UserLevel;
import org.opendaylight.controller.usermanager.AuthResponse;
+import org.opendaylight.controller.usermanager.AuthorizationConfig;
+import org.opendaylight.controller.usermanager.UserConfig;
/*
* This test case includes tests for UserConfig and the extending class AuthorizationConfig
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.usermanager.internal;
+package org.opendaylight.controller.usermanager;
public class ServerConfigTest {
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?> <project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+
+ <artifactId>usermanager.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.6</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.opendaylight.controller.clustering.services,
+ org.opendaylight.controller.configuration,
+ org.opendaylight.controller.sal.authorization,
+ org.opendaylight.controller.sal.core,
+ org.opendaylight.controller.sal.packet,
+ org.opendaylight.controller.sal.utils,
+ org.opendaylight.controller.switchmanager,
+ org.opendaylight.controller.containermanager,
+ org.slf4j,
+ org.eclipse.osgi.framework.console,
+ org.osgi.framework,
+ org.apache.felix.dm,
+ org.apache.commons.lang3.builder,
+ org.apache.commons.logging,
+ javax.servlet,
+ javax.servlet.http,
+ org.springframework.security.web.context,
+ org.springframework.security.core,
+ org.springframework.security.core.context,
+ org.apache.commons.lang3,
+ org.springframework.security.authentication,
+ org.springframework.security.core.authority,
+ org.springframework.security.core.userdetails,
+ org.opendaylight.controller.usermanager
+ </Import-Package>
+ <Export-Package>
+<!--
+ org.opendaylight.controller.usermanager,
+ org.opendaylight.controller.usermanager.internal
+ -->
+ </Export-Package>
+ <Bundle-Activator>
+ org.opendaylight.controller.usermanager.internal.Activator
+ </Bundle-Activator>
+ </instructions>
+ <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>usermanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>containermanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
import org.opendaylight.controller.sal.utils.ObjectWriter;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.usermanager.AuthResponse;
+import org.opendaylight.controller.usermanager.AuthorizationConfig;
import org.opendaylight.controller.usermanager.IAAAProvider;
import org.opendaylight.controller.usermanager.ISessionManager;
import org.opendaylight.controller.usermanager.IUserManager;
+import org.opendaylight.controller.usermanager.ServerConfig;
+import org.opendaylight.controller.usermanager.UserConfig;
import org.opendaylight.controller.usermanager.security.SessionManager;
import org.opendaylight.controller.usermanager.security.UserSecurityContextRepository;
+import org.opendaylight.controller.usermanager.internal.AuthenticatedUser;
+
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.opendaylight.controller.usermanager.AuthResponse;
import org.opendaylight.controller.usermanager.IAAAProvider;
import org.opendaylight.controller.usermanager.IUserManager;
+import org.opendaylight.controller.usermanager.ServerConfig;
+import org.opendaylight.controller.usermanager.UserConfig;
+import org.opendaylight.controller.usermanager.AuthorizationConfig;
/**
* Unit Tests for UserManagerImpl
/**
* Test method for
- * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#addRemoveLocalUser(org.opendaylight.controller.usermanager.internal.UserConfig, boolean)}
+ * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#addRemoveLocalUser(org.opendaylight.controller.usermanager.org.opendaylight.controller.usermanager.internal.UserConfig, boolean)}
* .
*/
@Test
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
xmlns:context="http://www.springframework.org/schema/context"\r
xmlns:mvc="http://www.springframework.org/schema/mvc"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd \r
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd\r
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd\r
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">\r
\r
<context:component-scan base-package="org.opendaylight.controller.devices.web"/>\r
- \r
+\r
<mvc:resources mapping="/js/**" location="/js/" />\r
<mvc:resources mapping="/css/**" location="/css/" />\r
<mvc:resources mapping="/img/**" location="/img/" />\r
<mvc:annotation-driven/>\r
- \r
+\r
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">\r
- <property name="prefix" value="/WEB-INF/jsp/"/>\r
- <property name="suffix" value=".jsp"/>\r
+ <property name="prefix" value="/WEB-INF/jsp/"/>\r
+ <property name="suffix" value=".jsp"/>\r
</bean>\r
</beans>\r
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>free access</web-resource-name>
- <url-pattern>/js/*</url-pattern>
- <url-pattern>/images/*</url-pattern>
- <url-pattern>/css/*</url-pattern>
- <url-pattern>/favicon.ico</url-pattern>
- </web-resource-collection>
- </security-constraint>
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>free access</web-resource-name>
+ <url-pattern>/js/*</url-pattern>
+ <url-pattern>/images/*</url-pattern>
+ <url-pattern>/css/*</url-pattern>
+ <url-pattern>/favicon.ico</url-pattern>
+ </web-resource-collection>
+ </security-constraint>
- <security-constraint>
- <display-name>DevicesApp</display-name>
- <web-resource-collection>
- <web-resource-name>DevicesGUI</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <display-name>DevicesApp</display-name>
+ <web-resource-collection>
+ <web-resource-name>DevicesGUI</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>FORM</auth-method>
- <form-login-config>
- <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
- <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
- </form-login-config>
- </login-config>
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <form-login-config>
+ <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
+ <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
+ </form-login-config>
+ </login-config>
<error-page>
<error-code>403</error-code>
<location>/WEB-INF/jsp/autherror.jsp</location>
</error-page>
- <servlet>
- <servlet-name>Devices</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
+ <servlet>
+ <servlet-name>Devices</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
- <servlet-mapping>
- <servlet-name>Devices</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Devices</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
- <listener>
- <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
- </listener>
- <session-config>
- <cookie-config>
- <path>/</path>
- </cookie-config>
- </session-config>
+ <listener>
+ <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
+ </listener>
+ <session-config>
+ <cookie-config>
+ <path>/</path>
+ </cookie-config>
+ </session-config>
</web-app>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
xmlns:context="http://www.springframework.org/schema/context"\r
xmlns:mvc="http://www.springframework.org/schema/mvc"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd \r
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd\r
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd\r
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">\r
\r
<context:component-scan base-package="org.opendaylight.controller.flows.web"/>\r
- \r
+\r
<mvc:resources mapping="/js/**" location="/js/" />\r
<mvc:resources mapping="/css/**" location="/css/" />\r
<mvc:resources mapping="/img/**" location="/img/" />\r
<mvc:annotation-driven/>\r
- \r
+\r
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">\r
- <property name="prefix" value="/WEB-INF/jsp/"/>\r
- <property name="suffix" value=".jsp"/>\r
+ <property name="prefix" value="/WEB-INF/jsp/"/>\r
+ <property name="suffix" value=".jsp"/>\r
</bean>\r
</beans>\r
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
- <servlet>
- <servlet-name>Flows</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
+ <servlet>
+ <servlet-name>Flows</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
- <servlet-mapping>
- <servlet-name>Flows</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Flows</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>free access</web-resource-name>
- <url-pattern>/js/*</url-pattern>
- <url-pattern>/images/*</url-pattern>
- <url-pattern>/css/*</url-pattern>
- <url-pattern>/favicon.ico</url-pattern>
- </web-resource-collection>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>free access</web-resource-name>
+ <url-pattern>/js/*</url-pattern>
+ <url-pattern>/images/*</url-pattern>
+ <url-pattern>/css/*</url-pattern>
+ <url-pattern>/favicon.ico</url-pattern>
+ </web-resource-collection>
+ </security-constraint>
- <security-constraint>
- <display-name>FlowApp</display-name>
- <web-resource-collection>
- <web-resource-name>FlowMgrGUI</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-constraint>
+ <display-name>FlowApp</display-name>
+ <web-resource-collection>
+ <web-resource-name>FlowMgrGUI</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>FORM</auth-method>
- <form-login-config>
- <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
- <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
- </form-login-config>
- </login-config>
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <form-login-config>
+ <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
+ <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
+ </form-login-config>
+ </login-config>
<error-page>
<error-code>403</error-code>
<location>/WEB-INF/jsp/autherror.jsp</location>
</error-page>
- <listener>
- <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
- </listener>
+ <listener>
+ <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
+ </listener>
- <session-config>
- <cookie-config>
- <path>/</path>
- </cookie-config>
- </session-config>
+ <session-config>
+ <cookie-config>
+ <path>/</path>
+ </cookie-config>
+ </session-config>
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.controller.usermanager.IUserManager;
-import org.opendaylight.controller.usermanager.internal.UserConfig;
+import org.opendaylight.controller.usermanager.UserConfig;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="org.opendaylight.controller.web"/>
-
+
<mvc:resources mapping="/js/**" location="/js/" />
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/img/**" location="/img/" />
<mvc:annotation-driven/>
-
+
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix" value="/WEB-INF/jsp/"/>
- <property name="suffix" value=".jsp"/>
+ <property name="prefix" value="/WEB-INF/jsp/"/>
+ <property name="suffix" value=".jsp"/>
</bean>
</beans>
\ No newline at end of file
<beans:beans xmlns="http://www.springframework.org/schema/security"
- xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
+ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
- <http pattern="/css/**" security="none" />
- <http pattern="/js/**" security="none" />
- <http pattern="/images/**" security="none" />
- <http pattern="/favicon.ico" security="none" />
- <http pattern="/controller/web/css/**" security="none" />
- <http pattern="/controller/web/js/**" security="none" />
- <http pattern="/controller/web/images/**" security="none" />
-
-
- <http auto-config="false" authentication-manager-ref="authenticationManager"
- security-context-repository-ref="securityContextRepo" entry-point-ref="loginUrlAuthenticationEntryPoint">
- <intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" />
- <intercept-url pattern="/logout*" access="IS_AUTHENTICATED_ANONYMOUSLY" />
-
-
- <intercept-url pattern="/**"
- access="ROLE_SYSTEM-ADMIN, ROLE_NETWORK-ADMIN, ROLE_NETWORK-OPERATOR, ROLE_CONTAINER-USER" />
- <custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER" />
- <custom-filter position="LOGOUT_FILTER" ref="logoutFilter" />
- <custom-filter position="LAST" ref="controllerFilter" />
- <remember-me services-ref="rememberMeServices" key="SDN" />
- </http>
-
- <beans:bean id="controllerFilter"
- class="org.opendaylight.controller.web.ControllerCustomFilter" />
-
- <authentication-manager id="authenticationManager">
- <authentication-provider ref="authenticationProviderWrapper" />
- </authentication-manager>
-
- <beans:bean id="authenticationFilter"
- class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
- <beans:property name="authenticationManager" ref="authenticationManager" />
- <beans:property name="authenticationFailureHandler"
- ref="authenticationFailureHandler" />
- <beans:property name="authenticationSuccessHandler">
- <beans:bean
- class="org.opendaylight.controller.web.ControllerAuthenticationSuccessHandler">
- <beans:property name="targetUrlParameter" value="x-page-url" />
- <beans:property name="defaultTargetUrl" value="/" />
- </beans:bean>
- </beans:property>
- <beans:property name="rememberMeServices" ref="rememberMeServices" />
- </beans:bean>
-
- <beans:bean id="securityContextRepo"
- class="org.opendaylight.controller.web.ControllerWebSecurityContextRepository" />
-
- <beans:bean id="authenticationFailureHandler"
- class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
- <beans:property name="useForward" value="false" />
- <beans:property name="defaultFailureUrl" value="/login" />
- </beans:bean>
-
- <beans:bean id="loginUrlAuthenticationEntryPoint"
- class="org.opendaylight.controller.web.ControllerLoginUrlAuthEntryPoint">
- <beans:property name="loginFormUrl" value="/login" />
- </beans:bean>
-
- <beans:bean id="authenticationProviderWrapper"
- class="org.opendaylight.controller.web.AuthenticationProviderWrapper" />
+ <http pattern="/css/**" security="none" />
+ <http pattern="/js/**" security="none" />
+ <http pattern="/images/**" security="none" />
+ <http pattern="/favicon.ico" security="none" />
+ <http pattern="/controller/web/css/**" security="none" />
+ <http pattern="/controller/web/js/**" security="none" />
+ <http pattern="/controller/web/images/**" security="none" />
+
+
+ <http auto-config="false" authentication-manager-ref="authenticationManager"
+ security-context-repository-ref="securityContextRepo" entry-point-ref="loginUrlAuthenticationEntryPoint">
+ <intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" />
+ <intercept-url pattern="/logout*" access="IS_AUTHENTICATED_ANONYMOUSLY" />
+
+
+ <intercept-url pattern="/**"
+ access="ROLE_SYSTEM-ADMIN, ROLE_NETWORK-ADMIN, ROLE_NETWORK-OPERATOR, ROLE_CONTAINER-USER" />
+ <custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER" />
+ <custom-filter position="LOGOUT_FILTER" ref="logoutFilter" />
+ <custom-filter position="LAST" ref="controllerFilter" />
+ <remember-me services-ref="rememberMeServices" key="SDN" />
+ </http>
+
+ <beans:bean id="controllerFilter"
+ class="org.opendaylight.controller.web.ControllerCustomFilter" />
+
+ <authentication-manager id="authenticationManager">
+ <authentication-provider ref="authenticationProviderWrapper" />
+ </authentication-manager>
+
+ <beans:bean id="authenticationFilter"
+ class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
+ <beans:property name="authenticationManager" ref="authenticationManager" />
+ <beans:property name="authenticationFailureHandler"
+ ref="authenticationFailureHandler" />
+ <beans:property name="authenticationSuccessHandler">
+ <beans:bean
+ class="org.opendaylight.controller.web.ControllerAuthenticationSuccessHandler">
+ <beans:property name="targetUrlParameter" value="x-page-url" />
+ <beans:property name="defaultTargetUrl" value="/" />
+ </beans:bean>
+ </beans:property>
+ <beans:property name="rememberMeServices" ref="rememberMeServices" />
+ </beans:bean>
+
+ <beans:bean id="securityContextRepo"
+ class="org.opendaylight.controller.web.ControllerWebSecurityContextRepository" />
+
+ <beans:bean id="authenticationFailureHandler"
+ class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
+ <beans:property name="useForward" value="false" />
+ <beans:property name="defaultFailureUrl" value="/login" />
+ </beans:bean>
+
+ <beans:bean id="loginUrlAuthenticationEntryPoint"
+ class="org.opendaylight.controller.web.ControllerLoginUrlAuthEntryPoint">
+ <beans:property name="loginFormUrl" value="/login" />
+ </beans:bean>
+
+ <beans:bean id="authenticationProviderWrapper"
+ class="org.opendaylight.controller.web.AuthenticationProviderWrapper" />
<!-- logout related -->
-
+
<beans:bean id="logoutHandler"
class="org.opendaylight.controller.web.ControllerLogoutHandler" />
-
+
<beans:bean id="securityContextLogoutHandler"
- class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" />
-
-
+ class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" />
+
+
<beans:bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
<!-- if logout succeed then this is the URL -->
<beans:constructor-arg value="/login" />
</beans:list>
</beans:constructor-arg>
<beans:property name="filterProcessesUrl" value="/logout" />
- </beans:bean>
-
+ </beans:bean>
+
+
+ <!-- remember me related -->
+ <beans:bean id="rememberMeFilter"
+ class="org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter">
+ <beans:property name="rememberMeServices" ref="rememberMeServices" />
+ <beans:property name="authenticationManager" ref="authenticationManager" />
+ </beans:bean>
- <!-- remember me related -->
- <beans:bean id="rememberMeFilter"
- class="org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter">
- <beans:property name="rememberMeServices" ref="rememberMeServices" />
- <beans:property name="authenticationManager" ref="authenticationManager" />
- </beans:bean>
+ <beans:bean id="rememberMeServices"
+ class="org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices">
+ <beans:property name="userDetailsService" ref="userDetailsServiceRef" />
+ <beans:property name="key" value="SDN" />
+ <beans:property name="alwaysRemember" value="true"></beans:property>
+ <beans:property name="tokenValiditySeconds" value="3600" />
+ <beans:property name="cookieName" value="SDN-Controller" />
+ </beans:bean>
- <beans:bean id="rememberMeServices"
- class="org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices">
- <beans:property name="userDetailsService" ref="userDetailsServiceRef" />
- <beans:property name="key" value="SDN" />
- <beans:property name="alwaysRemember" value="true"></beans:property>
- <beans:property name="tokenValiditySeconds" value="3600" />
- <beans:property name="cookieName" value="SDN-Controller" />
- </beans:bean>
+ <beans:bean id="userDetailsServiceRef" class="org.opendaylight.controller.web.ControllerUserDetailsService" />
- <beans:bean id="userDetailsServiceRef" class="org.opendaylight.controller.web.ControllerUserDetailsService" />
+ <beans:bean id="rememberMeAuthenticationProvider"
+ class="org.springframework.security.authentication.RememberMeAuthenticationProvider">
+ <beans:property name="key" value="SDN" />
+ </beans:bean>
- <beans:bean id="rememberMeAuthenticationProvider"
- class="org.springframework.security.authentication.RememberMeAuthenticationProvider">
- <beans:property name="key" value="SDN" />
- </beans:bean>
-
</beans:beans>
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
- version="2.4"> -->
+<!-- <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4"> -->
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>free access</web-resource-name>
- <url-pattern>/js/*</url-pattern>
- <url-pattern>/images/*</url-pattern>
- <url-pattern>/css/*</url-pattern>
- <url-pattern>/favicon.ico</url-pattern>
- </web-resource-collection>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>free access</web-resource-name>
+ <url-pattern>/js/*</url-pattern>
+ <url-pattern>/images/*</url-pattern>
+ <url-pattern>/css/*</url-pattern>
+ <url-pattern>/favicon.ico</url-pattern>
+ </web-resource-collection>
+ </security-constraint>
- <security-constraint>
- <display-name>RootApp</display-name>
- <web-resource-collection>
- <web-resource-name>RootGUI</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <display-name>RootApp</display-name>
+ <web-resource-collection>
+ <web-resource-name>RootGUI</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>FORM</auth-method>
- <form-login-config>
- <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
- <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
- </form-login-config>
- </login-config>
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <form-login-config>
+ <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
+ <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
+ </form-login-config>
+ </login-config>
<error-page>
<error-code>403</error-code>
<location>/WEB-INF/jsp/autherror.jsp</location>
</error-page>
- <servlet>
- <servlet-name>RootGUI</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
+ <servlet>
+ <servlet-name>RootGUI</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
- <servlet-mapping>
- <servlet-name>RootGUI</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>RootGUI</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
- <display-name>OpenDaylight Controller</display-name>
- <description>OpenDaylight Controller</description>
+ <display-name>OpenDaylight Controller</display-name>
+ <description>OpenDaylight Controller</description>
- <listener>
- <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
- </listener>
+ <listener>
+ <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
+ </listener>
- <session-config>
- <cookie-config>
- <path>/</path>
- </cookie-config>
- </session-config>
+ <session-config>
+ <cookie-config>
+ <path>/</path>
+ </cookie-config>
+ </session-config>
</web-app>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
xmlns:context="http://www.springframework.org/schema/context"\r
xmlns:mvc="http://www.springframework.org/schema/mvc"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd \r
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd\r
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd\r
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">\r
\r
<context:component-scan base-package="org.opendaylight.controller.topology.web"/>\r
- \r
+\r
<mvc:resources mapping="/js/**" location="/js/" />\r
<mvc:resources mapping="/css/**" location="/css/" />\r
<mvc:resources mapping="/img/**" location="/img/" />\r
<mvc:annotation-driven/>\r
- \r
+\r
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">\r
- <property name="prefix" value="/WEB-INF/jsp/"/>\r
- <property name="suffix" value=".jsp"/>\r
+ <property name="prefix" value="/WEB-INF/jsp/"/>\r
+ <property name="suffix" value=".jsp"/>\r
</bean>\r
</beans>\r
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>free access</web-resource-name>
- <url-pattern>/js/*</url-pattern>
- <url-pattern>/images/*</url-pattern>
- <url-pattern>/css/*</url-pattern>
- <url-pattern>/favicon.ico</url-pattern>
- </web-resource-collection>
- </security-constraint>
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>free access</web-resource-name>
+ <url-pattern>/js/*</url-pattern>
+ <url-pattern>/images/*</url-pattern>
+ <url-pattern>/css/*</url-pattern>
+ <url-pattern>/favicon.ico</url-pattern>
+ </web-resource-collection>
+ </security-constraint>
- <security-constraint>
- <display-name>TopologyApp</display-name>
- <web-resource-collection>
- <web-resource-name>TopoGUI</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-constraint>
+ <display-name>TopologyApp</display-name>
+ <web-resource-collection>
+ <web-resource-name>TopoGUI</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>FORM</auth-method>
- <form-login-config>
- <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
- <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
- </form-login-config>
- </login-config>
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <form-login-config>
+ <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
+ <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
+ </form-login-config>
+ </login-config>
<error-page>
<error-code>403</error-code>
<location>/WEB-INF/jsp/autherror.jsp</location>
</error-page>
- <servlet>
- <servlet-name>Topology</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
+ <servlet>
+ <servlet-name>Topology</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
- <servlet-mapping>
- <servlet-name>Topology</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Topology</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
- <listener>
- <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
- </listener>
+ <listener>
+ <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
+ </listener>
- <session-config>
- <cookie-config>
- <path>/</path>
- </cookie-config>
- </session-config>
+ <session-config>
+ <cookie-config>
+ <path>/</path>
+ </cookie-config>
+ </session-config>
</web-app>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
xmlns:context="http://www.springframework.org/schema/context"\r
xmlns:mvc="http://www.springframework.org/schema/mvc"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd \r
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd\r
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd\r
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">\r
\r
<context:component-scan base-package="org.opendaylight.controller.troubleshoot.web"/>\r
- \r
+\r
<mvc:resources mapping="/js/**" location="/js/" />\r
<mvc:resources mapping="/css/**" location="/css/" />\r
<mvc:resources mapping="/img/**" location="/img/" />\r
<mvc:annotation-driven/>\r
- \r
+\r
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">\r
- <property name="prefix" value="/WEB-INF/jsp/"/>\r
- <property name="suffix" value=".jsp"/>\r
+ <property name="prefix" value="/WEB-INF/jsp/"/>\r
+ <property name="suffix" value=".jsp"/>\r
</bean>\r
</beans>\r
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
- <servlet>
- <servlet-name>Troubleshoot</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
+ <servlet>
+ <servlet-name>Troubleshoot</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
- <servlet-mapping>
- <servlet-name>Troubleshoot</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Troubleshoot</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>free access</web-resource-name>
- <url-pattern>/js/*</url-pattern>
- <url-pattern>/images/*</url-pattern>
- <url-pattern>/css/*</url-pattern>
- <url-pattern>/favicon.ico</url-pattern>
- </web-resource-collection>
- </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>free access</web-resource-name>
+ <url-pattern>/js/*</url-pattern>
+ <url-pattern>/images/*</url-pattern>
+ <url-pattern>/css/*</url-pattern>
+ <url-pattern>/favicon.ico</url-pattern>
+ </web-resource-collection>
+ </security-constraint>
- <security-constraint>
- <display-name>TroubleShootApp</display-name>
- <web-resource-collection>
- <web-resource-name>TroubleShootGUI</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- <role-name>Network-Operator</role-name>
- <role-name>Container-User</role-name>
- </auth-constraint>
- </security-constraint>
+ <security-constraint>
+ <display-name>TroubleShootApp</display-name>
+ <web-resource-collection>
+ <web-resource-name>TroubleShootGUI</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Operator</role-name>
- </security-role>
- <security-role>
- <role-name>Container-User</role-name>
- </security-role>
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
- <login-config>
- <auth-method>FORM</auth-method>
- <form-login-config>
- <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
- <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
- </form-login-config>
- </login-config>
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <form-login-config>
+ <form-login-page>/WEB-INF/jsp/login.jsp</form-login-page>
+ <form-error-page>/WEB-INF/jsp/error.jsp</form-error-page>
+ </form-login-config>
+ </login-config>
<error-page>
<error-code>403</error-code>
<location>/WEB-INF/jsp/autherror.jsp</location>
</error-page>
- <listener>
- <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
- </listener>
+ <listener>
+ <listener-class>org.opendaylight.controller.web.ControllerUISessionManager</listener-class>
+ </listener>
- <session-config>
- <cookie-config>
- <path>/</path>
- </cookie-config>
- </session-config>
+ <session-config>
+ <cookie-config>
+ <path>/</path>
+ </cookie-config>
+ </session-config>