KickJava   Java API By Example, From Geeks To Geeks.

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


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 DisplayLogDeleteAction 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         // Extract attributes we will need
44
Locale locale = getLocale(request);
45         ActionErrors errors = new ActionErrors();
46         
47         // first check if the user has a connection
48
Connection c = (Connection)request.getSession().getAttribute("connection");
49         if (c == null)
50         {
51             errors.add(ActionErrors.GLOBAL_ERROR,
52             new ActionError("error.not.logged.in"));
53             saveErrors(request, errors);
54             return mapping.findForward("logon");
55         }
56
57         AccountElement element = (AccountElement)request.getSession().getAttribute("userInfo");
58         if (element.isAdminLevel() == false)
59         {
60             errors.add(ActionErrors.GLOBAL_ERROR,
61             new ActionError("error.insufficient.privilege"));
62             saveErrors(request, errors);
63             
64             return mapping.findForward("main_menu");
65         }
66         
67         // add related tasks to the navigation bar
68
RelatedTasks menu = new RelatedTasks();
69         menu.addLink(new LinkAttribute("View logs", "display_log_search"));
70         request.setAttribute("menu", menu);
71         
72         return (new ActionForward(mapping.getInput()));
73     }
74 }
75
Popular Tags