List of usage examples for javax.xml.registry.infomodel EmailAddress getAddress
public String getAddress() throws JAXRException;
From source file:JAXRQuery.java
/** * Searches for organizations containing a string and * displays data about them.// w ww . j a v a 2 s . co m * * @param qString the string argument */ public void executeQuery(String qString) { RegistryService rs = null; BusinessQueryManager bqm = null; try { // Get registry service and query manager rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); System.out.println("Got registry service and query manager"); // Define find qualifiers and name patterns Collection<String> findQualifiers = new ArrayList<String>(); findQualifiers.add(SORT_BY_NAME_DESC); Collection<String> namePatterns = new ArrayList<String>(); namePatterns.add("%" + qString + "%"); // Find orgs with names that contain qString BulkResponse response = bqm.findOrganizations(findQualifiers, namePatterns, null, null, null, null); Collection orgs = response.getCollection(); // Display information about the organizations found int numOrgs = 0; if (orgs.isEmpty()) { System.out.println("No organizations found"); } else { for (Object o : orgs) { numOrgs++; Organization org = (Organization) o; System.out.println("Org name: " + getName(org)); System.out.println("Org description: " + getDescription(org)); System.out.println("Org key id: " + getKey(org)); // 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(null); for (Object n : phNums) { TelephoneNumber num = (TelephoneNumber) n; System.out.println(" Phone number: " + num.getNumber()); } Collection eAddrs = pc.getEmailAddresses(); for (Object a : eAddrs) { EmailAddress eAd = (EmailAddress) a; System.out.println(" Email address: " + eAd.getAddress()); } } // Display service and binding information Collection services = org.getServices(); for (Object s : services) { Service svc = (Service) s; System.out.println(" Service name: " + getName(svc)); System.out.println(" Service description: " + getDescription(svc)); Collection serviceBindings = svc.getServiceBindings(); for (Object b : serviceBindings) { ServiceBinding sb = (ServiceBinding) b; System.out.println(" Binding description: " + getDescription(sb)); System.out.println(" Access URI: " + sb.getAccessURI()); } } // Print spacer between organizations System.out.println(" --- "); } } System.out.println("Found " + numOrgs + " organization(s)"); } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:JAXRQueryByNAICSClassification.java
/** * Searches for organizations corresponding to an NAICS * classification and displays data about them. *///from w w w .j a v a2 s.co m public void executeQuery() { RegistryService rs = null; BusinessQueryManager bqm = null; BusinessLifeCycleManager blcm = null; try { // Get registry service and managers rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); blcm = rs.getBusinessLifeCycleManager(); System.out.println("Got registry service, query " + "manager, and lifecycle manager"); ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); // Find using an NAICS classification // Set classification scheme to NAICS, using // well-known UUID of ntis-gov:naics:1997 String uuid_naics = "uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"; ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(uuid_naics, LifeCycleManager.CLASSIFICATION_SCHEME); Collection<Classification> classifications = new ArrayList<Classification>(); if (cScheme != null) { // Create and add classification InternationalString sn = blcm.createInternationalString(bundle.getString("classification.name")); Classification classification = blcm.createClassification(cScheme, sn, bundle.getString("classification.value")); classifications.add(classification); } else { System.out.println("Classification scheme not found"); } BulkResponse response = bqm.findOrganizations(null, null, classifications, null, null, null); Collection orgs = response.getCollection(); // Display information about the organizations found int numOrgs = 0; if (orgs.isEmpty()) { System.out.println("No organizations found"); } else { for (Object o : orgs) { numOrgs++; Organization org = (Organization) o; System.out.println("Org name: " + getName(org)); System.out.println("Org description: " + getDescription(org)); System.out.println("Org key id: " + getKey(org)); // 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(null); for (Object n : phNums) { TelephoneNumber num = (TelephoneNumber) n; System.out.println(" Phone number: " + num.getNumber()); } Collection eAddrs = pc.getEmailAddresses(); for (Object a : eAddrs) { EmailAddress eAd = (EmailAddress) a; System.out.println(" Email Address: " + eAd.getAddress()); } } // Display classifications Collection classList = org.getClassifications(); for (Object cl : classList) { Classification c = (Classification) cl; System.out.println(" Classification name: " + getName(c)); System.out.println(" Classification value: " + c.getValue()); ClassificationScheme sch = c.getClassificationScheme(); System.out.println(" Classification scheme key: " + getKey(sch)); } // Print spacer between organizations System.out.println(" --- "); } } System.out.println("Found " + numOrgs + " organization(s)"); } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:JAXRQueryPostal.java
/** * Searches for organizations containing a string and * displays data about them, including the postal address in * either the JAXR PostalAddress format or the Slot format. *//from ww w . j av a 2s .com * @param qString the string argument */ public void executeQuery(String qString) { RegistryService rs = null; BusinessQueryManager bqm = null; try { // Get registry service and query manager rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); System.out.println("Got registry service and " + "query manager"); // Define find qualifiers and name patterns Collection<String> findQualifiers = new ArrayList<String>(); findQualifiers.add(SORT_BY_NAME_DESC); Collection<String> namePatterns = new ArrayList<String>(); namePatterns.add("%" + qString + "%"); // Find using the name BulkResponse response = bqm.findOrganizations(findQualifiers, namePatterns, null, null, null, null); Collection orgs = response.getCollection(); // Display information about the organizations found for (Object o : orgs) { Organization org = (Organization) o; System.out.println("Org name: " + getName(org)); System.out.println("Org description: " + getDescription(org)); System.out.println("Org key id: " + getKey(org)); // 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(null); for (Object n : phNums) { TelephoneNumber num = (TelephoneNumber) n; System.out.println(" Phone number: " + num.getNumber()); } Collection eAddrs = pc.getEmailAddresses(); for (Object a : eAddrs) { EmailAddress eAd = (EmailAddress) a; System.out.println(" Email Address: " + eAd.getAddress()); } // Display postal addresses // using PostalAddress methods Collection pAddrs = pc.getPostalAddresses(); for (Object pa : pAddrs) { PostalAddress pAd = (PostalAddress) pa; System.out.println(" Postal Address (PostalAddress methods):\n " + pAd.getStreetNumber() + " " + pAd.getStreet() + "\n " + pAd.getCity() + ", " + pAd.getStateOrProvince() + " " + pAd.getPostalCode() + "\n " + pAd.getCountry()); } // Display postal addresses // using Slot methods Collection pAddrs2 = pc.getPostalAddresses(); for (Object pa2 : pAddrs2) { PostalAddress pAd = (PostalAddress) pa2; Collection slots = pAd.getSlots(); System.out.println(" Postal Address (Slot methods):"); for (Object s : slots) { Slot slot = (Slot) s; Collection values = slot.getValues(); for (Object v : values) { String line = (String) v; System.out.println(" Line: " + line); } } } } // Display service and binding information Collection services = org.getServices(); for (Object s : services) { Service svc = (Service) s; System.out.println(" Service name: " + getName(svc)); System.out.println(" Service description: " + getDescription(svc)); Collection serviceBindings = svc.getServiceBindings(); for (Object b : serviceBindings) { ServiceBinding sb = (ServiceBinding) b; System.out.println(" Binding " + "Description: " + getDescription(sb)); System.out.println(" Access URI: " + sb.getAccessURI()); } } // Print spacer between organizations System.out.println(" --- "); } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:it.cnr.icar.eric.client.ui.thin.RegistrationInfoBean.java
public String doRegister() { log.trace("doRegister started"); String result = "unknown"; FacesContext context = FacesContext.getCurrentInstance(); if (!doCheckAuthDetails()) { return result; }// w ww. ja v a 2 s. c o m try { User user = (User) RegistryObjectCollectionBean.getInstance().getCurrentRegistryObjectBean() .getRegistryObject(); Collection<?> emails = user.getEmailAddresses(); ArrayList<EmailAddress> newList = new ArrayList<EmailAddress>(); Iterator<?> iters = emails.iterator(); while (iters.hasNext()) { EmailAddress email = (EmailAddress) iters.next(); if (null != email.getAddress() && email.getAddress().length() > 0) { newList.add(email); } } user.setEmailAddresses(newList); List<User> users = new ArrayList<User>(); users.add(user); BusinessLifeCycleManagerImpl blcm = RegistryBrowser.getBLCM(); handleAuth(); log.trace("calling saveObjects()"); BulkResponse resp = blcm.saveObjects(users); log.trace("saveObjects() returned"); if ((resp != null) && (resp.getStatus() != JAXRResponse.STATUS_SUCCESS)) { Collection<?> exceptions = resp.getExceptions(); if (exceptions != null && !exceptions.isEmpty()) { String msg = WebUIResourceBundle.getInstance().getString("errorRegistrationNeeded"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); log.error(msg); Iterator<?> iter = exceptions.iterator(); while (iter.hasNext()) { Exception e = (Exception) iter.next(); OutputExceptions.error(log, e); } } else { String msg = WebUIResourceBundle.getInstance().getString("registrationFailed"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); log.error(WebUIResourceBundle.getInstance().getString("message.RegistrationFailed")); } result = "error"; } else { // ??? Is (null == resp) really success? result = "registered"; doNext(); } } catch (Throwable t) { OutputExceptions.error(log, WebUIResourceBundle.getInstance().getString("message.RegistrationFailed"), WebUIResourceBundle.getInstance().getString("registrationFailed"), t); result = "error"; } finally { try { RegistryBrowser.getInstance().clearCredentials(); } catch (Throwable t) { // User doesn't need to hear about a cleanup problem OutputExceptions.logWarning(log, WebUIResourceBundle.getInstance().getString("message.couldNotClearCredentials"), t); } } return result; }
From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java
private List<RegistryObjectBean> getEmailAddressesSearchResultsBeans(RegistryObjectBean roBean) throws ClassNotFoundException, NoSuchMethodException, ExceptionInInitializerError, Exception { Collection<?> emailAddresses = roBean.getEmailAddresses(); if (emailAddresses == null) { return null; }/*from w w w . j ava2s . c o m*/ int numEmailAddressObjects = emailAddresses.size(); @SuppressWarnings("unused") ArrayList<Object> list = new ArrayList<Object>(numEmailAddressObjects); Iterator<?> roItr = emailAddresses.iterator(); if (log.isDebugEnabled()) { log.debug("Query results: "); } String objectType = "EmailAddress"; int numCols = 2; // Replace ObjectType with Id. TODO - formalize this convention List<RegistryObjectBean> roBeans = new ArrayList<RegistryObjectBean>(numEmailAddressObjects); for (@SuppressWarnings("unused") int i = 0; roItr.hasNext(); i++) { EmailAddress emailAddress = (EmailAddress) roItr.next(); String header = null; Object columnValue = null; @SuppressWarnings("unused") List<?> srvbHeader = new ArrayList<Object>(numCols); List<SearchResultValueBean> searchResultValueBeans = new ArrayList<SearchResultValueBean>(numCols); header = WebUIResourceBundle.getInstance().getString("Details"); columnValue = roBean.getId() + "." + emailAddress.hashCode(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = WebUIResourceBundle.getInstance().getString("Email Address"); columnValue = emailAddress.getAddress(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = WebUIResourceBundle.getInstance().getString("Type"); columnValue = emailAddress.getType(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = ""; columnValue = ""; searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); RegistryObjectBean srb = new RegistryObjectBean(searchResultValueBeans, roBean.getRegistryObject(), objectType, emailAddress, false); roBeans.add(srb); } return roBeans; }
From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java
/** * * Convert JAXR User Object to UDDI Contact *//*from w w w . j a va 2s .co m*/ public static Contact getContactFromJAXRUser(User user) throws JAXRException { Contact ct = objectFactory.createContact(); if (user == null) { return null; } Address[] addarr = new Address[0]; Phone[] phonearr = new Phone[0]; Email[] emailarr = new Email[0]; try { if (user.getPersonName() != null && user.getPersonName().getFullName() != null) { ct.setPersonName(user.getPersonName().getFullName()); } if (user.getType() != null) { ct.setUseType(user.getType()); } // Postal Address Collection<PostalAddress> postc = user.getPostalAddresses(); addarr = new Address[postc.size()]; Iterator<PostalAddress> iterator = postc.iterator(); int addarrPos = 0; while (iterator.hasNext()) { PostalAddress post = (PostalAddress) iterator.next(); addarr[addarrPos] = ScoutJaxrUddiHelper.getAddress(post); addarrPos++; } // Phone Numbers Collection ph = user.getTelephoneNumbers(null); phonearr = new Phone[ph.size()]; Iterator it = ph.iterator(); int phonearrPos = 0; while (it.hasNext()) { TelephoneNumber t = (TelephoneNumber) it.next(); Phone phone = objectFactory.createPhone(); String str = t.getNumber(); log.debug("Telephone=" + str); // FIXME: If phone number is null, should the phone // not be set at all, or set to empty string? if (str != null) { phone.setValue(str); } else { phone.setValue(""); } phonearr[phonearrPos] = phone; phonearrPos++; } // Email Addresses Collection ec = user.getEmailAddresses(); emailarr = new Email[ec.size()]; Iterator iter = ec.iterator(); int emailarrPos = 0; while (iter.hasNext()) { EmailAddress ea = (EmailAddress) iter.next(); Email email = objectFactory.createEmail(); if (ea.getAddress() != null) { email.setValue(ea.getAddress()); } // email.setText( ea.getAddress() ); if (ea.getType() != null) { email.setUseType(ea.getType()); } emailarr[emailarrPos] = email; emailarrPos++; } ct.getAddress().addAll(Arrays.asList(addarr)); ct.getPhone().addAll(Arrays.asList(phonearr)); ct.getEmail().addAll(Arrays.asList(emailarr)); } catch (Exception ud) { throw new JAXRException("Apache JAXR Impl:", ud); } return ct; }
From source file:org.apache.ws.scout.util.ScoutJaxrUddiV3Helper.java
/** * * Convert JAXR User Object to UDDI Contact *//* w w w . j a va 2 s . c o m*/ public static Contact getContactFromJAXRUser(User user) throws JAXRException { Contact ct = objectFactory.createContact(); if (user == null) { return null; } Address[] addarr = new Address[0]; Phone[] phonearr = new Phone[0]; Email[] emailarr = new Email[0]; try { if (user.getPersonName() != null && user.getPersonName().getFullName() != null) { org.uddi.api_v3.PersonName pn = new org.uddi.api_v3.PersonName(); pn.setValue(user.getPersonName().getFullName()); ct.getPersonName().add(pn); } if (user.getType() != null) { ct.setUseType(user.getType()); } // Postal Address Collection<PostalAddress> postc = user.getPostalAddresses(); addarr = new Address[postc.size()]; Iterator<PostalAddress> iterator = postc.iterator(); int addarrPos = 0; while (iterator.hasNext()) { PostalAddress post = (PostalAddress) iterator.next(); addarr[addarrPos] = ScoutJaxrUddiV3Helper.getAddress(post); addarrPos++; } // Phone Numbers Collection ph = user.getTelephoneNumbers(null); phonearr = new Phone[ph.size()]; Iterator it = ph.iterator(); int phonearrPos = 0; while (it.hasNext()) { TelephoneNumber t = (TelephoneNumber) it.next(); Phone phone = objectFactory.createPhone(); String str = t.getNumber(); log.debug("Telephone=" + str); // FIXME: If phone number is null, should the phone // not be set at all, or set to empty string? if (str != null) { phone.setValue(str); } else { phone.setValue(""); } phonearr[phonearrPos] = phone; phonearrPos++; } // Email Addresses Collection ec = user.getEmailAddresses(); emailarr = new Email[ec.size()]; Iterator iter = ec.iterator(); int emailarrPos = 0; while (iter.hasNext()) { EmailAddress ea = (EmailAddress) iter.next(); Email email = objectFactory.createEmail(); if (ea.getAddress() != null) { email.setValue(ea.getAddress()); } // email.setText( ea.getAddress() ); if (ea.getType() != null) { email.setUseType(ea.getType()); } emailarr[emailarrPos] = email; emailarrPos++; } ct.getAddress().addAll(Arrays.asList(addarr)); ct.getPhone().addAll(Arrays.asList(phonearr)); ct.getEmail().addAll(Arrays.asList(emailarr)); } catch (Exception ud) { throw new JAXRException("Apache JAXR Impl:", ud); } return ct; }