KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.quikj.application.communicator.admin.controller;
2
3 import java.io.*;
4 import java.util.*;
5 import javax.servlet.*;
6 import javax.servlet.http.*;
7 import org.apache.struts.action.*;
8 import java.sql.*;
9
10 import com.quikj.application.communicator.admin.model.*;
11
12 /**
13  * Implementation of <strong>Action</strong> that validates a user logon.
14  * Based on Apache Struts framework.
15  *
16  * @author Elizabeth Roman
17  * @version $Revision: 1.2 $ $Date: 2004/05/03 11:09:17 $
18  */

19
20 public final class DisplayLogSearchAction extends Action
21 {
22     /**
23      * Process the specified HTTP request, and create the corresponding HTTP
24      * response (or forward to another web component that will create it).
25      * Return an <code>ActionForward</code> instance describing where and how
26      * control should be forwarded, or <code>null</code> if the response has
27      * already been completed.
28      *
29      * @param mapping The ActionMapping used to select this instance
30      * @param actionForm The optional ActionForm bean for this request (if any)
31      * @param request The HTTP request we are processing
32      * @param response The HTTP response we are creating
33      *
34      * @exception IOException if an input/output error occurs
35      * @exception ServletException if a servlet exception occurs
36      */

37     public ActionForward execute(ActionMapping mapping,
38     ActionForm form,
39     HttpServletRequest request,
40     HttpServletResponse response)
41     throws IOException, ServletException
42     {
43         LogSearchForm lform = (LogSearchForm)form;
44         
45         // Extract attributes we will need
46
Locale locale = getLocale(request);
47         ActionErrors errors = new ActionErrors();
48         
49         // first check if the user has a connection
50
Connection c = (Connection)request.getSession().getAttribute("connection");
51         if (c == null)
52         {
53             errors.add(ActionErrors.GLOBAL_ERROR,
54             new ActionError("error.not.logged.in"));
55             saveErrors(request, errors);
56             return mapping.findForward("logon");
57         }
58
59         AccountElement element = (AccountElement)request.getSession().getAttribute("userInfo");
60         if (element.isAdminLevel() == false)
61         {
62             errors.add(ActionErrors.GLOBAL_ERROR,
63             new ActionError("error.insufficient.privilege"));
64             saveErrors(request, errors);
65             
66             return mapping.findForward("main_menu");
67         }
68         
69         // get the list of unique process names
70
LogsTable logs = new LogsTable(AdminConfig.getInstance().getDBParams().getAdminDb());
71         logs.setConnection(c);
72         
73         request.getSession().setAttribute("logProcessNames", logs.getUniqueProcessNames());
74         
75         // add related tasks to the navigation bar
76
RelatedTasks menu = new RelatedTasks();
77         menu.addLink(new LinkAttribute("Delete logs", "display_log_delete"));
78         request.setAttribute("menu", menu);
79         
80         return (new ActionForward(mapping.getInput()));
81     }
82 }
83
Popular Tags