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 | |
| 3 | import java.util.ArrayList; |
| 4 | |
HIGUCHI Yuta | 60a1014 | 2013-06-14 15:50:10 -0700 | [diff] [blame] | 5 | import net.onrc.onos.ofcontroller.flowmanager.IFlowService; |
HIGUCHI Yuta | 356086e | 2013-06-12 15:21:19 -0700 | [diff] [blame] | 6 | import net.onrc.onos.ofcontroller.util.FlowPath; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 7 | |
| 8 | import org.restlet.resource.Get; |
| 9 | import org.restlet.resource.ServerResource; |
| 10 | import org.slf4j.Logger; |
| 11 | import org.slf4j.LoggerFactory; |
| 12 | |
admin | 944ef4f | 2013-10-08 17:48:37 -0700 | [diff] [blame] | 13 | /** |
HIGUCHI Yuta | eb567aa | 2013-10-08 19:27:35 -0700 | [diff] [blame] | 14 | * Flow Manager REST API implementation: Get all Flow state. |
admin | 944ef4f | 2013-10-08 17:48:37 -0700 | [diff] [blame] | 15 | * |
| 16 | * GET /wm/flow/getall/json" |
| 17 | */ |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 18 | public class GetAllFlowsResource extends ServerResource { |
Yuta HIGUCHI | 6ac8d18 | 2013-10-22 15:24:56 -0700 | [diff] [blame] | 19 | protected final static Logger log = LoggerFactory.getLogger(GetAllFlowsResource.class); |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 20 | |
admin | 944ef4f | 2013-10-08 17:48:37 -0700 | [diff] [blame] | 21 | /** |
| 22 | * Implement the API. |
| 23 | * |
| 24 | * @return the collection of Flow states if any found, otherwise null. |
| 25 | */ |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 26 | @Get("json") |
| 27 | public ArrayList<FlowPath> retrieve() { |
Pavlin Radoslavov | b6f5354 | 2013-03-01 16:02:14 -0800 | [diff] [blame] | 28 | ArrayList<FlowPath> result = null; |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 29 | |
| 30 | IFlowService flowService = |
| 31 | (IFlowService)getContext().getAttributes(). |
| 32 | get(IFlowService.class.getCanonicalName()); |
| 33 | |
| 34 | if (flowService == null) { |
| 35 | log.debug("ONOS Flow Service not found"); |
| 36 | return result; |
| 37 | } |
| 38 | |
| 39 | // Extract the arguments |
| 40 | log.debug("Get All Flows Endpoints"); |
| 41 | |
Pavlin Radoslavov | b6f5354 | 2013-03-01 16:02:14 -0800 | [diff] [blame] | 42 | result = flowService.getAllFlows(); |
Pavlin Radoslavov | 5ab6851 | 2013-02-18 09:59:33 -0800 | [diff] [blame] | 43 | |
| 44 | return result; |
| 45 | } |
| 46 | } |