1    package com.instantbank.collections.security.web;
2    
3    import java.io.IOException;
4    import javax.servlet.RequestDispatcher;
5    import javax.servlet.ServletConfig;
6    import javax.servlet.ServletContext;
7    import javax.servlet.ServletException;
8    import javax.servlet.http.HttpServlet;
9    import javax.servlet.http.HttpServletRequest;
10   import javax.servlet.http.HttpServletResponse;
11   import javax.servlet.http.HttpSession;
12   import com.instantbank.collections.security.ejb.SecurityProfilesServices;
13   import com.instantbank.collections.security.ejb.SecurityProfilesServicesHome;
14   import com.instantbank.collections.security.ejb.SecurityServices;
15   import com.instantbank.collections.security.ejb.SecurityServicesHome;
16   import com.instantbank.collections.util.FilterChain;
17   import com.instantbank.collections.util.InstantbankException;
18   import com.instantbank.collections.util.ServiceLocator;
19   
20   
21   public class SecurityReportController extends HttpServlet {
22     private Long companyId;
23     private String debug;
24     private Long maximunRows;
25     private SecurityProfilesServices PrfServices;
26     private SecurityServices SecServices;
27     private HttpSession session;
28   
29   
30     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
31       doPost(request, response);
32     }
33   
34   
35     public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
36       String action = "";
37       com.instantbank.collections.util.FilterChain chain;
38   
39       debug = "set action";
40       try {
41         action = request.getParameter("action");
42         session = request.getSession(false);
43         session.setAttribute("hasException", "0");
44         try {
45           chain = new com.instantbank.collections.util.FilterChain(true, getServletConfig().getServletContext());
46           if(chain.processFilter(request, response)) {
47             return;
48           }
49           if(action.equals("initialize")) {
50             initialize(request, response);
51           }
52           else {
53             throw new InstantbankException("132001", "Action " + action + " not supported");
54           }
55         }
56         catch(Exception e) {
57           throw new InstantbankException(e, "132002", "Failed to execute controller action " + action);
58         }
59       }
60       catch(InstantbankException e) {
61         session.setAttribute("hasException", "1");
62         session.setAttribute("Exception", e);
63         if(response.isCommitted()) {
64           return;
65         }
66         response.sendRedirect("../main_web/ControllerError.jsp?showTechnical=0");
67       }
68     }
69   
70   
71     public String getServletInfo() {
72       return "com.instantbank.collections.security.web.SecurityReportController Information";
73     }
74   
75   
76     public void init(ServletConfig config) throws ServletException {
77       super.init(config);
78       try {
79         SecurityServicesHome SecHome = (SecurityServicesHome)
80           ServiceLocator.instance().createEJB("SecurityServicesHome", SecurityServicesHome.class, false);
81         SecServices = SecHome.create();
82         SecurityProfilesServicesHome PrfHome = (SecurityProfilesServicesHome)
83           ServiceLocator.instance().createEJB("SecurityProfilesServicesHome", SecurityProfilesServicesHome.class, false);
84         PrfServices = PrfHome.create();
85       }
86       catch(Exception e) {
87         throw new ServletException(e);
88       }
89     }
90   
91   
92     private void initialize(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InstantbankException {
93       String dateGenerated;
94       String timeGenerated;
95       String xml;
96       String xmlProfiles;
97   
98       companyId = (Long)session.getAttribute("companyId");
99       maximunRows = new Long(10);
100      /* number of records in the page */
101      xml = SecServices.getGroupsUsers(companyId);
102      dateGenerated = SecServices.getSysdate("MM/DD/YYYY");
103      timeGenerated = SecServices.getSysdate("HH:MI:SS");
104      ServletContext sc = getServletConfig().getServletContext();
105      request.setAttribute("data", xml);
106      request.setAttribute("maximun", maximunRows);
107      request.setAttribute("dateGenerated", dateGenerated);
108      request.setAttribute("timeGenerated", timeGenerated);
109      RequestDispatcher rd = sc.getRequestDispatcher("/security_web/SecurityReportView.jsp");
110      rd.forward(request, response);
111    }
112  }
113