1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.admininterface;
35
36 import info.magnolia.cms.servlets.MVCServlet;
37 import info.magnolia.cms.servlets.MVCServletHandler;
38 import info.magnolia.cms.util.RequestFormUtil;
39
40 import javax.servlet.http.HttpServletRequest;
41 import javax.servlet.http.HttpServletResponse;
42
43 import org.apache.commons.lang.StringUtils;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46
47
48
49
50
51
52 public class PageMVCServlet extends MVCServlet {
53
54
55
56
57 private static final long serialVersionUID = 222L;
58
59
60
61
62 private static Logger log = LoggerFactory.getLogger(PageMVCServlet.class);
63
64
65
66
67 protected MVCServletHandler getHandler(HttpServletRequest request, HttpServletResponse response) {
68
69 String pageName = RequestFormUtil.getParameter(request, "mgnlPage");
70 if (StringUtils.isEmpty(pageName)) {
71 if (StringUtils.isNotEmpty((String) request.getAttribute("javax.servlet.include.servlet_path"))) {
72 pageName = (String) request.getAttribute("javax.servlet.include.path_info");
73 }
74
75 if (StringUtils.isEmpty(pageName)) {
76 pageName = request.getPathInfo();
77 }
78
79
80 pageName = StringUtils.substringAfterLast(pageName, "/");
81
82 pageName = StringUtils.substringBeforeLast(pageName, ".");
83 }
84
85 PageMVCHandler handler = null;
86
87 if (StringUtils.isNotEmpty(pageName)) {
88
89 try {
90 handler = PageHandlerManager.getInstance().getPageHandler(pageName, request, response);
91 }
92 catch (InvalidDialogPageHandlerException e) {
93 log.error("Could not instanciate page handler with name " + pageName, e);
94 }
95 }
96 else {
97 log.warn("No dialogpage name passed for url {}", request.getRequestURI());
98 }
99
100 return handler;
101 }
102
103 }