blob: 2863c79cdaf6f88817a45e4adb01e568b1042c57 [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
7import org.openflow.util.HexString;
8import org.restlet.resource.Get;
9import org.restlet.resource.ServerResource;
10import org.slf4j.Logger;
11import org.slf4j.LoggerFactory;
12
13public class GetFlowByIdResource extends ServerResource {
14 protected static Logger log = LoggerFactory.getLogger(GetFlowByIdResource.class);
15
16 @Get("json")
17 public FlowPath retrieve() {
18 FlowPath result = null;
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 String flowIdStr = (String) getRequestAttributes().get("flow-id");
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080031 FlowId flowId = new FlowId(HexString.toLong(flowIdStr));
32
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080033 log.debug("Get Flow Id: " + flowIdStr);
34
Pavlin Radoslavova10a9a82013-02-22 11:47:54 -080035 flowService.getFlow(flowId, result);
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080036
37 return result;
38 }
39}