blob: deb4d048b9c628b11182138f0293491cb24196ba [file] [log] [blame]
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08001package net.floodlightcontroller.flowcache.web;
2
3import java.util.ArrayList;
4
5import net.floodlightcontroller.flowcache.IFlowService;
6import net.floodlightcontroller.util.FlowPath;
7
8import org.restlet.resource.Get;
9import org.restlet.resource.ServerResource;
10import org.slf4j.Logger;
11import org.slf4j.LoggerFactory;
12
13public class GetAllFlowsResource extends ServerResource {
14 protected static Logger log = LoggerFactory.getLogger(GetAllFlowsResource.class);
15
16 @Get("json")
17 public ArrayList<FlowPath> retrieve() {
18 ArrayList<FlowPath> result = new ArrayList<FlowPath>();
19
20 IFlowService flowService =
21 (IFlowService)getContext().getAttributes().
22 get(IFlowService.class.getCanonicalName());
23
24 if (flowService == null) {
25 log.debug("ONOS Flow Service not found");
26 return result;
27 }
28
29 // Extract the arguments
30 log.debug("Get All Flows Endpoints");
31
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080032 flowService.getAllFlows(result);
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080033 FlowPath flowPath = new FlowPath();
34 result.add(flowPath);
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080035
36 return result;
37 }
38}