1/*2 * Copyright 2013 The Apache Software Foundation.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package org.apache.juddi.v3.client.cli;
1718import javax.xml.bind.JAXB;
19import org.apache.juddi.jaxb.PrintUDDI;
20import org.apache.juddi.v3.client.UDDIConstants;
21import org.apache.juddi.v3.client.ext.wsdm.WSDMQosConstants;
22import org.apache.juddi.v3.client.transport.Transport;
23import org.uddi.api_v3.BindingDetail;
24import org.uddi.api_v3.BusinessList;
25import org.uddi.api_v3.FindBinding;
26import org.uddi.api_v3.FindBusiness;
27import org.uddi.api_v3.FindQualifiers;
28import org.uddi.api_v3.FindService;
29import org.uddi.api_v3.Name;
30import org.uddi.api_v3.ServiceList;
31import org.uddi.api_v3.TModelBag;
32import org.uddi.v3_service.UDDIInquiryPortType;
3334/**35 *36 * @author Alex O'Ree37 */38publicclassSearchByQos {
3940privateUDDIInquiryPortType inquiry;
4142publicvoid doFindService(String token, Transport transport) throws Exception {
4344// Now you create a reference to the UDDI API4546 inquiry = transport.getUDDIInquiryService();
4748// Making API call that retrieves the authentication token for the 'root' user.49//String rootAuthToken = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());50 String uddi = token;// security.getAuthToken(getAuthTokenRoot).getAuthInfo();5152ServiceList after = getServiceList(uddi);
53if (after.getServiceInfos()==null || after.getServiceInfos().getServiceInfo() == null) {
54 System.out.println("no services returned!");
55return;
56 }
57//PrintUDDI<ServiceList> p = new PrintUDDI<ServiceList>();58 System.out.println(after.getServiceInfos().getServiceInfo().size() + " services returned!");
59 JAXB.marshal(after,System.out);
606162 }
6364publicvoid doFindBinding(String token, Transport transport) throws Exception {
6566// Now you create a reference to the UDDI API67 inquiry = transport.getUDDIInquiryService();
6869// Making API call that retrieves the authentication token for the 'root' user.70//String rootAuthToken = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());71 String uddi = token;//security.getAuthToken(getAuthTokenRoot).getAuthInfo();7273BindingDetail after = getBindingList(uddi);
74if (after.getBindingTemplate() == null) {
75 System.out.println("no bindings returned!");
76return;
77 }
78 PrintUDDI<BindingDetail> p = new PrintUDDI<BindingDetail>();
7980 System.out.println(p.print(after));
8182 }
8384publicvoid doFindBusiness(String token, Transport transport) throws Exception {
85// create a manager and read the config in the archive; 86// you can use your config file name8788// Now you create a reference to the UDDI API89 inquiry = transport.getUDDIInquiryService();
90 String uddi = token;//security.getAuthToken(getAuthTokenRoot).getAuthInfo();9192BusinessList after2 = getBusinessList(uddi);
9394 PrintUDDI<BusinessList> p2 = new PrintUDDI<BusinessList>();
9596 System.out.println(p2.print(after2));
9798 }
99100101privateBusinessList getBusinessList(String token) throws Exception {
102FindBusiness fb = newFindBusiness();
103 fb.setAuthInfo(token);
104 org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
105 fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
106 fq.getFindQualifier().add(UDDIConstants.OR_ALL_KEYS);
107 fb.setFindQualifiers(fq);
108 fb.getName().add((new Name(UDDIConstants.WILDCARD, null)));
109110 fb.setTModelBag(newTModelBag());
111 fb.getTModelBag().getTModelKey().addAll(WSDMQosConstants.getAllQOSKeys());
112113return inquiry.findBusiness(fb);
114 }
115116privateServiceList getServiceList(String token) throws Exception {
117FindService fb = newFindService();
118 fb.setAuthInfo(token);
119 org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
120 fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
121 fq.getFindQualifier().add(UDDIConstants.OR_ALL_KEYS);
122 fb.setFindQualifiers(fq);
123 fb.getName().add((new Name(UDDIConstants.WILDCARD, null)));
124125 fb.setTModelBag(newTModelBag());
126 fb.getTModelBag().getTModelKey().addAll(WSDMQosConstants.getAllQOSKeys());
127128return inquiry.findService(fb);
129 }
130131privateBindingDetail getBindingList(String token) throws Exception {
132FindBinding fb = newFindBinding();
133 fb.setAuthInfo(token);
134 fb.setTModelBag(newTModelBag());
135 fb.getTModelBag().getTModelKey().addAll(WSDMQosConstants.getAllQOSKeys());
136 fb.setFindQualifiers(newFindQualifiers());
137 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.OR_ALL_KEYS_TMODEL);
138return inquiry.findBinding(fb);
139 }
140141142 }