1 13 package info.magnolia.module.admininterface; 14 15 import info.magnolia.cms.servlets.MVCServlet; 16 import info.magnolia.cms.servlets.MVCServletHandler; 17 import info.magnolia.cms.util.RequestFormUtil; 18 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.http.HttpServletResponse ; 21 22 import org.apache.commons.lang.StringUtils; 23 import org.slf4j.Logger; 24 import org.slf4j.LoggerFactory; 25 26 27 31 public class PageMVCServlet extends MVCServlet { 32 33 36 private static final long serialVersionUID = 222L; 37 38 41 private static Logger log = LoggerFactory.getLogger(PageMVCServlet.class); 42 43 46 protected MVCServletHandler getHandler(HttpServletRequest request, HttpServletResponse response) { 47 48 String pageName = RequestFormUtil.getParameter(request, "mgnlPage"); if (StringUtils.isEmpty(pageName)) { 50 pageName = (String ) request.getAttribute("javax.servlet.include.request_uri"); if (StringUtils.isEmpty(pageName)) { 52 pageName = (String ) request.getAttribute("javax.servlet.forward.servlet_path"); } 54 if (StringUtils.isEmpty(pageName)) { 55 pageName = request.getRequestURI(); 56 } 57 pageName = StringUtils.substringAfterLast(pageName, "/pages/"); 59 pageName = StringUtils.substringBeforeLast(pageName, "."); 61 } 62 63 PageMVCHandler handler = null; 64 65 if (pageName != null) { 66 try { 68 handler = PageHandlerManager.getInstance().getPageHandler(pageName, request, response); 69 } 70 catch (InvalidDialogPageHandlerException e) { 71 log.error("no page found: [" + pageName + "]"); } 73 } 74 else { 75 log.error("no dialogpage name passed"); } 77 78 return handler; 79 } 80 81 } | Popular Tags |