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