1 package org.openkilda.controller;
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.http.HttpStatus;
8 import org.springframework.stereotype.Controller;
9 import org.springframework.web.bind.annotation.PathVariable;
10 import org.springframework.web.bind.annotation.RequestBody;
11 import org.springframework.web.bind.annotation.RequestMapping;
12 import org.springframework.web.bind.annotation.RequestMethod;
13 import org.springframework.web.bind.annotation.ResponseBody;
14 import org.springframework.web.bind.annotation.ResponseStatus;
15 import org.springframework.web.servlet.ModelAndView;
18 import java.util.ArrayList;
19 import java.util.Collection;
20 import java.util.List;
22 import javax.servlet.http.HttpServletRequest;
43 @RequestMapping(
value =
"/flows")
46 private static final Logger LOGGER = LoggerFactory.getLogger(
FlowController.class);
65 public ModelAndView
flowList(
final HttpServletRequest request) {
75 @RequestMapping(
value =
"/details")
76 public ModelAndView flowDetails(final HttpServletRequest request) {
86 @RequestMapping(
value =
"/count", method = RequestMethod.GET)
87 @ResponseStatus(HttpStatus.OK)
88 public @ResponseBody Collection<
FlowCount> getFlowCount() {
89 Collection<FlowCount> flowsInfo =
new ArrayList<FlowCount>();
90 List<Flow> flows = flowService.getAllFlowList();
92 flowsInfo = flowService.getFlowsCount(flows);
102 @RequestMapping(
value =
"/list", method = RequestMethod.GET)
103 @ResponseStatus(HttpStatus.OK)
105 return flowService.getAllFlows();
114 @RequestMapping(
value =
"/path/{flowId}", method = RequestMethod.GET)
115 @ResponseStatus(HttpStatus.OK)
116 public @ResponseBody
FlowPayload getFlowPath(@PathVariable final String flowId) {
117 LOGGER.info(
"[getFlowPath] - start. Flow id: " + flowId);
118 return flowService.getFlowPath(flowId);
127 @RequestMapping(
value =
"/{flowId}/reroute", method = RequestMethod.GET)
128 @ResponseStatus(HttpStatus.OK)
129 public @ResponseBody
FlowPath rerouteFlow(@PathVariable final String flowId) {
131 LOGGER.info(
"[rerouteFlow] - start. Flow id: " + flowId);
132 return flowService.rerouteFlow(flowId);
141 @RequestMapping(
value =
"/{flowId}/validate", method = RequestMethod.GET)
142 @ResponseStatus(HttpStatus.OK)
143 public @ResponseBody String validateFlow(@PathVariable final String flowId) {
145 LOGGER.info(
"[validateFlow] - start. Flow id: " + flowId);
146 return flowService.validateFlow(flowId);
155 @RequestMapping(
value =
"/{flowId}", method = RequestMethod.GET)
156 @ResponseStatus(HttpStatus.OK)
157 public @ResponseBody
Flow getFlowById(@PathVariable final String flowId) {
158 LOGGER.info(
"[getFlowById] - start. Flow id: " + flowId);
159 return flowService.getFlowById(flowId);
168 @RequestMapping(
value =
"/{flowId}/status", method = RequestMethod.GET)
169 @ResponseStatus(HttpStatus.OK)
170 public @ResponseBody
FlowStatus getFlowStatusById(@PathVariable final String flowId) {
171 LOGGER.info(
"[getFlowStatusById] - start. Flow id: " + flowId);
172 return flowService.getFlowStatusById(flowId);
181 @RequestMapping(method = RequestMethod.PUT)
182 @ResponseStatus(HttpStatus.CREATED)
185 LOGGER.info(
"[createFlow] - start. Flow id: " + flow.getId());
186 return flowService.createFlow(flow);
196 @RequestMapping(
value =
"/{flowId}", method = RequestMethod.PUT)
197 @ResponseStatus(HttpStatus.CREATED)
199 public @ResponseBody
Flow updateFlow(@PathVariable(
"flowId")
final String flowId,@RequestBody
final Flow flow) {
200 LOGGER.info(
"[updateFlow] - start. Flow id: " + flowId);
201 return flowService.updateFlow(flowId, flow);
211 @RequestMapping(
value =
"/{flowId}", method = RequestMethod.DELETE)
212 @ResponseStatus(HttpStatus.OK)
215 @PathVariable(
"flowId")
final String flowId) {
216 LOGGER.info(
"[deleteFlow] - start. Flow id: " + flowId);
217 if (serverContext.getRequestContext() != null) {
218 userInfo.setUserId(serverContext.getRequestContext().getUserId());
220 return flowService.deleteFlow(flowId, userInfo);
Flow deleteFlow(@RequestBody final UserInfo userInfo, @PathVariable("flowId") final String flowId)
static final String FW_FLOW_UPDATE
static final String FW_FLOW_CREATE
Flow updateFlow(@PathVariable("flowId") final String flowId, @RequestBody final Flow flow)
static final String FLOW_DETAILS
Flow createFlow(@RequestBody final Flow flow)
static final String FW_FLOW_DELETE
static final String MENU_FLOWS
static final String FLOW_LIST
ModelAndView flowList(final HttpServletRequest request)