public void setPrimaryContact(User user) throws JAXRException { if (user == null) { throw new IllegalArgumentException("primaryContact must not be null"); } /* * first check to see if user already exists in user set */ primaryContact = user; if (!users.contains(user)) { addUser(user); } }
public void printUser(Organization org) throws JAXRException { // Display primary contact information User pc = org.getPrimaryContact(); if (pc != null) { PersonName pcName = pc.getPersonName(); System.out.println(" Contact name: " + pcName.getFullName()); Collection phNums = pc.getTelephoneNumbers(pc.getType()); for (Iterator phIter = phNums.iterator(); phIter.hasNext();) { TelephoneNumber num = (TelephoneNumber) phIter.next(); System.out.println(" Phone number: " + num.getNumber()); } Collection eAddrs = pc.getEmailAddresses(); for (Iterator eaIter = eAddrs.iterator(); eaIter.hasNext();) { System.out.println(" Email Address: " + (EmailAddress) eaIter.next()); } } }
public User getPrimaryContact() throws JAXRException { //TODO: How do we fix this? Run JAXRQueryTest and you will hit this problem. // // gmj : I think I fixed w/ primary contact hack... // //if (primaryContact == null) { // throw new IllegalStateException("primaryContact is null and the spec says we cannot return a null value"); //} return primaryContact; }
public void addUser(User user) throws JAXRException { doPrimaryContactHack(user); users.add(user); ((UserImpl) user).setOrganization(this); }
public void addUsers(Collection collection) throws JAXRException { // do this by hand to ensure all members are actually instances of User for (Iterator iterator = collection.iterator(); iterator.hasNext();) { User user = (User) iterator.next(); addUser(user); } }
public void removeUser(User user) throws JAXRException { if (user != null) { users.remove(user); } /* * more primaryContact hakiness - nothing says that you can't * remove the user that is the PC... */ if (!users.contains(primaryContact)) { primaryContact = null; } }
public List<User> getUsers() { // ... return Collections.emptyList(); }
private List<User> getUsers() { // ... return userStore.getUsers(); }
public Collection<User> getUsers() throws JAXRException { return users; }
public User createUser() throws JAXRException { return (User) this.createObject(LifeCycleManager.USER); }
public void testCreateObjectUser() throws JAXRException { User user = (User) manager.createObject(LifeCycleManager.USER); assertEquals(UserImpl.class, user.getClass()); assertSame(manager, user.getLifeCycleManager()); }
@SuppressWarnings("unchecked") @Test public void queryOrganization() { login(); try { // Get registry service and business query manager RegistryService rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); System.out.println("We have the Business Query Manager"); Printer printer = new Printer(); Finder finder = new Finder(bqm, uddiversion); Collection orgs = finder.findOrganizationsByName(this.getClass().getName()); if (orgs == null) { fail("Only Expecting 1 Organization"); } else { assertEquals(1,orgs.size()); // then step through them for (Iterator orgIter = orgs.iterator(); orgIter.hasNext();) { Organization org = (Organization) orgIter.next(); System.out.println("Org name: " + printer.getName(org)); System.out.println("Org description: " + printer.getDescription(org)); System.out.println("Org key id: " + printer.getKey(org)); User user = org.getPrimaryContact(); System.out.println("Primary Contact Full Name : " + user.getPersonName().getFullName()); assertEquals("User name does not match", user.getPersonName().getFullName(), PERSON_NAME); Collection<EmailAddress> emailAddresses = user.getEmailAddresses(); System.out.println("Found " + emailAddresses.size() + " email addresses."); assertEquals("Should have found 1 email address, found " + emailAddresses.size(), 1, emailAddresses.size()); for (EmailAddress email : emailAddresses) { System.out.println("Primary Contact email : " + email.getAddress()); assertEquals("Email should be " + EMAIL, EMAIL, email.getAddress()); } Collection<PostalAddress> postalAddresses = user.getPostalAddresses(); System.out.println("Found " + postalAddresses.size() + " postal addresses."); assertEquals("Should have found 1 postal address, found " + postalAddresses.size(), 1, postalAddresses.size()); for (PostalAddress postalAddress : postalAddresses) { System.out.println("Postal Address is " + postalAddress); assertEquals("Street number should be " + STREET_NUMBER, STREET_NUMBER, postalAddress.getStreetNumber()); assertEquals("Street should be " + STREET, STREET, postalAddress.getStreet()); assertEquals("City should be " + CITY, CITY, postalAddress.getCity()); assertEquals("State should be " + STATE, STATE, postalAddress.getStateOrProvince()); assertEquals("Country should be " + COUNTRY, COUNTRY, postalAddress.getCountry()); assertEquals("Postal code should be " + POSTAL_CODE, POSTAL_CODE, postalAddress.getPostalCode()); } Collection<TelephoneNumber> numbers = user.getTelephoneNumbers(null); System.out.println("Found " + numbers.size() + " telephone numbers."); assertEquals("Should have found 1 phone number, found " + numbers.size(), 1, numbers.size()); for (TelephoneNumber tele : numbers) { System.out.println("Phone number is " + tele.getNumber()); assertEquals("Telephone number should be " + PHONE_NUMBER, PHONE_NUMBER, tele.getNumber()); } printer.printServices(org); printer.printClassifications(org); } }//end else } catch (JAXRException e) { e.printStackTrace(); fail(e.getMessage()); } }
/** * * to solve the getPrimaryContactProblem(), if we have no defined * primaryContact, we'll designate the first user as such * * @param user */ private void doPrimaryContactHack(User user) { if (primaryContact == null && users.size() == 0) { primaryContact = user; } }