KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > business > customer > CustomerManagerImpl


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: CustomerManagerImpl.java,v 1.1 2004/08/16 09:33:11 slobodan Exp $
18  */

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 /**
30  * Class declaration
31  */

32 public class CustomerManagerImpl implements CustomerManager{
33
34     /**
35      * Creates an empty customer.
36      *
37      *
38      * @return
39      *
40      * @throws AirSentBusinessException
41      *
42      *
43      */

44     public Customer create() throws AirSentBusinessException {
45     try {
46         return new CustomerImpl();
47     } catch (Exception JavaDoc ex) {
48         throw new AirSentBusinessException("Error creating Messenger");
49     }
50     }
51
52     /**
53      * Finds a customer by business.
54      *
55      *
56      * @param business
57      *
58      * @return
59      *
60      * @throws AirSentBusinessException
61      *
62      *
63      */

64     public Customer findByBusiness(String JavaDoc business)
65         throws AirSentBusinessException {
66     Customer theCustomer = null;
67
68     try {
69         CustomerQuery query = new CustomerQuery();
70
71         // Require that we only find ONE Customer
72
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 JavaDoc ex) {
82         throw new AirSentBusinessException("Exception in findByBusiness",
83                            ex);
84     }
85     }
86
87     /**
88      * Finds a Customer by login.
89      *
90      *
91      * @param login
92      *
93      * @return
94      *
95      * @throws AirSentBusinessException
96      *
97      *
98      */

99     public Customer findByLogin(String JavaDoc login)
100         throws AirSentBusinessException {
101     Customer theCustomer = null;
102   String JavaDoc exe="Test";
103     try {
104         CustomerQuery query = new CustomerQuery();
105
106         // Require that we only find ONE Customer
107
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 JavaDoc ex) {
117         throw new AirSentBusinessException("Exception in findByLogin"+exe,
118                            ex);
119     }
120     }
121
122     /**
123      * Validates the customer based password and login.
124      *
125      *
126      * @param login
127      * @param password
128      *
129      * @return
130      *
131      * @throws AirSentBusinessException
132      *
133      *
134      */

135     public Customer validatePassword(String JavaDoc login, String JavaDoc 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 JavaDoc ex) {
150         throw new AirSentBusinessException("Exception in findByPassword",
151                            ex);
152     }
153     }
154
155 }
156
157
Popular Tags