1 2 24 25 package barracudaDiscRack.presentation; 26 27 import barracudaDiscRack.presentation.personMgmt.events.*; 29 import barracudaDiscRack.business.person.*; 30 31 import com.lutris.appserver.server.httpPresentation.*; 33 import com.lutris.appserver.server.Enhydra; 34 import com.lutris.util.KeywordValueException; 35 import com.lutris.logging.*; 36 37 import org.enhydra.barracuda.core.event.*; 39 40 public class BaseDiscRackEventGateway extends DefaultEventGateway { 41 42 46 51 protected void initUsingContext( EventContext context ) throws EventException { 52 try { 53 this.myComms = 54 (HttpPresentationComms)context.getState( ApplicationGateway.EXTERNAL_CONTEXT_OBJ_NAME ); 55 this.initSessionData(this.myComms); 56 } catch ( ClassCastException ex ) { 57 String errMsg = "ERROR: External Context object is NOT a HttpPresentationComms object. Cannot function"; 58 throw ( new EventException( errMsg, ex ) ); 59 } catch ( DiscRackPresentationException ex ) { 60 String errMsg = "ERROR: Could not get session data from session:"; 61 throw ( new EventException( errMsg, ex ) ); 62 } 63 } 64 65 71 public HttpPresentationComms getComms() { 72 return this.myComms; 73 } 74 75 80 public DiscRackSessionData getSessionData() { 81 return this.mySessionData; 82 } 83 84 90 public void setUser(Person thePerson) 91 throws DiscRackPresentationException { 92 this.getSessionData().setUser(thePerson); 93 } 94 95 100 public Person getUser() { 101 return this.getSessionData().getUser(); 102 } 103 104 107 public void removeUserFromSession() { 108 this.getSessionData().removeUser(); 109 } 110 111 118 protected void initSessionData(HttpPresentationComms comms) 119 throws DiscRackPresentationException { 120 this.myComms = comms; 121 122 try { 123 Object obj = comms.sessionData.get(DiscRackSessionData.SESSION_KEY); 124 if ( null != obj ) { 126 this.mySessionData = (DiscRackSessionData)obj; 127 } else { 128 this.mySessionData = new DiscRackSessionData(); 130 comms.sessionData.set(DiscRackSessionData.SESSION_KEY, this.mySessionData); 131 } 132 } catch ( KeywordValueException ex ) { 133 writeDebugMsg("Problem getting session data from session: " + 134 ex.getMessage()); 135 } 136 } 137 138 144 public static void writeDebugMsg(String msg) { 145 Enhydra.getLogChannel().write(Logger.DEBUG,msg); 146 } 147 148 151 private HttpPresentationComms myComms = null; 152 private DiscRackSessionData mySessionData = null; 153 154 157 private Person myPerson = null; 158 159 } 160 | Popular Tags |