1 package hero.user; 2 30 import hero.interfaces.BnUserLocal; 31 import hero.interfaces.BnUserLocalHome; 32 import javax.ejb.FinderException ; 33 34 import java.util.ArrayList ; 35 import java.util.Collection ; 36 import java.util.Iterator ; 37 import java.util.Map ; 38 import java.util.Hashtable ; 39 40 public class DefaultUserBase implements UserBase { 41 44 private String url; 45 private String user; 46 private String password; 47 private String driver; 48 49 public DefaultUserBase() { 50 51 } 52 53 56 public String getUserName(String userId) throws UserBaseException { 57 return userId; 58 } 59 62 public Map getUserInfos(String userId) throws UserBaseException { 63 Hashtable uinfos=new Hashtable (); 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 ne) { 74 throw new UserBaseException(ne.getMessage()); 75 } catch (FinderException fe) { 76 throw new UserBaseException(fe.getMessage()); 77 } 78 } 79 80 83 public Collection getUsers() throws UserBaseException { 84 try { 85 Collection allUsers = new ArrayList (); 86 BnUserLocalHome userhome = hero.interfaces.BnUserUtil.getLocalHome(); 87 Collection users = userhome.findAll(); 88 Iterator i = users.iterator(); 89 while (i.hasNext()) 90 { 91 Hashtable uinfos=new Hashtable (); 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 ne) { 98 throw new UserBaseException(ne.getMessage()); 99 } catch (FinderException fe) { 100 throw new UserBaseException(fe.getMessage()); 101 } 102 } 103 104 107 public boolean handle(String userId) throws UserBaseException { 108 return false; 110 } 111 114 public boolean isMutable() { 115 return true; 116 } 117 120 public void create(String userId, String password, String userName, String userEmail, Map userInfos) throws UserBaseException, 121 ImmutableException { 122 } 123 126 public void edit(String userId, String password, String userName, 127 String userEmail, Map userInfos) throws UserBaseException, 128 ImmutableException { 129 } 131 134 public void deleteUser(String userId) throws UserBaseException, 135 ImmutableException { 136 } 138 } 139 | Popular Tags |