Quickfix: Remove deprecated providers from Restconf Application 28/16028/9
authorVaclav Demcak <vdemcak@cisco.com>
Fri, 6 Mar 2015 13:36:50 +0000 (14:36 +0100)
committerVaclav Demcak <vdemcak@cisco.com>
Mon, 9 Mar 2015 14:42:25 +0000 (15:42 +0100)
Jersey 1.17 has problem with multiple Entity providers,
which consumes same content-type and produces different
Entity class. In wiring phase it does not report any problems,
but in runtime it may select incorrect one, which
will result in IllegalArgumentException, which is not
reported.

So in order to unblock most of functionality, legacy
providers are disabled.

This will fix data-store access, but without
subsequent patches RPCs are not usable.

Change-Id: I860e162232d887d13629504421076495a50a075b
Signed-off-by: Vaclav Demcak <vdemcak@cisco.com>
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfApplication.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java

index 9ab8fa8..52cd96b 100644 (file)
@@ -47,10 +47,10 @@ public class RestconfApplication extends Application {
         singletons.add(brokerFacade);
         singletons.add(schemaRetrieval);
         singletons.add(new RestconfCompositeWrapper(StatisticsRestconfServiceWrapper.getInstance(), schemaRetrieval));
-        singletons.add(StructuredDataToXmlProvider.INSTANCE);
-        singletons.add(StructuredDataToJsonProvider.INSTANCE);
-        singletons.add(JsonToCompositeNodeProvider.INSTANCE);
-        singletons.add(XmlToCompositeNodeProvider.INSTANCE);
+//        singletons.add(StructuredDataToXmlProvider.INSTANCE);
+//        singletons.add(StructuredDataToJsonProvider.INSTANCE);
+//        singletons.add(JsonToCompositeNodeProvider.INSTANCE);
+//        singletons.add(XmlToCompositeNodeProvider.INSTANCE);
         return singletons;
     }
 
index a0b0515..4f124f5 100644 (file)
@@ -501,7 +501,7 @@ public class ControllerContext implements SchemaContextListener {
         }
 
         if (strings.isEmpty()) {
-            return new InstanceIdentifierContext(builder.toInstance(), ((DataSchemaNode) parentNode), mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : globalSchema);
+            return createContext(builder.toInstance(), ((DataSchemaNode) parentNode), mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : globalSchema);
         }
 
         final String head = strings.iterator().next();
@@ -671,7 +671,14 @@ public class ControllerContext implements SchemaContextListener {
                     returnJustMountPoint);
         }
 
-        return new InstanceIdentifierContext(builder.toInstance(), targetNode, mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : globalSchema);
+        return createContext(builder.build(), targetNode, mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : globalSchema);
+    }
+
+    private InstanceIdentifierContext createContext(final YangInstanceIdentifier instance, final DataSchemaNode dataSchemaNode,
+            final DOMMountPoint mountPoint, final SchemaContext schemaContext) {
+
+        final YangInstanceIdentifier instanceIdentifier = new DataNormalizer(schemaContext).toNormalized(instance);
+        return new InstanceIdentifierContext(instanceIdentifier, dataSchemaNode, mountPoint,schemaContext);
     }
 
     public static DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container, final String name,
