1    package com.instantbank.servicing.control.ejb.handlers;
2    
3    import java.util.ArrayList;
4    import java.rmi.RemoteException;
5    import javax.naming.InitialContext;
6    import javax.naming.NamingException;
7    import javax.ejb.CreateException;
8    import javax.ejb.DuplicateKeyException;
9    import javax.ejb.FinderException;
10   
11   import com.instantbank.common.utilcomponents.CodeDescription;
12   import com.instantbank.servicing.control.event.ParmRestrictionsEvent;
13   import com.instantbank.common.utilcomponents.Debug;
14   import com.instantbank.component.parameter.ejb.Parameter;
15   import com.instantbank.servicing.control.ServicingEventException;
16   import com.instantbank.servicing.control.event.ServicingEvent;
17   
18   /**
19    *  Parameter Restriction  usecase: handler of user requests in the Services layer
20    *
21    * @author Instant-bank (Roberto Contreras)
22    * @created October 9,  2002
23    */
24   public class ParmRestrictionsHandler extends StateHandlerSupport {
25   
26     private Debug debug = null;
27   
28   
29     /**
30      *  Principal method that process a user request invoking Model EJBs methods
31      *
32      * @param event request data
33      * @return answer to request
34      * @exception ServicingEventException
35      */
36     public Object perform(ServicingEvent event)
37        throws ServicingEventException {
38       debug = new Debug();
39       debug.setDebugginOn(true);
40       debug.setPreMessage("** ParmRestrictionsHandler-services tier: ");
41       Object answer = "";
42       ParmRestrictionsEvent ce = (ParmRestrictionsEvent)event;
43   
44       switch (ce.getActionType()) {
45   
46         case ParmRestrictionsEvent.LIST_PARM_RESTRICTIONS:
47         {
48           debug.println("LIST_PARM_RESTRICTIONS event");
49           try {
50             // obtaining EJB reference:
51             Parameter parameter = machine.getServicingControllerEJB()
52               .getParameter(ce.getCompanyId(), ce.getUserId());
53   
54             // invoking EJB methods :
55   
56             answer = parameter.listParamRestrictions();
57           }
58           catch(Exception e) {
59             // podrian distinguirse: RemoteException,
60             // CreateException, FinderException, NamingException, ...
61             throw new ServicingEventException(e.getMessage());
62           }
63         }
64           break;
65         case ParmRestrictionsEvent.UPDATE_PARM_RESTRICTIONS:
66         {
67           debug.println("UPDATE_PARM_RESTRICTIONS event");
68           try {
69             Parameter parameter = machine.getServicingControllerEJB()
70               .getParameter(ce.getCompanyId(), ce.getUserId());
71   
72             answer = parameter.updateParamRestrictions(ce.getItemsUpdate());
73           }
74           catch(Exception e) {
75             throw new ServicingEventException(e.getMessage());
76           }
77         }
78           break;
79         default:
80           debug.println("Error: not implemented yet");
81           break;
82       }
83       return answer;
84     }
85   }
86   
87