KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > admin > users > GroupMembersTool


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13

14 package org.jahia.admin.users;
15
16 import java.io.IOException JavaDoc;
17 import javax.servlet.ServletException JavaDoc;
18 import javax.servlet.http.HttpServletRequest JavaDoc;
19 import javax.servlet.http.HttpServletResponse JavaDoc;
20 import javax.servlet.http.HttpSession JavaDoc;
21
22 import org.jahia.bin.JahiaAdministration;
23 import org.jahia.data.JahiaData;
24 import org.jahia.data.viewhelper.principal.PrincipalViewHelper;
25 import org.jahia.params.ParamBean;
26 import org.jahia.registries.ServicesRegistry;
27 import org.jahia.resourcebundle.JahiaResourceBundle;
28 import org.jahia.services.sites.JahiaSite;
29 import org.jahia.services.usermanager.JahiaUserManagerService;
30
31 /**
32  * desc: This class is used by the administration to select future group members.
33  *
34  * Copyright: Copyright (c) 2002
35  * Company: Jahia Ltd
36  *
37  * @version 1.0
38  */

39 public class GroupMembersTool
40 {
41     private static final String JavaDoc CLASS_NAME = GroupMembersTool.class.getName();
42     private static final String JavaDoc JSP_PATH = JahiaAdministration.JSP_PATH;
43
44     private JahiaSite jahiaSite;
45
46     public static final String JavaDoc ENGINE_LAUNCHER_NAME = CLASS_NAME;
47
48     /**
49      * Default constructor.
50      *
51      * @param request Servlet request.
52      * @param response Servlet response.
53      * @param session Servlet session.
54      */

55     public GroupMembersTool(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response,
56                             HttpSession JavaDoc session)
57     {
58         // get the current website. get the jahiaserver if it's null...
59
jahiaSite = (JahiaSite)session.getAttribute(ParamBean.SESSION_SITE);
60         // continue the execution of the request...
61
requestDispatcher(request, response, session);
62     }
63
64     /**
65      * This method is used like a dispatcher for home page tool requests.
66      *
67      * @param request Servlet request.
68      * @param response Servlet response.
69      * @param session Servlet session.
70      */

71     public void requestDispatcher(HttpServletRequest JavaDoc request,
72                                   HttpServletResponse JavaDoc response,
73                                   HttpSession JavaDoc session)
74     {
75         String JavaDoc operation = request.getParameter("subaction");
76         if (operation.equals("display")) {
77             displayGroupMembersTool(request, response, session);
78         } else if (operation.equals("search")) {
79             displayGroupMembersTool(request, response, session);
80         }
81     }
82
83     /**
84      * Forward the servlet request and servlet response objects, using the request
85      * dispatcher (from the ServletContext). Note: please be careful, use only
86      * context relative path.
87      *
88      * @param request servlet request.
89      * @param response servlet response.
90      * @param target target, context-relative path.
91      */

92     private void doRedirect(HttpServletRequest JavaDoc request,
93                             HttpServletResponse JavaDoc response,
94                             HttpSession JavaDoc session,
95                             String JavaDoc target )
96     {
97         try {
98             JahiaAdministration.doRedirect(request, response, session, target);
99         } catch (IOException JavaDoc ie) {
100             logger.error("Error", ie);
101         } catch (ServletException JavaDoc se) {
102             logger.error("Error", se.getRootCause());
103         }
104     }
105
106     /**
107      * Display the group members issuing from the user search engine.
108      *
109      * @param request
110      * @param response
111      * @param session
112      */

113     private void displayGroupMembersTool(HttpServletRequest JavaDoc request,
114                                          HttpServletResponse JavaDoc response,
115                                          HttpSession JavaDoc session)
116     {
117         logger.debug("Started");
118         JahiaUserManagerService uMgr = ServicesRegistry.getInstance().getJahiaUserManagerService();
119         request.setAttribute("providerList", uMgr.getProviderList());
120         request.setAttribute("resultList", PrincipalViewHelper.getSearchResult(request, jahiaSite.getID()));
121         request.setAttribute("userSearch", JSP_PATH + "user_management/user_search.jsp");
122         request.setAttribute("jspSource", JSP_PATH + "group_management/group_members_tool.jsp");
123         JahiaData jData = (JahiaData)request.getAttribute ("org.jahia.data.JahiaData");
124         ParamBean jParams = null;
125         if (jData != null) {
126             jParams = jData.params ();
127         }
128         session.setAttribute("jahiaDisplayMessage",
129             JahiaResourceBundle.getAdminResource("org.jahia.admin.copyright",
130                 jParams, jParams.getLocale()));
131         doRedirect(request, response, session, JSP_PATH + "adminpopup.jsp");
132     }
133
134     private static org.apache.log4j.Logger logger =
135             org.apache.log4j.Logger.getLogger(GroupMembersTool.class);
136
137 }
138
Popular Tags