List of usage examples for javax.xml.registry.infomodel PostalAddress getCity
public String getCity() throws JAXRException;
From source file:it.cnr.icar.eric.client.xml.registry.util.CertificateUtil.java
/** * DOCUMENT ME!//w ww . ja v a2 s. co m * * @param user * DOCUMENT ME! * * @return DOCUMENT ME! * * @throws JAXRException * DOCUMENT ME! */ private static String getDNameFromUser(UserRegistrationInfo userRegInfo) throws JAXRException { User user = userRegInfo.getUser(); String dname = "CN="; LifeCycleManager lcm = user.getLifeCycleManager(); Collection<?> addresses = user.getPostalAddresses(); PostalAddress address; PersonName personName = user.getPersonName(); // CN=Farrukh Najmi, OU=freebxml.org, O=ebxmlrr, L=Islamabad, ST=Punjab, // C=PK if (personName == null) { personName = lcm.createPersonName("firstName", "middleName", "lastName"); } if ((addresses != null) && (addresses.size() > 0)) { address = (PostalAddress) (addresses.iterator().next()); } else { address = lcm.createPostalAddress("number", "street", "city", "state", "country", "postalCode", "Office"); } String city = address.getCity(); if ((city == null) || (city.length() == 0)) { city = "Unknown"; } String state = address.getStateOrProvince(); if ((state == null) || (state.length() == 0)) { state = "Unknown"; } String country = address.getCountry(); if ((country == null) || (country.length() == 0)) { country = "US"; } if (country.length() > 0) { country = country.substring(0, 2); } String organization = userRegInfo.getOrganization(); if (organization == null || organization.trim().length() == 0) { organization = "Unknown"; } String unit = userRegInfo.getOrganizationUnit(); if (unit == null || unit.trim().length() == 0) { unit = "Unknown"; } // Escape "," in formattedName per section 2.4 of RFC 2253. \u002c is // hex code for "," String formattedName = ((PersonNameImpl) personName).getFormattedName(); formattedName = formattedName.replaceAll(",", "\\\\,"); dname += (formattedName + ", OU=" + unit + ", O=" + organization + ", L=" + city + ", ST=" + state + ", C=" + country); return dname; }
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. *// ww w . java2 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 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 doCheckUserDetails() { log.trace("doCheckUserDetails started"); boolean valid = true; FacesContext context = FacesContext.getCurrentInstance(); UserPreferencesBean userPreferenceBean = (UserPreferencesBean) context.getExternalContext().getSessionMap() .get("userPreferencesBean"); User user = (User) RegistryObjectCollectionBean.getInstance().getCurrentRegistryObjectBean() .getRegistryObject();/*from w w w . j av a2 s.co m*/ try { if (user.getPersonName().getFirstName() == null || "".equals(user.getPersonName().getFirstName().trim())) { String msg = WebUIResourceBundle.getInstance().getString("requiredFieldMissing"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); valid = false; } else if (user.getPersonName().getLastName() == null || "".equals(user.getPersonName().getLastName().trim())) { String msg = WebUIResourceBundle.getInstance().getString("requiredFieldMissing"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); valid = false; } else if (user.getPostalAddresses() == null || user.getPostalAddresses().size() == 0) { String msg = WebUIResourceBundle.getInstance().getString("requiredFieldMissing"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); valid = false; } else { PostalAddress address = (PostalAddress) user.getPostalAddresses().iterator().next(); if (address.getCity() == null || "".equals(address.getCity().trim()) || (ProviderProperties.getInstance().getProperty("noStateOrProvince") .indexOf(userPreferenceBean.getContentLocale().getLanguage()) == -1 && (address.getStateOrProvince() == null || "".equals(address.getStateOrProvince().trim()))) || address.getCountry() == null || "".equals(address.getCountry().trim())) { String msg = WebUIResourceBundle.getInstance().getString("requiredFieldMissing"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); valid = false; } else if (address.getCountry().trim().length() != 2) { String msg = WebUIResourceBundle.getInstance().getString("countryDefinedByTwoChars"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); valid = false; } } } catch (JAXRException e) { OutputExceptions.error(log, WebUIResourceBundle.getInstance().getString("message.ExceptionOccured"), e); valid = false; } if (valid) { try { getX500Bean().setName(user.getPersonName().getFullName()); if (user.getPostalAddresses() != null && user.getPostalAddresses().size() > 0) { PostalAddress address = (PostalAddress) user.getPostalAddresses().iterator().next(); getX500Bean().setCity(address.getCity()); getX500Bean().setStateOrProvince(address.getStateOrProvince()); getX500Bean().setCountry(address.getCountry()); } } catch (JAXRException e) { OutputExceptions.error(log, WebUIResourceBundle.getInstance().getString("message.ExceptionOccured"), e); valid = false; } } if (valid) { doNext(); return "ok"; } else { return "error"; } }
From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java
private List<RegistryObjectBean> getPostalAddressesSearchResultsBeans(RegistryObjectBean roBean) throws ClassNotFoundException, NoSuchMethodException, ExceptionInInitializerError, Exception { Collection<?> postalAddresses = roBean.getPostalAddresses(); if (postalAddresses == null) { return null; }//from w ww .j a v a 2 s . c o m int numPostalAddressObjects = postalAddresses.size(); @SuppressWarnings("unused") ArrayList<Object> list = new ArrayList<Object>(numPostalAddressObjects); Iterator<?> roItr = postalAddresses.iterator(); if (log.isDebugEnabled()) { log.debug("Query results: "); } String objectType = "PostalAddress"; int numCols = 2; // Replace ObjectType with Id. TODO - formalize this convention ArrayList<RegistryObjectBean> roBeans = new ArrayList<RegistryObjectBean>(numPostalAddressObjects); for (@SuppressWarnings("unused") int i = 0; roItr.hasNext(); i++) { PostalAddress postalAddress = (PostalAddress) roItr.next(); String header = null; Object columnValue = null; @SuppressWarnings("unused") ArrayList<Object> srvbHeader = new ArrayList<Object>(numCols); ArrayList<SearchResultValueBean> searchResultValueBeans = new ArrayList<SearchResultValueBean>(numCols); header = WebUIResourceBundle.getInstance().getString("Details"); columnValue = roBean.getId() + "." + postalAddress.hashCode(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = WebUIResourceBundle.getInstance().getString("Street Number"); columnValue = postalAddress.getStreetNumber(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = WebUIResourceBundle.getInstance().getString("Street"); columnValue = postalAddress.getStreet(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = WebUIResourceBundle.getInstance().getString("City"); columnValue = postalAddress.getCity(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); RegistryObjectBean srb = new RegistryObjectBean(searchResultValueBeans, roBean.getRegistryObject(), objectType, postalAddress, false); roBeans.add(srb); } return roBeans; }
From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java
/** * Get UDDI Address given JAXR Postal Address *//*from w ww. j a v a 2s. c om*/ public static Address getAddress(PostalAddress postalAddress) throws JAXRException { Address address = objectFactory.createAddress(); AddressLine[] addarr = new AddressLine[6]; String stnum = postalAddress.getStreetNumber(); String st = postalAddress.getStreet(); String city = postalAddress.getCity(); String country = postalAddress.getCountry(); String code = postalAddress.getPostalCode(); String state = postalAddress.getStateOrProvince(); AddressLine stnumAL = objectFactory.createAddressLine(); stnumAL.setKeyName("STREET_NUMBER"); if (stnum != null) { stnumAL.setKeyValue(stnum); } AddressLine stAL = objectFactory.createAddressLine(); stAL.setKeyName("STREET"); if (st != null) { stAL.setKeyValue(st); } AddressLine cityAL = objectFactory.createAddressLine(); cityAL.setKeyName("CITY"); if (city != null) { cityAL.setKeyValue(city); } AddressLine countryAL = objectFactory.createAddressLine(); countryAL.setKeyName("COUNTRY"); if (country != null) { countryAL.setKeyValue(country); } AddressLine codeAL = objectFactory.createAddressLine(); codeAL.setKeyName("POSTALCODE"); if (code != null) { codeAL.setKeyValue(code); } AddressLine stateAL = objectFactory.createAddressLine(); stateAL.setKeyName("STATE"); if (state != null) { stateAL.setKeyValue(state); } // Add the AddressLine to vector addarr[0] = stnumAL; addarr[1] = stAL; addarr[2] = cityAL; addarr[3] = countryAL; addarr[4] = codeAL; addarr[5] = stateAL; address.getAddressLine().addAll(Arrays.asList(addarr)); return address; }
From source file:org.apache.ws.scout.util.ScoutJaxrUddiV3Helper.java
/** * Get UDDI Address given JAXR Postal Address *///from w w w.jav a 2 s.com public static Address getAddress(PostalAddress postalAddress) throws JAXRException { Address address = objectFactory.createAddress(); AddressLine[] addarr = new AddressLine[7]; String stnum = postalAddress.getStreetNumber(); String st = postalAddress.getStreet(); String city = postalAddress.getCity(); String country = postalAddress.getCountry(); String code = postalAddress.getPostalCode(); String state = postalAddress.getStateOrProvince(); String type = postalAddress.getType(); AddressLine stnumAL = objectFactory.createAddressLine(); stnumAL.setKeyName("STREET_NUMBER"); if (stnum != null) { stnumAL.setKeyValue("STREET_NUMBER"); stnumAL.setValue(stnum); } AddressLine stAL = objectFactory.createAddressLine(); stAL.setKeyName("STREET"); if (st != null) { stAL.setKeyValue("STREET"); stAL.setValue(st); } AddressLine cityAL = objectFactory.createAddressLine(); cityAL.setKeyName("CITY"); if (city != null) { cityAL.setKeyValue("CITY"); cityAL.setValue(city); } AddressLine countryAL = objectFactory.createAddressLine(); countryAL.setKeyName("COUNTRY"); if (country != null) { countryAL.setKeyValue("COUNTRY"); countryAL.setValue(country); } AddressLine codeAL = objectFactory.createAddressLine(); codeAL.setKeyName("POSTALCODE"); if (code != null) { codeAL.setKeyValue("POSTALCODE"); codeAL.setValue(code); } AddressLine stateAL = objectFactory.createAddressLine(); stateAL.setKeyName("STATE"); if (state != null) { stateAL.setKeyValue("STATE"); stateAL.setValue(state); } AddressLine typeAL = objectFactory.createAddressLine(); typeAL.setKeyName("TYPE"); if (type != null) { typeAL.setKeyValue("TYPE"); typeAL.setValue(type); } // Add the AddressLine to vector addarr[0] = stnumAL; addarr[1] = stAL; addarr[2] = cityAL; addarr[3] = countryAL; addarr[4] = codeAL; addarr[5] = stateAL; addarr[6] = typeAL; address.getAddressLine().addAll(Arrays.asList(addarr)); return address; }