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