1 19 20 package com.lutris.airsent.business.messenger; 21 22 23 import com.lutris.airsent.spec.AirSentException; 24 import com.lutris.airsent.business.*; 25 26 27 import com.lutris.airsent.spec.messenger.Messenger; 28 import com.lutris.airsent.spec.customer.Customer; 29 import com.lutris.airsent.spec.address.Address; 30 import com.lutris.airsent.business.address.AddressManager; 31 32 import com.lutris.airsent.business.address.*; 33 import com.lutris.airsent.business.address.AddressImpl; 34 35 import com.lutris.airsent.data.person.*; 36 import com.lutris.appserver.server.sql.*; 37 import com.lutris.dods.builder.generator.query.DataObjectException; 38 39 42 public class MessengerImpl implements Messenger, java.io.Serializable { 43 MessengerDO messengerDO = null; 44 PersonDO personDO = null; 45 46 51 MessengerImpl() 52 throws AirSentException { 53 try { 54 messengerDO = MessengerDO.createVirgin(); 55 personDO = PersonDO.createVirgin(); 56 AddressManager af = HomeManagerImpl.getInstance().getAddressManager(); 57 AddressImpl addr = af.create(); 58 personDO.setAddressID(addr.getDataObject()); 59 messengerDO.setPersonID(personDO); 60 } catch (Exception ex) { 61 throw new AirSentException("Error creating Messenger", ex); 62 } 63 } 64 65 70 MessengerImpl(MessengerDO messenger) 71 throws AirSentException { 72 try { 73 this.messengerDO = messenger; 74 this.personDO = messengerDO.getPersonID(); 75 } catch (Exception ex) { 76 throw new AirSentException("Error creating Messenger", ex); 77 } 78 } 79 80 85 MessengerImpl(String id) 86 throws AirSentException { 87 try { 88 this.messengerDO = messengerDO.createExisting(id); 89 this.personDO = messengerDO.getPersonID(); 90 } catch (Exception ex) { 91 throw new AirSentException("Error creating Messenger", ex); 92 } 93 } 94 95 101 public String getHandle() 102 throws AirSentException { 103 try { 104 return messengerDO.getHandle(); 105 } catch (Exception ex) { 106 throw new AirSentException("Error getting messenger's handle", ex); 107 } 108 } 109 110 116 public String getFirstName() 117 throws AirSentException { 118 try { 119 return personDO.getFirstName(); 120 } catch (Exception ex) { 121 throw new AirSentException("Error getting messenger's firstname", ex); 122 } 123 } 124 125 132 public void setFirstName(String first) 133 throws AirSentException, AirSentBusinessException { 134 if (first.length() > Customer.MAX_FIRST_NAME) { 135 throw new AirSentBusinessException("Exceeds maximum size"); 136 } 137 try { 138 this.personDO.setFirstName(first); 139 } catch (Exception ex) { 140 throw new AirSentException("Error setting messenger's name", ex); 141 } 142 } 143 144 149 public String getEmail() 150 throws AirSentException { 151 try { 152 return personDO.getEmail(); 153 } catch (Exception ex) { 154 throw new AirSentException("Error getting messenger's firstname", ex); 155 } 156 } 157 158 166 public void setEmail(String email) 167 throws AirSentException, AirSentBusinessException { 168 if (email.length() > Customer.MAX_EMAIL) { 169 throw new AirSentBusinessException("Exceeds maximum size"); 170 } 171 try { 172 this.personDO.setEmail(email); 173 } catch (Exception ex) { 174 throw new AirSentException("Error setting messenger's name", ex); 175 } 176 } 177 178 184 public String getLastName() 185 throws AirSentException { 186 try { 187 return personDO.getLastName(); 188 } catch (Exception ex) { 189 throw new AirSentException("Error getting messenger's lastname", ex); 190 } 191 } 192 193 200 public void setLastName(String last) 201 throws AirSentException, AirSentBusinessException { 202 if (last.length() > Customer.MAX_LAST_NAME) { 203 throw new AirSentBusinessException("Exceeds maximum size"); 204 } 205 try { 206 this.personDO.setLastName(last); 207 } catch (Exception ex) { 208 throw new AirSentException("Error setting messenger's last name", ex); 209 } 210 } 211 212 219 public Address getAddress() 220 throws AirSentException { 221 try { 222 AddressManager af = HomeManagerImpl.getInstance().getAddressManager(); 223 return af.create(personDO.getAddressID()); 224 } catch (Exception ex) { 225 throw new AirSentBusinessException("Error getting messenger's address", ex); 226 } 227 } 228 229 230 236 public String getBadge() 237 throws AirSentException { 238 try { 239 return messengerDO.getBadge(); 240 } catch (Exception ex) { 241 throw new AirSentBusinessException("Error getting messenger's badge", ex); 242 } 243 } 244 245 250 public void setBadge(String badge) 251 throws AirSentException, AirSentBusinessException { 252 if (badge.length() > Messenger.MAX_BADGE) { 253 throw new AirSentBusinessException("Exceeds maximum size"); 254 } 255 try { 256 this.messengerDO.setBadge(badge); 257 } catch (Exception ex) { 258 throw new AirSentException("Error setting messenger's badge", ex); 259 } 260 } 261 262 268 public String getPassword() 269 throws AirSentException { 270 try { 271 return messengerDO.getPassword(); 272 } catch (Exception ex) { 273 throw new AirSentException("Error getting customers's lastname", ex); 274 } 275 } 276 277 283 public void setPassword(String password) 284 throws AirSentException, AirSentBusinessException { 285 if (password.length() > Messenger.MAX_PASSWORD) { 286 throw new AirSentBusinessException("Exceeds maximum size"); 287 } 288 try { 289 this.messengerDO.setPassword(password); 290 } catch (Exception ex) { 291 throw new AirSentException("Error setting customers's last name", ex); 292 } 293 } 294 295 301 public String getGeocode() 302 throws AirSentException { 303 try { 304 return messengerDO.getGeocode(); 305 } catch (Exception ex) { 306 throw new AirSentException("Error getting messenger's geocode", ex); 307 } 308 } 309 310 315 public void save() 316 throws AirSentException { 317 try { 318 this.messengerDO.commit(); 319 } catch (Exception ex) { 320 throw new AirSentException("Error saving address", ex); 321 } 322 } 323 324 329 public void delete() 330 throws AirSentException { 331 try { 332 this.messengerDO.delete(); 333 } catch (Exception ex) { 334 throw new AirSentException("Error deleting address", ex); 335 } 336 } 337 } 338 339 | Popular Tags |