+ return (result.isSuccess()) ? StatusCode.SUCCESS.toString() : result.getDescription();
+ }
+
+ @SuppressWarnings("unchecked")
+ @RequestMapping(value = "/flow/deleteFlows", method = RequestMethod.POST)
+ @ResponseBody
+ public String removeSelectedFlows(@RequestParam(required = false) String body, HttpServletRequest request,
+ @RequestParam(required = false) String container) {
+ String containerName = (container == null) ? GlobalConstants.DEFAULT.toString() : container;
+
+ // Authorization check
+ String userName = request.getUserPrincipal().getName();
+ if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) != Privilege.WRITE) {
+ return "Operation not authorized";
+ }
+ IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
+ IForwardingRulesManager.class, containerName, this);
+ if (frm == null) {
+ return "Forwarding Rules Manager is not available";
+ }
+
+ List<Map<String, String>> flowList = new ArrayList<Map<String, String>>();
+ flowList = gson.fromJson(body, flowList.getClass());
+ Status result = new Status(StatusCode.BADREQUEST, "Invalid request");
+ String status = "";
+ for (Map<String, String> flowEntry : flowList) {
+ Node node = Node.fromString(flowEntry.get("node"));
+ result = frm.removeStaticFlow(flowEntry.get("name"), node);
+ if (result.isSuccess()) {
+ DaylightWebUtil.auditlog("Flow Entry", userName, "removed", flowEntry.get("name") + " on Node "
+ + DaylightWebUtil.getNodeDesc(node, containerName, this), containerName);
+ } else {
+ status = flowEntry.get("name") + ", " + status;
+ }
+ }
+ if (!status.equals("")) {
+ return "Could not remove " + status.substring(0, status.length() - 2) + " Flow(s)";
+ } else {
+ return "Success";
+ }