1 19 20 package com.lutris.airsent.business.messenger; 21 22 import com.lutris.airsent.business.AirSentBusinessException; 23 24 import com.lutris.airsent.data.person.MessengerDO; 25 import com.lutris.airsent.data.person.MessengerQuery; 26 import com.lutris.airsent.spec.messenger.Messenger; 27 import com.lutris.airsent.spec.messenger.MessengerManager; 28 29 36 public class MessengerManagerImpl implements MessengerManager { 37 38 47 public Messenger create() throws AirSentBusinessException { 48 try { 49 return new MessengerImpl(); 50 } catch (Exception ex) { 51 throw new AirSentBusinessException("Error creating Messenger"); 52 } 53 } 54 55 56 public Messenger create(String id) throws AirSentBusinessException { 57 try { 58 return new MessengerImpl(id); 59 } catch (Exception ex) { 60 throw new AirSentBusinessException("Error creating Messenger"); 61 } 62 } 63 64 65 77 public Messenger findByBadge(String badge) 78 throws AirSentBusinessException { 79 Messenger theMessenger = null; 80 81 try { 82 MessengerQuery query = new MessengerQuery(); 83 84 query.setQueryBadge(badge); 86 87 MessengerDO[] messengerDO = query.getDOArray(); 88 89 if (messengerDO.length == 0) { 90 return null; 91 } else { 92 return new MessengerImpl(messengerDO[0]); 93 } 94 } catch (Exception ex) { 95 throw new AirSentBusinessException("Exception in findByInvoice", 96 ex); 97 } 98 } 99 100 113 public Messenger findByProximity(String geocode) 114 throws AirSentBusinessException { 115 Messenger theMessenger = null; 116 117 try { 118 MessengerQuery query = new MessengerQuery(); 119 120 query.requireUniqueInstance(); 122 query.setQueryGeocode(geocode); 123 124 MessengerDO theMessengerDO = query.getNextDO(); 125 126 theMessenger = new MessengerImpl(theMessengerDO); 127 128 return theMessenger; 129 } catch (Exception ex) { 130 throw new AirSentBusinessException("Exception in findByInvoice", 131 ex); 132 } 133 } 134 135 145 public Messenger[] findAll() throws AirSentBusinessException { 146 Messenger[] theMessengerArray = null; 147 148 try { 149 MessengerQuery query = new MessengerQuery(); 150 151 MessengerDO[] DOarray = query.getDOArray(); 154 155 theMessengerArray = new Messenger[DOarray.length]; 156 157 for (int i = 0; i < DOarray.length; i++) { 158 theMessengerArray[i] = new MessengerImpl(DOarray[i]); 159 } 160 } catch (Exception ex) { 161 throw new AirSentBusinessException("Exception in findByMessenger", 162 ex); 163 } 164 165 return theMessengerArray; 166 } 167 168 181 public Messenger validatePassword(String badge, String password) 182 throws AirSentBusinessException { 183 Messenger theMessenger = null; 184 185 try { 186 if ((theMessenger = findByBadge(badge)) == null) { 187 return null; 188 } else { 189 if (theMessenger.getPassword().equals(password)) { 190 return theMessenger; 191 } else { 192 return null; 193 } 194 } 195 } catch (Exception ex) { 196 throw new AirSentBusinessException("Exception in validateLogin", 197 ex); 198 } 199 } 200 201 } 202 203 | Popular Tags |