1 23 24 25 26 package discRack.business.person; 27 28 import discRack.data.person.*; 29 import discRack.business.DiscRackBusinessException; 30 import com.lutris.dods.builder.generator.query.*; 31 import java.util.*; 32 33 36 public class PersonFactory { 37 38 39 52 public static Person findPerson(String username) 53 throws DiscRackBusinessException { 54 try { 55 PersonQuery query = new PersonQuery(); 56 query.setQueryLogin(username); 58 query.requireUniqueInstance(); 60 61 PersonDO[] foundPerson = query.getDOArray(); 62 if(foundPerson.length != 0) { 63 return new Person(foundPerson[0]); 64 } else { 65 return null; 66 } 67 } catch(NonUniqueQueryException ex) { 68 throw new DiscRackBusinessException("More than one user found with username: " + 69 username); 70 } catch(DataObjectException ex) { 71 throw new DiscRackBusinessException("Database error retrieving user: ", ex); 72 } catch(QueryException ex) { 73 throw new DiscRackBusinessException("Query exception retrieving user: ", ex); 74 } 75 } 76 77 } 78 | Popular Tags |