Merge "Migrate XML output to yang-data-codec-xml"
authorTomas Cere <tcere@cisco.com>
Tue, 20 Jun 2017 13:39:59 +0000 (13:39 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 20 Jun 2017 13:39:59 +0000 (13:39 +0000)
78 files changed:
features/netconf-connector/features-netconf-connector/pom.xml
features/netconf-connector/features4-netconf-connector/pom.xml
features/netconf-connector/odl-message-bus/pom.xml
features/netconf-connector/odl-netconf-callhome-ssh/pom.xml
features/netconf-connector/odl-netconf-clustered-topology/pom.xml
features/netconf-connector/odl-netconf-connector-all/pom.xml
features/netconf-connector/odl-netconf-connector-ssh/pom.xml
features/netconf-connector/odl-netconf-connector/pom.xml
features/netconf-connector/odl-netconf-console/pom.xml
features/netconf-connector/odl-netconf-topology/pom.xml
features/netconf-connector/pom.xml
features/netconf/features-netconf/pom.xml
features/netconf/features4-netconf/pom.xml
features/netconf/odl-aaa-netconf-plugin-no-cluster/pom.xml
features/netconf/odl-aaa-netconf-plugin/pom.xml
features/netconf/odl-config-netconf-connector/pom.xml
features/netconf/odl-netconf-all/pom.xml
features/netconf/odl-netconf-api/pom.xml
features/netconf/odl-netconf-client/pom.xml
features/netconf/odl-netconf-impl/pom.xml
features/netconf/odl-netconf-mapping-api/pom.xml
features/netconf/odl-netconf-mdsal/pom.xml
features/netconf/odl-netconf-monitoring/pom.xml
features/netconf/odl-netconf-netty-util/pom.xml
features/netconf/odl-netconf-notifications-api/pom.xml
features/netconf/odl-netconf-notifications-impl/pom.xml
features/netconf/odl-netconf-ssh/pom.xml
features/netconf/odl-netconf-tcp/pom.xml
features/netconf/odl-netconf-util/pom.xml
features/netconf/pom.xml
features/restconf/features-restconf/pom.xml
features/restconf/features-restconf/src/main/features/features.xml
features/restconf/features4-restconf/pom.xml
features/restconf/odl-mdsal-apidocs/pom.xml
features/restconf/odl-restconf-all/pom.xml
features/restconf/odl-restconf-noauth/pom.xml
features/restconf/odl-restconf/pom.xml
features/restconf/pom.xml
features/yanglib/features-yanglib/pom.xml
features/yanglib/features4-yanglib/pom.xml
features/yanglib/odl-yanglib/pom.xml
features/yanglib/pom.xml
karaf/pom.xml
netconf/config-netconf-connector/pom.xml
netconf/mdsal-netconf-tcp/pom.xml
netconf/models/pom.xml
netconf/netconf-artifacts/pom.xml
netconf/netconf-config/pom.xml
netconf/netconf-connector-config/pom.xml
netconf/netconf-monitoring/pom.xml
netconf/netconf-netty-util/pom.xml
netconf/netconf-topology-config/pom.xml
netconf/netconf-util/pom.xml
netconf/pom.xml
netconf/tools/netconf-cli/pom.xml
netconf/tools/netconf-testtool/pom.xml
pom.xml
restconf/pom.xml
restconf/restconf-artifacts/pom.xml
restconf/sal-rest-connector-config/pom.xml
restconf/sal-rest-connector/pom.xml
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/api/JSONRestconfService.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/JSONRestconfServiceImpl.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/base/services/impl/RestconfOperationsServiceImpl.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java
restconf/sal-rest-docgen-maven/pom.xml
restconf/sal-rest-docgen/pom.xml
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocServiceImpl.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/jaxrs/JaxbContextResolver.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/swagger/ApiDeclaration.java
restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGeneratorTest.java
restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/DocGenTestHelper.java
restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGeneratorTest.java

index 3b07dfd6ce4b66a15226c7a81f5e9259a8144dcb..459ca607c3b4f079cd6a359cb4079cbcb11bf018 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>features-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
   <groupId>org.opendaylight.netconf</groupId>
@@ -24,7 +24,7 @@
     <commons.opendaylight.version>1.9.0-SNAPSHOT</commons.opendaylight.version>
     <controller.mdsal.version>1.6.0-SNAPSHOT</controller.mdsal.version>
     <config.version>0.7.0-SNAPSHOT</config.version>
-    <features.test.version>1.8.0-Carbon</features.test.version>
+    <features.test.version>1.9.0</features.test.version>
     <mdsal.version>2.3.0-SNAPSHOT</mdsal.version>
     <mdsal.model.version>0.11.0-SNAPSHOT</mdsal.model.version>
     <netconf.version>1.3.0-SNAPSHOT</netconf.version>
index 9a1975f917045038b5290247ad950ae5ed39ce9b..1dedb471115546ef410a4989a372b93ab931a8af 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>feature-repo-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 361ef600324be765d32718544a1d3fc3fdf39bc5..5dc029e547706d0a1d501dcf931c8d30318191af 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index d2ab40e1ba4e171e6a3df0b119a9577cbc587b6a..685359848f3f5005b9647e85a885cf8a8e197930 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 46affd9207ccc7c6fb2a3463457eb7b3e6b9e2d8..a8a1c57b1f252879b0aa2a03cb7ac8ac7901da61 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 523b0f374f621c0867fa7a391cb168aa25ca96a5..850f193920f44b05e41ce8437c2e5f56895f8060 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 3a3c3dfdd80870a8157bf6f478e37c0532a4f929..3ee02ad429f4c9c06b12db782059c50838b6b34b 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 0de0095188172f0b153d85a1663c3a7455afdd53..338aa7ab3f720d6c7d5b1eed481d9258aa6075c1 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index d62465b87eb63e9cf59308ff9f6f682548ef53a6..8eb72deb8be1537baedeccaca752f572e068b4aa 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 4e137d080bf1108a3542c3401d70e4527b828f51..7972ad252f19472ca47f4835bdeaa97866599008 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 66c6a53eb5cd8fb939a16455f3f95b0e6ee4d7da..8d20cb371d18ea0a099a9d9596dcf22a6013e2a3 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
     <groupId>org.opendaylight.netconf</groupId>
@@ -24,7 +24,7 @@
       <commons.opendaylight.version>1.9.0-SNAPSHOT</commons.opendaylight.version>
       <controller.mdsal.version>1.6.0-SNAPSHOT</controller.mdsal.version>
       <config.version>0.7.0-SNAPSHOT</config.version>
-      <features.test.version>1.8.0-Carbon</features.test.version>
+      <features.test.version>1.9.0</features.test.version>
       <mdsal.version>2.3.0-SNAPSHOT</mdsal.version>
       <mdsal.model.version>0.11.0-SNAPSHOT</mdsal.model.version>
       <netconf.version>1.3.0-SNAPSHOT</netconf.version>
index ec91150e1c575af99f0c08af44f2f4843106c11f..92af98cd6b92c31ce55c54ef25a2f5bb55fe7101 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>features-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
@@ -25,7 +25,7 @@
     <commons.opendaylight.version>1.9.0-SNAPSHOT</commons.opendaylight.version>
     <controller.mdsal.version>1.6.0-SNAPSHOT</controller.mdsal.version>
     <config.version>0.7.0-SNAPSHOT</config.version>
-    <features.test.version>1.8.0-Carbon</features.test.version>
+    <features.test.version>1.9.0</features.test.version>
     <mdsal.model.version>0.11.0-SNAPSHOT</mdsal.model.version>
     <netconf.version>1.3.0-SNAPSHOT</netconf.version>
     <protocol-framework.version>0.10.0-SNAPSHOT</protocol-framework.version>
@@ -45,7 +45,7 @@
       <dependency>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-artifacts</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index 4de3769f3ba2eb39151003f2a24265ab0ee88a43..fd946008c24ec71937edcd2be933f13d1c6009c0 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>feature-repo-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index c0e8986b90694031f97de0e33d331ed652bff4a4..9782c1e790f83039c944d9d23190bd50cfc3c2aa 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index b8788a3532d5dae2c9cb6d7bb485a7481223144d..6a4c81a1089b70cff8201d5a772b79b14616091a 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index e3ea8b2f2905e10469aad8502497c0da1dd5c97b..225749b007eeffafe240f20e6fd7d269badc2ea4 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index cc74e74e29fbf7ca483ce4cbcadc7fe670d3a542..b8d32ec9f0cbf232b55599508de3ecdcaf763d9a 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 75f1535f966eef1051bd4c926e2f3f6394d665d0..36069bff53303e36ba36e84eab29c265e38108e3 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 563ecbdd2658ece40f9a1e0dab996e388fc6a494..7e8a4ba90303e0249d1ce67531a631ac8a7762c4 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 9c6d186e80485e3387fd7af38922cafff9142164..c6e34c6ba7dfde8123204c37f36b4dcbffe4f414 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index e0f282e8448b9558333a3ecf74a147b6caea2271..939de1ed8c27aba165906c659e442d4f12e3a6b9 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 81d337c40d9317a2509738c149067f9aa9513ef1..f2038ada9ef4ed30d974a6c99280bcb2c4ef7617 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 6ccb878e87be124ca5418ddec96c027bb6bee694..c2e922dfcb52e049cea2ffb79d6bb79036e24473 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index b111ba069725a45db17a8081ce40ec06c7901504..ac6250e68e8c69bd1ea50390c146c1ff6bf91207 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
@@ -58,7 +58,7 @@
         <dependency>
             <groupId>org.opendaylight.odlparent</groupId>
             <artifactId>odl4-netty-4</artifactId>
-            <version>1.8.0-Carbon</version>
+            <version>1.9.0</version>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
index b08de0a5fddbd39d69086074c9e5680c3ea95f40..5399bb38468fcb9287dfcce31b9d434fe88c5d21 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 239e77e49b629f1a1c4348760338c86119dfaeab..64dd65747e93a43cc182d839ba6c7e1f4335b878 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index e5f6d1e1f27a3c634096afadaa845b8b1891aed5..459492540f805fd2129d562d7dd56b212b1da4ea 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 54a911ee590828d51c961f021a0dd457bdffbd98..c4a911ebdaab52e0a00c4bf6eaf565995cc3e6dd 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 2b96904c2370168d2c865dfefbe58d605a5a60f1..92802443dcce16b6d8fc1dee37b309293f5f940b 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index ecaa7e0e1590eede19156943e4ed1deb2a99c442..a54a9b6b5f76761402238d50e25c6acc00e2fe2d 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index 71088ebd097a7b5b467b9967b2d2335b7f319b32..ae922a5d95e6f73728ee868fa2cf7d9c9eb3601d 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>features-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
   <artifactId>features-restconf</artifactId>
@@ -23,7 +23,7 @@
     <aaa.version>0.6.0-SNAPSHOT</aaa.version>
     <commons.opendaylight.version>1.9.0-SNAPSHOT</commons.opendaylight.version>
     <controller.mdsal.version>1.6.0-SNAPSHOT</controller.mdsal.version>
-    <features.test.version>1.8.0-Carbon</features.test.version>
+    <features.test.version>1.9.0</features.test.version>
     <mdsal.version>2.3.0-SNAPSHOT</mdsal.version>
     <mdsal.model.version>0.11.0-SNAPSHOT</mdsal.model.version>
     <restconf.version>1.6.0-SNAPSHOT</restconf.version>
@@ -40,7 +40,7 @@
       <dependency>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-artifacts</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
       <artifactId>jackson-databind</artifactId>
     </dependency>
     <dependency>
-      <groupId>com.fasterxml.jackson.datatype</groupId>
-      <artifactId>jackson-datatype-json-org</artifactId>
+      <groupId>com.fasterxml.jackson.dataformat</groupId>
+      <artifactId>jackson-dataformat-xml</artifactId>
+      <version>2.3.2</version>
     </dependency>
     <dependency>
       <groupId>com.fasterxml.jackson.module</groupId>
       <groupId>com.fasterxml.jackson.jaxrs</groupId>
       <artifactId>jackson-jaxrs-json-provider</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.json</groupId>
-      <artifactId>json</artifactId>
-    </dependency>
 
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
index 77c9687fba7862f018b8cea43830cc1b9688c8e5..cc371cde3af6cdee9ce86ae99301c38a92624a5e 100644 (file)
@@ -37,6 +37,9 @@
         <bundle>mvn:com.google.code.gson/gson/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/yang-data-codec-gson/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/yang-model-export/{{VERSION}}</bundle>
+        <bundle>mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-xml/{{VERSION}}</bundle>
+        <bundle>mvn:org.codehaus.woodstox/stax2-api/{{VERSION}}</bundle>
+        <bundle>wrap:mvn:javax.xml.stream/stax-api/{{VERSION}}</bundle>
         <configfile finalname="${config.configfile.directory}/${config.restconf.configfile}">mvn:org.opendaylight.netconf/sal-rest-connector-config/{{VERSION}}/xml/config</configfile>
         <configfile finalname="${config.configfile.directory}/${config.restconf.service.configfile}">mvn:org.opendaylight.netconf/sal-rest-connector-config/{{VERSION}}/xml/configrestconfservice</configfile>
     </feature>
         <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/{{VERSION}}</bundle>
         <bundle>mvn:com.fasterxml.jackson.core/jackson-core/{{VERSION}}</bundle>
         <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/{{VERSION}}</bundle>
-        <bundle>mvn:com.fasterxml.jackson.datatype/jackson-datatype-json-org/{{VERSION}}</bundle>
         <bundle>mvn:com.fasterxml.jackson.module/jackson-module-jaxb-annotations/{{VERSION}}</bundle>
         <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/{{VERSION}}</bundle>
         <bundle>mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/{{VERSION}}</bundle>
         <bundle>mvn:com.sun.jersey/jersey-core/{{VERSION}}</bundle>
         <bundle>mvn:com.sun.jersey/jersey-server/{{VERSION}}</bundle>
         <bundle>mvn:com.sun.jersey/jersey-servlet/{{VERSION}}</bundle>
-        <bundle>wrap:mvn:org.json/json/{{VERSION}}</bundle>
     </feature>
 
 </features>
index d4ad5bdd72c2a366aae45c0ab4443345d8ca764a..e950a44e293fbb46c13ddf1e03a8efd7f947ee69 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>feature-repo-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index edcb1ede4a351f9bf48fe312a2522cdc31383de7..3aa0f2d13685c612ec5a76053094e24e2d4e94ce 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
             <artifactId>sal-rest-docgen</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-annotations</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-databind</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.datatype</groupId>
-            <artifactId>jackson-datatype-json-org</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.module</groupId>
-            <artifactId>jackson-module-jaxb-annotations</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.jaxrs</groupId>
-            <artifactId>jackson-jaxrs-base</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.jaxrs</groupId>
-            <artifactId>jackson-jaxrs-json-provider</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-server</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-servlet</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-        </dependency>
     </dependencies>
 </project>
\ No newline at end of file
index f9ca1e7a276d17b64d2a565d973e64b15a6016a4..262725f5a8d5ee8a2ff87c7d497841451ee1f8c7 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index b2d99ce30a5ceee7802a58c3fbd200dd957bf294..9b6da6017002b5b378526ac8246dfb34ace3f051 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
@@ -36,7 +36,7 @@
             <dependency>
                 <groupId>org.opendaylight.odlparent</groupId>
                 <artifactId>odlparent-artifacts</artifactId>
-                <version>1.8.0-Carbon</version>
+                <version>1.9.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
@@ -89,7 +89,7 @@
         <dependency>
             <groupId>org.opendaylight.odlparent</groupId>
             <artifactId>odl4-netty-4</artifactId>
-            <version>1.8.0-Carbon</version>
+            <version>1.9.0</version>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
             <groupId>org.opendaylight.netconf</groupId>
             <artifactId>sal-rest-connector</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-data-codec-gson</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-model-export</artifactId>
-        </dependency>
         <dependency>
             <!-- finalname="${config.configfile.directory}/${config.restconf.configfile}" -->
             <groupId>org.opendaylight.netconf</groupId>
index 5495bf2234d8912a74c4f2670a02566a48376bfa..7892457dbb294738f691933e60d80821584751a6 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 156eed958bc0f8931dc059768f4d162941c7e80b..c0e92bb719b252b611cf832ecce06a92e29d8b0a 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
     <artifactId>features-restconf-aggregator</artifactId>
index fc726bff7e3ad2d41501cbf466810de05357ea28..9c046f9e36b960aab63bdfdba4272c6910686e08 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>features-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
@@ -35,7 +35,7 @@
             <dependency>
                 <groupId>org.opendaylight.odlparent</groupId>
                 <artifactId>odlparent-artifacts</artifactId>
-                <version>1.8.0-Carbon</version>
+                <version>1.9.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index db2a93e73a3d53a6c23d53e6ebdfa62e5ea5b5fa..477d598ec1bbdd69a071a2345aa6287e24660ae1 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>feature-repo-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 21ce35885e67db4891cf591097b9feebe02dc53e..b277a07311a4e0c3fb9f120420b7744a9f8b8719 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>single-feature-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 5714be61294940d2cafdcae7726c121f4863f418..57cdb13bc68672663dfd263a31aacc153e2efb75 100644 (file)
@@ -11,7 +11,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 82f6c2ea1dfc5352a7ac95c2100f1d51039583d9..3ab1d1478ed79c3ee70520c4ee63ccca9f651666 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>karaf4-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
   <groupId>org.opendaylight.netconf</groupId>
index e9b2683671cf74d4d961f7944e2baae595b774ef..72a1afb0229e72ec8527b51ff1822844f30a7d94 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index 82d08ece4872c2c76158a4610f414cc237e91781..8f604922e9cd672b4fd0f4359a48e23dd73da9f3 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index 40e02a0123cd380201ca2cc777c154d112431502..7ff91789cbef7c7089fe40fc7bcd7def10dcfedf 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index bbff11b7d3e00f181e28d90dbabbc57817355054..f50f8e7cd91be0da84771b79ff02f6207b9c03d9 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
       <groupId>org.opendaylight.odlparent</groupId>
       <artifactId>odlparent-lite</artifactId>
-      <version>1.8.0-Carbon</version>
+      <version>1.9.0</version>
       <relativePath/>
     </parent>
 
index fbfdb39c6332ab570e38debe2bcad243c06d9923..3e7a49071402398dd7f3964b1a070272874fc2cb 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index e2a17feba335429f6fa5e5ac4788230f3101880b..9b125c9f1fe8a3792ae2c3ef4352d087df3ec80e 100644 (file)
@@ -13,7 +13,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index e7c21986f895e43717e38e34170fdfbbfb3d38fa..2d7a4dbb2a90c3a4fa7c2244b104887c675e95da 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index d9238f485b3122a7f532053e41c00769208556c9..fc37a0bf1f9fb66177a84ca8119aa2f3b907a5a9 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index 6682b51caad613c1e35736dab349f67a67bb426d..3d6991765f75e53b84198dc36cc250f8877e66bb 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>bundle-parent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index f17d454bcb4c954258d06d0796944313be241fc5..54c2c72155ba4d75a2dc970ce33a7d538d1f5dcd 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index 92487e72d4eaaf30397320a420fc9f1a6a0df17d..89fde0829b0b81adca84154f74ffec9ab17ac310 100644 (file)
@@ -13,7 +13,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index 1022fe1a10a1ccadbc0919ed1236c215ccbb079d..7a1a323966071e75a17a14b3eb96851c93ddf213 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index c8483befe8ecf6fca82ce46463cd876f1ea0cee1..48c3d44e20688f27aad3be61951f0c9ce123b106 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
diff --git a/pom.xml b/pom.xml
index 81533bcef2548cbe95b9a4220a0e8b9ba6f32405..34b0cdf1634ac9427dd15b07f860709f7fcc2b03 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
@@ -33,7 +33,7 @@
     <properties>
         <config.version>0.7.0-SNAPSHOT</config.version>
         <config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
-        <features.test.version>1.8.0-Carbon</features.test.version>
+        <features.test.version>1.9.0</features.test.version>
 
         <mdsal.version>2.3.0-SNAPSHOT</mdsal.version>
         <mdsal.model.version>0.11.0-SNAPSHOT</mdsal.model.version>
index 1e58f0dc96d2b0e52e75b75b23546f54a4c67d15..3eef0055ea5652a9e733fd3de4e51634f2427b16 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 921504e02abc0497479953904846c292f1a55f6f..854b308af0d076df6ba69fb55791d96428a8e4bd 100644 (file)
@@ -15,7 +15,7 @@
     <parent>
       <groupId>org.opendaylight.odlparent</groupId>
       <artifactId>odlparent-lite</artifactId>
-      <version>1.8.0-Carbon</version>
+      <version>1.9.0</version>
       <relativePath/>
     </parent>
 
index ae55f0a9da268b6d0b91e5faf1c4337222f647b5..924c638e75fd78a81d3d84ccb9296e041ea5fddf 100644 (file)
@@ -12,7 +12,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>odlparent-lite</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
index 26528b81b8f30e80aac57e9e582b59f99b092082..81b4042c478f3bfc22789206f8759dfbfac81363 100644 (file)
       <groupId>net.java.dev.stax-utils</groupId>
       <artifactId>stax-utils</artifactId>
     </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.dataformat</groupId>
+      <artifactId>jackson-dataformat-xml</artifactId>
+
+      <!-- Remove this once odlparent provides it -->
+      <version>2.3.2</version>
+    </dependency>
     <dependency>
       <groupId>ch.qos.logback</groupId>
       <artifactId>logback-classic</artifactId>
       <scope>test</scope>
     </dependency>
 
-    <dependency>
-      <groupId>org.json</groupId>
-      <artifactId>json</artifactId>
-    </dependency>
-
     <!-- Testing Dependencies -->
     <dependency>
       <groupId>org.glassfish.jersey.test-framework.providers</groupId>
index 3550ddee8749a3d27b56e3d0edbae898c4e64a5d..df3e3f1afbece575ad37d504c7c5665e9c5aeb8d 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.netconf.sal.restconf.api;
 
 import com.google.common.base.Optional;
 import javax.annotation.Nonnull;
-import javax.ws.rs.core.UriInfo;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.common.OperationFailedException;
 
@@ -32,7 +31,7 @@ public interface JSONRestconfService {
      * @param payload the payload data in JSON format.
      * @throws OperationFailedException if the request fails.
      */
-    void put(String uriPath, @Nonnull String payload, UriInfo uriInfo) throws OperationFailedException;
+    void put(String uriPath, @Nonnull String payload) throws OperationFailedException;
 
     /**
      * Issues a restconf POST request to the configuration data store.
@@ -42,7 +41,7 @@ public interface JSONRestconfService {
      * @param payload the payload data in JSON format.
      * @throws OperationFailedException if the request fails.
      */
-    void post(String uriPath, @Nonnull String payload, UriInfo uriInfo) throws OperationFailedException;
+    void post(String uriPath, @Nonnull String payload) throws OperationFailedException;
 
     /**
      * Issues a restconf DELETE request to the configuration data store.
@@ -62,7 +61,7 @@ public interface JSONRestconfService {
      * @return an Optional containing the data in JSON format if present.
      * @throws OperationFailedException if the request fails.
      */
-    Optional<String> get(String uriPath, LogicalDatastoreType datastoreType, UriInfo uriInfo)
+    Optional<String> get(String uriPath, LogicalDatastoreType datastoreType)
             throws OperationFailedException;
 
     /**
index 77c6dc99c641023f5e37bb29921e959163b64655..f6359a68b85c5014cf41aa0dde5bd6e789af366a 100644 (file)
@@ -14,9 +14,15 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
+import java.net.URI;
 import java.nio.charset.StandardCharsets;
+import java.util.Collections;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
@@ -42,7 +48,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
-    public void put(final String uriPath, final String payload, final UriInfo uriInfo) throws OperationFailedException {
+    public void put(final String uriPath, final String payload) throws OperationFailedException {
         Preconditions.checkNotNull(payload, "payload can't be null");
 
         LOG.debug("put: uriPath: {}, payload: {}", uriPath, payload);
@@ -54,7 +60,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
         LOG.debug("Parsed NormalizedNode: {}", context.getData());
 
         try {
-            RestconfImpl.getInstance().updateConfigurationData(uriPath, context, uriInfo);
+            RestconfImpl.getInstance().updateConfigurationData(uriPath, context, new SimpleUriInfo(uriPath));
         } catch (final Exception e) {
             propagateExceptionAs(uriPath, e, "PUT");
         }
@@ -62,7 +68,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
-    public void post(final String uriPath, final String payload, final UriInfo uriInfo)
+    public void post(final String uriPath, final String payload)
             throws OperationFailedException {
         Preconditions.checkNotNull(payload, "payload can't be null");
 
@@ -75,7 +81,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
         LOG.debug("Parsed NormalizedNode: {}", context.getData());
 
         try {
-            RestconfImpl.getInstance().createConfigurationData(uriPath, context, uriInfo);
+            RestconfImpl.getInstance().createConfigurationData(uriPath, context, new SimpleUriInfo(uriPath));
         } catch (final Exception e) {
             propagateExceptionAs(uriPath, e, "POST");
         }
@@ -95,12 +101,13 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
-    public Optional<String> get(final String uriPath, final LogicalDatastoreType datastoreType, final UriInfo uriInfo)
+    public Optional<String> get(final String uriPath, final LogicalDatastoreType datastoreType)
             throws OperationFailedException {
         LOG.debug("get: uriPath: {}", uriPath);
 
         try {
             NormalizedNodeContext readData;
+            final SimpleUriInfo uriInfo = new SimpleUriInfo(uriPath);
             if (datastoreType == LogicalDatastoreType.CONFIGURATION) {
                 readData = RestconfImpl.getInstance().readConfigurationData(uriPath, uriInfo);
             } else {
@@ -225,4 +232,113 @@ public class JSONRestconfServiceImpl implements JSONRestconfService, AutoCloseab
             }
         }
     }
+
+    private static class SimpleUriInfo implements UriInfo {
+        private final String path;
+        private final MultivaluedMap<String, String> queryParams;
+
+        SimpleUriInfo(String path) {
+            this(path, new MultivaluedHashMap<>());
+        }
+
+        SimpleUriInfo(String path, MultivaluedMap<String, String> queryParams) {
+            this.path = path;
+            this.queryParams = queryParams;
+        }
+
+        @Override
+        public String getPath() {
+            return path;
+        }
+
+        @Override
+        public String getPath(boolean decode) {
+            return path;
+        }
+
+        @Override
+        public List<PathSegment> getPathSegments() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public List<PathSegment> getPathSegments(boolean decode) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public URI getRequestUri() {
+            return URI.create(path);
+        }
+
+        @Override
+        public UriBuilder getRequestUriBuilder() {
+            return UriBuilder.fromUri(getRequestUri());
+        }
+
+        @Override
+        public URI getAbsolutePath() {
+            return getRequestUri();
+        }
+
+        @Override
+        public UriBuilder getAbsolutePathBuilder() {
+            return UriBuilder.fromUri(getAbsolutePath());
+        }
+
+        @Override
+        public URI getBaseUri() {
+            return URI.create("");
+        }
+
+        @Override
+        public UriBuilder getBaseUriBuilder() {
+            return UriBuilder.fromUri(getBaseUri());
+        }
+
+        @Override
+        public MultivaluedMap<String, String> getPathParameters() {
+            return new MultivaluedHashMap<>();
+        }
+
+        @Override
+        public MultivaluedMap<String, String> getPathParameters(boolean decode) {
+            return getPathParameters();
+        }
+
+        @Override
+        public MultivaluedMap<String, String> getQueryParameters() {
+            return queryParams;
+        }
+
+        @Override
+        public MultivaluedMap<String, String> getQueryParameters(boolean decode) {
+            return getQueryParameters();
+        }
+
+        @Override
+        public List<String> getMatchedURIs() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<String> getMatchedURIs(boolean decode) {
+            return getMatchedURIs();
+        }
+
+        @Override
+        public List<Object> getMatchedResources() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public URI resolve(URI uri) {
+            return uri;
+        }
+
+        @Override
+        public URI relativize(URI uri) {
+            return uri;
+        }
+    }
 }
index 7c4a7d508423b38573b8ef026e7cce55c5b52e74..4abc492dff87e6bdadcd89e000507358faab2115 100644 (file)
@@ -106,7 +106,7 @@ import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveSchemaContext;
+import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -383,9 +383,7 @@ public class RestconfImpl implements RestconfService {
         neededModules.forEach(imp -> fakeModules.add(new FakeImportedModule(imp)));
         fakeModules.add(new FakeRestconfModule(neededModules, fakeCont));
 
-        // FIXME: use a separate sublcass of AbstractSchemaContext
-        final SchemaContext fakeSchemaCtx =
-                EffectiveSchemaContext.resolveSchemaContext(ImmutableSet.copyOf(fakeModules));
+        final SchemaContext fakeSchemaCtx = SimpleSchemaContext.forModules(ImmutableSet.copyOf(fakeModules));
         final InstanceIdentifierContext<ContainerSchemaNode> instanceIdentifierContext =
                 new InstanceIdentifierContext<>(null, fakeCont, mountPoint, fakeSchemaCtx);
         return new NormalizedNodeContext(instanceIdentifierContext, containerBuilder.build());
@@ -1264,7 +1262,7 @@ public class RestconfImpl implements RestconfService {
      * @return {@link URI} of location
      */
     private URI dataSubs(final String identifier, final UriInfo uriInfo, final Instant start, final Instant stop,
-            final String filter, boolean leafNodesOnly) {
+            final String filter, final boolean leafNodesOnly) {
         final String streamName = Notificator.createStreamNameFromUri(identifier);
         if (Strings.isNullOrEmpty(streamName)) {
             throw new RestconfDocumentedException("Stream name is empty.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
index 8a2ab0511e9ace0962796223190e3628f5b34ab8..832aaf24814bb8d16e27a77c9638ddd825116a1b 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.netconf.sal.streams.listeners;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
 import java.io.IOException;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
-import org.json.JSONObject;
-import org.json.XML;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
@@ -117,8 +118,13 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements DOMData
     private void prepareAndPostData(final String xml) {
         final Event event = new Event(EventType.NOTIFY);
         if (this.outputType.equals(NotificationOutputType.JSON)) {
-            final JSONObject jsonObject = XML.toJSONObject(xml);
-            event.setData(jsonObject.toString());
+            try {
+                JsonNode node = new XmlMapper().readTree(xml.getBytes());
+                event.setData(node.toString());
+            } catch (IOException e) {
+                LOG.error("Error parsing XML {}", xml, e);
+                Throwables.propagate(e);
+            }
         } else {
             event.setData(xml);
         }
index cdf1ff26451cb70e68b684789f4975d95e1ed663..a5999ddfacc1aefef9b1e9f955988a40d4c80924 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.netconf.sal.streams.listeners;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.io.Writer;
@@ -16,7 +18,6 @@ import java.time.Instant;
 import java.util.Collection;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
-import org.json.JSONObject;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
@@ -137,9 +138,10 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
      */
     @VisibleForTesting
     String prepareJson() {
-        final JSONObject json = new JSONObject();
-        json.put("ietf-restconf:notification",
-                new JSONObject(writeBodyToString()).put("event-time", ListenerAdapter.toRFC3339(Instant.now())));
+        JsonParser jsonParser = new JsonParser();
+        JsonObject json = new JsonObject();
+        json.add("ietf-restconf:notification", jsonParser.parse(writeBodyToString()));
+        json.addProperty("event-time", ListenerAdapter.toRFC3339(Instant.now()));
         return json.toString();
     }
 
index 62fc11e92bb0be7c5ad86d151be35057d0b79294..5053db01ad90d60707d655ecf2d75d7a42d39331 100644 (file)
@@ -35,7 +35,7 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveSchemaContext;
+import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -129,9 +129,7 @@ public class RestconfOperationsServiceImpl implements RestconfOperationsService
         neededModules.forEach(imp -> fakeModules.add(new FakeImportedModule(imp)));
         fakeModules.add(new FakeRestconfModule(neededModules, fakeCont));
 
-        // FIXME: use a separate sublcass of AbstractSchemaContext
-        final SchemaContext fakeSchemaCtx =
-                EffectiveSchemaContext.resolveSchemaContext(ImmutableSet.copyOf(fakeModules));
+        final SchemaContext fakeSchemaCtx = SimpleSchemaContext.forModules(ImmutableSet.copyOf(fakeModules));
         final InstanceIdentifierContext<ContainerSchemaNode> instanceIdentifierContext =
                 new InstanceIdentifierContext<>(null, fakeCont, mountPoint, fakeSchemaCtx);
         return new NormalizedNodeContext(instanceIdentifierContext, containerBuilder.build());
index f0b797c0257f0662ab9c737c357cd3c58280c2f0..89d5412ef55d5e03f0d804d7bcfeeb658b657d08 100644 (file)
@@ -29,13 +29,9 @@ import com.google.common.util.concurrent.Futures;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriInfo;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -140,11 +136,7 @@ public class JSONRestconfServiceImplTest {
         when(result.getStatus()).thenReturn(Status.OK);
         final String uriPath = "ietf-interfaces:interfaces/interface/eth0";
         final String payload = loadData("/parts/ietf-interfaces_interfaces.json");
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        this.service.put(uriPath, payload, uriInfo);
+        this.service.put(uriPath, payload);
 
         final ArgumentCaptor<YangInstanceIdentifier> capturedPath =
                 ArgumentCaptor.forClass(YangInstanceIdentifier.class);
@@ -178,11 +170,7 @@ public class JSONRestconfServiceImplTest {
         final String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1";
         final String payload = loadData("/full-versions/testCont1Data.json");
 
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        this.service.put(uriPath, payload, uriInfo);
+        this.service.put(uriPath, payload);
 
         final ArgumentCaptor<YangInstanceIdentifier> capturedPath =
                 ArgumentCaptor.forClass(YangInstanceIdentifier.class);
@@ -214,11 +202,7 @@ public class JSONRestconfServiceImplTest {
         final String uriPath = "ietf-interfaces:interfaces/interface/eth0";
         final String payload = loadData("/parts/ietf-interfaces_interfaces.json");
 
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        this.service.put(uriPath, payload, uriInfo);
+        this.service.put(uriPath, payload);
     }
 
     @SuppressWarnings("rawtypes")
@@ -231,13 +215,7 @@ public class JSONRestconfServiceImplTest {
         final String uriPath = null;
         final String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
 
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        final UriBuilder uriBuilder = UriBuilder.fromPath("");
-        Mockito.when(uriInfo.getBaseUriBuilder()).thenReturn(uriBuilder);
-        this.service.post(uriPath, payload, uriInfo);
+        this.service.post(uriPath, payload);
 
         final ArgumentCaptor<YangInstanceIdentifier> capturedPath =
                 ArgumentCaptor.forClass(YangInstanceIdentifier.class);
@@ -278,13 +256,7 @@ public class JSONRestconfServiceImplTest {
         final String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont";
         final String payload = loadData("/full-versions/testCont1Data.json");
 
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        final UriBuilder uriBuilder = UriBuilder.fromPath("");
-        Mockito.when(uriInfo.getBaseUriBuilder()).thenReturn(uriBuilder);
-        this.service.post(uriPath, payload, uriInfo);
+        this.service.post(uriPath, payload);
 
         final ArgumentCaptor<YangInstanceIdentifier> capturedPath =
                 ArgumentCaptor.forClass(YangInstanceIdentifier.class);
@@ -311,15 +283,8 @@ public class JSONRestconfServiceImplTest {
         final String uriPath = null;
         final String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
 
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        final UriBuilder uriBuilder = UriBuilder.fromPath("");
-        Mockito.when(uriInfo.getBaseUriBuilder()).thenReturn(uriBuilder);
-
         try {
-            this.service.post(uriPath, payload, uriInfo);
+            this.service.post(uriPath, payload);
         } catch (final OperationFailedException e) {
             assertNotNull(e.getCause());
             throw e.getCause();
@@ -365,21 +330,13 @@ public class JSONRestconfServiceImplTest {
         doReturn(null).when(brokerFacade).readConfigurationData(notNull(YangInstanceIdentifier.class),
                 Mockito.anyString());
         final String uriPath = "ietf-interfaces:interfaces";
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        this.service.get(uriPath, LogicalDatastoreType.CONFIGURATION, uriInfo);
+        this.service.get(uriPath, LogicalDatastoreType.CONFIGURATION);
     }
 
     @Test(expected = OperationFailedException.class)
     public void testGetFailure() throws Exception {
         final String invalidUriPath = "/ietf-interfaces:interfaces/invalid";
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        this.service.get(invalidUriPath, LogicalDatastoreType.CONFIGURATION, uriInfo);
+        this.service.get(invalidUriPath, LogicalDatastoreType.CONFIGURATION);
     }
 
     @SuppressWarnings("rawtypes")
@@ -474,14 +431,8 @@ public class JSONRestconfServiceImplTest {
         }
 
         final String uriPath = "/ietf-interfaces:interfaces/interface/eth0";
-        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
-        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
-        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
-        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
-        Mockito.when(uriInfo.getQueryParameters(false)).thenReturn(value);
-        Mockito.when(value.getFirst("depth")).thenReturn("");
-
-        final Optional<String> optionalResp = this.service.get(uriPath, datastoreType, uriInfo);
+
+        final Optional<String> optionalResp = this.service.get(uriPath, datastoreType);
         assertEquals("Response present", true, optionalResp.isPresent());
         final String jsonResp = optionalResp.get();
 
index fe8e84b324d5607d2b3505d87fd14dcd4a3ba233..990bfa2b9ddd616986b018ae08b1030e428d2a8b 100644 (file)
@@ -12,7 +12,7 @@
     <parent>
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent</artifactId>
-        <version>1.8.0-Carbon</version>
+        <version>1.9.0</version>
         <relativePath/>
     </parent>
 
index 1bb69be1a3a6c0775fd275eae4c73fcad5620e4f..262448a461b9d6757c2b78096830f063e71563eb 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.odlparent</groupId>
     <artifactId>bundle-parent</artifactId>
-    <version>1.8.0-Carbon</version>
+    <version>1.9.0</version>
     <relativePath/>
   </parent>
 
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-databind</artifactId>
     </dependency>
-    <dependency>
-      <groupId>com.fasterxml.jackson.datatype</groupId>
-      <artifactId>jackson-datatype-json-org</artifactId>
-    </dependency>
 
     <dependency>
       <groupId>com.google.guava</groupId>
       <artifactId>jaxrs-api</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>org.json</groupId>
-      <artifactId>json</artifactId>
-    </dependency>
-
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-core-api</artifactId>
               org.apache.shiro.web.env
             </Import-Package>
             <Export-Package>
-              com.fasterxml.jackson.datatype.*,
-              org.json
+              com.fasterxml.jackson.datatype.*
             </Export-Package>
             <Bundle-Activator>org.opendaylight.netconf.sal.rest.doc.DocProvider</Bundle-Activator>
             <Web-ContextPath>/apidoc</Web-ContextPath>
index 2f22fa9a426bc5db11d82f021d0523f99f4a9c68..f5002e03714f36dce76c32778202972b3a2965b8 100644 (file)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.netconf.sal.rest.doc.impl;
 
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
 import java.util.Map.Entry;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
-import org.json.JSONWriter;
 import org.opendaylight.netconf.sal.rest.doc.api.ApiDocService;
 import org.opendaylight.netconf.sal.rest.doc.mountpoints.MountPointSwagger;
 import org.opendaylight.netconf.sal.rest.doc.swagger.ApiDeclaration;
@@ -86,16 +87,16 @@ public class ApiDocServiceImpl implements ApiDocService {
     public synchronized Response getListOfMounts(final UriInfo uriInfo) {
         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try (OutputStreamWriter streamWriter = new OutputStreamWriter(baos, StandardCharsets.UTF_8)) {
-            final JSONWriter writer = new JSONWriter(streamWriter);
-            writer.array();
+            JsonGenerator writer = new JsonFactory().createGenerator(streamWriter);
+            writer.writeStartArray();
             for (final Entry<String, Long> entry : MountPointSwagger.getInstance().getInstanceIdentifiers()
                     .entrySet()) {
-                writer.object();
-                writer.key("instance").value(entry.getKey());
-                writer.key("id").value(entry.getValue());
-                writer.endObject();
+                writer.writeStartObject();
+                writer.writeObjectField("instance", entry.getKey());
+                writer.writeObjectField("id", entry.getValue());
+                writer.writeEndObject();
             }
-            writer.endArray();
+            writer.writeEndArray();
         } catch (final Exception e) {
             return Response.status(500).entity(e.getMessage()).build();
         }
index 7ffc4c58169500bbbffe35eab9678adc4013e1dd..91612c1eac0354fa9bc42d1de953e1eeb243e82b 100644 (file)
@@ -11,7 +11,7 @@ import static org.opendaylight.netconf.sal.rest.doc.util.RestDocgenUtil.resolveP
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.base.Preconditions;
 import java.io.IOException;
 import java.net.URI;
@@ -28,8 +28,6 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 import javax.ws.rs.core.UriInfo;
-import org.json.JSONException;
-import org.json.JSONObject;
 import org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder;
 import org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder.Delete;
 import org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder.Get;
@@ -72,7 +70,6 @@ public class BaseYangSwaggerGenerator {
     private static boolean newDraft;
 
     protected BaseYangSwaggerGenerator() {
-        this.mapper.registerModule(new JsonOrgModule());
         this.mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
     }
 
@@ -231,7 +228,7 @@ public class BaseYangSwaggerGenerator {
 
         if (!apis.isEmpty()) {
             doc.setApis(apis);
-            JSONObject models = null;
+            ObjectNode models = null;
 
             try {
                 models = this.jsonConverter.convertToJsonSchema(module, schemaContext);
@@ -239,7 +236,7 @@ public class BaseYangSwaggerGenerator {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug(this.mapper.writeValueAsString(doc));
                 }
-            } catch (IOException | JSONException e) {
+            } catch (IOException e) {
                 LOG.error("Exception occured in ModelGenerator", e);
             }
 
index f4ba8d41899199b2b82055e311a9d72017374006..5149200a091064f75b2f169527c3ee053c1edbd6 100644 (file)
@@ -9,17 +9,18 @@ package org.opendaylight.netconf.sal.rest.doc.impl;
 
 import static org.opendaylight.netconf.sal.rest.doc.util.RestDocgenUtil.resolveNodesName;
 
-import com.google.common.base.Optional;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.NullNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.node.TextNode;
 import com.mifmif.common.regex.Generex;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
 import javax.annotation.concurrent.NotThreadSafe;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
 import org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder;
 import org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder.Post;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -103,14 +104,13 @@ public class ModelGenerator {
      *
      * @param module        - Yang module to be converted
      * @param schemaContext - SchemaContext of all Yang files used by Api Doc
-     * @return JSONObject containing data used for creating examples and models in Api Doc
+     * @return ObjectNode containing data used for creating examples and models in Api Doc
      * @throws IOException if I/O operation fails
-     * @throws JSONException when things are amiss
      */
-    public JSONObject convertToJsonSchema(final Module module,
-                                          final SchemaContext schemaContext) throws IOException, JSONException {
-        final JSONObject models = new JSONObject();
-        models.put(UNIQUE_EMPTY_IDENTIFIER, new JSONObject());
+    public ObjectNode convertToJsonSchema(final Module module,
+                                          final SchemaContext schemaContext) throws IOException {
+        final ObjectNode models = JsonNodeFactory.instance.objectNode();
+        models.put(UNIQUE_EMPTY_IDENTIFIER, NullNode.getInstance());
         topLevelModule = module;
         processModules(module, models, schemaContext);
         processContainersAndLists(module, models, schemaContext);
@@ -119,14 +119,14 @@ public class ModelGenerator {
         return models;
     }
 
-    private void processModules(final Module module, final JSONObject models,
-                                final SchemaContext schemaContext) throws JSONException {
+    private void processModules(final Module module, final ObjectNode models,
+                                final SchemaContext schemaContext) {
         createConcreteModelForPost(models, module.getName() + BaseYangSwaggerGenerator.MODULE_NAME_SUFFIX,
                 createPropertiesForPost(module, schemaContext, module.getName()));
     }
 
-    private void processContainersAndLists(final Module module, final JSONObject models,
-                                           final SchemaContext schemaContext) throws IOException, JSONException {
+    private void processContainersAndLists(final Module module, final ObjectNode models,
+                                           final SchemaContext schemaContext) throws IOException {
         final String moduleName = module.getName();
 
         for (final DataSchemaNode childNode : module.getChildNodes()) {
@@ -144,22 +144,20 @@ public class ModelGenerator {
      * for each RPC that contains input & output elements.
      *
      * @param module module
-     * @throws JSONException when things are amiss
      * @throws IOException if I/O operation fails
      */
-    private void processRPCs(final Module module, final JSONObject models,
-                             final SchemaContext schemaContext) throws JSONException,
-            IOException {
+    private void processRPCs(final Module module, final ObjectNode models,
+                             final SchemaContext schemaContext) throws IOException {
         final Set<RpcDefinition> rpcs = module.getRpcs();
         final String moduleName = module.getName();
         for (final RpcDefinition rpc : rpcs) {
             final ContainerSchemaNode input = rpc.getInput();
             if (!input.getChildNodes().isEmpty()) {
-                final JSONObject properties =
+                final ObjectNode properties =
                         processChildren(input.getChildNodes(), moduleName, models, true, schemaContext);
 
                 final String filename = "(" + rpc.getQName().getLocalName() + ")input";
-                final JSONObject childSchema = getSchemaTemplate();
+                final ObjectNode childSchema = getSchemaTemplate();
                 childSchema.put(TYPE_KEY, OBJECT_TYPE);
                 childSchema.put(PROPERTIES_KEY, properties);
                 childSchema.put(ID_KEY, filename);
@@ -170,10 +168,10 @@ public class ModelGenerator {
 
             final ContainerSchemaNode output = rpc.getOutput();
             if (!output.getChildNodes().isEmpty()) {
-                final JSONObject properties =
+                final ObjectNode properties =
                         processChildren(output.getChildNodes(), moduleName, models, true, schemaContext);
                 final String filename = "(" + rpc.getQName().getLocalName() + ")output";
-                final JSONObject childSchema = getSchemaTemplate();
+                final ObjectNode childSchema = getSchemaTemplate();
                 childSchema.put(TYPE_KEY, OBJECT_TYPE);
                 childSchema.put(PROPERTIES_KEY, properties);
                 childSchema.put(ID_KEY, filename);
@@ -184,18 +182,18 @@ public class ModelGenerator {
         }
     }
 
-    private JSONObject processTopData(final String filename, final JSONObject models, final SchemaNode schemaNode) {
-        final JSONObject items = new JSONObject();
+    private ObjectNode processTopData(final String filename, final ObjectNode models, final SchemaNode schemaNode) {
+        final ObjectNode items = JsonNodeFactory.instance.objectNode();
 
         items.put(REF_KEY, filename);
-        final JSONObject dataNodeProperties = new JSONObject();
+        final ObjectNode dataNodeProperties = JsonNodeFactory.instance.objectNode();
         dataNodeProperties.put(TYPE_KEY, schemaNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE);
         dataNodeProperties.put(ITEMS_KEY, items);
 
-        dataNodeProperties.putOpt(DESCRIPTION_KEY, schemaNode.getDescription());
-        final JSONObject properties = new JSONObject();
+        putIfNonNull(dataNodeProperties, DESCRIPTION_KEY, schemaNode.getDescription());
+        final ObjectNode properties = JsonNodeFactory.instance.objectNode();
         properties.put(topLevelModule.getName() + ":" + schemaNode.getQName().getLocalName(), dataNodeProperties);
-        final JSONObject finalChildSchema = getSchemaTemplate();
+        final ObjectNode finalChildSchema = getSchemaTemplate();
         finalChildSchema.put(TYPE_KEY, OBJECT_TYPE);
         finalChildSchema.put(PROPERTIES_KEY, properties);
         finalChildSchema.put(ID_KEY, filename + OperationBuilder.TOP);
@@ -208,42 +206,42 @@ public class ModelGenerator {
      * Processes the 'identity' statement in a yang model and maps it to a 'model' in the Swagger JSON spec.
      *
      * @param module The module from which the identity stmt will be processed
-     * @param models The JSONObject in which the parsed identity will be put as a 'model' obj
+     * @param models The ObjectNode in which the parsed identity will be put as a 'model' obj
      */
-    private static void processIdentities(final Module module, final JSONObject models) throws JSONException {
+    private static void processIdentities(final Module module, final ObjectNode models) {
 
         final String moduleName = module.getName();
         final Set<IdentitySchemaNode> idNodes = module.getIdentities();
         LOG.debug("Processing Identities for module {} . Found {} identity statements", moduleName, idNodes.size());
 
         for (final IdentitySchemaNode idNode : idNodes) {
-            final JSONObject identityObj = new JSONObject();
+            final ObjectNode identityObj = JsonNodeFactory.instance.objectNode();
             final String identityName = idNode.getQName().getLocalName();
             LOG.debug("Processing Identity: {}", identityName);
 
             identityObj.put(ID_KEY, identityName);
-            identityObj.put(DESCRIPTION_KEY, idNode.getDescription());
+            putIfNonNull(identityObj, DESCRIPTION_KEY, idNode.getDescription());
 
-            final JSONObject props = new JSONObject();
+            final ObjectNode props = JsonNodeFactory.instance.objectNode();
             final IdentitySchemaNode baseId = idNode.getBaseIdentity();
 
             if (baseId == null) {
-                /**
+                /*
                  * This is a base identity. So lets see if it has sub types. If it does, then add them to the model
                  * definition.
                  */
                 final Set<IdentitySchemaNode> derivedIds = idNode.getDerivedIdentities();
 
                 if (derivedIds != null) {
-                    final JSONArray subTypes = new JSONArray();
+                    final ArrayNode subTypes = new ArrayNode(JsonNodeFactory.instance);
                     for (final IdentitySchemaNode derivedId : derivedIds) {
-                        subTypes.put(derivedId.getQName().getLocalName());
+                        subTypes.add(derivedId.getQName().getLocalName());
                     }
                     identityObj.put(SUB_TYPES_KEY, subTypes);
 
                 }
             } else {
-                /**
+                /*
                  * This is a derived entity. Add it's base type & move on.
                  */
                 props.put(TYPE_KEY, baseId.getQName().getLocalName());
@@ -255,18 +253,18 @@ public class ModelGenerator {
         }
     }
 
-    private JSONObject processDataNodeContainer(
-            final DataNodeContainer dataNode, final String parentName, final JSONObject models, final boolean isConfig,
-            final SchemaContext schemaContext) throws JSONException, IOException {
+    private ObjectNode processDataNodeContainer(
+            final DataNodeContainer dataNode, final String parentName, final ObjectNode models, final boolean isConfig,
+            final SchemaContext schemaContext) throws IOException {
         if (dataNode instanceof ListSchemaNode || dataNode instanceof ContainerSchemaNode) {
             final Iterable<DataSchemaNode> containerChildren = dataNode.getChildNodes();
             final String localName = ((SchemaNode) dataNode).getQName().getLocalName();
-            final JSONObject properties =
+            final ObjectNode properties =
                     processChildren(containerChildren, parentName + "/" + localName, models, isConfig, schemaContext);
             final String nodeName = parentName + (isConfig ? OperationBuilder.CONFIG : OperationBuilder.OPERATIONAL)
                     + localName;
 
-            final JSONObject childSchema = getSchemaTemplate();
+            final ObjectNode childSchema = getSchemaTemplate();
             childSchema.put(TYPE_KEY, OBJECT_TYPE);
             childSchema.put(PROPERTIES_KEY, properties);
 
@@ -283,30 +281,29 @@ public class ModelGenerator {
         return null;
     }
 
-    private static void createConcreteModelForPost(final JSONObject models, final String localName,
-                                                   final JSONObject properties) throws JSONException {
+    private static void createConcreteModelForPost(final ObjectNode models, final String localName,
+                                                   final JsonNode properties) {
         final String nodePostName = OperationBuilder.CONFIG + localName + Post.METHOD_NAME;
-        final JSONObject postSchema = getSchemaTemplate();
+        final ObjectNode postSchema = getSchemaTemplate();
         postSchema.put(TYPE_KEY, OBJECT_TYPE);
         postSchema.put(ID_KEY, nodePostName);
         postSchema.put(PROPERTIES_KEY, properties);
         models.put(nodePostName, postSchema);
     }
 
-    private JSONObject createPropertiesForPost(final DataNodeContainer dataNodeContainer,
-                                               final SchemaContext schemaContext, final String parentName)
-            throws JSONException {
-        final JSONObject properties = new JSONObject();
+    private JsonNode createPropertiesForPost(final DataNodeContainer dataNodeContainer,
+                                               final SchemaContext schemaContext, final String parentName) {
+        final ObjectNode properties = JsonNodeFactory.instance.objectNode();
         for (final DataSchemaNode childNode : dataNodeContainer.getChildNodes()) {
             if (childNode instanceof ListSchemaNode || childNode instanceof ContainerSchemaNode) {
-                final JSONObject items = new JSONObject();
+                final ObjectNode items = JsonNodeFactory.instance.objectNode();
                 items.put(REF_KEY, parentName + "(config)" + childNode.getQName().getLocalName());
-                final JSONObject property = new JSONObject();
+                final ObjectNode property = JsonNodeFactory.instance.objectNode();
                 property.put(TYPE_KEY, childNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE);
                 property.put(ITEMS_KEY, items);
                 properties.put(childNode.getQName().getLocalName(), property);
             } else if (childNode instanceof LeafSchemaNode) {
-                final JSONObject property = processLeafNode((LeafSchemaNode) childNode, schemaContext);
+                final ObjectNode property = processLeafNode((LeafSchemaNode) childNode, schemaContext);
                 properties.put(childNode.getQName().getLocalName(), property);
             }
         }
@@ -316,15 +313,14 @@ public class ModelGenerator {
     /**
      * Processes the nodes.
      */
-    private JSONObject processChildren(
-            final Iterable<DataSchemaNode> nodes, final String parentName, final JSONObject models,
-            final boolean isConfig, final SchemaContext schemaContext)
-            throws JSONException, IOException {
-        final JSONObject properties = new JSONObject();
+    private ObjectNode processChildren(
+            final Iterable<DataSchemaNode> nodes, final String parentName, final ObjectNode models,
+            final boolean isConfig, final SchemaContext schemaContext) throws IOException {
+        final ObjectNode properties = JsonNodeFactory.instance.objectNode();
         for (final DataSchemaNode node : nodes) {
             if (node.isConfiguration() == isConfig) {
                 final String name = resolveNodesName(node, topLevelModule, schemaContext);
-                final JSONObject property;
+                final ObjectNode property;
                 if (node instanceof LeafSchemaNode) {
                     property = processLeafNode((LeafSchemaNode) node, schemaContext);
 
@@ -352,22 +348,22 @@ public class ModelGenerator {
                 } else {
                     throw new IllegalArgumentException("Unknown DataSchemaNode type: " + node.getClass());
                 }
-                property.putOpt(DESCRIPTION_KEY, node.getDescription());
+                putIfNonNull(property, DESCRIPTION_KEY, node.getDescription());
                 properties.put(topLevelModule.getName() + ":" + name, property);
             }
         }
         return properties;
     }
 
-    private JSONObject processLeafListNode(final LeafListSchemaNode listNode,
-                                           final SchemaContext schemaContext) throws JSONException {
-        final JSONObject props = new JSONObject();
+    private ObjectNode processLeafListNode(final LeafListSchemaNode listNode,
+                                           final SchemaContext schemaContext) {
+        final ObjectNode props = JsonNodeFactory.instance.objectNode();
         props.put(TYPE_KEY, ARRAY_TYPE);
 
-        final JSONObject itemsVal = new JSONObject();
+        final ObjectNode itemsVal = JsonNodeFactory.instance.objectNode();
         final ConstraintDefinition constraints = listNode.getConstraints();
-        final Optional<Integer> maxOptional = Optional.fromNullable(constraints.getMaxElements());
-        if (maxOptional.or(2) >= 2) {
+        int max = constraints.getMaxElements() == null ? 2 : constraints.getMaxElements();
+        if (max >= 2) {
             processTypeDef(listNode.getType(), listNode, itemsVal, schemaContext);
             processTypeDef(listNode.getType(), listNode, itemsVal, schemaContext);
         } else {
@@ -382,12 +378,12 @@ public class ModelGenerator {
     }
 
     private void processChoiceNode(
-            final Iterable<DataSchemaNode> nodes, final String moduleName, final JSONObject models,
-            final SchemaContext schemaContext, final boolean isConfig, final JSONObject properties)
-            throws JSONException, IOException {
+            final Iterable<DataSchemaNode> nodes, final String moduleName, final ObjectNode models,
+            final SchemaContext schemaContext, final boolean isConfig, final ObjectNode properties)
+           throws IOException {
         for (final DataSchemaNode node : nodes) {
             final String name = resolveNodesName(node, topLevelModule, schemaContext);
-            final JSONObject property;
+            final ObjectNode property;
 
             if (node instanceof LeafSchemaNode) {
                 property = processLeafNode((LeafSchemaNode) node, schemaContext);
@@ -417,13 +413,13 @@ public class ModelGenerator {
                 throw new IllegalArgumentException("Unknown DataSchemaNode type: " + node.getClass());
             }
 
-            property.putOpt(DESCRIPTION_KEY, node.getDescription());
+            putIfNonNull(property, DESCRIPTION_KEY, node.getDescription());
             properties.put(name, property);
         }
     }
 
     private static void processConstraints(final ConstraintDefinition constraints,
-                                           final JSONObject props) throws JSONException {
+                                           final ObjectNode props) {
         final boolean isMandatory = constraints.isMandatory();
         props.put(REQUIRED_KEY, isMandatory);
 
@@ -437,23 +433,23 @@ public class ModelGenerator {
         }
     }
 
-    private JSONObject processLeafNode(final LeafSchemaNode leafNode,
-                                       final SchemaContext schemaContext) throws JSONException {
-        final JSONObject property = new JSONObject();
+    private ObjectNode processLeafNode(final LeafSchemaNode leafNode,
+                                       final SchemaContext schemaContext) {
+        final ObjectNode property = JsonNodeFactory.instance.objectNode();
 
         final String leafDescription = leafNode.getDescription();
-        property.put(DESCRIPTION_KEY, leafDescription);
+        putIfNonNull(property, DESCRIPTION_KEY, leafDescription);
         processConstraints(leafNode.getConstraints(), property);
         processTypeDef(leafNode.getType(), leafNode, property, schemaContext);
 
         return property;
     }
 
-    private static JSONObject processAnyXMLNode(final AnyXmlSchemaNode leafNode) throws JSONException {
-        final JSONObject property = new JSONObject();
+    private static ObjectNode processAnyXMLNode(final AnyXmlSchemaNode leafNode) {
+        final ObjectNode property = JsonNodeFactory.instance.objectNode();
 
         final String leafDescription = leafNode.getDescription();
-        property.put(DESCRIPTION_KEY, leafDescription);
+        putIfNonNull(property, DESCRIPTION_KEY, leafDescription);
 
         processConstraints(leafNode.getConstraints(), property);
         final String localName = leafNode.getQName().getLocalName();
@@ -463,7 +459,7 @@ public class ModelGenerator {
     }
 
     private String processTypeDef(final TypeDefinition<?> leafTypeDef, final DataSchemaNode node,
-                                  final JSONObject property, final SchemaContext schemaContext) throws JSONException {
+                                  final ObjectNode property, final SchemaContext schemaContext) {
         final String jsonType;
         if (leafTypeDef.getDefaultValue() == null) {
             if (leafTypeDef instanceof BinaryTypeDefinition) {
@@ -514,11 +510,11 @@ public class ModelGenerator {
         } else {
             jsonType = String.valueOf(leafTypeDef.getDefaultValue());
         }
-        property.putOpt(TYPE_KEY, jsonType);
+        putIfNonNull(property, TYPE_KEY, jsonType);
         return jsonType;
     }
 
-    private String processLeafRef(final DataSchemaNode node, final JSONObject property,
+    private String processLeafRef(final DataSchemaNode node, final ObjectNode property,
                                   final SchemaContext schemaContext, final TypeDefinition<?> leafTypeDef) {
         RevisionAwareXPath xpath = ((LeafrefTypeDefinition) leafTypeDef).getPathStatement();
         final SchemaNode schemaNode;
@@ -544,42 +540,41 @@ public class ModelGenerator {
                 .findModuleByNamespaceAndRevision(qualifiedName.getNamespace(), qualifiedName.getRevision());
     }
 
-    private static String processBinaryType(final JSONObject property) throws JSONException {
-        final JSONObject media = new JSONObject();
+    private static String processBinaryType(final ObjectNode property) {
+        final ObjectNode media = JsonNodeFactory.instance.objectNode();
         media.put(BINARY_ENCODING_KEY, BASE_64);
         property.put(MEDIA_KEY, media);
         return "bin1 bin2";
     }
 
     private static String processEnumType(final EnumTypeDefinition enumLeafType,
-                                          final JSONObject property) throws JSONException {
+                                          final ObjectNode property) {
         final List<EnumPair> enumPairs = enumLeafType.getValues();
-        final List<String> enumNames = new ArrayList<>();
+        ArrayNode enumNames = new ArrayNode(JsonNodeFactory.instance);
         for (final EnumPair enumPair : enumPairs) {
-            enumNames.add(enumPair.getName());
+            enumNames.add(new TextNode(enumPair.getName()));
         }
 
-        property.putOpt(ENUM, new JSONArray(enumNames));
+        property.put(ENUM, enumNames);
         return enumLeafType.getValues().iterator().next().getName();
     }
 
     private static String processBitsType(final BitsTypeDefinition bitsType,
-                                          final JSONObject property) throws JSONException {
+                                          final ObjectNode property) {
         property.put(MIN_ITEMS, 0);
         property.put(UNIQUE_ITEMS_KEY, true);
-        final List<String> enumNames = new ArrayList<>();
+        ArrayNode enumNames = new ArrayNode(JsonNodeFactory.instance);
         final List<Bit> bits = bitsType.getBits();
         for (final Bit bit : bits) {
-            enumNames.add(bit.getName());
+            enumNames.add(new TextNode(bit.getName()));
         }
-        property.put(ENUM, new JSONArray(enumNames));
+        property.put(ENUM, enumNames);
 
         return enumNames.iterator().next() + " " + enumNames.get(enumNames.size() - 1);
     }
 
     private static String processStringType(final TypeDefinition<?> stringType,
-                                            final JSONObject property, final String nodeName)
-            throws JSONException {
+                                            final ObjectNode property, final String nodeName) {
         StringTypeDefinition type = (StringTypeDefinition) stringType;
         List<LengthConstraint> lengthConstraints = ((StringTypeDefinition) stringType).getLengthConstraints();
         while (lengthConstraints.isEmpty() && type.getBaseType() != null) {
@@ -592,8 +587,8 @@ public class ModelGenerator {
         for (final LengthConstraint lengthConstraint : lengthConstraints) {
             final Number min = lengthConstraint.getMin();
             final Number max = lengthConstraint.getMax();
-            property.putOpt(MIN_LENGTH_KEY, min);
-            property.putOpt(MAX_LENGTH_KEY, max);
+            putIfNonNull(property, MIN_LENGTH_KEY, min);
+            putIfNonNull(property, MAX_LENGTH_KEY, max);
         }
         if (type.getPatternConstraints().iterator().hasNext()) {
             final PatternConstraint pattern = type.getPatternConstraints().iterator().next();
@@ -606,25 +601,46 @@ public class ModelGenerator {
         }
     }
 
-    private String processUnionType(final UnionTypeDefinition unionType, final JSONObject property,
-                                    final SchemaContext schemaContext, final DataSchemaNode node)
-            throws JSONException {
-        final List<String> unionNames = new ArrayList<>();
+    private String processUnionType(final UnionTypeDefinition unionType, final ObjectNode property,
+                                    final SchemaContext schemaContext, final DataSchemaNode node) {
+        final ArrayNode unionNames = new ArrayNode(JsonNodeFactory.instance);
         for (final TypeDefinition<?> typeDef : unionType.getTypes()) {
             unionNames.add(processTypeDef(typeDef, node, property, schemaContext));
         }
-        property.put(ENUM, new JSONArray(unionNames));
-        return unionNames.iterator().next();
+        property.put(ENUM, unionNames);
+        return unionNames.iterator().next().asText();
     }
 
     /**
      * Helper method to generate a pre-filled JSON schema object.
      */
-    private static JSONObject getSchemaTemplate() throws JSONException {
-        final JSONObject schemaJSON = new JSONObject();
+    private static ObjectNode getSchemaTemplate() {
+        final ObjectNode schemaJSON = JsonNodeFactory.instance.objectNode();
         schemaJSON.put(SCHEMA_KEY, SCHEMA_URL);
 
         return schemaJSON;
     }
 
+    private static void putIfNonNull(ObjectNode property, String key, Number number) {
+        if (key != null && number != null) {
+            if (number instanceof Double) {
+                property.put(key, (Double) number);
+            } else if (number instanceof Float) {
+                property.put(key, (Float) number);
+            } else if (number instanceof Integer) {
+                property.put(key, (Integer) number);
+            } else if (number instanceof Short) {
+                property.put(key, (Short) number);
+            } else if (number instanceof Long) {
+                property.put(key, (Long) number);
+            }
+        }
+    }
+
+    private static void putIfNonNull(ObjectNode property, String key, String value) {
+        if (key != null && value != null) {
+            property.put(key, value);
+        }
+    }
+
 }
\ No newline at end of file
index de8c5bc50163f590e8aa37dc088cb6ab59fcf23b..a8baa7774c544d7167c63a758b8a0b99c91741db 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.netconf.sal.rest.doc.jaxrs;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
@@ -26,7 +25,6 @@ public class JaxbContextResolver implements ContextResolver<ObjectMapper> {
 
     public JaxbContextResolver() {
         ctx = new ObjectMapper();
-        ctx.registerModule(new JsonOrgModule());
         ctx.getSerializationConfig().withSerializationInclusion(JsonInclude.Include.ALWAYS);
     }
 
index 3d735ac2f6898e49729cf6b7729a7052b9389593..00c6de8fe3d7818d3e5adb88fe18077843f8ab7d 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.netconf.sal.rest.doc.swagger;
 
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import java.util.List;
-import org.json.JSONObject;
 
 /**
  * Implementation of swagger spec (see <a href=
@@ -23,13 +23,13 @@ public class ApiDeclaration {
     private String resourcePath;
     private List<String> produces;
     private List<Api> apis;
-    private JSONObject models;
+    private ObjectNode models;
 
-    public JSONObject getModels() {
+    public ObjectNode getModels() {
         return models;
     }
 
-    public void setModels(JSONObject models) {
+    public void setModels(ObjectNode models) {
         this.models = models;
     }
 
@@ -86,6 +86,6 @@ public class ApiDeclaration {
     }
 
     public boolean hasModel() {
-        return (models != null && models.length() > 0);
+        return (models != null && models.size() > 0);
     }
 }
index 91cbcec2c7d3888077d4af2d28b8f18c83588946..50fe6b62254d757172a0404103c652b888e88e8c 100644 (file)
@@ -13,6 +13,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.base.Preconditions;
 import java.sql.Date;
 import java.util.Arrays;
@@ -21,8 +23,6 @@ import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
 import javax.ws.rs.core.UriInfo;
-import org.json.JSONException;
-import org.json.JSONObject;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -164,72 +164,67 @@ public class ApiDocGeneratorTest {
      * Validates whether doc {@code doc} contains concrete specified models.
      */
     private void validateSwaggerModules(final ApiDeclaration doc) {
-        final JSONObject models = doc.getModels();
+        final ObjectNode models = doc.getModels();
         assertNotNull(models);
-        try {
-            final JSONObject configLstTop = models.getJSONObject("toaster2(config)lst-TOP");
-            assertNotNull(configLstTop);
 
-            containsReferences(configLstTop, "toaster2:lst", "toaster2(config)");
+        final JsonNode configLstTop = models.get("toaster2(config)lst-TOP");
+        assertNotNull(configLstTop);
 
-            final JSONObject configLst = models.getJSONObject("toaster2(config)lst");
-            assertNotNull(configLst);
+        containsReferences(configLstTop, "toaster2:lst", "toaster2(config)");
 
-            containsReferences(configLst, "toaster2:lst1", "toaster2/lst(config)");
-            containsReferences(configLst, "toaster2:cont1", "toaster2/lst(config)");
+        final JsonNode configLst = models.get("toaster2(config)lst");
+        assertNotNull(configLst);
 
-            final JSONObject configLst1Top = models.getJSONObject("toaster2/lst(config)lst1-TOP");
-            assertNotNull(configLst1Top);
+        containsReferences(configLst, "toaster2:lst1", "toaster2/lst(config)");
+        containsReferences(configLst, "toaster2:cont1", "toaster2/lst(config)");
 
-            containsReferences(configLst1Top, "toaster2:lst1", "toaster2/lst(config)");
+        final JsonNode configLst1Top = models.get("toaster2/lst(config)lst1-TOP");
+        assertNotNull(configLst1Top);
 
-            final JSONObject configLst1 = models.getJSONObject("toaster2/lst(config)lst1");
-            assertNotNull(configLst1);
+        containsReferences(configLst1Top, "toaster2:lst1", "toaster2/lst(config)");
 
-            final JSONObject configCont1Top = models.getJSONObject("toaster2/lst(config)cont1-TOP");
-            assertNotNull(configCont1Top);
+        final JsonNode configLst1 = models.get("toaster2/lst(config)lst1");
+        assertNotNull(configLst1);
 
-            containsReferences(configCont1Top, "toaster2:cont1", "toaster2/lst(config)");
-            final JSONObject configCont1 = models.getJSONObject("toaster2/lst(config)cont1");
-            assertNotNull(configCont1);
+        final JsonNode configCont1Top = models.get("toaster2/lst(config)cont1-TOP");
+        assertNotNull(configCont1Top);
 
-            containsReferences(configCont1, "toaster2:cont11", "toaster2/lst/cont1(config)");
-            containsReferences(configCont1, "toaster2:lst11", "toaster2/lst/cont1(config)");
+        containsReferences(configCont1Top, "toaster2:cont1", "toaster2/lst(config)");
+        final JsonNode configCont1 = models.get("toaster2/lst(config)cont1");
+        assertNotNull(configCont1);
 
-            final JSONObject configCont11Top = models.getJSONObject("toaster2/lst/cont1(config)cont11-TOP");
-            assertNotNull(configCont11Top);
+        containsReferences(configCont1, "toaster2:cont11", "toaster2/lst/cont1(config)");
+        containsReferences(configCont1, "toaster2:lst11", "toaster2/lst/cont1(config)");
 
-            containsReferences(configCont11Top, "toaster2:cont11", "toaster2/lst/cont1(config)");
-            final JSONObject configCont11 = models.getJSONObject("toaster2/lst/cont1(config)cont11");
-            assertNotNull(configCont11);
+        final JsonNode configCont11Top = models.get("toaster2/lst/cont1(config)cont11-TOP");
+        assertNotNull(configCont11Top);
 
-            final JSONObject configlst11Top = models.getJSONObject("toaster2/lst/cont1(config)lst11-TOP");
-            assertNotNull(configlst11Top);
+        containsReferences(configCont11Top, "toaster2:cont11", "toaster2/lst/cont1(config)");
+        final JsonNode configCont11 = models.get("toaster2/lst/cont1(config)cont11");
+        assertNotNull(configCont11);
 
-            containsReferences(configlst11Top, "toaster2:lst11", "toaster2/lst/cont1(config)");
-            final JSONObject configLst11 = models.getJSONObject("toaster2/lst/cont1(config)lst11");
-            assertNotNull(configLst11);
-        } catch (final JSONException e) {
-            fail("JSONException wasn't expected");
-        }
+        final JsonNode configlst11Top = models.get("toaster2/lst/cont1(config)lst11-TOP");
+        assertNotNull(configlst11Top);
 
+        containsReferences(configlst11Top, "toaster2:lst11", "toaster2/lst/cont1(config)");
+        final JsonNode configLst11 = models.get("toaster2/lst/cont1(config)lst11");
+        assertNotNull(configLst11);
     }
 
     /**
      * Checks whether object {@code mainObject} contains in properties/items key $ref with concrete value.
      */
-    private void containsReferences(final JSONObject mainObject, final String childObject, final String prefix)
-            throws JSONException {
-        final JSONObject properties = mainObject.getJSONObject("properties");
+    private void containsReferences(final JsonNode mainObject, final String childObject, final String prefix) {
+        final JsonNode properties = mainObject.get("properties");
         assertNotNull(properties);
 
-        final JSONObject nodeInProperties = properties.getJSONObject(childObject);
+        final JsonNode nodeInProperties = properties.get(childObject);
         assertNotNull(nodeInProperties);
 
-        final JSONObject itemsInNodeInProperties = nodeInProperties.getJSONObject("items");
+        final JsonNode itemsInNodeInProperties = nodeInProperties.get("items");
         assertNotNull(itemsInNodeInProperties);
 
-        final String itemRef = itemsInNodeInProperties.getString("$ref");
+        final String itemRef = itemsInNodeInProperties.get("$ref").asText();
         assertEquals(prefix + childObject.split(":")[1], itemRef);
     }
 
@@ -246,7 +241,7 @@ public class ApiDocGeneratorTest {
 
                 // testing bugs.opendaylight.org bug 1290. UnionType model type.
                 final String jsonString = doc.getModels().toString();
-                assertTrue(jsonString.contains("testUnion\":{\"type\":\"-2147483648\",\"required\":false,"
+                assertTrue(jsonString.contains("testUnion\":{\"required\":false,\"type\":\"-2147483648\","
                         + "\"enum\":[\"-2147483648\",\"Some testUnion\"]}"));
             }
         }
@@ -263,13 +258,13 @@ public class ApiDocGeneratorTest {
                         this.schemaContext);
                 assertNotNull(doc);
 
-                final JSONObject models = doc.getModels();
-                final JSONObject inputTop = models.getJSONObject("(make-toast)input-TOP");
+                final ObjectNode models = doc.getModels();
+                final JsonNode inputTop = models.get("(make-toast)input-TOP");
                 final String testString =
                         "{\"toaster:input\":{\"type\":\"object\",\"items\":{\"$ref\":\"(make-toast)input\"}}}";
-                assertEquals(testString, inputTop.getJSONObject("properties").toString());
-                final JSONObject input = models.getJSONObject("(make-toast)input");
-                final JSONObject properties = input.getJSONObject("properties");
+                assertEquals(testString, inputTop.get("properties").toString());
+                final JsonNode input = models.get("(make-toast)input");
+                final JsonNode properties = input.get("properties");
                 assertTrue(properties.has("toaster:toasterDoneness"));
                 assertTrue(properties.has("toaster:toasterToastType"));
             }
@@ -322,7 +317,7 @@ public class ApiDocGeneratorTest {
 
         // TODO: we should really do some more validation of the
         // documentation...
-        /**
+        /*
          * Missing validation: Explicit validation of URLs, and their methods Input / output models.
          */
     }
@@ -355,28 +350,24 @@ public class ApiDocGeneratorTest {
     }
 
     private void validateTosterDocContainsModulePrefixes(final ApiDeclaration doc) {
-        final JSONObject topLevelJson = doc.getModels();
-        try {
-            final JSONObject configToaster = topLevelJson.getJSONObject("toaster2(config)toaster");
-            assertNotNull("(config)toaster JSON object missing", configToaster);
-            // without module prefix
-            containsProperties(configToaster, "toaster2:toasterSlot");
-
-            final JSONObject toasterSlot = topLevelJson.getJSONObject("toaster2/toaster(config)toasterSlot");
-            assertNotNull("(config)toasterSlot JSON object missing", toasterSlot);
-            // with module prefix
-            containsProperties(toasterSlot, "toaster2:toaster-augmented:slotInfo");
-
-        } catch (final JSONException e) {
-            fail("Json exception while reading JSON object. Original message " + e.getMessage());
-        }
+        final ObjectNode topLevelJson = doc.getModels();
+
+        final JsonNode configToaster = topLevelJson.get("toaster2(config)toaster");
+        assertNotNull("(config)toaster JSON object missing", configToaster);
+        // without module prefix
+        containsProperties(configToaster, "toaster2:toasterSlot");
+
+        final JsonNode toasterSlot = topLevelJson.get("toaster2/toaster(config)toasterSlot");
+        assertNotNull("(config)toasterSlot JSON object missing", toasterSlot);
+        // with module prefix
+        containsProperties(toasterSlot, "toaster2:toaster-augmented:slotInfo");
     }
 
-    private void containsProperties(final JSONObject jsonObject, final String... properties) throws JSONException {
+    private void containsProperties(final JsonNode jsonObject, final String... properties) {
         for (final String property : properties) {
-            final JSONObject propertiesObject = jsonObject.getJSONObject("properties");
+            final JsonNode propertiesObject = jsonObject.get("properties");
             assertNotNull("Properties object missing in ", propertiesObject);
-            final JSONObject concretePropertyObject = propertiesObject.getJSONObject(property);
+            final JsonNode concretePropertyObject = propertiesObject.get(property);
             assertNotNull(property + " is missing", concretePropertyObject);
         }
     }
index 3adc8569837f3638c5a97cb422899d44d6000daa..a8196dac47d562035afaa33cfa15d626e9e8c122 100644 (file)
@@ -12,7 +12,6 @@ import static org.mockito.Mockito.when;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.net.URI;
@@ -65,7 +64,6 @@ public class DocGenTestHelper {
     public void setUp() throws Exception {
         this.modules = loadModules("/yang");
         this.mapper = new ObjectMapper();
-        this.mapper.registerModule(new JsonOrgModule());
         this.mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
     }
 
index b4ab8f4f5620477c4181f610e07c82b83959a863..58478425b9d4866edea4462a897ddca078e4abf4 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.controller.sal.rest.doc.impl;
 
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.base.Preconditions;
 import java.sql.Date;
-import org.json.JSONObject;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -45,7 +45,7 @@ public class ModelGeneratorTest {
             if (m.getQNameModule().getNamespace().toString().equals(NAMESPACE)
                     && m.getQNameModule().getRevision().equals(REVISION)) {
 
-                final JSONObject jsonObject = generator.convertToJsonSchema(m, this.schemaContext);
+                final ObjectNode jsonObject = generator.convertToJsonSchema(m, this.schemaContext);
                 Assert.assertNotNull(jsonObject);
             }
         }