KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > admin > controller > LogoffAction


1 package com.quikj.application.communicator.admin.controller;
2
3 import com.quikj.application.communicator.admin.model.*;
4 import com.quikj.server.framework.*;
5 import com.quikj.client.raccess.*;
6
7 import java.io.IOException JavaDoc;
8 import java.util.*;
9 import javax.servlet.*;
10 import javax.servlet.http.*;
11 import java.sql.*;
12 import org.apache.struts.action.*;
13
14
15 /**
16  * Implementation of <strong>Action</strong> that processes a
17  * user logoff. Based on Apache Struts framework.
18  *
19  * @author Vinod Batra
20  * @version $Revision: 1.5 $ $Date: 2004/05/03 11:09:17 $
21  */

22
23 public final class LogoffAction extends Action
24 {
25     
26     
27     // --------------------------------------------------------- Public Methods
28

29     
30     /**
31      * Process the specified HTTP request, and create the corresponding HTTP
32      * response (or forward to another web component that will create it).
33      * Return an <code>ActionForward</code> instance describing where and how
34      * control should be forwarded, or <code>null</code> if the response has
35      * already been completed.
36      *
37      * @param mapping The ActionMapping used to select this instance
38      * @param actionForm The optional ActionForm bean for this request (if any)
39      * @param request The HTTP request we are processing
40      * @param response The HTTP response we are creating
41      *
42      * @exception IOException if an input/output error occurs
43      * @exception ServletException if a servlet exception occurs
44      */

45     public ActionForward execute(ActionMapping mapping,
46     ActionForm form,
47     HttpServletRequest request,
48     HttpServletResponse response)
49     throws IOException JavaDoc, ServletException
50     {
51         
52         // Extract attributes we will need
53
Locale locale = getLocale(request);
54         HttpSession session = request.getSession();
55         
56         Connection c = (Connection)request.getSession().getAttribute("connection");
57         if (c == null)
58         {
59             return mapping.findForward("logon");
60         }
61         else
62         {
63             try
64             {
65                 c.close();
66             }
67             catch (SQLException ex)
68             {
69             }
70         }
71         
72         // unregister user login with the Ace Application Server
73
RemoteAccessClient cl = (RemoteAccessClient)request.getSession().getServletContext().getAttribute("remoteAccess");
74         if (cl == null)
75         {
76             AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG,
77             "LogoffAction.execute(): Could not obtain RMI client object");
78         }
79         else
80         {
81             try
82             {
83                 String JavaDoc authcode = (String JavaDoc)request.getSession().getAttribute("authCode");
84                 
85                 if (authcode != null)
86                 {
87                     cl.getRemoteAccess().setParam("com.quikj.application.web.oamp.plugin.CommunicatorClientList",
88                     "unregister:" + authcode, "");
89                 }
90             }
91             catch (Exception JavaDoc ex)
92             {
93                 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG,
94                 "LogoffAction.execute(): RMIException: " + ex.getMessage());
95             }
96         }
97         
98         AceLogger.Instance().log(AceLogger.INFORMATIONAL, AceLogger.USER_LOG,
99             "User "
100             + ((AccountElement)(request.getSession().getAttribute("userInfo"))).getName()
101             + " logged out");
102         
103         session.invalidate();
104         
105         // Forward control to the specified success URI
106
return (mapping.findForward("logon"));
107     }
108     
109     
110 }
111
Popular Tags