1
2
3
4
5
6
7
8
9
10
11 package psiprobe.controllers.connectors;
12
13 import jakarta.inject.Inject;
14 import jakarta.servlet.http.HttpServletRequest;
15 import jakarta.servlet.http.HttpServletResponse;
16
17 import org.springframework.beans.factory.annotation.Value;
18 import org.springframework.stereotype.Controller;
19 import org.springframework.web.bind.ServletRequestUtils;
20 import org.springframework.web.bind.annotation.RequestMapping;
21 import org.springframework.web.servlet.ModelAndView;
22 import org.springframework.web.servlet.mvc.ParameterizableViewController;
23 import org.springframework.web.servlet.view.RedirectView;
24
25 import psiprobe.beans.stats.collectors.ConnectorStatsCollectorBean;
26
27
28
29
30 @Controller
31 public class ResetConnectorStatsController extends ParameterizableViewController {
32
33
34 @Inject
35 private ConnectorStatsCollectorBean collectorBean;
36
37
38
39
40
41
42 public ConnectorStatsCollectorBean getCollectorBean() {
43 return collectorBean;
44 }
45
46
47
48
49
50
51 public void setCollectorBean(ConnectorStatsCollectorBean collectorBean) {
52 this.collectorBean = collectorBean;
53 }
54
55 @RequestMapping(path = "/app/connectorReset.htm")
56 @Override
57 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
58 throws Exception {
59 return super.handleRequest(request, response);
60 }
61
62 @Override
63 protected ModelAndView handleRequestInternal(HttpServletRequest request,
64 HttpServletResponse response) throws Exception {
65
66 String connectorName = ServletRequestUtils.getRequiredStringParameter(request, "cn");
67 collectorBean.reset(connectorName);
68 return new ModelAndView(new RedirectView(request.getContextPath() + getViewName()));
69 }
70
71 @Value("/connectors.htm")
72 @Override
73 public void setViewName(String viewName) {
74 super.setViewName(viewName);
75 }
76
77 }