1 package org.jahia.services.htmleditors.fckeditor; 2 3 import javax.servlet.ServletException ; 4 import javax.servlet.http.HttpServlet ; 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.http.HttpServletResponse ; 7 8 import org.apache.log4j.Logger; 9 import org.jahia.bin.Jahia; 10 import org.jahia.exceptions.JahiaException; 11 import org.jahia.params.AdminParamBean; 12 import org.jahia.params.ParamBean; 13 import org.jahia.services.database.ConnectionDispenser; 14 import org.jahia.services.sites.JahiaSite; 15 import org.jahia.services.usermanager.JahiaUser; 16 17 22 23 public abstract class FCKeditorBaseConnector extends HttpServlet 24 { 25 26 protected static transient Logger logger = Logger 27 .getLogger(FCKeditorBaseConnector.class); 28 29 protected ParamBean getJahiaParamBean(HttpServletRequest request, 30 HttpServletResponse response) throws ServletException 31 { 32 return getJahiaParamBean(request, response, true); 33 } 34 35 protected ParamBean getJahiaParamBean(HttpServletRequest request, 36 HttpServletResponse response, boolean allowAdminParamBean) 37 throws ServletException 38 { 39 ParamBean jParams; 40 try 41 { 42 JahiaSite site = null; 43 JahiaUser user = null; 44 if (allowAdminParamBean) 45 { 46 site = (JahiaSite)request.getSession().getAttribute( 47 ParamBean.SESSION_SITE); 48 user = (JahiaUser)request.getSession().getAttribute( 49 ParamBean.SESSION_USER); 50 } 51 52 if (site != null && user != null) 53 { 54 jParams = new AdminParamBean(request, response, getServletContext(), 55 Jahia.getSettings(), System.currentTimeMillis(), 56 ParamBean.GET_METHOD, site, user, null); 57 } 58 else 59 { 60 jParams = new ParamBean(request, response, getServletContext(), Jahia 61 .getSettings(), System.currentTimeMillis(), ParamBean.GET_METHOD); 62 } 63 } 64 catch (JahiaException ex) 65 { 66 logger 67 .error( 68 "Unable to create Jahia ParamBean. Failed processing FCKeditor command", 69 ex); 70 throw new ServletException ( 71 "Unable to create Jahia ParamBean. Failed processing FCKeditor command", 72 ex); 73 } 74 75 return jParams; 76 } 77 78 protected void releaseResources() 79 { 80 ConnectionDispenser.terminateConnection(); 81 } 82 } 83 | Popular Tags |