1 23 24 25 26 package barracudaDiscRack.business.person; 27 28 import barracudaDiscRack.data.person.*; 29 import barracudaDiscRack.business.DiscRackBusinessException; 30 import com.lutris.dods.builder.generator.query.*; 31 import com.lutris.appserver.server.Enhydra; 32 import com.lutris.logging.*; 33 34 35 38 public class PersonFactory { 39 40 53 public static Person findPerson(String username) 54 throws DiscRackBusinessException { 55 try { 56 PersonQuery query = new PersonQuery(); 57 query.setQueryLogin(username); 59 query.requireUniqueInstance(); 61 62 PersonDO[] foundPerson = query.getDOArray(); 63 if(foundPerson.length != 0) { 64 return new Person(foundPerson[0]); 65 } else { 66 return null; 67 } 68 } catch(NonUniqueQueryException ex) { 69 Enhydra.getLogChannel().write(Logger.DEBUG, 70 "Non-unique user found in database: " + 71 ex.getMessage()); 72 throw new DiscRackBusinessException("More than one user found with username: " + 73 username); 74 } catch(DataObjectException ex) { 75 throw new DiscRackBusinessException("Database error retrieving user: ", ex); 76 } catch(QueryException ex) { 77 throw new DiscRackBusinessException("Query exception retrieving user: ", ex); 78 } 79 80 } 81 } 82 | Popular Tags |