index 82ac862..74c2d90 100644 (file)
@@ -872,13 +872,10 @@ public class RestconfImpl implements RestconfService {
         final InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier(identifier);
         final DOMMountPoint mountPoint = iiWithData.getMountPoint();
         NormalizedNode<?, ?> data = null;
-        YangInstanceIdentifier normalizedII;
+        final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
         if (mountPoint != null) {
-            normalizedII = new DataNormalizer(mountPoint.getSchemaContext()).toNormalized(iiWithData
-                    .getInstanceIdentifier());
             data = broker.readConfigurationData(mountPoint, normalizedII);
         } else {
-            normalizedII = controllerContext.toNormalized(iiWithData.getInstanceIdentifier());
             data = broker.readConfigurationData(normalizedII);
         }
         return new NormalizedNodeContext(iiWithData, data);
@@ -931,13 +928,10 @@ public class RestconfImpl implements RestconfService {
         final InstanceIdentifierContext iiWithData = controllerContext.toInstanceIdentifier(identifier);
         final DOMMountPoint mountPoint = iiWithData.getMountPoint();
         NormalizedNode<?, ?> data = null;
-        YangInstanceIdentifier normalizedII;
+        final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
         if (mountPoint != null) {
-            normalizedII = new DataNormalizer(mountPoint.getSchemaContext()).toNormalized(iiWithData
-                    .getInstanceIdentifier());
             data = broker.readOperationalData(mountPoint, normalizedII);
         } else {
-            normalizedII = controllerContext.toNormalized(iiWithData.getInstanceIdentifier());
             data = broker.readOperationalData(normalizedII);
         }
 
index efd5482..fd099d3 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
@@ -43,9 +44,9 @@ public class URITest {
 
     @BeforeClass
     public static void init() throws FileNotFoundException {
-        Set<Module> allModules = TestUtils.loadModulesFrom("/full-versions/yangs");
+        final Set<Module> allModules = TestUtils.loadModulesFrom("/full-versions/yangs");
         assertNotNull(allModules);
-        SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
+        final SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
         controllerContext.setSchemas(schemaContext);
     }
 
@@ -80,7 +81,7 @@ public class URITest {
 
     @Test
     public void testToInstanceIdentifierContainer() throws FileNotFoundException {
-        InstanceIdentifierContext instanceIdentifier = controllerContext.toInstanceIdentifier("simple-nodes:users");
+        final InstanceIdentifierContext instanceIdentifier = controllerContext.toInstanceIdentifier("simple-nodes:users");
         assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "users");
         assertTrue(instanceIdentifier.getSchemaNode() instanceof ContainerSchemaNode);
         assertEquals(2, ((ContainerSchemaNode) instanceIdentifier.getSchemaNode()).getChildNodes().size());
@@ -88,7 +89,7 @@ public class URITest {
 
     @Test
     public void testToInstanceIdentifierChoice() throws FileNotFoundException {
-        InstanceIdentifierContext instanceIdentifier = controllerContext
+        final InstanceIdentifierContext instanceIdentifier = controllerContext
                 .toInstanceIdentifier("simple-nodes:food/nonalcoholic");
         assertEquals(instanceIdentifier.getSchemaNode().getQName().getLocalName(), "nonalcoholic");
     }
@@ -120,17 +121,17 @@ public class URITest {
     @Test
     public void testMountPointWithExternModul() throws FileNotFoundException {
         initMountService(true);
-        InstanceIdentifierContext instanceIdentifier = controllerContext
+        final InstanceIdentifierContext instanceIdentifier = controllerContext
                 .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name");
         assertEquals(
-                "[(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)student[{(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)name=name}]]",
+                "[(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)student, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)student[{(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)name=name}]]",
                 ImmutableList.copyOf(instanceIdentifier.getInstanceIdentifier().getPathArguments()).toString());
     }
 
     @Test
     public void testMountPointWithoutExternModul() throws FileNotFoundException {
         initMountService(true);
-        InstanceIdentifierContext instanceIdentifier = controllerContext
+        final InstanceIdentifierContext instanceIdentifier = controllerContext
                 .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/");
         assertTrue(Iterables.isEmpty(instanceIdentifier.getInstanceIdentifier().getPathArguments()));
     }
@@ -152,16 +153,16 @@ public class URITest {
     }
 
     public void initMountService(final boolean withSchema) {
-        DOMMountPointService mountService = mock(DOMMountPointService.class);
+        final DOMMountPointService mountService = mock(DOMMountPointService.class);
         controllerContext.setMountService(mountService);
-        BrokerFacade brokerFacade = mock(BrokerFacade.class);
-        RestconfImpl restconfImpl = RestconfImpl.getInstance();
+        final BrokerFacade brokerFacade = mock(BrokerFacade.class);
+        final RestconfImpl restconfImpl = RestconfImpl.getInstance();
         restconfImpl.setBroker(brokerFacade);
         restconfImpl.setControllerContext(controllerContext);
 
-        Set<Module> modules2 = TestUtils.loadModulesFrom("/test-config-data/yang2");
-        SchemaContext schemaContext2 = TestUtils.loadSchemaContext(modules2);
-        DOMMountPoint mountInstance = mock(DOMMountPoint.class);
+        final Set<Module> modules2 = TestUtils.loadModulesFrom("/test-config-data/yang2");
+        final SchemaContext schemaContext2 = TestUtils.loadSchemaContext(modules2);
+        final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
         if (withSchema) {
             when(mountInstance.getSchemaContext()).thenReturn(schemaContext2);
         } else {