From 468405c27b007e896bf12713651ae383740b6c2c Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Mon, 9 Sep 2013 05:00:39 -0700 Subject: [PATCH] Bug #60 : JSON list responses from the NB-APIs returns native object (instead of List) when the API returns a single element. We use Jersey and JAXB frameworks for the NB-API implementation. Jersey by default uses Jettison for the JSON marshalling/demarshalling. It seems like there is a bug in Jettison for this case. And the recommended approach is to use Jackson instead. Among various approaches to replace Jettison with Jackson (including package scanning, etc..), the only easy approach in an OSGi environment is to directly refer to the JerseyJaxbJsonProvider class from the Northbound application. JerseyJaxbJsonProvider has dependancies on jersey-xc which is also pulled in. The Northbound Integration Test has inbuilt assumption that the NB-APIs use Jettison & hence a whole bunch of such bugs were hidden and not visible to the tests as well. The correct approach is to use JAXB bindings in the IT so that immaterial of Jettison or Jackson as the NB Marshalling infra, the IT need not change. But, that is a bigger change and hence to restrict to the changes being addressed, this changeset just fixed these incorrect assumptions and continued to use the Jettison library for demarshalling (while the actual Northbound API uses Jackson). Also note that, such infra changes call for bumping both the NB-API version and the bundle version. But, given the fact that the API freeze is scheduled later in October and more NB related changes are coming, the version bump process can be scheduled later to ease the development work. Change-Id: I47d8309dfbe11c251a30316bca37c7823cb0325a Signed-off-by: Madhu Venugopal --- opendaylight/commons/opendaylight/pom.xml | 5 + .../northbound/flowprogrammer/pom.xml | 1 + .../northbound/FlowProgrammerNorthbound.java | 11 +- ...FlowProgrammerNorthboundRSApplication.java | 3 + opendaylight/northbound/hosttracker/pom.xml | 1 + .../northbound/HostTrackerNorthbound.java | 4 +- .../HostTrackerNorthboundRSApplication.java | 3 + .../northbound/integrationtest/pom.xml | 5 + .../integrationtest/NorthboundIT.java | 257 +++++++++++------- .../networkconfiguration/bridgedomain/pom.xml | 1 + .../BridgeDomainNorthboundApplication.java | 3 + opendaylight/northbound/staticrouting/pom.xml | 1 + .../northbound/StaticRoutingNorthbound.java | 4 +- .../StaticRoutingNorthboundRSApplication.java | 3 + opendaylight/northbound/statistics/pom.xml | 1 + .../StatisticsNorthboundRSApplication.java | 3 + opendaylight/northbound/subnets/pom.xml | 1 + .../subnets/northbound/SubnetConfigs.java | 2 +- .../subnets/northbound/SubnetsNorthbound.java | 22 +- .../SubnetsNorthboundRSApplication.java | 3 + opendaylight/northbound/switchmanager/pom.xml | 1 + .../SwitchNorthboundRSApplication.java | 3 + opendaylight/northbound/topology/pom.xml | 1 + .../northbound/TopologyNorthboundJAXRS.java | 9 +- .../TopologyNorthboundRSApplication.java | 3 + .../northbound/TopologyUserLinks.java | 2 +- .../controller/sal/action/Action.java | 3 +- .../controller/sal/core/TimeStamp.java | 2 +- .../samples/northbound/loadbalancer/pom.xml | 1 + .../northbound/LoadBalancerNorthbound.java | 16 +- .../LoadBalancerNorthboundRSApplication.java | 3 + 31 files changed, 246 insertions(+), 132 deletions(-) diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index f6282d86a2..aecb269ba6 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -630,6 +630,11 @@ jackson-jaxrs ${jackson.version} + + org.codehaus.jackson + jackson-xc + ${jackson.version} + org.codehaus.jettison jettison diff --git a/opendaylight/northbound/flowprogrammer/pom.xml b/opendaylight/northbound/flowprogrammer/pom.xml index 6319c7c8de..7aef0652fe 100644 --- a/opendaylight/northbound/flowprogrammer/pom.xml +++ b/opendaylight/northbound/flowprogrammer/pom.xml @@ -55,6 +55,7 @@ javax.xml.bind.annotation, javax.xml.bind, org.slf4j, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs diff --git a/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java b/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java index 7bd36a3cbf..257fbbda67 100644 --- a/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java +++ b/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java @@ -417,7 +417,7 @@ public class FlowProgrammerNorthbound { @PathParam(value = "name") String name, @PathParam("nodeType") String nodeType, @PathParam(value = "nodeId") String nodeId, - @TypeHint(FlowConfig.class) JAXBElement flowConfig) { + @TypeHint(FlowConfig.class) FlowConfig flowConfig) { if (!NorthboundUtils.isAuthorized( getUserName(), containerName, Privilege.WRITE, this)) { @@ -425,12 +425,13 @@ public class FlowProgrammerNorthbound { "User is not authorized to perform this operation on container " + containerName); } - if (flowConfig.getValue().getNode() == null) { + + if (flowConfig.getNode() == null) { return Response.status(Response.Status.BAD_REQUEST).entity("Invalid Configuration. Node is null or empty") .build(); } - handleResourceCongruence(name, flowConfig.getValue().getName()); - handleResourceCongruence(nodeId, flowConfig.getValue().getNode().getNodeIDString()); + handleResourceCongruence(name, flowConfig.getName()); + handleResourceCongruence(nodeId, flowConfig.getNode().getNodeIDString()); handleDefaultDisabled(containerName); IForwardingRulesManager frm = getForwardingRulesManagerService(containerName); @@ -448,7 +449,7 @@ public class FlowProgrammerNorthbound { + RestMessages.RESOURCECONFLICT.toString()); } - Status status = frm.addStaticFlow(flowConfig.getValue()); + Status status = frm.addStaticFlow(flowConfig); if (status.isSuccess()) { NorthboundUtils.auditlog("Flow", username, "added", name, containerName); diff --git a/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthboundRSApplication.java b/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthboundRSApplication.java index 3c6a5f8639..68c0ec1e5b 100644 --- a/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthboundRSApplication.java +++ b/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthboundRSApplication.java @@ -13,6 +13,8 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * Instance of javax.ws.rs.core.Application used to return the classes * that will be instantiated for JAXRS processing, this is necessary @@ -25,6 +27,7 @@ public class FlowProgrammerNorthboundRSApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(FlowProgrammerNorthbound.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } diff --git a/opendaylight/northbound/hosttracker/pom.xml b/opendaylight/northbound/hosttracker/pom.xml index 74e33863b5..3757ea1f36 100644 --- a/opendaylight/northbound/hosttracker/pom.xml +++ b/opendaylight/northbound/hosttracker/pom.xml @@ -58,6 +58,7 @@ javax.xml.bind, org.slf4j, org.apache.catalina.filters, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs /controller/nb/v2/host diff --git a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java index 91185bb405..f0bdf5d891 100644 --- a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java +++ b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java @@ -432,7 +432,7 @@ public class HostTrackerNorthbound { @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") }) public Response addHost(@Context UriInfo uriInfo, @PathParam("containerName") String containerName, @PathParam("networkAddress") String networkAddress, - @TypeHint(HostConfig.class) JAXBElement hostConfig) { + @TypeHint(HostConfig.class) HostConfig hostConfig) { if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.WRITE, this)) { return Response.status(Response.Status.UNAUTHORIZED) @@ -443,7 +443,7 @@ public class HostTrackerNorthbound { IfIptoHost hostTracker = getIfIpToHostService(containerName); - HostConfig hc = hostConfig.getValue(); + HostConfig hc = hostConfig; if (!networkAddress.equals(hc.getNetworkAddress())) { return Response.status(Response.Status.CONFLICT) .entity("Resource name in config object doesn't match URI") diff --git a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthboundRSApplication.java b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthboundRSApplication.java index 89bee5ba1a..5d50dbf0b2 100644 --- a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthboundRSApplication.java +++ b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthboundRSApplication.java @@ -13,6 +13,8 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * This class is an instance of javax.ws.rs.core.Application used to return the classes * that will be instantiated for JAXRS processing, this is necessary @@ -25,6 +27,7 @@ public class HostTrackerNorthboundRSApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(HostTrackerNorthbound.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } diff --git a/opendaylight/northbound/integrationtest/pom.xml b/opendaylight/northbound/integrationtest/pom.xml index 88cff5ed83..90b36de7ef 100644 --- a/opendaylight/northbound/integrationtest/pom.xml +++ b/opendaylight/northbound/integrationtest/pom.xml @@ -278,6 +278,11 @@ jackson-jaxrs ${jackson.version} + + org.codehaus.jackson + jackson-xc + ${jackson.version} + org.codehaus.jettison jettison diff --git a/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java b/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java index f7ebfe438f..27a50c015d 100644 --- a/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java +++ b/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java @@ -189,6 +189,9 @@ public class NorthboundIT { } is.close(); connection.disconnect(); + if (debugMsg) { + System.out.println("Response : "+sb.toString()); + } return sb.toString(); } catch (Exception e) { return null; @@ -203,34 +206,47 @@ public class NorthboundIT { Assert.assertEquals(nodeId, (Integer) nodeInfo.getInt("id")); Assert.assertEquals(nodeType, nodeInfo.getString("type")); - JSONObject properties = node.getJSONObject("properties"); - - if (timestamp == null || timestampName == null) { - Assert.assertFalse(properties.has("timeStamp")); - } else { - Assert.assertEquals(timestamp, (Integer) properties.getJSONObject("timeStamp").getInt("value")); - Assert.assertEquals(timestampName, properties.getJSONObject("timeStamp").getString("name")); - } - if (actionsValue == null) { - Assert.assertFalse(properties.has("actions")); - } else { - Assert.assertEquals(actionsValue, (Integer) properties.getJSONObject("actions").getInt("value")); - } - if (capabilitiesValue == null) { - Assert.assertFalse(properties.has("capabilities")); - } else { - Assert.assertEquals(capabilitiesValue, - (Integer) properties.getJSONObject("capabilities").getInt("value")); - } - if (tablesValue == null) { - Assert.assertFalse(properties.has("tables")); - } else { - Assert.assertEquals(tablesValue, (Integer) properties.getJSONObject("tables").getInt("value")); - } - if (buffersValue == null) { - Assert.assertFalse(properties.has("buffers")); - } else { - Assert.assertEquals(buffersValue, (Integer) properties.getJSONObject("buffers").getInt("value")); + JSONArray propsArray = node.getJSONArray("properties"); + + for (int j = 0; j < propsArray.length(); j++) { + JSONObject properties = propsArray.getJSONObject(j); + String propName = properties.getString("name"); + if (propName.equals("timeStamp")) { + if (timestamp == null || timestampName == null) { + Assert.assertFalse("Timestamp exist", true); + } else { + Assert.assertEquals(timestamp, (Integer) properties.getInt("value")); + Assert.assertEquals(timestampName, properties.getString("timestampName")); + } + } + if (propName.equals("actions")) { + if (actionsValue == null) { + Assert.assertFalse("Actions exist", true); + } else { + Assert.assertEquals(actionsValue, (Integer) properties.getInt("value")); + } + } + if (propName.equals("capabilities")) { + if (capabilitiesValue == null) { + Assert.assertFalse("Capabilities exist", true); + } else { + Assert.assertEquals(capabilitiesValue, (Integer) properties.getInt("value")); + } + } + if (propName.equals("tables")) { + if (tablesValue == null) { + Assert.assertFalse("Tables exist", true); + } else { + Assert.assertEquals(tablesValue, (Integer) properties.getInt("value")); + } + } + if (propName.equals("buffers")) { + if (buffersValue == null) { + Assert.assertFalse("Buffers exist", true); + } else { + Assert.assertEquals(buffersValue, (Integer) properties.getInt("value")); + } + } } } @@ -240,29 +256,38 @@ public class NorthboundIT { JSONObject nodeConnector = nodeConnectorProperties.getJSONObject("nodeconnector"); JSONObject node = nodeConnector.getJSONObject("node"); - JSONObject properties = nodeConnectorProperties.getJSONObject("properties"); Assert.assertEquals(ncId, (Integer) nodeConnector.getInt("id")); Assert.assertEquals(ncType, nodeConnector.getString("type")); Assert.assertEquals(nodeId, (Integer) node.getInt("id")); Assert.assertEquals(nodeType, node.getString("type")); - if (state == null) { - Assert.assertFalse(properties.has("state")); - } else { - Assert.assertEquals(state, (Integer) properties.getJSONObject("state").getInt("value")); - } - if (capabilities == null) { - Assert.assertFalse(properties.has("capabilities")); - } else { - Assert.assertEquals(capabilities, - (Integer) properties.getJSONObject("capabilities").getInt("value")); - } - if (bandwidth == null) { - Assert.assertFalse(properties.has("bandwidth")); - } else { - Assert.assertEquals(bandwidth, (Integer) properties.getJSONObject("bandwidth").getInt("value")); - } + JSONArray propsArray = nodeConnectorProperties.getJSONArray("properties"); + for (int j = 0; j < propsArray.length(); j++) { + JSONObject properties = propsArray.getJSONObject(j); + String propName = properties.getString("name"); + if (propName.equals("state")) { + if (state == null) { + Assert.assertFalse("State exist", true); + } else { + Assert.assertEquals(state, (Integer) properties.getInt("value")); + } + } + if (propName.equals("capabilities")) { + if (capabilities == null) { + Assert.assertFalse("Capabilities exist", true); + } else { + Assert.assertEquals(capabilities, (Integer) properties.getInt("value")); + } + } + if (propName.equals("bandwidth")) { + if (bandwidth == null) { + Assert.assertFalse("bandwidth exist", true); + } else { + Assert.assertEquals(bandwidth, (Integer) properties.getInt("value")); + } + } + } } @Test @@ -291,14 +316,15 @@ public class NorthboundIT { String result = getJsonResult(baseURL + "default/subnet/all"); JSONTokener jt = new JSONTokener(result); JSONObject json = new JSONObject(jt); - Assert.assertEquals("{}", result); + JSONArray subnetConfigs = json.getJSONArray("subnetConfig"); + Assert.assertEquals(subnetConfigs.length(), 0); // Test GET subnet1 expecting 404 result = getJsonResult(baseURL + "default/subnet/" + name1); Assert.assertEquals(404, httpResponseCode.intValue()); // Test POST subnet1 - JSONObject jo = new JSONObject().append("name", name1).append("subnet", subnet1); + JSONObject jo = new JSONObject().put("name", name1).put("subnet", subnet1); // execute HTTP request and verify response code result = getJsonResult(baseURL + "default/subnet/" + name1, "POST", jo.toString()); Assert.assertTrue(httpResponseCode == 201); @@ -312,7 +338,7 @@ public class NorthboundIT { Assert.assertEquals(subnet1, json.getString("subnet")); // Test POST subnet2 - JSONObject jo2 = new JSONObject().append("name", name2).append("subnet", subnet2); + JSONObject jo2 = new JSONObject().put("name", name2).put("subnet", subnet2); // execute HTTP request and verify response code result = getJsonResult(baseURL + "default/subnet/" + name2, "POST", jo2.toString()); Assert.assertEquals(201, httpResponseCode.intValue()); @@ -322,7 +348,7 @@ public class NorthboundIT { result = getJsonResult(baseURL + "default/subnet/" + name2 + "/node-ports", "POST", jo2.toString()); Assert.assertEquals(200, httpResponseCode.intValue()); // Test POST subnet3 - JSONObject jo3 = new JSONObject().append("name", name3).append("subnet", subnet3); + JSONObject jo3 = new JSONObject().put("name", name3).put("subnet", subnet3); // execute HTTP request and verify response code result = getJsonResult(baseURL + "default/subnet/" + name3, "POST", jo3.toString()); Assert.assertEquals(201, httpResponseCode.intValue()); @@ -350,14 +376,14 @@ public class NorthboundIT { Assert.assertEquals(subnet1, subnetConfig.getString("subnet")); } else if (subnetConfig.getString("name").equals(name2)) { Assert.assertEquals(subnet2, subnetConfig.getString("subnet")); - String[] nodePortsGet2 = subnetConfig.getString("nodePorts").split(","); + String[] nodePortsGet2 = subnetConfig.getJSONArray("nodePorts").getString(0).split(","); Assert.assertEquals(nodePorts2[0], nodePortsGet2[0]); Assert.assertEquals(nodePorts2[1], nodePortsGet2[1]); Assert.assertEquals(nodePorts2[2], nodePortsGet2[2]); Assert.assertEquals(nodePorts2[3], nodePortsGet2[3]); } else if (subnetConfig.getString("name").equals(name3)) { Assert.assertEquals(subnet3, subnetConfig.getString("subnet")); - String[] nodePortsGet = subnetConfig.getString("nodePorts").split(","); + String[] nodePortsGet = subnetConfig.getJSONArray("nodePorts").getString(0).split(","); Assert.assertEquals(nodePorts3[0], nodePortsGet[0]); Assert.assertEquals(nodePorts3[1], nodePortsGet[1]); Assert.assertEquals(nodePorts3[2], nodePortsGet[2]); @@ -396,7 +422,8 @@ public class NorthboundIT { String result = getJsonResult(baseURL + "default"); JSONTokener jt = new JSONTokener(result); JSONObject json = new JSONObject(jt); - Assert.assertEquals("{}", result); + JSONArray staticRoutes = json.getJSONArray("staticRoute"); + Assert.assertEquals(staticRoutes.length(), 0); // Test insert static route String requestBody = "{\"name\":\"" + name1 + "\", \"prefix\":\"" + prefix1 + "\", \"nextHop\":\"" + nextHop1 @@ -412,8 +439,8 @@ public class NorthboundIT { result = getJsonResult(baseURL + "default"); jt = new JSONTokener(result); json = new JSONObject(jt); - JSONArray staticRoutes = json.getJSONArray("staticRoute"); - Assert.assertEquals(2, staticRoutes.length()); + JSONArray staticRouteArray = json.getJSONArray("staticRoute"); + Assert.assertEquals(2, staticRouteArray.length()); JSONObject route; for (int i = 0; i < staticRoutes.length(); i++) { route = staticRoutes.getJSONObject(i); @@ -453,7 +480,9 @@ public class NorthboundIT { result = getJsonResult(baseURL + "default"); jt = new JSONTokener(result); json = new JSONObject(jt); - JSONObject singleStaticRoute = json.getJSONObject("staticRoute"); + + staticRouteArray = json.getJSONArray("staticRoute"); + JSONObject singleStaticRoute = staticRouteArray.getJSONObject(0); Assert.assertEquals(name2, singleStaticRoute.getString("name")); } @@ -511,7 +540,8 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/" + nodeId_1); jt = new JSONTokener(result); json = new JSONObject(jt); - JSONObject nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + JSONArray nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + JSONObject nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1, ncType, nodeId_1, nodeType, ncState, ncCapabilities, ncBandwidth); @@ -520,7 +550,10 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/" + nodeId_2); jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); + testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState, ncCapabilities, ncBandwidth); @@ -530,7 +563,8 @@ public class NorthboundIT { jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_3, ncType, nodeId_3, nodeType, ncState, ncCapabilities, ncBandwidth); @@ -547,8 +581,19 @@ public class NorthboundIT { json = new JSONObject(jt); node = getJsonInstance(json, "nodeProperties", nodeId_1); Assert.assertNotNull(node); - Assert.assertEquals(1001, node.getJSONObject("properties").getJSONObject("tier").getInt("value")); - Assert.assertEquals("node1", node.getJSONObject("properties").getJSONObject("description").getString("value")); + + JSONArray propsArray = node.getJSONArray("properties"); + + for (int j = 0; j < propsArray.length(); j++) { + JSONObject properties = propsArray.getJSONObject(j); + String propName = properties.getString("name"); + if (propName.equals("tier")) { + Assert.assertEquals(1001, properties.getInt("value")); + } + if (propName.equals("description")) { + Assert.assertEquals("node1", properties.getString("value")); + } + } // Test delete nodeConnector property // Delete state property of nodeconnector1 @@ -559,7 +604,8 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/" + nodeId_1); jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1, ncType, nodeId_1, nodeType, null, ncCapabilities, ncBandwidth); @@ -572,7 +618,8 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/" + nodeId_2); jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState, null, ncBandwidth); @@ -588,7 +635,8 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/" + nodeId_1); jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); // Check for new bandwidth value, state value removed from previous // test @@ -599,9 +647,9 @@ public class NorthboundIT { @Test public void testStatistics() throws JSONException { - final String actionTypes[] = { "drop", "loopback", "flood", "floodAll", "controller", "swPath", "hwPath", "output", - "setDlSrc", "setDlDst", "setDlType", "setVlanId", "setVlanPcp", "setVlanCfi", "popVlan", "pushVlan", - "setNwSrc", "setNwDst", "setNwTos", "setTpSrc", "setTpDst" }; + final String actionTypes[] = { "DROP", "LOOPBACK", "FLOOD", "FLOOD_ALL", "CONTROLLER", "SW_PATH", "HW_PATH", "OUTPUT", + "SET_DL_SRC", "SET_DL_DST", "SET_DL_TYPE", "SET_VLAN_ID", "SET_VLAN_PCP", "SET_VLAN_CFI", "POP_VLAN", "PUSH_VLAN", + "SET_NW_SRC", "SET_NW_DST", "SET_NW_TOS", "SET_TP_SRC", "SET_TP_DST" }; System.out.println("Starting Statistics JAXB client."); String baseURL = "http://127.0.0.1:8080/controller/nb/v2/statistics/default/"; @@ -635,7 +683,8 @@ public class NorthboundIT { Assert.assertEquals(node2.getString("type"), "STUB"); // test that port statistic results are correct - JSONObject portStat = portStatistics.getJSONObject("portStatistic"); + JSONArray portStatArray = portStatistics.getJSONArray("portStatistic"); + JSONObject portStat = portStatArray.getJSONObject(0); Assert.assertTrue(portStat.getInt("receivePackets") == 250); Assert.assertTrue(portStat.getInt("transmitPackets") == 500); Assert.assertTrue(portStat.getInt("receiveBytes") == 1000); @@ -674,7 +723,9 @@ public class NorthboundIT { Assert.assertEquals(node2.getString("type"), "STUB"); // test that port statistic results are correct - portStat = json.getJSONObject("portStatistic"); + portStatArray = json.getJSONArray("portStatistic"); + portStat = portStatArray.getJSONObject(0); + Assert.assertTrue(portStat.getInt("receivePackets") == 250); Assert.assertTrue(portStat.getInt("transmitPackets") == 500); Assert.assertTrue(portStat.getInt("receiveBytes") == 1000); @@ -703,14 +754,18 @@ public class NorthboundIT { Assert.assertTrue(flow.getInt("hardTimeout") == 2000); Assert.assertTrue(flow.getInt("id") == 12345); - JSONObject match = (flow.getJSONObject("match").getJSONObject("matchField")); + JSONArray matches = (flow.getJSONObject("match").getJSONArray("matchField")); + Assert.assertEquals(matches.length(), 1); + JSONObject match = matches.getJSONObject(0); Assert.assertTrue(match.getString("type").equals("NW_DST")); Assert.assertTrue(match.getString("value").equals("1.1.1.1")); - JSONObject act = flow.getJSONObject("actions"); - Assert.assertTrue(act.getString("@type").equals(actionType)); + JSONArray actionsArray = flow.getJSONArray("actions"); + Assert.assertEquals(actionsArray.length(), 1); + JSONObject act = actionsArray.getJSONObject(0); + Assert.assertTrue(act.getString("type").equals(actionType)); - if (act.getString("@type").equals("output")) { + if (act.getString("type").equals("OUTPUT")) { JSONObject port = act.getJSONObject("port"); JSONObject port_node = port.getJSONObject("node"); Assert.assertTrue(port.getInt("id") == 51966); @@ -719,7 +774,7 @@ public class NorthboundIT { Assert.assertTrue(port_node.getString("type").equals("STUB")); } - if (act.getString("@type").equals("setDlSrc")) { + if (act.getString("type").equals("SET_DL_SRC")) { byte srcMatch[] = { (byte) 5, (byte) 4, (byte) 3, (byte) 2, (byte) 1 }; String src = act.getString("address"); byte srcBytes[] = new byte[5]; @@ -731,7 +786,7 @@ public class NorthboundIT { Assert.assertTrue(Arrays.equals(srcBytes, srcMatch)); } - if (act.getString("@type").equals("setDlDst")) { + if (act.getString("type").equals("SET_DL_DST")) { byte dstMatch[] = { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 }; String dst = act.getString("address"); byte dstBytes[] = new byte[5]; @@ -742,21 +797,21 @@ public class NorthboundIT { dstBytes[4] = Byte.parseByte(dst.substring(8, 10)); Assert.assertTrue(Arrays.equals(dstBytes, dstMatch)); } - if (act.getString("@type").equals("setDlType")) + if (act.getString("type").equals("SET_DL_TYPE")) Assert.assertTrue(act.getInt("dlType") == 10); - if (act.getString("@type").equals("setVlanId")) + if (act.getString("type").equals("SET_VLAN_ID")) Assert.assertTrue(act.getInt("vlanId") == 2); - if (act.getString("@type").equals("setVlanPcp")) + if (act.getString("type").equals("SET_VLAN_PCP")) Assert.assertTrue(act.getInt("pcp") == 3); - if (act.getString("@type").equals("setVlanCfi")) + if (act.getString("type").equals("SET_VLAN_CFI")) Assert.assertTrue(act.getInt("cfi") == 1); - if (act.getString("@type").equals("setNwSrc")) + if (act.getString("type").equals("SET_NW_SRC")) Assert.assertTrue(act.getString("address").equals("2.2.2.2")); - if (act.getString("@type").equals("setNwDst")) + if (act.getString("type").equals("SET_NW_DST")) Assert.assertTrue(act.getString("address").equals("1.1.1.1")); - if (act.getString("@type").equals("pushVlan")) { + if (act.getString("type").equals("PUSH_VLAN")) { int head = act.getInt("VlanHeader"); // parsing vlan header int id = head & 0xfff; @@ -768,11 +823,11 @@ public class NorthboundIT { Assert.assertTrue(pcp == 1); Assert.assertTrue(tag == 0x8100); } - if (act.getString("@type").equals("setNwTos")) + if (act.getString("type").equals("SET_NW_TOS")) Assert.assertTrue(act.getInt("tos") == 16); - if (act.getString("@type").equals("setTpSrc")) + if (act.getString("type").equals("SET_TP_SRC")) Assert.assertTrue(act.getInt("port") == 4201); - if (act.getString("@type").equals("setTpDst")) + if (act.getString("type").equals("SET_TP_DST")) Assert.assertTrue(act.getInt("port") == 8080); } @@ -786,7 +841,7 @@ public class NorthboundIT { Assert.assertTrue(result.equals("404")); // test add flow1 - String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; + String fc = "{\"name\":\"test1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "PUT", fc); Assert.assertTrue(httpResponseCode == 201); @@ -797,7 +852,8 @@ public class NorthboundIT { JSONTokener jt = new JSONTokener(result); JSONObject json = new JSONObject(jt); Assert.assertEquals(json.getString("name"), "test1"); - Assert.assertEquals(json.getString("actions"), "DROP"); + JSONArray actionsArray = json.getJSONArray("actions"); + Assert.assertEquals(actionsArray.getString(0), "DROP"); Assert.assertEquals(json.getString("installInHw"), "true"); JSONObject node = json.getJSONObject("node"); Assert.assertEquals(node.getString("type"), "STUB"); @@ -807,13 +863,13 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "PUT", fc); Assert.assertTrue(result.equals("409")); - fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; + fc = "{\"name\":\"test2\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc); // test should return 409 for error due to same flow being added. Assert.assertTrue(result.equals("409")); // add second flow that's different - fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; + fc = "{\"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc); Assert.assertTrue(httpResponseCode == 201); @@ -1132,10 +1188,20 @@ public class NorthboundIT { JSONObject headNC = edge.getJSONObject("headNodeConnector"); JSONObject headNode = headNC.getJSONObject("node"); - JSONObject Props = edgeProp.getJSONObject("properties"); - JSONObject bandw = Props.getJSONObject("bandwidth"); - JSONObject stt = Props.getJSONObject("state"); - JSONObject ltc = Props.getJSONObject("latency"); + + JSONArray propsArray = edgeProp.getJSONArray("properties"); + + JSONObject bandw = null; + JSONObject stt = null; + JSONObject ltc = null; + + for (int j = 0; j < propsArray.length(); j++) { + JSONObject props = propsArray.getJSONObject(j); + String propName = props.getString("name"); + if (propName.equals("bandwidth")) bandw = props; + if (propName.equals("state")) stt = props; + if (propName.equals("latency")) ltc = props; + } if (headNC.getInt("id") == headNC1_nodeConnId) { Assert.assertEquals(headNode.getString("type"), nodeType); @@ -1174,10 +1240,10 @@ public class NorthboundIT { Integer nodeConnectorId_2 = 34; JSONObject jo = new JSONObject() - .append("name", "userLink_1") - .append("srcNodeConnector", + .put("name", "userLink_1") + .put("srcNodeConnector", nodeConnectorType_1 + "|" + nodeConnectorId_1 + "@" + nodeType_1 + "|" + nodeId_1) - .append("dstNodeConnector", + .put("dstNodeConnector", nodeConnectorType_2 + "|" + nodeConnectorId_2 + "@" + nodeType_2 + "|" + nodeId_2); // execute HTTP request and verify response code result = getJsonResult(baseURL + "/user-link", "PUT", jo.toString()); @@ -1331,6 +1397,7 @@ public class NorthboundIT { mavenBundle("org.codehaus.jackson", "jackson-mapper-asl").versionAsInProject(), mavenBundle("org.codehaus.jackson", "jackson-core-asl").versionAsInProject(), mavenBundle("org.codehaus.jackson", "jackson-jaxrs").versionAsInProject(), + mavenBundle("org.codehaus.jackson", "jackson-xc").versionAsInProject(), mavenBundle("org.codehaus.jettison", "jettison").versionAsInProject(), mavenBundle("commons-io", "commons-io").versionAsInProject(), diff --git a/opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml b/opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml index 5993f16787..b7da9641fa 100644 --- a/opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml +++ b/opendaylight/northbound/networkconfiguration/bridgedomain/pom.xml @@ -58,6 +58,7 @@ javax.xml.bind.annotation, javax.xml.bind, org.apache.catalina.filters, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs diff --git a/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthboundApplication.java b/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthboundApplication.java index 1d1fd15a4a..0d98d2282d 100644 --- a/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthboundApplication.java +++ b/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthboundApplication.java @@ -13,6 +13,8 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * Instance of javax.ws.rs.core.Application used to return the classes * that will be instantiated for JAXRS processing, this is necessary @@ -25,6 +27,7 @@ public class BridgeDomainNorthboundApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(BridgeDomainNorthbound.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } diff --git a/opendaylight/northbound/staticrouting/pom.xml b/opendaylight/northbound/staticrouting/pom.xml index d308fba3d9..62f5b42699 100644 --- a/opendaylight/northbound/staticrouting/pom.xml +++ b/opendaylight/northbound/staticrouting/pom.xml @@ -56,6 +56,7 @@ javax.xml.bind.annotation, javax.xml.bind, org.apache.catalina.filters, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs diff --git a/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java b/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java index 8462ef804a..65e68aab7d 100644 --- a/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java +++ b/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java @@ -233,7 +233,7 @@ public class StaticRoutingNorthbound { @Context UriInfo uriInfo, @PathParam(value = "containerName") String containerName, @PathParam(value = "route") String route, - @TypeHint(StaticRoute.class) JAXBElement staticRouteData) { + @TypeHint(StaticRoute.class) StaticRoute staticRouteData) { if(!NorthboundUtils.isAuthorized(getUserName(), containerName, @@ -253,7 +253,7 @@ public class StaticRoutingNorthbound { .toString()); } - StaticRoute sRoute = staticRouteData.getValue(); + StaticRoute sRoute = staticRouteData; StaticRouteConfig cfgObject = new StaticRouteConfig(sRoute.getName(), sRoute.getPrefix(), sRoute.getNextHop()); Status response = staticRouting.addStaticRoute(cfgObject); diff --git a/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundRSApplication.java b/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundRSApplication.java index a39794df74..a98a124524 100644 --- a/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundRSApplication.java +++ b/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthboundRSApplication.java @@ -13,6 +13,8 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * Instance of javax.ws.rs.core.Application used to return the classes * that will be instantiated for JAXRS processing, this is necessary @@ -25,6 +27,7 @@ public class StaticRoutingNorthboundRSApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(StaticRoutingNorthbound.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } diff --git a/opendaylight/northbound/statistics/pom.xml b/opendaylight/northbound/statistics/pom.xml index 6a5a08e4a9..eb2bf587de 100644 --- a/opendaylight/northbound/statistics/pom.xml +++ b/opendaylight/northbound/statistics/pom.xml @@ -64,6 +64,7 @@ javax.xml.bind, org.slf4j, org.apache.catalina.filters, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs diff --git a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundRSApplication.java b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundRSApplication.java index d38740751d..2b6dccc8b9 100644 --- a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundRSApplication.java +++ b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthboundRSApplication.java @@ -12,6 +12,8 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * Instance of javax.ws.rs.core.Application used to return the classes * that will be instantiated for JAXRS processing, this is necessary @@ -24,6 +26,7 @@ public class StatisticsNorthboundRSApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(StatisticsNorthbound.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } diff --git a/opendaylight/northbound/subnets/pom.xml b/opendaylight/northbound/subnets/pom.xml index 72b0a04c90..9feb95fce0 100644 --- a/opendaylight/northbound/subnets/pom.xml +++ b/opendaylight/northbound/subnets/pom.xml @@ -71,6 +71,7 @@ javax.xml.bind.annotation, org.slf4j, org.apache.catalina.filters, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs diff --git a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetConfigs.java b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetConfigs.java index 3361f1b3d2..224bb14831 100644 --- a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetConfigs.java +++ b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetConfigs.java @@ -17,7 +17,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.opendaylight.controller.switchmanager.SubnetConfig; -@XmlRootElement +@XmlRootElement (name = "list") @XmlAccessorType(XmlAccessType.NONE) public class SubnetConfigs { diff --git a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java index a5e805d396..50024fd739 100644 --- a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java +++ b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java @@ -254,7 +254,7 @@ public class SubnetsNorthbound { @ResponseCode(code = 503, condition = "Service unavailable") }) public Response addSubnet(@PathParam("containerName") String containerName, @PathParam("subnetName") String subnetName, - @TypeHint(SubnetConfig.class) JAXBElement subnetConfigData) { + @TypeHint(SubnetConfig.class) SubnetConfig subnetConfigData) { handleContainerDoesNotExist(containerName); @@ -262,7 +262,7 @@ public class SubnetsNorthbound { throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName); } - SubnetConfig cfgObject = subnetConfigData.getValue(); + SubnetConfig cfgObject = subnetConfigData; handleNameMismatch(cfgObject.getName(), subnetName); ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName, this); @@ -377,7 +377,7 @@ public class SubnetsNorthbound { @ResponseCode(code = 503, condition = "Service unavailable") }) public Response modifySubnet(@PathParam("containerName") String containerName, @PathParam("subnetName") String subnetName, - @TypeHint(SubnetConfig.class) JAXBElement subnetConfigData) { + @TypeHint(SubnetConfig.class) SubnetConfig subnetConfigData) { handleContainerDoesNotExist(containerName); @@ -385,7 +385,7 @@ public class SubnetsNorthbound { throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName); } - handleNameMismatch(subnetConfigData.getValue().getName(), subnetName); + handleNameMismatch(subnetConfigData.getName(), subnetName); ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName, this); @@ -393,7 +393,7 @@ public class SubnetsNorthbound { throw new ServiceUnavailableException("SwitchManager " + RestMessages.SERVICEUNAVAILABLE.toString()); } - SubnetConfig subnetConf = subnetConfigData.getValue(); + SubnetConfig subnetConf = subnetConfigData; SubnetConfig existingConf = switchManager.getSubnetConfig(subnetName); boolean successful = true; @@ -488,7 +488,7 @@ public class SubnetsNorthbound { @ResponseCode(code = 503, condition = "Service unavailable") }) public Response addNodePorts(@PathParam("containerName") String containerName, @PathParam("subnetName") String subnetName, - @TypeHint(SubnetConfig.class) JAXBElement subnetConfigData) { + @TypeHint(SubnetConfig.class) SubnetConfig subnetConfigData) { handleContainerDoesNotExist(containerName); @@ -496,9 +496,9 @@ public class SubnetsNorthbound { throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName); } - handleNameMismatch(subnetConfigData.getValue().getName(), subnetName); + handleNameMismatch(subnetConfigData.getName(), subnetName); - SubnetConfig subnetConf = subnetConfigData.getValue(); + SubnetConfig subnetConf = subnetConfigData; ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName, this); @@ -586,7 +586,7 @@ public class SubnetsNorthbound { @ResponseCode(code = 503, condition = "Service unavailable") }) public Response deleteNodePorts(@PathParam("containerName") String containerName, @PathParam("subnetName") String subnetName, - @TypeHint(SubnetConfig.class) JAXBElement subnetConfigData) { + @TypeHint(SubnetConfig.class) SubnetConfig subnetConfigData) { handleContainerDoesNotExist(containerName); @@ -594,9 +594,9 @@ public class SubnetsNorthbound { throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName); } - handleNameMismatch(subnetConfigData.getValue().getName(), subnetName); + handleNameMismatch(subnetConfigData.getName(), subnetName); - SubnetConfig subnetConf = subnetConfigData.getValue(); + SubnetConfig subnetConf = subnetConfigData; if (subnetConf.getNodePorts() == null || subnetConf.getNodePorts().isEmpty()) { throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : invalid node ports"); diff --git a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundRSApplication.java b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundRSApplication.java index a5eaf94f26..e03cac6562 100644 --- a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundRSApplication.java +++ b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundRSApplication.java @@ -12,6 +12,8 @@ import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * Instance of javax.ws.rs.core.Application used to return the classes * that will be instantiated for JAXRS processing, this is necessary @@ -24,6 +26,7 @@ public class SubnetsNorthboundRSApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(SubnetsNorthbound.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } diff --git a/opendaylight/northbound/switchmanager/pom.xml b/opendaylight/northbound/switchmanager/pom.xml index 719688305e..965075a271 100644 --- a/opendaylight/northbound/switchmanager/pom.xml +++ b/opendaylight/northbound/switchmanager/pom.xml @@ -57,6 +57,7 @@ javax.xml.bind, org.slf4j, org.apache.catalina.filters, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs /controller/nb/v2/switch diff --git a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthboundRSApplication.java b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthboundRSApplication.java index d33c3c99fc..1cdfd31e3f 100644 --- a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthboundRSApplication.java +++ b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthboundRSApplication.java @@ -13,6 +13,8 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * Instance of javax.ws.rs.core.Application used to return the classes * that will be instantiated for JAXRS processing, this is necessary @@ -25,6 +27,7 @@ public class SwitchNorthboundRSApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(SwitchNorthbound.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } diff --git a/opendaylight/northbound/topology/pom.xml b/opendaylight/northbound/topology/pom.xml index ec43a5ee63..b2b7b9c85f 100644 --- a/opendaylight/northbound/topology/pom.xml +++ b/opendaylight/northbound/topology/pom.xml @@ -60,6 +60,7 @@ javax.xml.bind.annotation, org.slf4j, org.apache.catalina.filters, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs /controller/nb/v2/topology diff --git a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java index c20cb26885..508ffafe6f 100644 --- a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java +++ b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java @@ -200,8 +200,7 @@ public class TopologyNorthboundJAXRS { if (topo != null) { List res = new ArrayList(); for (Map.Entry> entry : topo.entrySet()) { - EdgeProperties el = new EdgeProperties(entry.getKey(), - entry.getValue()); + EdgeProperties el = new EdgeProperties(entry.getKey(), entry.getValue()); res.add(el); } return new Topology(res); @@ -316,7 +315,7 @@ public class TopologyNorthboundJAXRS { @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") }) public Response addUserLink( @PathParam(value = "containerName") String containerName, - @TypeHint(TopologyUserLinkConfig.class) JAXBElement userLinkConfig) { + @TypeHint(TopologyUserLinkConfig.class) TopologyUserLinkConfig userLinkConfig) { if (!NorthboundUtils.isAuthorized( getUserName(), containerName, Privilege.WRITE, this)) { @@ -331,9 +330,9 @@ public class TopologyNorthboundJAXRS { RestMessages.NOCONTAINER.toString()); } - Status status = topologyManager.addUserLink(userLinkConfig.getValue()); + Status status = topologyManager.addUserLink(userLinkConfig); if (status.isSuccess()) { - NorthboundUtils.auditlog("User Link", username, "added", userLinkConfig.getValue().getName(), containerName); + NorthboundUtils.auditlog("User Link", username, "added", userLinkConfig.getName(), containerName); return Response.status(Response.Status.CREATED).build(); } throw new InternalServerErrorException(status.getDescription()); diff --git a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundRSApplication.java b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundRSApplication.java index 299bfcd224..992cf6ac52 100644 --- a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundRSApplication.java +++ b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundRSApplication.java @@ -13,6 +13,8 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * Instance of javax.ws.rs.core.Application used to return the classes * that will be instantiated for JAXRS processing, this is necessary @@ -25,6 +27,7 @@ public class TopologyNorthboundRSApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(TopologyNorthboundJAXRS.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } diff --git a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyUserLinks.java b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyUserLinks.java index db24755a29..dee2e243d4 100644 --- a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyUserLinks.java +++ b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyUserLinks.java @@ -18,7 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig; -@XmlRootElement +@XmlRootElement (name = "list") @XmlAccessorType(XmlAccessType.NONE) public class TopologyUserLinks { diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java index 8fc8fc16bf..515a61eab7 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java @@ -12,6 +12,7 @@ import java.io.Serializable; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlTransient; @@ -34,7 +35,7 @@ public abstract class Action implements Serializable { private static final Logger logger = LoggerFactory.getLogger(Action.class); private static boolean debug = false; // Enable to find where in the code an // invalid assignment is made - @XmlTransient + @XmlElement protected ActionType type; private transient boolean isValid = true; diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java index a2d3d36c6f..c0c8da7ae2 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java @@ -29,7 +29,7 @@ public class TimeStamp extends Property { private static final long serialVersionUID = 1L; @XmlElement(name = "value") private long timestamp; - @XmlElement(name = "name") + @XmlElement(name = "timestampName") private String timestampName; public static final String TimeStampPropName = "timeStamp"; diff --git a/opendaylight/samples/northbound/loadbalancer/pom.xml b/opendaylight/samples/northbound/loadbalancer/pom.xml index 3b0ae0cdeb..5ec72024c2 100644 --- a/opendaylight/samples/northbound/loadbalancer/pom.xml +++ b/opendaylight/samples/northbound/loadbalancer/pom.xml @@ -58,6 +58,7 @@ javax.xml.bind, org.slf4j, org.apache.catalina.filters, + org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs /one/nb/v2/lb diff --git a/opendaylight/samples/northbound/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/northbound/LoadBalancerNorthbound.java b/opendaylight/samples/northbound/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/northbound/LoadBalancerNorthbound.java index 8ea0d78360..5a4473bf8c 100644 --- a/opendaylight/samples/northbound/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/northbound/LoadBalancerNorthbound.java +++ b/opendaylight/samples/northbound/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/northbound/LoadBalancerNorthbound.java @@ -208,9 +208,9 @@ public class LoadBalancerNorthbound { @ResponseCode(code = 409, condition = "VIP already exist"), @ResponseCode(code = 415, condition = "Invalid input data")}) public Response addVIP(@PathParam("containerName") String containerName, - @TypeHint(VIP.class) JAXBElement inVIP){ + @TypeHint(VIP.class) VIP inVIP){ - VIP vipInput = inVIP.getValue(); + VIP vipInput = inVIP; String name = vipInput.getName(); String ip = vipInput.getIp(); String protocol = vipInput.getProtocol(); @@ -253,9 +253,9 @@ public class LoadBalancerNorthbound { @ResponseCode(code = 405, condition = "Pool already attached to the VIP"), @ResponseCode(code = 415, condition = "Invalid input name")}) public Response updateVIP(@PathParam("containerName") String containerName, - @TypeHint(VIP.class) JAXBElement inVIP) { + @TypeHint(VIP.class) VIP inVIP) { - VIP vipInput = inVIP.getValue(); + VIP vipInput = inVIP; String name = vipInput.getName(); String poolName = vipInput.getPoolName(); if(name.isEmpty() || @@ -325,9 +325,9 @@ public class LoadBalancerNorthbound { @ResponseCode(code = 409, condition = "Pool already exist"), @ResponseCode(code = 415, condition = "Invalid input data")}) public Response addPool(@PathParam("containerName") String containerName, - @TypeHint(Pool.class) JAXBElement inPool) { + @TypeHint(Pool.class) Pool inPool) { - Pool poolInput = inPool.getValue(); + Pool poolInput = inPool; String name = poolInput.getName(); String lbMethod =poolInput.getLbMethod(); if(name.isEmpty() || @@ -398,9 +398,9 @@ public class LoadBalancerNorthbound { @ResponseCode(code = 409, condition = "Pool member already exist"), @ResponseCode(code = 415, condition = "Invalid input data")}) public Response addPoolMember(@PathParam("containerName") String containerName, - @TypeHint(PoolMember.class) JAXBElement inPoolMember){ + @TypeHint(PoolMember.class) PoolMember inPoolMember){ - PoolMember pmInput = inPoolMember.getValue(); + PoolMember pmInput = inPoolMember; String name = pmInput.getName(); String memberIP = pmInput.getIp(); String poolName = pmInput.getPoolName(); diff --git a/opendaylight/samples/northbound/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/northbound/LoadBalancerNorthboundRSApplication.java b/opendaylight/samples/northbound/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/northbound/LoadBalancerNorthboundRSApplication.java index 0c17c84ec4..2f5aacab67 100644 --- a/opendaylight/samples/northbound/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/northbound/LoadBalancerNorthboundRSApplication.java +++ b/opendaylight/samples/northbound/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/northbound/LoadBalancerNorthboundRSApplication.java @@ -12,6 +12,8 @@ import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; + /** * This class is an instance of javax.ws.rs.core.Application and is used to return the classes * that will be instantiated for JAXRS processing. This is necessary @@ -23,6 +25,7 @@ public class LoadBalancerNorthboundRSApplication extends Application { public Set> getClasses() { Set> classes = new HashSet>(); classes.add(LoadBalancerNorthbound.class); + classes.add(JacksonJaxbJsonProvider.class); return classes; } } -- 2.36.6