View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
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   * The Class ResetConnectorStatsController.
29   */
30  @Controller
31  public class ResetConnectorStatsController extends ParameterizableViewController {
32  
33    /** The collector bean. */
34    @Inject
35    private ConnectorStatsCollectorBean collectorBean;
36  
37    /**
38     * Gets the collector bean.
39     *
40     * @return the collector bean
41     */
42    public ConnectorStatsCollectorBean getCollectorBean() {
43      return collectorBean;
44    }
45  
46    /**
47     * Sets the collector bean.
48     *
49     * @param collectorBean the new collector bean
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  }