1
2
3
4
5
6
7
8
9
10
11 package psiprobe.controllers.logs;
12
13 import jakarta.inject.Inject;
14 import jakarta.servlet.http.HttpServletRequest;
15 import jakarta.servlet.http.HttpServletResponse;
16
17 import java.util.List;
18
19 import org.springframework.beans.factory.annotation.Value;
20 import org.springframework.stereotype.Controller;
21 import org.springframework.web.bind.ServletRequestUtils;
22 import org.springframework.web.bind.annotation.RequestMapping;
23 import org.springframework.web.servlet.ModelAndView;
24 import org.springframework.web.servlet.mvc.ParameterizableViewController;
25
26 import psiprobe.beans.LogResolverBean;
27 import psiprobe.tools.logging.LogDestination;
28
29
30
31
32 @Controller
33 public class ListLogsController extends ParameterizableViewController {
34
35
36 private String errorView;
37
38
39 @Inject
40 private LogResolverBean logResolver;
41
42
43
44
45
46
47 public String getErrorView() {
48 return errorView;
49 }
50
51
52
53
54
55
56 @Value("logs_notsupported")
57 public void setErrorView(String errorView) {
58 this.errorView = errorView;
59 }
60
61
62
63
64
65
66 public LogResolverBean getLogResolver() {
67 return logResolver;
68 }
69
70
71
72
73
74
75 public void setLogResolver(LogResolverBean logResolver) {
76 this.logResolver = logResolver;
77 }
78
79 @RequestMapping(path = {"/logs", "/list.htm"})
80 @Override
81 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
82 throws Exception {
83 return super.handleRequest(request, response);
84 }
85
86 @Override
87 protected ModelAndView handleRequestInternal(HttpServletRequest request,
88 HttpServletResponse response) throws Exception {
89
90 boolean showAll = ServletRequestUtils.getBooleanParameter(request, "apps", false);
91 List<LogDestination> uniqueList = logResolver.getLogDestinations(showAll);
92 if (!uniqueList.isEmpty()) {
93 return new ModelAndView(getViewName()).addObject("logs", uniqueList);
94 }
95 return new ModelAndView(errorView);
96 }
97
98 @Value("logs")
99 @Override
100 public void setViewName(String viewName) {
101 super.setViewName(viewName);
102 }
103
104 }