KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > htmleditors > fckeditor > FCKeditorBaseConnector


1 package org.jahia.services.htmleditors.fckeditor;
2
3 import javax.servlet.ServletException JavaDoc;
4 import javax.servlet.http.HttpServlet JavaDoc;
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
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 /**
18  * FCKeditor Connector for Jahia.
19  *
20  * @author Sergiy Shyrkov
21  */

22
23 public abstract class FCKeditorBaseConnector extends HttpServlet JavaDoc
24 {
25   /** An instance of logger for this class. */
26   protected static transient Logger logger = Logger
27     .getLogger(FCKeditorBaseConnector.class);
28
29   protected ParamBean getJahiaParamBean(HttpServletRequest JavaDoc request,
30     HttpServletResponse JavaDoc response) throws ServletException JavaDoc
31   {
32     return getJahiaParamBean(request, response, true);
33   }
34
35   protected ParamBean getJahiaParamBean(HttpServletRequest JavaDoc request,
36     HttpServletResponse JavaDoc response, boolean allowAdminParamBean)
37     throws ServletException JavaDoc
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 JavaDoc(
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