Leftover follow-up commit for "1c8f47754241fea8b9c1463c08539ec31638a5de":
* Use the "@JsonProperty()" annotation to serialize/deserialize
objects that don't require any specialized processing.
Use "@JsonSerialize" and "@JsonDeserialize" only for objects
that need more specialized processing.
* Remove FooSerializer JSON classes that are not used/needed anymore.
* Update the implementation of remaining FooSerializer classes,
and associated Foo classes.
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
index f32d124..feb43d3 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
@@ -1,9 +1,15 @@
package net.floodlightcontroller.flowcache.web;
+import java.io.IOException;
+
import net.floodlightcontroller.flowcache.IFlowService;
import net.floodlightcontroller.util.FlowId;
import net.floodlightcontroller.util.FlowPath;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -26,14 +32,29 @@
return result;
}
+ //
// Extract the arguments
+ // NOTE: The "flow" is specified in JSON format.
+ //
+ ObjectMapper mapper = new ObjectMapper();
String flowPathStr = (String) getRequestAttributes().get("flow");
- FlowPath flowPath = new FlowPath(flowPathStr);
-
+ FlowPath flowPath = null;
log.debug("Add Flow Path: " + flowPathStr);
+ try {
+ flowPath = mapper.readValue(flowPathStr, FlowPath.class);
+ } catch (JsonGenerationException e) {
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
- if (flowService.addFlow(flowPath, result) != true) {
- result = new FlowId(); // Error: Empty Flow Id
+ // Process the request
+ if (flowPath != null) {
+ if (flowService.addFlow(flowPath, result) != true) {
+ result = new FlowId(); // Error: Return empty Flow Id
+ }
}
return result;
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
index cefad18..f418c1e 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
@@ -27,12 +27,11 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
- FlowId flowId = new FlowId(HexString.toLong(flowIdStr));
-
+ FlowId flowId = new FlowId(flowIdStr);
log.debug("Delete Flow Id: " + flowIdStr);
+ // Process the request
result = flowService.deleteFlow(flowId);
-
- return result;
+ return result;
}
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
index 4e96c0c..c485d91 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
@@ -9,7 +9,6 @@
import net.floodlightcontroller.util.Port;
import net.floodlightcontroller.util.SwitchPort;
-import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -40,9 +39,9 @@
log.debug("Get All Flows Endpoints: " + srcDpidStr + "--" +
srcPortStr + "--" + dstDpidStr + "--" + dstPortStr);
- Dpid srcDpid = new Dpid(HexString.toLong(srcDpidStr));
+ Dpid srcDpid = new Dpid(srcDpidStr);
Port srcPort = new Port(Short.parseShort(srcPortStr));
- Dpid dstDpid = new Dpid(HexString.toLong(dstDpidStr));
+ Dpid dstDpid = new Dpid(dstDpidStr);
Port dstPort = new Port(Short.parseShort(dstPortStr));
SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
index 5bf3a50..deb4d04 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
@@ -30,6 +30,8 @@
log.debug("Get All Flows Endpoints");
flowService.getAllFlows(result);
+ FlowPath flowPath = new FlowPath();
+ result.add(flowPath);
return result;
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
index 2863c79..d5b2730 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
@@ -4,7 +4,6 @@
import net.floodlightcontroller.util.FlowId;
import net.floodlightcontroller.util.FlowPath;
-import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -28,7 +27,7 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
- FlowId flowId = new FlowId(HexString.toLong(flowIdStr));
+ FlowId flowId = new FlowId(flowIdStr);
log.debug("Get Flow Id: " + flowIdStr);
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
index 6b5f7f4..cb4e6ef 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
@@ -8,7 +8,6 @@
import net.floodlightcontroller.util.Port;
import net.floodlightcontroller.util.SwitchPort;
-import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -42,9 +41,9 @@
dstDpidStr + "--" + dstPortStr);
CallerId installerId = new CallerId(installerIdStr);
- Dpid srcDpid = new Dpid(HexString.toLong(srcDpidStr));
+ Dpid srcDpid = new Dpid(srcDpidStr);
Port srcPort = new Port(Short.parseShort(srcPortStr));
- Dpid dstDpid = new Dpid(HexString.toLong(dstDpidStr));
+ Dpid dstDpid = new Dpid(dstDpidStr);
Port dstPort = new Port(Short.parseShort(dstPortStr));
SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);