001: package hero.user;
002:
003: /**
004: *
005: * Bonita
006: * Copyright (C) 1999 Bull S.A.
007: * Bull 68 route de versailles 78434 Louveciennes Cedex France
008: * Further information: bonita@objectweb.org
009: *
010: * This library is free software; you can redistribute it and/or
011: * modify it under the terms of the GNU Lesser General Public
012: * License as published by the Free Software Foundation; either
013: * version 2.1 of the License, or any later version.
014: *
015: * This library is distributed in the hope that it will be useful,
016: * but WITHOUT ANY WARRANTY; without even the implied warranty of
017: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018: * Lesser General Public License for more details.
019: *
020: * You should have received a copy of the GNU Lesser General Public
021: * License along with this library; if not, write to the Free Software
022: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
023: * USA
024: *
025: *
026: --------------------------------------------------------------------------
027: * $Id: DefaultUserBase.java,v 1.3 2005/11/15 15:22:31 dparisek Exp $
028: *
029: --------------------------------------------------------------------------
030: */
031: import hero.interfaces.BnUserLocal;
032: import hero.interfaces.BnUserLocalHome;
033: import javax.ejb.FinderException;
034:
035: import java.util.ArrayList;
036: import java.util.Collection;
037: import java.util.Iterator;
038: import java.util.Map;
039: import java.util.Hashtable;
040:
041: public class DefaultUserBase implements UserBase {
042: /**
043: *
044: */
045: private String url;
046: private String user;
047: private String password;
048: private String driver;
049:
050: public DefaultUserBase() {
051:
052: }
053:
054: /* (non-Javadoc)
055: * @see hero.util.user.UserBase#getUserName(java.lang.String)
056: */
057: public String getUserName(String userId) throws UserBaseException {
058: return userId;
059: }
060:
061: /* (non-Javadoc)
062: * @see hero.util.user.UserBase#getUserInfos(java.lang.String)
063: */
064: public Map getUserInfos(String userId) throws UserBaseException {
065: Hashtable uinfos = new Hashtable();
066: try {
067: BnUserLocalHome userhome = hero.interfaces.BnUserUtil
068: .getLocalHome();
069: BnUserLocal user = userhome.findByName(userId);
070: uinfos.put("name", userId);
071: if (user.getPassword() != null)
072: uinfos.put("password", user.getPassword());
073: if (user.getEmail() != null)
074: uinfos.put("email", user.getEmail());
075: if (user.getJabber() != null)
076: uinfos.put("jabber", user.getJabber());
077: return uinfos;
078: } catch (javax.naming.NamingException ne) {
079: throw new UserBaseException(ne.getMessage());
080: } catch (FinderException fe) {
081: throw new UserBaseException(fe.getMessage());
082: }
083: }
084:
085: /* (non-Javadoc)
086: * @see hero.util.user.UserBase#getUserInfos(java.lang.String)
087: */
088: public Collection getUsers() throws UserBaseException {
089: try {
090: Collection allUsers = new ArrayList();
091: BnUserLocalHome userhome = hero.interfaces.BnUserUtil
092: .getLocalHome();
093: Collection users = userhome.findAll();
094: Iterator i = users.iterator();
095: while (i.hasNext()) {
096: Hashtable uinfos = new Hashtable();
097: BnUserLocal user = (BnUserLocal) i.next();
098: uinfos.put("name", user.getName());
099: allUsers.add(uinfos);
100: }
101: return allUsers;
102: } catch (javax.naming.NamingException ne) {
103: throw new UserBaseException(ne.getMessage());
104: } catch (FinderException fe) {
105: throw new UserBaseException(fe.getMessage());
106: }
107: }
108:
109: /* (non-Javadoc)
110: * @see hero.util.user.UserBase#handle(java.lang.String)
111: */
112: public boolean handle(String userId) throws UserBaseException {
113: // TODO Auto-generated method stub
114: return false;
115: }
116:
117: /* (non-Javadoc)
118: * @see hero.util.user.UserBase#isMutable()
119: */
120: public boolean isMutable() {
121: return true;
122: }
123:
124: /* (non-Javadoc)
125: * @see hero.util.user.UserBase#create(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Map)
126: */
127: public void create(String userId, String password, String userName,
128: String userEmail, Map userInfos) throws UserBaseException,
129: ImmutableException {
130: }
131:
132: /* (non-Javadoc)
133: * @see hero.util.user.UserBase#edit(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Map)
134: */
135: public void edit(String userId, String password, String userName,
136: String userEmail, Map userInfos) throws UserBaseException,
137: ImmutableException {
138: // TODO Auto-generated method stub
139: }
140:
141: /* (non-Javadoc)
142: * @see hero.util.user.UserBase#deleteUser(java.lang.String)
143: */
144: public void deleteUser(String userId) throws UserBaseException,
145: ImmutableException {
146: // TODO Auto-generated method stub
147: }
148: }
|