blob: 48e7369be55d906535afe4fc54ebce0a4e0aa0f5 [file] [log] [blame]
HIGUCHI Yuta60a10142013-06-14 15:50:10 -07001package net.onrc.onos.ofcontroller.flowmanager.web;
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08002
HIGUCHI Yuta60a10142013-06-14 15:50:10 -07003import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07004import net.onrc.onos.ofcontroller.util.FlowId;
5import net.onrc.onos.ofcontroller.util.FlowPath;
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08006
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}