X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fweb%2Fflows%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fflows%2Fweb%2FFlows.java;h=7cb2b3a054f679b435f5c0963a6d80469800e3e4;hp=0254ab3152250f3f648c90fb74c1aece6961c4d7;hb=ea1001f9e92eb9ec1ec77eaad8af24a210626c7f;hpb=4dd0b2f1ff059a91237dde38d95083e3f6bfd295 diff --git a/opendaylight/web/flows/src/main/java/org/opendaylight/controller/flows/web/Flows.java b/opendaylight/web/flows/src/main/java/org/opendaylight/controller/flows/web/Flows.java index 0254ab3152..7cb2b3a054 100644 --- a/opendaylight/web/flows/src/main/java/org/opendaylight/controller/flows/web/Flows.java +++ b/opendaylight/web/flows/src/main/java/org/opendaylight/controller/flows/web/Flows.java @@ -22,7 +22,6 @@ import org.opendaylight.controller.sal.authorization.UserLevel; import org.opendaylight.controller.sal.core.Name; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.ServiceHelper; import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; @@ -30,6 +29,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.switchmanager.Switch; import org.opendaylight.controller.switchmanager.SwitchConfig; import org.opendaylight.controller.usermanager.IUserManager; +import org.opendaylight.controller.web.DaylightWebUtil; import org.opendaylight.controller.web.IDaylightWeb; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -47,7 +47,6 @@ public class Flows implements IDaylightWeb { private static final String WEB_NAME = "Flows"; private static final String WEB_ID = "flows"; private static final short WEB_ORDER = 2; - private final String containerName = GlobalConstants.DEFAULT.toString(); public Flows() { ServiceHelper.registerGlobalService(IDaylightWeb.class, this, null); @@ -75,7 +74,9 @@ public class Flows implements IDaylightWeb { @RequestMapping(value = "/main") @ResponseBody - public Set> getFlows() { + public Set> getFlows(HttpServletRequest request, @RequestParam(required = false) String container) { + String containerName = DaylightWebUtil.getAuthorizedContainer(request, container, this); + // fetch frm IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper .getInstance(IForwardingRulesManager.class, containerName, this); @@ -110,7 +111,9 @@ public class Flows implements IDaylightWeb { @RequestMapping(value = "/node-ports") @ResponseBody - public Map getNodePorts() { + public Map getNodePorts(HttpServletRequest request, @RequestParam(required = false) String container) { + String containerName = DaylightWebUtil.getAuthorizedContainer(request, container, this); + ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, containerName, this); if (switchManager == null) { @@ -155,14 +158,16 @@ public class Flows implements IDaylightWeb { @RequestMapping(value = "/node-flows") @ResponseBody - public Map getNodeFlows() { + public Map getNodeFlows(HttpServletRequest request, @RequestParam(required = false) String container) { + String containerName = DaylightWebUtil.getAuthorizedContainer(request, container, this); + ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, containerName, this); if (switchManager == null) { return null; } IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper - .getInstance(IForwardingRulesManager.class, "default", this); + .getInstance(IForwardingRulesManager.class, containerName, this); if (frm == null) { return null; } @@ -192,10 +197,12 @@ public class Flows implements IDaylightWeb { public String actionFlow(@RequestParam(required = true) String action, @RequestParam(required = false) String body, @RequestParam(required = true) String nodeId, - HttpServletRequest request) { + HttpServletRequest request, @RequestParam(required = false) String container) { if (!isUserAuthorized(UserLevel.NETWORKADMIN, request)) { return "Operation not authorized"; } + + String containerName = DaylightWebUtil.getAuthorizedContainer(request, container, this); IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper .getInstance(IForwardingRulesManager.class, containerName, this); @@ -221,11 +228,12 @@ public class Flows implements IDaylightWeb { public String removeFlow(@PathVariable("nodeId") String nodeId, @PathVariable("name") String name, @RequestParam(required = true) String action, - HttpServletRequest request) { + HttpServletRequest request, @RequestParam(required = false) String container) { if (!isUserAuthorized(UserLevel.NETWORKADMIN, request)) { - return "Operation not authorized"; } + + String containerName = DaylightWebUtil.getAuthorizedContainer(request, container, this); IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper .getInstance(IForwardingRulesManager.class, containerName, this);