KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > admininterface > DialogPageMVCServlet


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

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 JavaDoc;
20 import javax.servlet.http.HttpServletResponse JavaDoc;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.apache.log4j.Logger;
24
25
26 /**
27  * @author Philipp Bracher
28  * @version $Id$
29  */

30 public class DialogPageMVCServlet extends MVCServlet {
31
32     /**
33      * Stable serialVersionUID.
34      */

35     private static final long serialVersionUID = 222L;
36
37     /**
38      * Logger.
39      */

40     private static Logger log = Logger.getLogger(DialogPageMVCServlet.class);
41
42     /**
43      *
44      */

45     protected MVCServletHandler getHandler(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
46
47         String JavaDoc pageName = RequestFormUtil.getParameter(request, "mgnlPage"); //$NON-NLS-1$
48
if (StringUtils.isEmpty(pageName)) {
49             pageName = (String JavaDoc) request.getAttribute("javax.servlet.include.request_uri"); //$NON-NLS-1$
50
if (StringUtils.isEmpty(pageName)) {
51                 pageName = (String JavaDoc) request.getAttribute("javax.servlet.forward.servlet_path"); //$NON-NLS-1$
52
}
53             if (StringUtils.isEmpty(pageName)) {
54                 pageName = request.getRequestURI();
55             }
56             pageName = StringUtils.replaceOnce(StringUtils.substringAfterLast(pageName, "/dialogpages/"), ".html", //$NON-NLS-1$ //$NON-NLS-2$
57
StringUtils.EMPTY);
58         }
59
60         DialogPageMVCHandler handler = null;
61
62         if (pageName != null) {
63             // try to get a registered handler
64
try {
65                 handler = Store.getInstance().getDialogPageHandler(pageName, request, response);
66             }
67             catch (InvalidDialogPageHandlerException e) {
68                 log.error("no dialogpage found: " + pageName); //$NON-NLS-1$
69
}
70         }
71         else {
72             log.error("no dialogpage name passed"); //$NON-NLS-1$
73
}
74
75         return handler;
76     }
77
78 }
Popular Tags