Merge "Bug #25: Installing/removing flows with ".""
[controller.git] / opendaylight / web / flows / src / main / java / org / opendaylight / controller / flows / web / Flows.java
index f9e6a6aaae24aef573a32a7acda652a731b3d64a..be7560985a56fdeb3df3ae1d28020f8f87cd56a7 100644 (file)
@@ -75,12 +75,13 @@ public class Flows implements IDaylightWeb {
 
     @RequestMapping(value = "/main")
     @ResponseBody
-    public Set<Map<String, Object>> getFlows(HttpServletRequest request, @RequestParam(required = false) String container) {
+    public Map<String, Object> getFlows(HttpServletRequest request, @RequestParam(required = false) String container) {
         String containerName = (container == null) ? GlobalConstants.DEFAULT.toString() : container;
 
         // Derive the privilege this user has on the current container
         String userName = request.getUserPrincipal().getName();
-        if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) == Privilege.NONE) {
+        Privilege privilege = DaylightWebUtil.getContainerPrivilege(userName, containerName, this);
+        if (privilege  == Privilege.NONE) {
             return null;
         }
 
@@ -100,7 +101,7 @@ public class Flows implements IDaylightWeb {
 
         // get static flow list
         List<FlowConfig> staticFlowList = frm.getStaticFlows();
-        Set<Map<String, Object>> output = new HashSet<Map<String, Object>>();
+        Set<Map<String, Object>> flowSet = new HashSet<Map<String, Object>>();
         for (FlowConfig flowConfig : staticFlowList) {
             Map<String, Object> entry = new HashMap<String, Object>();
             entry.put("flow", flowConfig);
@@ -110,9 +111,12 @@ public class Flows implements IDaylightWeb {
             entry.put("node", (description.isEmpty() || description
                     .equalsIgnoreCase("none")) ? node.toString() : description);
             entry.put("nodeId", node.toString());
-            output.add(entry);
+            flowSet.add(entry);
         }
 
+        Map <String, Object> output = new HashMap<String, Object>(2);
+        output.put("flows", flowSet);
+        output.put("privilege", privilege);
         return output;
     }
 
@@ -244,7 +248,7 @@ public class Flows implements IDaylightWeb {
                 .getDescription();
     }
 
-    @RequestMapping(value = "/flow/{nodeId}/{name}", method = RequestMethod.POST)
+    @RequestMapping(value = "/flow/{nodeId}/{name:.*}", method = RequestMethod.POST)
     @ResponseBody
     public String removeFlow(@PathVariable("nodeId") String nodeId,
             @PathVariable("name") String name,