1 package com.instantbank.servicing.control.web.handlers;
2
3 import java.util.HashMap;
4 import java.util.ArrayList;
5 import java.util.Enumeration;
6 import java.util.Locale;
7 import java.util.Hashtable;
8 import javax.servlet.http.HttpServletRequest;
9 import javax.servlet.http.HttpSession;
10 import javax.servlet.ServletContext;
11
12 import oracle.xml.parser.v2.*;
13 import org.w3c.dom.*;
14 import org.xml.sax.*;
15
16 import com.instantbank.servicing.control.event.ParmRestrictionsEvent;
17 import com.instantbank.servicing.control.util.JSPUtil;
18 import com.instantbank.servicing.control.util.WebKeys;
19 import com.instantbank.common.utilcomponents.Debug;
20 import com.instantbank.common.utilcomponents.ServicingExceptionMessage;
21 import com.instantbank.servicing.control.ServicingEventException;
22 import com.instantbank.servicing.control.event.ServicingEvent;
23 import com.instantbank.component.parameter.util.ParmRestrictionUpdate;
24
25
31 public class ParmRestrictionsHandler extends RequestHandlerSupport {
32
33 private Debug debug = null;
34 ServletContext context;
35
36
37
46 public ServicingEvent processRequest(HttpServletRequest request,
47 ServletContext context)
48 throws ServicingEventException {
49 debug = new Debug();
50 debug.setDebugginOn(true);
51 debug.setPreMessage("** ParmRestrictionsHandler-application tier: ");
52
53 HttpSession session = request.getSession();
54
55 this.context = context;
56 String action = request.getParameter("action");
57 debug.println("Creation of an ParmRestrictionsEvent Event; "
58 + "ParmRestrictionsHandler (web): action=" + action);
59
60 if(action == null) {
61 throw new ServicingEventException
62 (ServicingExceptionMessage.SERVICE_NOT_SELECTED);
63 }
64 else if(action.equals("listParmRestrictions")) {
65 return createListParmRestrictionsEvent(request);
66 }
67 else if(action.equals("updateParmRestrictions")) {
68 return createUpdateParmRestrictionsEvent(request);
69 }
70 return null;
71 }
72
73
74
82 private ServicingEvent createListParmRestrictionsEvent
83 (HttpServletRequest request)
84 throws ServicingEventException {
85
86 try {
87
88
89 ParmRestrictionsEvent event
90 = new ParmRestrictionsEvent
91 (ParmRestrictionsEvent.LIST_PARM_RESTRICTIONS,
92 (String)request.getSession()
93 .getAttribute(WebKeys.CompanyId),
94 (Long)request.getSession().
95 getAttribute(WebKeys.UserId),
96 null, null);
97
98 request.setAttribute(WebKeys.ParmRestrictionsEvent, event);
99 return event;
100 }
101 catch(Exception e) {
102 throw new ServicingEventException
103 (ServicingExceptionMessage.PROBLEM_PARSING + e.getMessage()
104 + ServicingExceptionMessage.RETRY);
105 }
106 }
107
108
109
117 private ServicingEvent createUpdateParmRestrictionsEvent
118 (HttpServletRequest request)
119 throws ServicingEventException {
120
121 ArrayList items = new ArrayList();
122 ArrayList codes = new ArrayList();
123 Hashtable tableCodes = new Hashtable();
124 ParmRestrictionUpdate parmUpdate;
125 int i;
126
127 HttpSession session = request.getSession();
128 tableCodes = (Hashtable)session.getAttribute(WebKeys.ParmRestrictionsTable);
129
130 try {
131 int j = 0;
132 int index;
133 int index1;
134 Enumeration parameters = request.getParameterNames();
135 while((parameters != null) && parameters.hasMoreElements()) {
136 index = 0;
137 index1 = 0;
138 String parameterName = new String(((String)parameters.nextElement()).trim());
139
140 if(!parameterName.equals("action")) {
141 String parameterValue = request.getParameter(parameterName);
142 index = parameterName.indexOf("_");
143 String temp = parameterName.substring(index + 1, parameterName.length());
144 index1 = temp.indexOf("_");
145
146 String code = temp.substring(0, index1);
147 code = code.trim();
148 String level = temp.substring(index1 + 1, temp.length());
149 level = level.trim();
150
151 for(Enumeration ee = tableCodes.keys(); ee.hasMoreElements(); ) {
152 String codeTable = (String)ee.nextElement();
153 if(codeTable.equals(code)) {
154 parmUpdate = (ParmRestrictionUpdate)tableCodes.get(codeTable);
155 if(level.equals("Level_1_2")) {
156 parmUpdate.setUpdateLevel_1_2(parameterValue);
157 tableCodes.put(codeTable, parmUpdate);
158 }
159 if(level.equals("Level_1_any")) {
160 parmUpdate.setUpdateLevel_1_any(parameterValue);
161 tableCodes.put(codeTable, parmUpdate);
162 }
163 if(level.equals("Level_any_2")) {
164 parmUpdate.setUpdateLevel_any_2(parameterValue);
165 tableCodes.put(codeTable, parmUpdate);
166 }
167 if(level.equals("Level_any_any")) {
168 parmUpdate.setUpdateLevel_any_any(parameterValue);
169 tableCodes.put(codeTable, parmUpdate);
170 }
171
172 }
173 }
174 }
175 }
176
177 ParmRestrictionsEvent event
178 = new ParmRestrictionsEvent
179 (ParmRestrictionsEvent.UPDATE_PARM_RESTRICTIONS,
180 (String)request.getSession().
181 getAttribute(WebKeys.CompanyId),
182 (Long)request.getSession().
183 getAttribute(WebKeys.UserId),
184 null, tableCodes);
185 request.setAttribute(WebKeys.ParmRestrictionsEvent, event);
186 return event;
187 }
188 catch(Exception e) {
189 throw new ServicingEventException
190 (ServicingExceptionMessage.PROBLEM_PARSING + e.getMessage()
191 + ServicingExceptionMessage.RETRY);
192 }
193 }
194
195 }
196
197