KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > user > DefaultUserBase


1 package hero.user;
2 /**
3 *
4 * Bonita
5 * Copyright (C) 1999 Bull S.A.
6 * Bull 68 route de versailles 78434 Louveciennes Cedex France
7 * Further information: bonita@objectweb.org
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
24 *
25 --------------------------------------------------------------------------
26 * $Id: DefaultUserBase.java,v 1.2 2004/11/25 13:53:12 mvaldes Exp $
27 *
28 --------------------------------------------------------------------------
29 */

30 import hero.interfaces.BnUserLocal;
31 import hero.interfaces.BnUserLocalHome;
32 import javax.ejb.FinderException JavaDoc;
33
34 import java.util.ArrayList JavaDoc;
35 import java.util.Collection JavaDoc;
36 import java.util.Iterator JavaDoc;
37 import java.util.Map JavaDoc;
38 import java.util.Hashtable JavaDoc;
39
40 public class DefaultUserBase implements UserBase {
41     /**
42      *
43      */

44     private String JavaDoc url;
45     private String JavaDoc user;
46     private String JavaDoc password;
47     private String JavaDoc driver;
48     
49     public DefaultUserBase() {
50
51     }
52     
53     /* (non-Javadoc)
54      * @see hero.util.user.UserBase#getUserName(java.lang.String)
55      */

56     public String JavaDoc getUserName(String JavaDoc userId) throws UserBaseException {
57         return userId;
58     }
59     /* (non-Javadoc)
60      * @see hero.util.user.UserBase#getUserInfos(java.lang.String)
61      */

62     public Map JavaDoc getUserInfos(String JavaDoc userId) throws UserBaseException {
63         Hashtable JavaDoc uinfos=new Hashtable JavaDoc();
64         try {
65             BnUserLocalHome userhome = hero.interfaces.BnUserUtil.getLocalHome();
66             BnUserLocal user = userhome.findByName(userId);
67             uinfos.put("name",userId);
68             uinfos.put("password",user.getPassword());
69             uinfos.put("email",user.getEmail());
70             if (user.getJabber()!=null)
71                 uinfos.put("jabber",user.getJabber());
72             return uinfos;
73         } catch (javax.naming.NamingException JavaDoc ne) {
74                 throw new UserBaseException(ne.getMessage());
75         } catch (FinderException JavaDoc fe) {
76             throw new UserBaseException(fe.getMessage());
77         }
78     }
79     
80     /* (non-Javadoc)
81      * @see hero.util.user.UserBase#getUserInfos(java.lang.String)
82      */

83     public Collection JavaDoc getUsers() throws UserBaseException {
84         try {
85             Collection JavaDoc allUsers = new ArrayList JavaDoc();
86             BnUserLocalHome userhome = hero.interfaces.BnUserUtil.getLocalHome();
87             Collection JavaDoc users = userhome.findAll();
88             Iterator JavaDoc i = users.iterator();
89             while (i.hasNext())
90             {
91                 Hashtable JavaDoc uinfos=new Hashtable JavaDoc();
92                 BnUserLocal user = (BnUserLocal)i.next();
93                 uinfos.put("name",user.getName());
94                 allUsers.add(uinfos);
95             }
96             return allUsers;
97         } catch (javax.naming.NamingException JavaDoc ne) {
98                 throw new UserBaseException(ne.getMessage());
99         } catch (FinderException JavaDoc fe) {
100             throw new UserBaseException(fe.getMessage());
101         }
102     }
103     
104     /* (non-Javadoc)
105      * @see hero.util.user.UserBase#handle(java.lang.String)
106      */

107     public boolean handle(String JavaDoc userId) throws UserBaseException {
108         // TODO Auto-generated method stub
109
return false;
110     }
111     /* (non-Javadoc)
112      * @see hero.util.user.UserBase#isMutable()
113      */

114     public boolean isMutable() {
115         return true;
116     }
117     /* (non-Javadoc)
118      * @see hero.util.user.UserBase#create(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Map)
119      */

120     public void create(String JavaDoc userId, String JavaDoc password, String JavaDoc userName, String JavaDoc userEmail, Map JavaDoc userInfos) throws UserBaseException,
121             ImmutableException {
122     }
123     /* (non-Javadoc)
124      * @see hero.util.user.UserBase#edit(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Map)
125      */

126     public void edit(String JavaDoc userId, String JavaDoc password, String JavaDoc userName,
127             String JavaDoc userEmail, Map JavaDoc userInfos) throws UserBaseException,
128             ImmutableException {
129         // TODO Auto-generated method stub
130
}
131     /* (non-Javadoc)
132      * @see hero.util.user.UserBase#deleteUser(java.lang.String)
133      */

134     public void deleteUser(String JavaDoc userId) throws UserBaseException,
135             ImmutableException {
136         // TODO Auto-generated method stub
137
}
138 }
139
Popular Tags