blob: 85d5b7e7e5518a6dbb859ae3dc8adeab9310df4a [file] [log] [blame]
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08001package net.floodlightcontroller.flowcache.web;
2
3import net.floodlightcontroller.flowcache.IFlowService;
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -08004import net.floodlightcontroller.util.FlowId;
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08005import net.floodlightcontroller.util.FlowPath;
6
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08007import org.restlet.resource.Get;
8import org.restlet.resource.ServerResource;
9import org.slf4j.Logger;
10import org.slf4j.LoggerFactory;
11
12public 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 Radoslavov2013cbb2013-02-26 10:15:18 -080030 FlowId flowId = new FlowId(flowIdStr);
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080031
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080032 log.debug("Get Flow Id: " + flowIdStr);
33
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080034 result = flowService.getFlow(flowId);
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080035
36 return result;
37 }
38}