Modified: juddi/trunk/juddi-examples/simple-browse/src/main/java/org/apache/juddi/example/browse/SimpleBrowse.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/simple-browse/src/main/java/org/apache/juddi/example/browse/SimpleBrowse.java?rev=1556671&r1=1556670&r2=1556671&view=diff ============================================================================== --- juddi/trunk/juddi-examples/simple-browse/src/main/java/org/apache/juddi/example/browse/SimpleBrowse.java (original) +++ juddi/trunk/juddi-examples/simple-browse/src/main/java/org/apache/juddi/example/browse/SimpleBrowse.java Wed Jan 8 23:34:32 2014 @@ -16,7 +16,6 @@ */ package org.apache.juddi.example.browse; - import java.util.List; import java.util.Properties; import org.apache.juddi.api_v3.AccessPointType; @@ -33,6 +32,7 @@ import org.uddi.api_v3.BusinessService; import org.uddi.api_v3.CategoryBag; import org.uddi.api_v3.Contacts; import org.uddi.api_v3.Description; +import org.uddi.api_v3.DiscardAuthToken; import org.uddi.api_v3.FindBusiness; import org.uddi.api_v3.GetAuthToken; import org.uddi.api_v3.GetBusinessDetail; @@ -51,345 +51,311 @@ import org.uddi.v3_service.UDDISecurityP */ public class SimpleBrowse { - private static UDDISecurityPortType security = null; - private static UDDIInquiryPortType inquiry = null; + private static UDDISecurityPortType security = null; + private static UDDIInquiryPortType inquiry = null; - /** - * This sets up the ws proxies using uddi.xml in META-INF - */ - public SimpleBrowse() { - try { + /** + * This sets up the ws proxies using uddi.xml in META-INF + */ + public SimpleBrowse() { + try { // create a manager and read the config in the archive; - // you can use your config file name - UDDIClient client = new UDDIClient("META-INF/simple-browse-uddi.xml"); + // you can use your config file name + UDDIClient client = new UDDIClient("META-INF/simple-browse-uddi.xml"); // a UDDIClient can be a client to multiple UDDI nodes, so - // supply the nodeName (defined in your uddi.xml. - // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml - Transport transport = client.getTransport("default"); - // Now you create a reference to the UDDI API - security = transport.getUDDISecurityService(); - inquiry = transport.getUDDIInquiryService(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static void DisplayHelp() { - //TODO - } - - /** - * Main entry point - * - * @param args - */ - public static void main(String args[]) { - if (args.length == 1 && args[0].equalsIgnoreCase("help")) { - DisplayHelp(); - return; - } - SimpleBrowse sp = new SimpleBrowse(); - sp.Browse(args); - } - - public void Browse(String[] args) { - try { - Properties prop = ParseArgs(args); - if (prop.containsKey("AuthStyle")) { - //TODO, determine a way to pass parameters from the command line, hardcoded for now - //UDDI Token - //HTTP Username/Password (basic or digest) - //HTTP Client Cert - } - - String token = GetAuthKey("uddi", "uddi", AuthStyle.UDDI_AUTH); - BusinessList findBusiness = GetBusinessList(token); - PrintBusinessInfo(findBusiness.getBusinessInfos()); - PrintBusinessDetails(findBusiness.getBusinessInfos(), token); - PrintServiceDetailsByBusiness(findBusiness.getBusinessInfos(), token); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Find all of the registered businesses. This list may be filtered based on - * access control rules - * - * @param token - * @return - * @throws Exception - */ - private BusinessList GetBusinessList(String token) throws Exception { - FindBusiness fb = new FindBusiness(); - fb.setAuthInfo(token); - org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers(); - fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH); - - fb.setFindQualifiers(fq); - Name searchname = new Name(); - searchname.setValue(UDDIConstants.WILDCARD); - fb.getName().add(searchname); - BusinessList findBusiness = inquiry.findBusiness(fb); - return findBusiness; - - } - - /** - * Converts category bags of tmodels to a readable string - * @param categoryBag - * @return - */ - private String CatBagToString(CategoryBag categoryBag) { - StringBuilder sb = new StringBuilder(); - if (categoryBag == null) { - return "no data"; - } - for (int i = 0; i < categoryBag.getKeyedReference().size(); i++) { - sb.append(KeyedReferenceToString(categoryBag.getKeyedReference().get(i))); - } - for (int i = 0; i < categoryBag.getKeyedReferenceGroup().size(); i++) { - sb.append("Key Ref Grp: TModelKey="); - for (int k = 0; k < categoryBag.getKeyedReferenceGroup().get(i).getKeyedReference().size(); k++) { - sb.append(KeyedReferenceToString(categoryBag.getKeyedReferenceGroup().get(i).getKeyedReference().get(k))); - } - } - return sb.toString(); - } - - - private String KeyedReferenceToString(KeyedReference item) { - StringBuilder sb = new StringBuilder(); - sb.append("Key Ref: Name="). - append(item.getKeyName()). - append(" Value="). - append(item.getKeyValue()). - append(" tModel="). - append(item.getTModelKey()). - append(System.getProperty("line.separator")); - return sb.toString(); - } - - - private void PrintContacts(Contacts contacts) { - if (contacts == null) { - return; - } - for (int i = 0; i < contacts.getContact().size(); i++) { - System.out.println("Contact " + i + " type:" + contacts.getContact().get(i).getUseType()); - for (int k = 0; k < contacts.getContact().get(i).getPersonName().size(); k++) { - System.out.println("Name: " + contacts.getContact().get(i).getPersonName().get(k).getValue()); - } - for (int k = 0; k < contacts.getContact().get(i).getEmail().size(); k++) { - System.out.println("Email: " + contacts.getContact().get(i).getEmail().get(k).getValue()); - } - for (int k = 0; k < contacts.getContact().get(i).getAddress().size(); k++) { - System.out.println("Address sort code " + contacts.getContact().get(i).getAddress().get(k).getSortCode()); - System.out.println("Address use type " + contacts.getContact().get(i).getAddress().get(k).getUseType()); - System.out.println("Address tmodel key " + contacts.getContact().get(i).getAddress().get(k).getTModelKey()); - for (int x = 0; x < contacts.getContact().get(i).getAddress().get(k).getAddressLine().size(); x++) { - System.out.println("Address line value " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getValue()); - System.out.println("Address line key name " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getKeyName()); - System.out.println("Address line key value " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getKeyValue()); - } - } - for (int k = 0; k < contacts.getContact().get(i).getDescription().size(); k++) { - System.out.println("Desc: " + contacts.getContact().get(i).getDescription().get(k).getValue()); - } - for (int k = 0; k < contacts.getContact().get(i).getPhone().size(); k++) { - System.out.println("Phone: " + contacts.getContact().get(i).getPhone().get(k).getValue()); - } - } - - } - - private void PrintServiceDetail(BusinessService get) { - if (get == null) { - return; - } - System.out.println("Name " + ListToString(get.getName())); - System.out.println("Desc " + ListToDescString(get.getDescription())); - System.out.println("Key " + (get.getServiceKey())); - System.out.println("Cat bag " + CatBagToString(get.getCategoryBag())); - if (!get.getSignature().isEmpty()) { - System.out.println("Item is digitally signed"); - } else { - System.out.println("Item is not digitally signed"); - } - PrintBindingTemplates(get.getBindingTemplates()); - } - - /** - * This function is useful for translating UDDI's somewhat complex data format to something that is more useful. - * @param bindingTemplates - */ - private void PrintBindingTemplates(BindingTemplates bindingTemplates) { - if (bindingTemplates == null) { - return; + // supply the nodeName (defined in your uddi.xml. + // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml + Transport transport = client.getTransport("default"); + // Now you create a reference to the UDDI API + security = transport.getUDDISecurityService(); + inquiry = transport.getUDDIInquiryService(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Main entry point + * + * @param args + */ + public static void main(String args[]) { + + SimpleBrowse sp = new SimpleBrowse(); + sp.Browse(args); + } + + public void Browse(String[] args) { + try { + + String token = GetAuthKey("uddi", "uddi"); + BusinessList findBusiness = GetBusinessList(token); + PrintBusinessInfo(findBusiness.getBusinessInfos()); + PrintBusinessDetails(findBusiness.getBusinessInfos(), token); + PrintServiceDetailsByBusiness(findBusiness.getBusinessInfos(), token); + + security.discardAuthToken(new DiscardAuthToken(token)); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Find all of the registered businesses. This list may be filtered + * based on access control rules + * + * @param token + * @return + * @throws Exception + */ + private BusinessList GetBusinessList(String token) throws Exception { + FindBusiness fb = new FindBusiness(); + fb.setAuthInfo(token); + org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers(); + fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH); + + fb.setFindQualifiers(fq); + Name searchname = new Name(); + searchname.setValue(UDDIConstants.WILDCARD); + fb.getName().add(searchname); + BusinessList findBusiness = inquiry.findBusiness(fb); + return findBusiness; + + } + + /** + * Converts category bags of tmodels to a readable string + * + * @param categoryBag + * @return + */ + private String CatBagToString(CategoryBag categoryBag) { + StringBuilder sb = new StringBuilder(); + if (categoryBag == null) { + return "no data"; + } + for (int i = 0; i < categoryBag.getKeyedReference().size(); i++) { + sb.append(KeyedReferenceToString(categoryBag.getKeyedReference().get(i))); + } + for (int i = 0; i < categoryBag.getKeyedReferenceGroup().size(); i++) { + sb.append("Key Ref Grp: TModelKey="); + for (int k = 0; k < categoryBag.getKeyedReferenceGroup().get(i).getKeyedReference().size(); k++) { + sb.append(KeyedReferenceToString(categoryBag.getKeyedReferenceGroup().get(i).getKeyedReference().get(k))); + } + } + return sb.toString(); + } + + private String KeyedReferenceToString(KeyedReference item) { + StringBuilder sb = new StringBuilder(); + sb.append("Key Ref: Name="). + append(item.getKeyName()). + append(" Value="). + append(item.getKeyValue()). + append(" tModel="). + append(item.getTModelKey()). + append(System.getProperty("line.separator")); + return sb.toString(); + } + + private void PrintContacts(Contacts contacts) { + if (contacts == null) { + return; + } + for (int i = 0; i < contacts.getContact().size(); i++) { + System.out.println("Contact " + i + " type:" + contacts.getContact().get(i).getUseType()); + for (int k = 0; k < contacts.getContact().get(i).getPersonName().size(); k++) { + System.out.println("Name: " + contacts.getContact().get(i).getPersonName().get(k).getValue()); + } + for (int k = 0; k < contacts.getContact().get(i).getEmail().size(); k++) { + System.out.println("Email: " + contacts.getContact().get(i).getEmail().get(k).getValue()); + } + for (int k = 0; k < contacts.getContact().get(i).getAddress().size(); k++) { + System.out.println("Address sort code " + contacts.getContact().get(i).getAddress().get(k).getSortCode()); + System.out.println("Address use type " + contacts.getContact().get(i).getAddress().get(k).getUseType()); + System.out.println("Address tmodel key " + contacts.getContact().get(i).getAddress().get(k).getTModelKey()); + for (int x = 0; x < contacts.getContact().get(i).getAddress().get(k).getAddressLine().size(); x++) { + System.out.println("Address line value " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getValue()); + System.out.println("Address line key name " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getKeyName()); + System.out.println("Address line key value " + contacts.getContact().get(i).getAddress().get(k).getAddressLine().get(x).getKeyValue()); + } + } + for (int k = 0; k < contacts.getContact().get(i).getDescription().size(); k++) { + System.out.println("Desc: " + contacts.getContact().get(i).getDescription().get(k).getValue()); + } + for (int k = 0; k < contacts.getContact().get(i).getPhone().size(); k++) { + System.out.println("Phone: " + contacts.getContact().get(i).getPhone().get(k).getValue()); + } + } + } - for (int i = 0; i < bindingTemplates.getBindingTemplate().size(); i++) { - System.out.println("Binding Key: " + bindingTemplates.getBindingTemplate().get(i).getBindingKey()); + + private void PrintServiceDetail(BusinessService get) { + if (get == null) { + return; + } + System.out.println("Name " + ListToString(get.getName())); + System.out.println("Desc " + ListToDescString(get.getDescription())); + System.out.println("Key " + (get.getServiceKey())); + System.out.println("Cat bag " + CatBagToString(get.getCategoryBag())); + if (!get.getSignature().isEmpty()) { + System.out.println("Item is digitally signed"); + } else { + System.out.println("Item is not digitally signed"); + } + PrintBindingTemplates(get.getBindingTemplates()); + } + + /** + * This function is useful for translating UDDI's somewhat complex data + * format to something that is more useful. + * + * @param bindingTemplates + */ + private void PrintBindingTemplates(BindingTemplates bindingTemplates) { + if (bindingTemplates == null) { + return; + } + for (int i = 0; i < bindingTemplates.getBindingTemplate().size(); i++) { + System.out.println("Binding Key: " + bindingTemplates.getBindingTemplate().get(i).getBindingKey()); //TODO The UDDI spec is kind of strange at this point. - //An access point could be a URL, a reference to another UDDI binding key, a hosting redirector (which is - //esscentially a pointer to another UDDI registry) or a WSDL Deployment - //From an end client's perspective, all you really want is the endpoint. - //http://uddi.org/pubs/uddi_v3.htm#_Ref8977716 - //So if you have a wsdlDeployment useType, fetch the wsdl and parse for the invocation URL - //If its hosting director, you'll have to fetch that data from uddi recursively until the leaf node is found - //Consult the UDDI specification for more information - - if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint() != null) { - System.out.println("Access Point: " + bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getValue() + " type " + bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType()); - if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType()!=null) - { - if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType().equalsIgnoreCase(AccessPointType.END_POINT.toString())) - { - System.out.println("Use this access point value as an invocation endpoint."); - } - if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType().equalsIgnoreCase(AccessPointType.BINDING_TEMPLATE.toString())) - { - System.out.println("Use this access point value as a reference to another binding template."); - } - if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType().equalsIgnoreCase(AccessPointType.WSDL_DEPLOYMENT.toString())) - { - System.out.println("Use this access point value as a URL to a WSDL document, which presumably will have a real access point defined."); - } - if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType().equalsIgnoreCase(AccessPointType.HOSTING_REDIRECTOR.toString())) - { - System.out.println("Use this access point value as an Inquiry URL of another UDDI registry, look up the same binding template there (usage varies)."); - } - } - } - - } - } - - private enum AuthStyle { - - HTTP_BASIC, - HTTP_DIGEST, - HTTP_NTLM, - UDDI_AUTH, - HTTP_CLIENT_CERT - } - - /** - * Gets a UDDI style auth token, otherwise, appends credentials to the ws - * proxies (not yet implemented) - * - * @param username - * @param password - * @param style - * @return - */ - private String GetAuthKey(String username, String password, AuthStyle style) { - try { - - GetAuthToken getAuthTokenRoot = new GetAuthToken(); - getAuthTokenRoot.setUserID(username); - getAuthTokenRoot.setCred(password); - - // Making API call that retrieves the authentication token for the 'root' user. - AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot); - System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo()); - return rootAuthToken.getAuthInfo(); - } catch (Exception ex) { - System.out.println("Could not authenticate with the provided credentials " + ex.getMessage()); - } - return null; - } - - /** - * Converts command line args into a simple property structure - * - * @param args - * @return - */ - private Properties ParseArgs(String[] args) { - - Properties p = new Properties(); - if (args == null) { - return p; - } - for (int i = 0; i < args.length; i++) { - if (args[i] != null && args[i].length() >= 3) { - p.put(args[i].split("=")[0], args[i].split("=")[1]); - } - } - return p; - } - - private void PrintBusinessInfo(BusinessInfos businessInfos) { - if (businessInfos == null) { - System.out.println("No data returned"); - } else { - for (int i = 0; i < businessInfos.getBusinessInfo().size(); i++) { - System.out.println("==============================================="); - System.out.println("Business Key: " + businessInfos.getBusinessInfo().get(i).getBusinessKey()); - System.out.println("Name: " + ListToString(businessInfos.getBusinessInfo().get(i).getName())); - - System.out.println("Description: " + ListToDescString(businessInfos.getBusinessInfo().get(i).getDescription())); - System.out.println("Services:"); - PrintServiceInfo(businessInfos.getBusinessInfo().get(i).getServiceInfos()); - } - } - } - - private String ListToString(List<Name> name) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < name.size(); i++) { - sb.append(name.get(i).getValue()).append(" "); - } - return sb.toString(); - } - - private String ListToDescString(List<Description> name) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < name.size(); i++) { - sb.append(name.get(i).getValue()).append(" "); - } - return sb.toString(); - } - - private void PrintServiceInfo(ServiceInfos serviceInfos) { - for (int i = 0; i < serviceInfos.getServiceInfo().size(); i++) { - System.out.println("-------------------------------------------"); - System.out.println("Service Key: " + serviceInfos.getServiceInfo().get(i).getServiceKey()); - System.out.println("Owning Business Key: " + serviceInfos.getServiceInfo().get(i).getBusinessKey()); - System.out.println("Name: " + ListToString(serviceInfos.getServiceInfo().get(i).getName())); - } - } - - private void PrintBusinessDetails(BusinessInfos businessInfos, String token) throws Exception { - GetBusinessDetail gbd = new GetBusinessDetail(); - gbd.setAuthInfo(token); - for (int i = 0; i < businessInfos.getBusinessInfo().size(); i++) { - gbd.getBusinessKey().add(businessInfos.getBusinessInfo().get(i).getBusinessKey()); - } - BusinessDetail businessDetail = inquiry.getBusinessDetail(gbd); - for (int i = 0; i < businessDetail.getBusinessEntity().size(); i++) { - System.out.println("Business Detail - key: " + businessDetail.getBusinessEntity().get(i).getBusinessKey()); - System.out.println("Name: " + ListToString(businessDetail.getBusinessEntity().get(i).getName())); - System.out.println("CategoryBag: " + CatBagToString(businessDetail.getBusinessEntity().get(i).getCategoryBag())); - PrintContacts(businessDetail.getBusinessEntity().get(i).getContacts()); - } - } - - private void PrintServiceDetailsByBusiness(BusinessInfos businessInfos, String token) throws Exception { - for (int i = 0; i < businessInfos.getBusinessInfo().size(); i++) { - GetServiceDetail gsd = new GetServiceDetail(); - for (int k = 0; k < businessInfos.getBusinessInfo().get(i).getServiceInfos().getServiceInfo().size(); k++) { - gsd.getServiceKey().add(businessInfos.getBusinessInfo().get(i).getServiceInfos().getServiceInfo().get(k).getServiceKey()); - } - gsd.setAuthInfo(token); - System.out.println("Fetching data for business " + businessInfos.getBusinessInfo().get(i).getBusinessKey()); - ServiceDetail serviceDetail = inquiry.getServiceDetail(gsd); - for (int k = 0; k < serviceDetail.getBusinessService().size(); k++) { - PrintServiceDetail(serviceDetail.getBusinessService().get(k)); - } - System.out.println("................"); + //An access point could be a URL, a reference to another UDDI binding key, a hosting redirector (which is + //esscentially a pointer to another UDDI registry) or a WSDL Deployment + //From an end client's perspective, all you really want is the endpoint. + //http://uddi.org/pubs/uddi_v3.htm#_Ref8977716 + //So if you have a wsdlDeployment useType, fetch the wsdl and parse for the invocation URL + //If its hosting director, you'll have to fetch that data from uddi recursively until the leaf node is found + //Consult the UDDI specification for more information + + if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint() != null) { + System.out.println("Access Point: " + bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getValue() + " type " + bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType()); + if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType() != null) { + if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType().equalsIgnoreCase(AccessPointType.END_POINT.toString())) { + System.out.println("Use this access point value as an invocation endpoint."); + } + if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType().equalsIgnoreCase(AccessPointType.BINDING_TEMPLATE.toString())) { + System.out.println("Use this access point value as a reference to another binding template."); + } + if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType().equalsIgnoreCase(AccessPointType.WSDL_DEPLOYMENT.toString())) { + System.out.println("Use this access point value as a URL to a WSDL document, which presumably will have a real access point defined."); + } + if (bindingTemplates.getBindingTemplate().get(i).getAccessPoint().getUseType().equalsIgnoreCase(AccessPointType.HOSTING_REDIRECTOR.toString())) { + System.out.println("Use this access point value as an Inquiry URL of another UDDI registry, look up the same binding template there (usage varies)."); + } + } + } + } + } + + private enum AuthStyle { + + HTTP_BASIC, + HTTP_DIGEST, + HTTP_NTLM, + UDDI_AUTH, + HTTP_CLIENT_CERT + } + + /** + * Gets a UDDI style auth token, otherwise, appends credentials to the + * ws proxies (not yet implemented) + * + * @param username + * @param password + * @param style + * @return + */ + private String GetAuthKey(String username, String password) { + try { + + GetAuthToken getAuthTokenRoot = new GetAuthToken(); + getAuthTokenRoot.setUserID(username); + getAuthTokenRoot.setCred(password); + + // Making API call that retrieves the authentication token for the user. + AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot); + System.out.println(username + " AUTHTOKEN = (don't log auth tokens!"); + return rootAuthToken.getAuthInfo(); + } catch (Exception ex) { + System.out.println("Could not authenticate with the provided credentials " + ex.getMessage()); + } + return null; + } + + + + private void PrintBusinessInfo(BusinessInfos businessInfos) { + if (businessInfos == null) { + System.out.println("No data returned"); + } else { + for (int i = 0; i < businessInfos.getBusinessInfo().size(); i++) { + System.out.println("==============================================="); + System.out.println("Business Key: " + businessInfos.getBusinessInfo().get(i).getBusinessKey()); + System.out.println("Name: " + ListToString(businessInfos.getBusinessInfo().get(i).getName())); + + System.out.println("Description: " + ListToDescString(businessInfos.getBusinessInfo().get(i).getDescription())); + System.out.println("Services:"); + PrintServiceInfo(businessInfos.getBusinessInfo().get(i).getServiceInfos()); + } + } + } + + private String ListToString(List<Name> name) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < name.size(); i++) { + sb.append(name.get(i).getValue()).append(" "); + } + return sb.toString(); + } + + private String ListToDescString(List<Description> name) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < name.size(); i++) { + sb.append(name.get(i).getValue()).append(" "); + } + return sb.toString(); + } + + private void PrintServiceInfo(ServiceInfos serviceInfos) { + for (int i = 0; i < serviceInfos.getServiceInfo().size(); i++) { + System.out.println("-------------------------------------------"); + System.out.println("Service Key: " + serviceInfos.getServiceInfo().get(i).getServiceKey()); + System.out.println("Owning Business Key: " + serviceInfos.getServiceInfo().get(i).getBusinessKey()); + System.out.println("Name: " + ListToString(serviceInfos.getServiceInfo().get(i).getName())); + } + } + + private void PrintBusinessDetails(BusinessInfos businessInfos, String token) throws Exception { + GetBusinessDetail gbd = new GetBusinessDetail(); + gbd.setAuthInfo(token); + for (int i = 0; i < businessInfos.getBusinessInfo().size(); i++) { + gbd.getBusinessKey().add(businessInfos.getBusinessInfo().get(i).getBusinessKey()); + } + BusinessDetail businessDetail = inquiry.getBusinessDetail(gbd); + for (int i = 0; i < businessDetail.getBusinessEntity().size(); i++) { + System.out.println("Business Detail - key: " + businessDetail.getBusinessEntity().get(i).getBusinessKey()); + System.out.println("Name: " + ListToString(businessDetail.getBusinessEntity().get(i).getName())); + System.out.println("CategoryBag: " + CatBagToString(businessDetail.getBusinessEntity().get(i).getCategoryBag())); + PrintContacts(businessDetail.getBusinessEntity().get(i).getContacts()); + } + } + + private void PrintServiceDetailsByBusiness(BusinessInfos businessInfos, String token) throws Exception { + for (int i = 0; i < businessInfos.getBusinessInfo().size(); i++) { + GetServiceDetail gsd = new GetServiceDetail(); + for (int k = 0; k < businessInfos.getBusinessInfo().get(i).getServiceInfos().getServiceInfo().size(); k++) { + gsd.getServiceKey().add(businessInfos.getBusinessInfo().get(i).getServiceInfos().getServiceInfo().get(k).getServiceKey()); + } + gsd.setAuthInfo(token); + System.out.println("Fetching data for business " + businessInfos.getBusinessInfo().get(i).getBusinessKey()); + ServiceDetail serviceDetail = inquiry.getServiceDetail(gsd); + for (int k = 0; k < serviceDetail.getBusinessService().size(); k++) { + PrintServiceDetail(serviceDetail.getBusinessService().get(k)); + } + System.out.println("................"); + + } } - } }
Modified: juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java?rev=1556671&r1=1556670&r2=1556671&view=diff ============================================================================== --- juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java (original) +++ juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java Wed Jan 8 23:34:32 2014 @@ -48,34 +48,17 @@ public class SimplePublish { } } + /** + * This function shows you how to publish to UDDI using a fairly generic mechanism + * that should be portable (meaning use any UDDI v3 library with this code) + */ public void publish() { try { - // Setting up the values to get an authentication token for the 'root' user ('root' user has admin privileges - // and can save other publishers). - GetAuthToken getAuthTokenRoot = new GetAuthToken(); - getAuthTokenRoot.setUserID("root"); - getAuthTokenRoot.setCred(""); - - // Making API call that retrieves the authentication token for the 'root' user. - AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot); - System.out.println("root AUTHTOKEN = " + "******* never log auth tokens!"); - - // Creating a new publisher that we will use to publish our entities to. - //START: Note, this step is optional and only applies to jUDDI UDDI Servers - Publisher p = new Publisher(); - p.setAuthorizedName("my-publisher"); - p.setPublisherName("My Publisher"); - - // Adding the publisher to the "save" structure, using the 'root' user authentication info and saving away. - SavePublisher sp = new SavePublisher(); - sp.getPublisher().add(p); - sp.setAuthInfo(rootAuthToken.getAuthInfo()); - juddiApi.savePublisher(sp); - //END: Note, this step is optional and only applies to jUDDI UDDI Servers - - // Our publisher is now saved, so now we want to retrieve its authentication token + + + // Login aka retrieve its authentication token GetAuthToken getAuthTokenMyPub = new GetAuthToken(); - getAuthTokenMyPub.setUserID("my-publisher"); + getAuthTokenMyPub.setUserID("uddi"); getAuthTokenMyPub.setCred(""); AuthToken myPubAuthToken = security.getAuthToken(getAuthTokenMyPub); System.out.println("myPub AUTHTOKEN = " + "******* never log auth tokens!"); @@ -123,6 +106,8 @@ public class SimplePublish { String myServKey = sd.getBusinessService().get(0).getServiceKey(); System.out.println("myService key: " + myServKey); + + security.discardAuthToken(new DiscardAuthToken(myPubAuthToken.getAuthInfo())); // Now you have a publisher saved who in turn published a business and service via // the jUDDI API! Modified: juddi/trunk/juddi-examples/uddi-annotations/src/main/java/org/apache/juddi/example/HelloWorldImpl.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/uddi-annotations/src/main/java/org/apache/juddi/example/HelloWorldImpl.java?rev=1556671&r1=1556670&r2=1556671&view=diff ============================================================================== --- juddi/trunk/juddi-examples/uddi-annotations/src/main/java/org/apache/juddi/example/HelloWorldImpl.java (original) +++ juddi/trunk/juddi-examples/uddi-annotations/src/main/java/org/apache/juddi/example/HelloWorldImpl.java Wed Jan 8 23:34:32 2014 @@ -21,6 +21,11 @@ import javax.jws.WebService; import org.apache.juddi.v3.annotations.UDDIService; import org.apache.juddi.v3.annotations.UDDIServiceBinding; +/** + * This example show you how to use UDDI Annotations to decorate a class. + * When the Servlet Listener + * + */ @UDDIService( businessKey="uddi:${keyDomain}:${department}-asf", Modified: juddi/trunk/juddi-examples/uddi-annotations/src/main/resources/META-INF/uddi-annotations.xml URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/uddi-annotations/src/main/resources/META-INF/uddi-annotations.xml?rev=1556671&r1=1556670&r2=1556671&view=diff ============================================================================== --- juddi/trunk/juddi-examples/uddi-annotations/src/main/resources/META-INF/uddi-annotations.xml (original) +++ juddi/trunk/juddi-examples/uddi-annotations/src/main/resources/META-INF/uddi-annotations.xml Wed Jan 8 23:34:32 2014 @@ -20,7 +20,7 @@ <proxyTransport>org.apache.juddi.v3.client.transport.InVMTransport</proxyTransport> <custodyTransferUrl>org.apache.juddi.api.impl.UDDICustodyTransferImpl</custodyTransferUrl> <inquiryUrl>org.apache.juddi.api.impl.UDDIInquiryImpl</inquiryUrl> - <inquiryRESTUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiryRest</inquiryRESTUrl> + <inquiryRESTUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiryRest</inquiryRESTUrl> <publishUrl>org.apache.juddi.api.impl.UDDIPublicationImpl</publishUrl> <securityUrl>org.apache.juddi.api.impl.UDDISecurityImpl</securityUrl> <subscriptionUrl>org.apache.juddi.api.impl.UDDISubscriptionImpl</subscriptionUrl> Modified: juddi/trunk/juddi-examples/wsdl2uddi/src/main/java/org/apache/juddi/example/wsdl2uddi/Publish.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/wsdl2uddi/src/main/java/org/apache/juddi/example/wsdl2uddi/Publish.java?rev=1556671&r1=1556670&r2=1556671&view=diff ============================================================================== --- juddi/trunk/juddi-examples/wsdl2uddi/src/main/java/org/apache/juddi/example/wsdl2uddi/Publish.java (original) +++ juddi/trunk/juddi-examples/wsdl2uddi/src/main/java/org/apache/juddi/example/wsdl2uddi/Publish.java Wed Jan 8 23:34:32 2014 @@ -99,7 +99,7 @@ public class Publish { // Making API call that retrieves the authentication token for the 'root' user. AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot); System.out.println("root AUTHTOKEN = " + rootAuthToken.getAuthInfo()); - //Creating joe publisher + //Creating joe publisher THIS IS JUDDI Specific code JUDDIApiPortType juddiApi = uddiClient.getTransport("default").getJUDDIApiService(); Publisher p = new Publisher(); p.setAuthorizedName("joepublisher"); @@ -109,7 +109,8 @@ public class Publish { sp.getPublisher().add(p); sp.setAuthInfo(rootAuthToken.getAuthInfo()); juddiApi.savePublisher(sp); - + //END jUDDI specific code + //Every publisher should have a keyGenerator, Joe has his: TModel keyGenerator = new TModel(); keyGenerator.setTModelKey("uddi:uddi.joepublisher.com:keygenerator"); Modified: juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/DiscardAuthToken.java URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/DiscardAuthToken.java?rev=1556671&r1=1556670&r2=1556671&view=diff ============================================================================== --- juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/DiscardAuthToken.java (original) +++ juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/DiscardAuthToken.java Wed Jan 8 23:34:32 2014 @@ -56,6 +56,10 @@ public class DiscardAuthToken implements @XmlElement(required = true) protected String authInfo; + public DiscardAuthToken(){} + public DiscardAuthToken(String token){ + this.authInfo = token; + } /** * Gets the value of the authInfo property. * --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
