Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.flowcache.web; |
| 2 | |
| 3 | import net.floodlightcontroller.flowcache.IFlowService; |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 4 | import net.floodlightcontroller.util.FlowId; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 5 | import net.floodlightcontroller.util.FlowPath; |
| 6 | |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 7 | import org.restlet.resource.Get; |
| 8 | import org.restlet.resource.ServerResource; |
| 9 | import org.slf4j.Logger; |
| 10 | import org.slf4j.LoggerFactory; |
| 11 | |
| 12 | public class GetFlowByIdResource extends ServerResource { |
| 13 | protected static Logger log = LoggerFactory.getLogger(GetFlowByIdResource.class); |
| 14 | |
| 15 | @Get("json") |
| 16 | public FlowPath retrieve() { |
| 17 | FlowPath result = null; |
| 18 | |
| 19 | IFlowService flowService = |
| 20 | (IFlowService)getContext().getAttributes(). |
| 21 | get(IFlowService.class.getCanonicalName()); |
| 22 | |
| 23 | if (flowService == null) { |
| 24 | log.debug("ONOS Flow Service not found"); |
| 25 | return result; |
| 26 | } |
| 27 | |
| 28 | // Extract the arguments |
| 29 | String flowIdStr = (String) getRequestAttributes().get("flow-id"); |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 30 | FlowId flowId = new FlowId(flowIdStr); |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 31 | |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 32 | log.debug("Get Flow Id: " + flowIdStr); |
| 33 | |
Pavlin Radoslavov | b6f5354 | 2013-03-01 16:02:14 -0800 | [diff] [blame] | 34 | result = flowService.getFlow(flowId); |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 35 | |
| 36 | return result; |
| 37 | } |
| 38 | } |