1 package de.webman.acl; 2 3 import com.teamkonzept.lib.TKException; 4 import com.teamkonzept.lib.TKVector; 5 import de.webman.acl.db.*; 6 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 7 8 15 public class UserFactory 16 implements ObjectFactory 17 { 18 19 21 23 26 private static UserFactory SINGLETON = null; 27 28 29 31 34 private LoginFactory factory = null; 35 36 37 39 44 private UserFactory (LoginFactory factory) 45 { 46 this.factory = factory; 47 } 48 49 50 52 58 public static synchronized final UserFactory getInstance () 59 throws TKException 60 { 61 if (SINGLETON == null) 62 { 63 SINGLETON = new UserFactory(LoginFactory.getInstance()); 64 } 65 66 return SINGLETON; 67 } 68 69 70 72 77 public final void configurationChanged () 78 throws TKException 79 { 80 this.factory.configurationChanged(); 81 } 82 83 90 public final WMObject getObject (Integer id) 91 throws TKException 92 { 93 return this.factory.getObject(id); 94 } 95 96 102 public final TKVector getObjects () 103 throws TKException 104 { 105 return this.factory.getObjects(getObjectIDs()); 106 } 107 108 115 public TKVector getObjects (TKVector ids) 116 throws TKException 117 { 118 return this.factory.getObjects(ids); 119 } 120 121 127 public final TKVector getObjectIDs () 128 throws TKException 129 { 130 TKVector proxies = null; 131 132 try 133 { 134 LoginDBData data = new LoginDBData(null, null, null, LoginDBInterface.TYPE_USER); 136 data.setQuery(LoginDBInterface.WM_USER_SELECT_BY_TYPE); 137 data.setPrototype(new ObjectCollectionDBData(null, 138 null, 139 LoginDBInterface.PRIMARY_KEY_NAME, 140 null)); 141 142 proxies = getObjectIDs(data); 144 } 145 catch (Exception x) 146 { 147 throw WebmanExceptionHandler.getException(x); 148 } 149 150 return proxies; 151 } 152 153 160 public final TKVector getObjectIDs (ObjectDBData data) 161 throws TKException 162 { 163 return this.factory.getObjectIDs(data); 164 } 165 166 173 public final TKVector getObjectAssociations (WMObject object) 174 throws TKException 175 { 176 return this.factory.getObjectAssociations(object); 177 } 178 179 186 public final WMObject createObject (ObjectDBData data) 187 throws TKException 188 { 189 return this.factory.createObject(data); 190 } 191 192 198 public final void modifyObject (WMObject object) 199 throws TKException 200 { 201 this.factory.modifyObject(object); 202 } 203 204 210 public final void deleteObject (WMObject object) 211 throws TKException 212 { 213 this.factory.deleteObject(object); 214 } 215 216 217 219 226 public final User getUser (Integer id) 227 throws TKException 228 { 229 return (User) getObject(id); 230 } 231 232 238 public final TKVector getUsers () 239 throws TKException 240 { 241 return getObjects(); 242 } 243 244 252 public final User createUser (String login, 253 String name) 254 throws TKException 255 { 256 this.factory.checkLogin(login); 258 259 return (User) createObject(new LoginDBData(null, 261 login, 262 name, 263 LoginDBInterface.TYPE_USER)); 264 } 265 266 272 public final void modifyUser (User user) 273 throws TKException 274 { 275 modifyObject(user); 276 } 277 278 284 public final void deleteUser (User user) 285 throws TKException 286 { 287 deleteObject(user); 288 } 289 290 } 291 | Popular Tags |