1 19 20 package com.lutris.airsent.business.customer; 21 22 import com.lutris.airsent.business.AirSentBusinessException; 23 24 import com.lutris.airsent.spec.customer.*; 25 26 import com.lutris.airsent.data.person.CustomerDO; 27 import com.lutris.airsent.data.person.CustomerQuery; 28 29 32 public class CustomerManagerImpl implements CustomerManager{ 33 34 44 public Customer create() throws AirSentBusinessException { 45 try { 46 return new CustomerImpl(); 47 } catch (Exception ex) { 48 throw new AirSentBusinessException("Error creating Messenger"); 49 } 50 } 51 52 64 public Customer findByBusiness(String business) 65 throws AirSentBusinessException { 66 Customer theCustomer = null; 67 68 try { 69 CustomerQuery query = new CustomerQuery(); 70 71 query.setQueryBusiness(business); 73 74 CustomerDO[] customerDO = query.getDOArray(); 75 76 if (customerDO.length == 0) { 77 return null; 78 } else { 79 return new CustomerImpl(customerDO[0]); 80 } 81 } catch (Exception ex) { 82 throw new AirSentBusinessException("Exception in findByBusiness", 83 ex); 84 } 85 } 86 87 99 public Customer findByLogin(String login) 100 throws AirSentBusinessException { 101 Customer theCustomer = null; 102 String exe="Test"; 103 try { 104 CustomerQuery query = new CustomerQuery(); 105 106 query.setQueryLogin(login); 108 exe="Dato Queriju"; 109 CustomerDO[] customerDO = query.getDOArray(); 110 exe="Dato Queriju i vracen DO"; 111 if (customerDO.length == 0) { 112 return null; 113 } else { 114 return new CustomerImpl(customerDO[0]); 115 } 116 } catch (Exception ex) { 117 throw new AirSentBusinessException("Exception in findByLogin"+exe, 118 ex); 119 } 120 } 121 122 135 public Customer validatePassword(String login, String password) 136 throws AirSentBusinessException { 137 Customer theCustomer = null; 138 139 try { 140 if ((theCustomer = findByLogin(login)) == null) { 141 return null; 142 } else { 143 if (theCustomer.getPassword().equals(password)) { 144 return theCustomer; 145 } else { 146 return null; 147 } 148 } 149 } catch (Exception ex) { 150 throw new AirSentBusinessException("Exception in findByPassword", 151 ex); 152 } 153 } 154 155 } 156 157 | Popular Tags |