1 13 package info.magnolia.module.admininterface; 14 15 import info.magnolia.cms.core.Content; 16 import info.magnolia.cms.servlets.MVCServlet; 17 import info.magnolia.cms.servlets.MVCServletHandler; 18 import info.magnolia.cms.util.RequestFormUtil; 19 import info.magnolia.module.admininterface.dialogs.ConfiguredDialog; 20 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpServletResponse ; 23 24 import org.apache.commons.lang.StringUtils; 25 import org.apache.log4j.Logger; 26 27 28 32 public class DialogMVCServlet extends MVCServlet { 33 34 37 private static final long serialVersionUID = 222L; 38 39 42 private static Logger log = Logger.getLogger(DialogMVCServlet.class); 43 44 47 protected MVCServletHandler getHandler(HttpServletRequest request, HttpServletResponse response) { 48 String dialogName = RequestFormUtil.getParameter(request, "mgnlDialog"); 50 if (StringUtils.isEmpty(dialogName)) { 51 if (StringUtils.isEmpty(dialogName)) { 52 dialogName = (String ) request.getAttribute("javax.servlet.include.request_uri"); if (StringUtils.isEmpty(dialogName)) { 54 dialogName = (String ) request.getAttribute("javax.servlet.forward.servlet_path"); } 56 if (StringUtils.isEmpty(dialogName)) { 57 dialogName = request.getRequestURI(); 58 } 59 dialogName = StringUtils.replaceOnce(StringUtils.substringAfterLast(dialogName, "/dialogs/"), ".html", StringUtils.EMPTY); 61 } 62 } 63 64 DialogMVCHandler handler = null; 65 66 if (StringUtils.isNotBlank(dialogName)) { 67 try { 69 handler = Store.getInstance().getDialogHandler(dialogName, request, response); 70 } 71 catch (InvalidDialogHandlerException e) { 72 log.info("can't find handler will try to load directly from the config", e); Content configNode = ConfiguredDialog.getConfigNode(request, dialogName); 74 if (configNode != null) { 76 handler = ConfiguredDialog.getConfiguredDialog(dialogName, configNode, request, response); 77 } 78 else { 79 log.error("no config node found for dialog : " + dialogName); } 81 } 82 } 83 84 if (handler == null) { 85 log.error("no dialog found: " + dialogName); } 87 88 return handler; 89 } 90 91 } | Popular Tags |