1 package org.tigris.scarab.om; 2 3 48 49 import java.util.List ; 50 51 import org.apache.torque.TorqueException; 52 import org.apache.torque.util.Criteria; 53 54 import org.tigris.scarab.tools.localization.L10NKeySet; 55 import org.tigris.scarab.util.AnonymousUserUtil; 56 import org.tigris.scarab.util.ScarabException; 57 58 import org.apache.fulcrum.security.TurbineSecurity; 59 import org.apache.fulcrum.security.util.DataBackendException; 60 import org.apache.fulcrum.security.util.UnknownEntityException; 61 62 69 public class ScarabUserManager 70 extends BaseScarabUserManager 71 { 72 77 public ScarabUserManager() 78 throws TorqueException 79 { 80 super(); 81 setRegion(getClassName().replace('.', '_')); 82 } 83 84 87 protected ScarabUser getInstanceImpl() 88 { 89 ScarabUser user = null; 90 try 91 { 92 user = (ScarabUser) AnonymousUserUtil.getAnonymousUser(); 93 } 94 catch (UnknownEntityException uee) 95 { 96 } 97 catch (DataBackendException e) 98 { 99 } 100 return user; 101 } 102 103 107 public static ScarabUser getInstance(String username, String domainName) 108 throws Exception 109 { 110 return getManager().getInstanceImpl(username, domainName); 111 } 112 113 121 public static List getUsers(String [] usernames, String domainName) 122 throws Exception 123 { 124 return getManager().getUsers(usernames, domainName); 125 } 126 127 131 protected ScarabUser getInstanceImpl(String username, String domainName) 132 throws Exception 133 { 134 ScarabUser user = null; 135 if (username != null) 136 { 137 Criteria crit = new Criteria(); 138 crit.add(ScarabUserImplPeer.USERNAME, username); 139 List users = ScarabUserImplPeer.doSelect(crit); 140 if (users.size() == 1) 141 { 142 user = (ScarabUser)users.get(0); 143 } 144 else if (users.size() > 1) 145 { 146 throw new ScarabException(L10NKeySet.ExceptionDuplicateUsername); 147 } 148 } 149 return user; 150 } 151 152 } 153 154 155 156 157 158 | Popular Tags |