HIGUCHI Yuta | 60a1014 | 2013-06-14 15:50:10 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.flowmanager.web; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 2 | |
HIGUCHI Yuta | 60a1014 | 2013-06-14 15:50:10 -0700 | [diff] [blame] | 3 | import net.onrc.onos.ofcontroller.flowmanager.IFlowService; |
HIGUCHI Yuta | 356086e | 2013-06-12 15:21:19 -0700 | [diff] [blame] | 4 | import net.onrc.onos.ofcontroller.util.FlowId; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 5 | |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 6 | import org.restlet.resource.Get; |
| 7 | import org.restlet.resource.ServerResource; |
| 8 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; |
| 10 | |
| 11 | public class DeleteFlowResource extends ServerResource { |
| 12 | protected static Logger log = LoggerFactory.getLogger(DeleteFlowResource.class); |
| 13 | |
| 14 | @Get("json") |
| 15 | public Boolean retrieve() { |
| 16 | Boolean result = false; |
| 17 | |
| 18 | IFlowService flowService = |
| 19 | (IFlowService)getContext().getAttributes(). |
| 20 | get(IFlowService.class.getCanonicalName()); |
| 21 | |
| 22 | if (flowService == null) { |
| 23 | log.debug("ONOS Flow Service not found"); |
| 24 | return result; |
| 25 | } |
| 26 | |
| 27 | // Extract the arguments |
| 28 | String flowIdStr = (String) getRequestAttributes().get("flow-id"); |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 29 | |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 30 | // Process the request |
Pavlin Radoslavov | baea924 | 2013-05-08 00:20:09 +0000 | [diff] [blame] | 31 | if (flowIdStr.equals("all")) { |
| 32 | log.debug("Delete All Flows"); |
| 33 | result = flowService.deleteAllFlows(); |
| 34 | } else { |
| 35 | FlowId flowId = new FlowId(flowIdStr); |
| 36 | log.debug("Delete Flow Id: " + flowIdStr); |
| 37 | result = flowService.deleteFlow(flowId); |
| 38 | } |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 39 | return result; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 40 | } |
| 41 | } |