List of usage examples for javax.xml.registry.infomodel ServiceBinding getAccessURI
String getAccessURI() throws JAXRException;
From source file:JAXRQuery.java
/** * Searches for organizations containing a string and * displays data about them./*from w w w . j ava2 s.c om*/ * * @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: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. */* w w w .j av a 2 s . 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:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java
public static BindingTemplate getBindingTemplateFromJAXRSB(ServiceBinding serviceBinding) throws JAXRException { BindingTemplate bt = objectFactory.createBindingTemplate(); if (serviceBinding.getKey() != null && serviceBinding.getKey().getId() != null) { bt.setBindingKey(serviceBinding.getKey().getId()); } else {//w w w . j a va2 s . c om bt.setBindingKey(""); } try { // Set Access URI String accessuri = serviceBinding.getAccessURI(); if (accessuri != null) { AccessPoint accessPoint = objectFactory.createAccessPoint(); accessPoint.setURLType(getURLType(accessuri)); accessPoint.setValue(accessuri); bt.setAccessPoint(accessPoint); } ServiceBinding sb = serviceBinding.getTargetBinding(); if (sb != null) { HostingRedirector red = objectFactory.createHostingRedirector(); Key key = sb.getKey(); if (key != null && key.getId() != null) { red.setBindingKey(key.getId()); } else { red.setBindingKey(""); } bt.setHostingRedirector(red); } else { if (bt.getAccessPoint() == null) { bt.setAccessPoint(objectFactory.createAccessPoint()); } } // TODO:Need to look further at the mapping b/w BindingTemplate and // Jaxr ServiceBinding // Get Service information Service svc = serviceBinding.getService(); if (svc != null && svc.getKey() != null && svc.getKey().getId() != null) { bt.setServiceKey(svc.getKey().getId()); } InternationalString idesc = serviceBinding.getDescription(); addDescriptions(bt.getDescription(), idesc); // SpecificationLink Collection<SpecificationLink> slcol = serviceBinding.getSpecificationLinks(); TModelInstanceDetails tid = objectFactory.createTModelInstanceDetails(); if (slcol != null && !slcol.isEmpty()) { Iterator<SpecificationLink> iter = slcol.iterator(); while (iter.hasNext()) { SpecificationLink slink = (SpecificationLink) iter.next(); TModelInstanceInfo emptyTInfo = objectFactory.createTModelInstanceInfo(); tid.getTModelInstanceInfo().add(emptyTInfo); RegistryObject specificationObject = slink.getSpecificationObject(); if (specificationObject.getKey() != null && specificationObject.getKey().getId() != null) { emptyTInfo.setTModelKey(specificationObject.getKey().getId()); if (specificationObject.getDescription() != null) { for (Object o : specificationObject.getDescription().getLocalizedStrings()) { LocalizedString locDesc = (LocalizedString) o; Description description = objectFactory.createDescription(); emptyTInfo.getDescription().add(description); description.setValue(locDesc.getValue()); description.setLang(locDesc.getLocale().getLanguage()); } } Collection<ExternalLink> externalLinks = slink.getExternalLinks(); if (externalLinks != null && externalLinks.size() > 0) { for (ExternalLink link : externalLinks) { InstanceDetails ids = objectFactory.createInstanceDetails(); emptyTInfo.setInstanceDetails(ids); if (link.getDescription() != null) { Description description = objectFactory.createDescription(); ids.getDescription().add(description); description.setValue(link.getDescription().getValue()); } if (link.getExternalURI() != null) { OverviewDoc overviewDoc = objectFactory.createOverviewDoc(); ids.setOverviewDoc(overviewDoc); overviewDoc.setOverviewURL(link.getExternalURI()); } } } } } } bt.setTModelInstanceDetails(tid); log.debug("BindingTemplate=" + bt.toString()); } catch (Exception ud) { throw new JAXRException("Apache JAXR Impl:", ud); } return bt; }
From source file:org.apache.ws.scout.util.ScoutJaxrUddiV3Helper.java
public static BindingTemplate getBindingTemplateFromJAXRSB(ServiceBinding serviceBinding) throws JAXRException { BindingTemplate bt = objectFactory.createBindingTemplate(); if (serviceBinding.getKey() != null && serviceBinding.getKey().getId() != null) { bt.setBindingKey(serviceBinding.getKey().getId()); } else {//from w w w. j ava 2 s . co m bt.setBindingKey(""); } try { // Set Access URI String accessuri = serviceBinding.getAccessURI(); if (accessuri != null) { AccessPoint accessPoint = objectFactory.createAccessPoint(); accessPoint.setUseType(getUseType(accessuri)); accessPoint.setValue(accessuri); bt.setAccessPoint(accessPoint); } ServiceBinding sb = serviceBinding.getTargetBinding(); if (sb != null) { HostingRedirector red = objectFactory.createHostingRedirector(); Key key = sb.getKey(); if (key != null && key.getId() != null) { red.setBindingKey(key.getId()); } else { red.setBindingKey(""); } bt.setHostingRedirector(red); } else { if (bt.getAccessPoint() == null) { bt.setAccessPoint(objectFactory.createAccessPoint()); } } // TODO:Need to look further at the mapping b/w BindingTemplate and // Jaxr ServiceBinding CategoryBag catBag = getCategoryBagFromClassifications(serviceBinding.getClassifications()); if (catBag != null) { bt.setCategoryBag(catBag); } // Get Service information Service svc = serviceBinding.getService(); if (svc != null && svc.getKey() != null && svc.getKey().getId() != null) { bt.setServiceKey(svc.getKey().getId()); } InternationalString idesc = serviceBinding.getDescription(); addDescriptions(bt.getDescription(), idesc); // SpecificationLink Collection<SpecificationLink> slcol = serviceBinding.getSpecificationLinks(); TModelInstanceDetails tid = objectFactory.createTModelInstanceDetails(); if (slcol != null && !slcol.isEmpty()) { Iterator<SpecificationLink> iter = slcol.iterator(); while (iter.hasNext()) { SpecificationLink slink = (SpecificationLink) iter.next(); TModelInstanceInfo emptyTInfo = objectFactory.createTModelInstanceInfo(); tid.getTModelInstanceInfo().add(emptyTInfo); RegistryObject specificationObject = slink.getSpecificationObject(); if (specificationObject.getKey() != null && specificationObject.getKey().getId() != null) { emptyTInfo.setTModelKey(specificationObject.getKey().getId()); if (specificationObject.getDescription() != null) { for (Object o : specificationObject.getDescription().getLocalizedStrings()) { LocalizedString locDesc = (LocalizedString) o; Description description = objectFactory.createDescription(); emptyTInfo.getDescription().add(description); description.setValue(locDesc.getValue()); description.setLang(locDesc.getLocale().getLanguage()); } } Collection<ExternalLink> externalLinks = slink.getExternalLinks(); if (externalLinks != null && externalLinks.size() > 0) { for (ExternalLink link : externalLinks) { InstanceDetails ids = objectFactory.createInstanceDetails(); emptyTInfo.setInstanceDetails(ids); if (link.getDescription() != null) { Description description = objectFactory.createDescription(); ids.getDescription().add(description); description.setValue(link.getDescription().getValue()); } if (link.getExternalURI() != null) { OverviewDoc overviewDoc = objectFactory.createOverviewDoc(); ids.getOverviewDoc().add(overviewDoc); org.uddi.api_v3.OverviewURL ourl = new org.uddi.api_v3.OverviewURL(); ourl.setValue(link.getExternalURI()); overviewDoc.setOverviewURL(ourl); } if (slink.getUsageParameters() != null) { StringBuffer buffer = new StringBuffer(); for (Object o : slink.getUsageParameters()) { String s = (String) o; buffer.append(s + " "); } ids.setInstanceParms(buffer.toString().trim()); } } } } } } if (tid.getTModelInstanceInfo().size() != 0) { bt.setTModelInstanceDetails(tid); } log.debug("BindingTemplate=" + bt.toString()); } catch (Exception ud) { throw new JAXRException("Apache JAXR Impl:", ud); } return bt; }