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.apps;
12  
13  import javax.servlet.http.HttpServletRequest;
14  import javax.servlet.http.HttpServletResponse;
15  
16  import org.apache.catalina.Context;
17  import org.springframework.beans.factory.annotation.Value;
18  import org.springframework.stereotype.Controller;
19  import org.springframework.web.bind.annotation.RequestMapping;
20  import org.springframework.web.servlet.ModelAndView;
21  
22  import psiprobe.controllers.AbstractContextHandlerController;
23  import psiprobe.tools.ApplicationUtils;
24  import psiprobe.tools.SecurityUtils;
25  
26  /**
27   * Retrieves a list of context initialization parameters for a web application.
28   */
29  @Controller
30  public class ListAppInitParamsController extends AbstractContextHandlerController {
31  
32    @RequestMapping(path = "/appinitparams.htm")
33    @Override
34    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
35        throws Exception {
36      return super.handleRequest(request, response);
37    }
38  
39    @Override
40    protected ModelAndView handleContext(String contextName, Context context,
41        HttpServletRequest request, HttpServletResponse response) throws Exception {
42  
43      ModelAndView mv = new ModelAndView(getViewName(), "appInitParams",
44          ApplicationUtils.getApplicationInitParams(context, getContainerWrapper()));
45      if (SecurityUtils.hasAttributeValueRole(getServletContext())) {
46        mv.addObject("allowedToViewValues", Boolean.TRUE);
47      }
48      return mv;
49    }
50  
51    @Value("appinitparams")
52    @Override
53    public void setViewName(String viewName) {
54      super.setViewName(viewName);
55    }
56  
57  }