Repository: juddi Updated Branches: refs/heads/master bcd3c0771 -> 9dafe4e83
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/WadlImport.java ---------------------------------------------------------------------- diff --git a/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/WadlImport.java b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/WadlImport.java new file mode 100644 index 0000000..8ce7e32 --- /dev/null +++ b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/WadlImport.java @@ -0,0 +1,197 @@ +/* + * Copyright 2001-2013 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.v3.client.cli; + +import java.io.File; +import java.net.URL; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import javax.xml.namespace.QName; + +import org.apache.juddi.jaxb.PrintUDDI; +import org.apache.juddi.v3.client.config.UDDIClerk; +import org.apache.juddi.v3.client.config.UDDIClient; +import org.apache.juddi.v3.client.config.UDDIClientContainer; +import org.apache.juddi.v3.client.mapping.URLLocalizerDefaultImpl; +import org.apache.juddi.v3.client.mapping.wadl.Application; +import org.apache.juddi.v3.client.mapping.wadl.WADL2UDDI; +import org.apache.juddi.v3.client.transport.Transport; +import org.apache.juddi.v3_service.JUDDIApiPortType; +import org.uddi.api_v3.AuthToken; +import org.uddi.api_v3.BusinessDetail; +import org.uddi.api_v3.BusinessEntity; +import org.uddi.api_v3.BusinessService; +import org.uddi.api_v3.BusinessServices; +import org.uddi.api_v3.GetAuthToken; +import org.uddi.api_v3.Name; +import org.uddi.api_v3.SaveBusiness; +import org.uddi.api_v3.SaveService; +import org.uddi.api_v3.SaveTModel; +import org.uddi.api_v3.TModel; +import org.uddi.v3_service.UDDIPublicationPortType; +import org.uddi.v3_service.UDDISecurityPortType; + +/** + * This class shows how to perform a WSDL2UDDI import manually. More + * specifically, this is WSDL2UDDI without using annotations. + * + * @author <a href="mailto:[email protected]">Alex O'Ree</a> + */ +public class WadlImport { + + static PrintUDDI<TModel> pTModel = new PrintUDDI<TModel>(); + static Properties properties = new Properties(); + + private static UDDISecurityPortType security = null; + private static JUDDIApiPortType juddiApi = null; + private static UDDIPublicationPortType publish = null; + + public void Fire(String pathOrURL, String businessKey, String token, Transport transport) throws Exception { + + if (transport == null) { + // create a manager and read the config in the archive; + // you can use your config file name + UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml"); + transport = clerkManager.getTransport(); + } + // Now you create a reference to the UDDI API + security = transport.getUDDISecurityService(); + publish = transport.getUDDIPublishService(); + + if (token == null) { + //step one, get a token + GetAuthToken getAuthTokenRoot = new GetAuthToken(); + getAuthTokenRoot.setUserID("uddi"); + getAuthTokenRoot.setCred("uddi"); + + // Making API call that retrieves the authentication token for the 'root' user. + AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot); + token = rootAuthToken.getAuthInfo(); + } + + //step two, identify the key used for all your stuff + //you must have a key generator created already + //here, we are assuming that you don't have one + //NOTE: these are some of the publically available WSDLs that were used to test WSDL2UDDI + //publish.saveTModel(stm); + //step three, we have two options + //1) import the wsdl's services into a brand new business + //2) import the wsdl's services into an existing business + //in either case, we're going to have to parse the WSDL + //Application app = WADL2UDDI.parseWadl(new URL("http://server/wsdl.wsdl"), "username", "password", clerkManager.getClientConfig().isX_To_Wsdl_Ignore_SSL_Errors() ); + Application app = null; + if (!pathOrURL.startsWith("http")) { + File f = new File("test.wadl"); + if (!f.exists()) { + System.out.println(pathOrURL + " doesn't exist!"); + return; + } else { + System.out.println("Attempting to parse " + f.getAbsolutePath()); + app = WADL2UDDI.parseWadl(f); + } + } else { + app = WADL2UDDI.parseWadl(new URL(pathOrURL)); + } + + List<URL> urls = WADL2UDDI.getBaseAddresses(app); + URL url = urls.get(0); + String domain = url.getHost(); + PrintUDDI<TModel> tmodelPrinter = new PrintUDDI<TModel>(); + TModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en"); + + //save the keygen + SaveTModel stm = new SaveTModel(); + stm.setAuthInfo(token); + stm.getTModel().add(keygen); + System.out.println("Saving the following tModel keygen"); + System.out.println(tmodelPrinter.print(keygen)); + publish.saveTModel(stm); + + properties.put("keyDomain", domain); + properties.put("businessName", domain); + properties.put("serverName", url.getHost()); + properties.put("serverPort", url.getPort()); + //wsdlURL = wsdlDefinition.getDocumentBaseURI(); + WADL2UDDI wadl2UDDI = new WADL2UDDI(null, new URLLocalizerDefaultImpl(), properties); + + BusinessService businessServices = wadl2UDDI.createBusinessService(new QName(domain, domain), app); + + Set<TModel> portTypeTModels = wadl2UDDI.createWADLPortTypeTModels(pathOrURL, app); + + // Set<TModel> createWSDLBindingTModels = wadl2UDDI.createWSDLBindingTModels(wsdlURL, allBindings); + //When parsing a WSDL, there's really two things going on + //1) convert a bunch of stuff (the portTypes) to tModels + //2) convert the service definition to a BusinessService + //Since the service depends on the tModel, we have to save the tModels first + stm = new SaveTModel(); + stm.setAuthInfo(token); + + TModel[] tmodels = portTypeTModels.toArray(new TModel[0]); + for (int i = 0; i < tmodels.length; i++) { + System.out.println(tmodelPrinter.print(tmodels[i])); + stm.getTModel().add(tmodels[i]); + } + + tmodels = wadl2UDDI.createWADLTModels(pathOrURL, app).toArray(new TModel[0]); + for (int i = 0; i < tmodels.length; i++) { + System.out.println(tmodelPrinter.print(tmodels[i])); + stm.getTModel().add(tmodels[i]); + } + //important, you'll need to save your new tModels, or else saving the business/service may fail + System.out.println("Saving the following tModels " + stm.getTModel().size()); + publish.saveTModel(stm); + + //finaly, we're ready to save all of the services defined in the WSDL + //again, we're creating a new business, if you have one already, look it up using the Inquiry getBusinessDetails + PrintUDDI<BusinessService> servicePrinter = new PrintUDDI<BusinessService>(); + + System.out.println("here's our new service: " + servicePrinter.print(businessServices)); + + if (businessKey == null || businessKey.length() == 0) { + BusinessEntity be = new BusinessEntity(); + be.setBusinessKey(businessServices.getBusinessKey()); + be.getName().add(new Name()); + be.getName().get(0).setValue(domain); + be.getName().get(0).setLang("en"); + be.setBusinessServices(new BusinessServices()); + be.getBusinessServices().getBusinessService().add(businessServices); + SaveBusiness sb = new SaveBusiness(); + sb.setAuthInfo(token); + sb.getBusinessEntity().add(be); + BusinessDetail saveBusiness = publish.saveBusiness(sb); + System.out.println("new business created, key = " + saveBusiness.getBusinessEntity().get(0).getBusinessKey()); + } + SaveService ss = new SaveService(); + ss.setAuthInfo(token); + businessServices.setBusinessKey(businessKey); + ss.getBusinessService().add(businessServices); + publish.saveService(ss); + System.out.println("Saved! " + businessServices.getServiceKey()); + + //and we're done + //Be sure to report any problems to the jUDDI JIRA bug tracker at + //https://issues.apache.org/jira/browse/JUDDI + } + + public static void main(String[] args) throws Exception { + + new WadlImport().Fire("http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/wadl/bookstoreImportResource.wadl", null, null, null); + + } +} http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/WsdlImport.java ---------------------------------------------------------------------- diff --git a/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/WsdlImport.java b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/WsdlImport.java new file mode 100644 index 0000000..6688983 --- /dev/null +++ b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/WsdlImport.java @@ -0,0 +1,214 @@ +/* + * Copyright 2001-2013 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.v3.client.cli; + +import java.net.URL; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.wsdl.Definition; +import javax.wsdl.PortType; +import javax.xml.namespace.QName; + +import org.apache.juddi.jaxb.PrintUDDI; +import org.apache.juddi.v3.client.config.UDDIClerk; +import org.apache.juddi.v3.client.config.UDDIClient; +import org.apache.juddi.v3.client.config.UDDIClientContainer; +import org.apache.juddi.v3.client.mapping.URLLocalizerDefaultImpl; +import org.apache.juddi.v3.client.mapping.wsdl.ReadWSDL; +import org.apache.juddi.v3.client.mapping.wsdl.WSDL2UDDI; +import org.apache.juddi.v3.client.transport.Transport; +import org.apache.juddi.v3_service.JUDDIApiPortType; +import org.uddi.api_v3.AuthToken; +import org.uddi.api_v3.BusinessDetail; +import org.uddi.api_v3.BusinessEntity; +import org.uddi.api_v3.BusinessService; +import org.uddi.api_v3.BusinessServices; +import org.uddi.api_v3.GetAuthToken; +import org.uddi.api_v3.Name; +import org.uddi.api_v3.SaveBusiness; +import org.uddi.api_v3.SaveService; +import org.uddi.api_v3.SaveTModel; +import org.uddi.api_v3.TModel; +import org.uddi.v3_service.UDDIPublicationPortType; +import org.uddi.v3_service.UDDISecurityPortType; + +/** + * This class shows how to perform a WSDL2UDDI import manually. More + * specifically, this is WSDL2UDDI without using annotations. + * + * @author <a href="mailto:[email protected]">Alex O'Ree</a> + */ +public class WsdlImport { + + static PrintUDDI<TModel> pTModel = new PrintUDDI<TModel>(); + static Properties properties = new Properties(); + static String wsdlURL = null; + private static UDDISecurityPortType security = null; + private static JUDDIApiPortType juddiApi = null; + private static UDDIPublicationPortType publish = null; + + public static void main(String[] args) throws Exception { + new WsdlImport().Fire("http://svn.apache.org/repos/asf/juddi/trunk/uddi-ws/src/main/resources/juddi_api_v1.wsdl", null, null, null); + } + + public void Fire(String pathOrURL, String businessKey, String token, Transport transport) throws Exception { + + if (transport == null) { + // create a manager and read the config in the archive; + // you can use your config file name + UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml"); + transport = clerkManager.getTransport(); + } + // Now you create a reference to the UDDI API + security = transport.getUDDISecurityService(); + publish = transport.getUDDIPublishService(); + + if (token == null) { + //step one, get a token + GetAuthToken getAuthTokenRoot = new GetAuthToken(); + getAuthTokenRoot.setUserID("uddi"); + getAuthTokenRoot.setCred("uddi"); + + // Making API call that retrieves the authentication token for the 'root' user. + AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot); + token = rootAuthToken.getAuthInfo(); + } + + //step two, identify the key used for all your stuff + //you must have a key generator created already + //here, we are assuming that you don't have one + //NOTE: these are some of the publically available WSDLs that were used to test WSDL2UDDI + //URL url = new URL("http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"); + //http://www.bccs.uni.no/~pve002/wsdls/ebi-mafft.wsdl"); + //http://www.webservicex.net/GenericNAICS.asmx?WSDL"); + //http://www.webservicex.net/stockquote.asmx?WSDL"); + //http://www.webservicex.com/globalweather.asmx?WSDL"); + //http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl"); + String domain = "localhost"; + int port = 80; + if (pathOrURL.startsWith("http")) { + URL url = new URL(pathOrURL); + domain = url.getHost(); + port = url.getPort(); + if (port == -1) { + if (pathOrURL.startsWith("https://")) { + port = 443; + } + if (pathOrURL.startsWith("http://")) { + port = 80; + } + + } + } + + TModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en"); + //save the keygen + SaveTModel stm = new SaveTModel(); + stm.setAuthInfo(token); + stm.getTModel().add(keygen); + System.out.println("Saving key gen " + keygen.getTModelKey()); + publish.saveTModel(stm); + System.out.println("Saved!"); + + //step three, we have two options + //1) import the wsdl's services into a brand new business + //2) import the wsdl's services into an existing business + //in either case, we're going to have to parse the WSDL + ReadWSDL rw = new ReadWSDL(); + Definition wsdlDefinition = null; + if (pathOrURL.startsWith("http")) { + wsdlDefinition = rw.readWSDL(new URL(pathOrURL)); + } else { + wsdlDefinition = rw.readWSDL(pathOrURL); + } + + if (wsdlDefinition == null) { + System.out.println("There was an error parsing the WSDL!"); + return; + } + properties.put("keyDomain", domain); + properties.put("businessName", domain); + properties.put("serverName", domain); + properties.put("serverPort", port); + wsdlURL = wsdlDefinition.getDocumentBaseURI(); + WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties); + BusinessServices businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition); + @SuppressWarnings("unchecked") + Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes(); + Set<TModel> portTypeTModels = wsdl2UDDI.createWSDLPortTypeTModels(wsdlURL, portTypes); + Map allBindings = wsdlDefinition.getAllBindings(); + Set<TModel> createWSDLBindingTModels = wsdl2UDDI.createWSDLBindingTModels(wsdlURL, allBindings); + //When parsing a WSDL, there's really two things going on + //1) convert a bunch of stuff (the portTypes) to tModels + //2) convert the service definition to a BusinessService + + //Since the service depends on the tModel, we have to save the tModels first + stm = new SaveTModel(); + stm.setAuthInfo(token); + + TModel[] tmodels = portTypeTModels.toArray(new TModel[0]); + for (int i = 0; i < tmodels.length; i++) { + stm.getTModel().add(tmodels[i]); + } + + tmodels = createWSDLBindingTModels.toArray(new TModel[0]); + for (int i = 0; i < tmodels.length; i++) { + stm.getTModel().add(tmodels[i]); + } + + //important, you'll need to save your new tModels first, or else saving the business/service may fail + System.out.println(new PrintUDDI<SaveTModel>().print(stm)); + System.out.println("Saving " + stm.getTModel().size() + " tModels"); + publish.saveTModel(stm); + System.out.println("Saved!"); + + if (businessKey == null || businessKey.length() == 0) { + SaveBusiness sb = new SaveBusiness(); + sb.setAuthInfo(token); + BusinessEntity be = new BusinessEntity(); + be.setBusinessKey(businessServices.getBusinessService().get(0).getBusinessKey()); + be.getName().add(new Name()); + be.getName().get(0).setValue(domain); + be.getName().get(0).setLang("en"); + sb.getBusinessEntity().add(be); + BusinessDetail saveBusiness = publish.saveBusiness(sb); + businessKey = saveBusiness.getBusinessEntity().get(0).getBusinessKey(); + System.out.println("new business created key= " + businessKey); + } + + //finaly, we're ready to save all of the services defined in the WSDL + //again, we're creating a new business, if you have one already, look it up using the Inquiry getBusinessDetails + SaveService ss = new SaveService(); + ss.setAuthInfo(token); + for (int i = 0; i < businessServices.getBusinessService().size(); i++) { + businessServices.getBusinessService().get(i).setBusinessKey(businessKey); + ss.getBusinessService().add(businessServices.getBusinessService().get(i)); + + } + + System.out.println("Here's our new service(s): " + new PrintUDDI<SaveService>().print(ss)); + + publish.saveService(ss); + System.out.println("Saved!"); + + //and we're done + //Be sure to report any problems to the jUDDI JIRA bug tracker at + //https://issues.apache.org/jira/browse/JUDDI + } +} http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/testStrings.java ---------------------------------------------------------------------- diff --git a/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/testStrings.java b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/testStrings.java new file mode 100644 index 0000000..d79f240 --- /dev/null +++ b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/testStrings.java @@ -0,0 +1,73 @@ +/* + * Copyright 2001-2013 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.v3.client.cli; + +import java.util.concurrent.atomic.AtomicReference; +import javax.xml.ws.Holder; + +/** + * A simple program to illistrate how to pass by "reference" vs by "value" in + * Java. Or more accurately, how to persist changes on method parameters to the + * caller. Written mostly because I forget it frequently and use this as + * reference material. + * + * @author <a href="mailto:[email protected]">Alex O'Ree</a> + */ +public class testStrings { + + public static void main(String[] args) { + String str = "hi"; + System.out.println(str); //hi + System.out.println(Test1(str)); //hir + System.out.println(Test2(str)); //hix + Test3(str); + System.out.println(str); //hi no change + Holder<String> holder = new Holder<String>(); + holder.value = str; + Test4(holder); + System.out.println(str); //hi no change + System.out.println(holder.value); //hiw changed persists + + AtomicReference<String> astr = new AtomicReference<String>(); + astr.set(str); + Test5(astr); + System.out.println(str); //hi no change + System.out.println(astr.get()); //hit change persists + + } + + static String Test1(String s) { + return s + "r"; + } + + static String Test2(String s) { + s += "x"; + return s; + } + + static void Test3(String s) { + s += "z"; + } + + static void Test4(Holder<String> s) { + s.value += "w"; + } + + static void Test5(AtomicReference<String> s) { + s.set(s.get() + "t"); + } +} http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/src/main/resources/META-INF/simple-publish-uddi.xml ---------------------------------------------------------------------- diff --git a/juddi-client-cli/src/main/resources/META-INF/simple-publish-uddi.xml b/juddi-client-cli/src/main/resources/META-INF/simple-publish-uddi.xml new file mode 100644 index 0000000..9d071a6 --- /dev/null +++ b/juddi-client-cli/src/main/resources/META-INF/simple-publish-uddi.xml @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- +/* + * Copyright 2001-2008 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + --> +<uddi xmlns="urn:juddi-apache-org:v3_client" xsi:schemaLocation="classpath:/xsd/uddi-client.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema"> + <reloadDelay>5000</reloadDelay> + <client name="example-client"> + <nodes> + <node isHomeJUDDI="true"> + <!-- required 'default' node --> + <name>default</name> + <properties> + <property name="serverName" value="localhost"/> + <property name="serverPort" value="8080"/> + + <!-- for UDDI nodes that use HTTP u/p, using the following + <property name="basicAuthUsername" value="root" /> + <property name="basicAuthPassword" value="password" /> + <property name="basicAuthPasswordIsEncrypted" value="false" /> + <property name="basicAuthPasswordCryptoProvider" value="org.apache.juddi.v3.client.crypto.AES128Cryptor (an example)" />--> + </properties> + <description>Main jUDDI node</description> + <!-- JAX-WS Transport --> + <proxyTransport>org.apache.juddi.v3.client.transport.JAXWSTransport</proxyTransport> + <custodyTransferUrl>http://${serverName}:${serverPort}/juddiv3/services/custody-transfer</custodyTransferUrl> + <inquiryUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiry</inquiryUrl> + <inquiryRESTUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiryRest</inquiryRESTUrl> + <publishUrl>http://${serverName}:${serverPort}/juddiv3/services/publish</publishUrl> + <securityUrl>http://${serverName}:${serverPort}/juddiv3/services/security</securityUrl> + <subscriptionUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription</subscriptionUrl> + <subscriptionListenerUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription-listener</subscriptionListenerUrl> + <juddiApiUrl>http://${serverName}:${serverPort}/juddiv3/services/juddi-api</juddiApiUrl> + <replicationUrl>https://${serverName}:8443/juddiv3replication/services/replication</replicationUrl> + </node> + <node> + <!-- required 'default' node --> + <name>uddi:another.juddi.apache.org:node2</name> + <properties> + <property name="serverName" value="localhost"/> + <property name="serverPort" value="9080"/> + + <!-- for UDDI nodes that use HTTP u/p, using the following + <property name="basicAuthUsername" value="root" /> + <property name="basicAuthPassword" value="password" /> + <property name="basicAuthPasswordIsEncrypted" value="false" /> + <property name="basicAuthPasswordCryptoProvider" value="org.apache.juddi.v3.client.crypto.AES128Cryptor (an example)" />--> + </properties> + <description>juddi node on 9080</description> + <!-- JAX-WS Transport --> + <proxyTransport>org.apache.juddi.v3.client.transport.JAXWSTransport</proxyTransport> + <custodyTransferUrl>http://${serverName}:${serverPort}/juddiv3/services/custody-transfer</custodyTransferUrl> + <inquiryUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiry</inquiryUrl> + <inquiryRESTUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiryRest</inquiryRESTUrl> + <publishUrl>http://${serverName}:${serverPort}/juddiv3/services/publish</publishUrl> + <securityUrl>http://${serverName}:${serverPort}/juddiv3/services/security</securityUrl> + <subscriptionUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription</subscriptionUrl> + <subscriptionListenerUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription-listener</subscriptionListenerUrl> + <juddiApiUrl>http://${serverName}:${serverPort}/juddiv3/services/juddi-api</juddiApiUrl> + <replicationUrl>https://${serverName}:9443/juddiv3replication/services/replication</replicationUrl> + </node> + + <node> + <!-- required 'default' node --> + <name>uddi:yet.another.juddi.apache.org:node3</name> + <properties> + <property name="serverName" value="localhost"/> + <property name="serverPort" value="10080"/> + + <!-- for UDDI nodes that use HTTP u/p, using the following + <property name="basicAuthUsername" value="root" /> + <property name="basicAuthPassword" value="password" /> + <property name="basicAuthPasswordIsEncrypted" value="false" /> + <property name="basicAuthPasswordCryptoProvider" value="org.apache.juddi.v3.client.crypto.AES128Cryptor (an example)" />--> + </properties> + <description>juddi node on 10080</description> + <!-- JAX-WS Transport --> + <proxyTransport>org.apache.juddi.v3.client.transport.JAXWSTransport</proxyTransport> + <custodyTransferUrl>http://${serverName}:${serverPort}/juddiv3/services/custody-transfer</custodyTransferUrl> + <inquiryUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiry</inquiryUrl> + <inquiryRESTUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiryRest</inquiryRESTUrl> + <publishUrl>http://${serverName}:${serverPort}/juddiv3/services/publish</publishUrl> + <securityUrl>http://${serverName}:${serverPort}/juddiv3/services/security</securityUrl> + <subscriptionUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription</subscriptionUrl> + <subscriptionListenerUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription-listener</subscriptionListenerUrl> + <juddiApiUrl>http://${serverName}:${serverPort}/juddiv3/services/juddi-api</juddiApiUrl> + <replicationUrl>https://${serverName}:10443/juddiv3replication/services/replication</replicationUrl> + </node> + </nodes> + <clerks registerOnStartup="false"> + <clerk name="default" node="default" publisher="uddi" password="uddi" isPasswordEncrypted="false" cryptoProvider=""/> + </clerks> + <signature> + <!-- signing stuff --> + <signingKeyStorePath>keystore.jks</signingKeyStorePath> + <signingKeyStoreType>JKS</signingKeyStoreType> + <signingKeyStoreFilePassword + isPasswordEncrypted="false" + cryptoProvider="org.apache.juddi.v3.client.crypto.AES128Cryptor">password</signingKeyStoreFilePassword> + <signingKeyPassword + isPasswordEncrypted="false" + cryptoProvider="org.apache.juddi.v3.client.crypto.AES128Cryptor">password</signingKeyPassword> + <signingKeyAlias>my special key</signingKeyAlias> + + <canonicalizationMethod>http://www.w3.org/2001/10/xml-exc-c14n#</canonicalizationMethod> + <signatureMethod>http://www.w3.org/2000/09/xmldsig#rsa-sha1</signatureMethod> + <XML_DIGSIG_NS>http://www.w3.org/2000/09/xmldsig#</XML_DIGSIG_NS> + + <!-- validation stuff + Used whenever someone views an entity that is signed and validation is required --> + <!-- if this doesn't exist or is incorrect, the client will atempt to load the standard jdk trust store--> + <trustStorePath>truststore.jks</trustStorePath> + <trustStoreType>JKS</trustStoreType> + <trustStorePassword + isPasswordEncrypted="false" + cryptoProvider="org.apache.juddi.v3.client.crypto.AES128Cryptor">password</trustStorePassword> + + <checkTimestamps>true</checkTimestamps> + <checkTrust>true</checkTrust> + <checkRevocationCRL>true</checkRevocationCRL> + <keyInfoInclusionSubjectDN>true</keyInfoInclusionSubjectDN> + <keyInfoInclusionSerial>true</keyInfoInclusionSerial> + <keyInfoInclusionBase64PublicKey>true</keyInfoInclusionBase64PublicKey> + <digestMethod>http://www.w3.org/2000/09/xmldsig#sha1</digestMethod> + </signature> + + <subscriptionCallbacks> + <keyDomain>uddi:somebusiness</keyDomain> + <listenUrl></listenUrl> <!-- this is to override the generated values --> + <autoRegisterBindingTemplate>true</autoRegisterBindingTemplate> + <autoRegisterBusinessServiceKey>uddi:somebusiness:someservicekey</autoRegisterBusinessServiceKey> + <signatureBehavior>DoNothing</signatureBehavior> + </subscriptionCallbacks> + </client> +</uddi> http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/truststore.jks ---------------------------------------------------------------------- diff --git a/juddi-client-cli/truststore.jks b/juddi-client-cli/truststore.jks new file mode 100644 index 0000000..e751384 Binary files /dev/null and b/juddi-client-cli/truststore.jks differ http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java ---------------------------------------------------------------------- diff --git a/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java b/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java index 81b2f70..ded2528 100644 --- a/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java +++ b/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java @@ -39,16 +39,25 @@ public abstract class WSDMQosConstants { * The number of requests to a given service. (number of requests) */ public static final String METRIC_REQUEST_COUNT_KEY = "urn:wsdm.org:metric:requestcount"; + /** + * The number of requests to a given service. (number of requests) + */ public static final String METRIC_RequestCount = "RequestCount"; /** * The number of replies from a given service. (number of replies) */ public static final String METRIC_REPLY_COUNT_KEY = "urn:wsdm.org:metric:replycount"; + /** + * The number of replies from a given service. (number of replies) + */ public static final String METRIC_ReplyCount = "ReplyCount"; /** * The number of faults from a given service. (number of faults) */ public static final String METRIC_FAULT_COUNT_KEY = "urn:wsdm.org:metric:faultcount"; + /** + * The number of faults from a given service. (number of faults) + */ public static final String METRIC_FaultCount = "FaultCount"; /** * This is the unique identity by which the resource (service) is known @@ -56,17 +65,29 @@ public abstract class WSDMQosConstants { * identification in URI format) */ public static final String IDENTITY_RESOURCE_ID_KEY = "urn:wsdm.org:identity:resourceId"; + /** + * This is the unique identity by which the resource (service) is known + * to the management system. It is useful for further queries. (resource + * identification in URI format) + */ public static final String IDENTITY_ResourceId = "ResourceId"; /** * Represents the last time this metric was updated. (time value) */ public static final String METRIC_LAST_UPDATE_TIME_KEY = "urn:wsdm.org:metric:lastupdatetime"; + /** + * Represents the last time this metric was updated. (time value) + */ public static final String METRIC_LastUpdateTime = "LastUpdateTime"; /** * Average response time of the service. (numeric value or symbolic * rating) */ public static final String QOS_RESPONSE_TIME_AVG_KEY = "urn:wsdm.org:qos:responsetime_average"; + /** + * Average response time of the service. (numeric value or symbolic + * rating) + */ public static final String QOS_ResponseTime_Average = "ResponseTime_Average"; /** * Throughput count. (numeric value or symbolic rating) @@ -77,29 +98,47 @@ public abstract class WSDMQosConstants { * Throughput bytes. (numeric value or symbolic rating) */ public static final String QOS_THROUGHPUT_BYTES_KEY = "urn:wsdm.org:qos:throughput_bytes"; + /** + * Throughput bytes. (numeric value or symbolic rating) + */ public static final String QOS_Throughput_bytes = "Throughput_bytes"; /** * Reliability or the measure of. (numeric value or symbolic rating) */ public static final String QOS_RELIABILITY_KEY = "urn:wsdm.org:qos:reliability"; + /** + * Reliability or the measure of. (numeric value or symbolic rating) + */ public static final String QOS_Reliability = "Reliability"; /** * The beginning on the reporting time period used for the information * above. (dateTime) */ public static final String QOS_REPORTING_PERIOD_START_KEY = "urn:wsdm.org:qos:reportingperiodstart"; + /** + * The beginning on the reporting time period used for the information + * above. (dateTime) + */ public static final String QOS_ReportingPeriodStart = "ReportingPeriodStart"; /** * The end of the reporting time period used for the information above. * (dateTime) */ public static final String QOS_REPORTING_PERIOD_END_KEY = "urn:wsdm.org:qos:reportingperiodend"; + /** + * The end of the reporting time period used for the information above. + * (dateTime) + */ public static final String QOS_ReportingPeriodEnd = "ReportingPeriodEnd"; /** * How often is this information updated in UDDI (it is not assumed to * be realtime). (duration) */ public static final String QOS_UPDATE_INTERVAL_KEY = "urn:wsdm.org:qos:updateinterval"; + /** + * How often is this information updated in UDDI (it is not assumed to + * be realtime). (duration) + */ public static final String QOS_UpdateInterval = "UpdateInterval"; public static List<String> getAllQOSKeys() { http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java ---------------------------------------------------------------------- diff --git a/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java b/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java index 706e115..6b9299a 100644 --- a/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java +++ b/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java @@ -51,12 +51,15 @@ public class ReadWSDL { File f = new File(fileName); URL url = null; if (f.exists()) { + log.info(fileName + " as a local file doesn't exist."); url = f.toURI().toURL(); } else { url = ClassUtil.getResource(fileName, this.getClass()); } - if (url==null) + if (url==null){ + log.info(fileName + " as a class path resource doesn't exist."); throw new WSDLException("null input", fileName); + } URI uri = url.toURI(); WSDLLocator locator = new WSDLLocatorImpl(uri); wsdlDefinition = reader.readWSDL(locator); http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client/src/main/java/org/apache/juddi/v3/client/subscription/SubscriptionCallbackListener.java ---------------------------------------------------------------------- diff --git a/juddi-client/src/main/java/org/apache/juddi/v3/client/subscription/SubscriptionCallbackListener.java b/juddi-client/src/main/java/org/apache/juddi/v3/client/subscription/SubscriptionCallbackListener.java index e1dd5c2..a424e19 100644 --- a/juddi-client/src/main/java/org/apache/juddi/v3/client/subscription/SubscriptionCallbackListener.java +++ b/juddi-client/src/main/java/org/apache/juddi/v3/client/subscription/SubscriptionCallbackListener.java @@ -81,10 +81,9 @@ import org.uddi.v3_service.UDDIPublicationPortType; * @author <a href="mailto:[email protected]">Alex O'Ree</a> * @since 3.2 */ - -@WebService(serviceName="UDDISubscriptionListenerClientService", - endpointInterface="org.uddi.v3_service.UDDISubscriptionListenerPortType", - targetNamespace = "urn:uddi-org:v3_service") +@WebService(serviceName = "UDDISubscriptionListenerClientService", + endpointInterface = "org.uddi.v3_service.UDDISubscriptionListenerPortType", + targetNamespace = "urn:uddi-org:v3_service") public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISubscriptionListenerPortType, Runnable { /** @@ -120,7 +119,7 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub * connect to the client's subscription listener service Recommend * specifying a port that is firewall friendly * @param keydomain - + * * @param autoregister * @param behavior * @param serviceKey @@ -133,7 +132,8 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub * @throws TransportException * @throws DispositionReportFaultMessage * @throws java.rmi.UnexpectedException - * @throws org.apache.juddi.v3.client.subscription.RegistrationAbortedException + * @throws + * org.apache.juddi.v3.client.subscription.RegistrationAbortedException * @throws java.net.MalformedURLException * @throws org.apache.juddi.v3.client.subscription.UnableToSignException * @see Endpoint @@ -158,7 +158,7 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub url = new URL("http://" + GetHostname() + ":" + GetRandomPort(4000) + "/" + UUID.randomUUID().toString()); } endpoint = url.toString(); - //if (endpoint == null || endpoint.equals("")) { + //if (endpoint == null || endpoint.equals("")) { // endpoint = "http://" + GetHostname() + ":" + GetRandomPort(url.getPort()) + "/" + UUID.randomUUID().toString(); int attempts = 5; @@ -210,7 +210,8 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub /** * Starts a subscription callback service using the juddi client config - * file's settings. This will use the config setting PROPERTY_NODE, or default if not defined + * file's settings. This will use the config setting PROPERTY_NODE, or + * default if not defined * * @param client * @return a bindingtemplate populated with the relevant information for @@ -222,19 +223,22 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub * @throws DispositionReportFaultMessage * @throws UnexpectedException * @throws RemoteException - * @throws org.apache.juddi.v3.client.subscription.RegistrationAbortedException + * @throws + * org.apache.juddi.v3.client.subscription.RegistrationAbortedException * @throws org.apache.juddi.v3.client.subscription.UnableToSignException * @throws java.net.MalformedURLException */ public static synchronized BindingTemplate start(UDDIClient client) throws ServiceAlreadyStartedException, SecurityException, ConfigurationException, TransportException, DispositionReportFaultMessage, UnexpectedException, RemoteException, RegistrationAbortedException, UnableToSignException, MalformedURLException { - return start(client, client.getClientConfig().getConfiguration().getString(PROPERTY_NODE,"default")); + return start(client, client.getClientConfig().getConfiguration().getString(PROPERTY_NODE, "default")); } + /** * Starts a subscription callback service using the juddi client config * file's settings. This will use the specified node * * @param client - * @param cfg_node_name the node to connect to and perform all operations on + * @param cfg_node_name the node to connect to and perform all + * operations on * @return a bindingtemplate populated with the relevant information for * most UDDI servers for asynchronous callbacks. * @throws ServiceAlreadyStartedException @@ -244,25 +248,31 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub * @throws DispositionReportFaultMessage * @throws UnexpectedException * @throws RemoteException - * @throws org.apache.juddi.v3.client.subscription.RegistrationAbortedException + * @throws + * org.apache.juddi.v3.client.subscription.RegistrationAbortedException * @throws org.apache.juddi.v3.client.subscription.UnableToSignException * @throws java.net.MalformedURLException */ public static synchronized BindingTemplate start(UDDIClient client, String cfg_node_name) throws ServiceAlreadyStartedException, SecurityException, ConfigurationException, TransportException, DispositionReportFaultMessage, UnexpectedException, RemoteException, RegistrationAbortedException, UnableToSignException, MalformedURLException { - boolean reg = (client.getClientConfig().getConfiguration().getBoolean(PROPERTY_AUTOREG_BT, false)); - String endpoint = client.getClientConfig().getConfiguration().getString(PROPERTY_LISTENURL); - String kd = client.getClientConfig().getConfiguration().getString(PROPERTY_KEYDOMAIN); - String key = client.getClientConfig().getConfiguration().getString(PROPERTY_AUTOREG_SERVICE_KEY); - String sbs = client.getClientConfig().getConfiguration().getString(PROPERTY_SIGNATURE_BEHAVIOR); - SignatureBehavior sb = SignatureBehavior.DoNothing; try { - sb = SignatureBehavior.valueOf(sbs); - } catch (Exception ex) { - log.warn("Unable to parse config setting for SignatureBehavior, defaulting to DoNothing", ex); + boolean reg = (client.getClientConfig().getConfiguration().getBoolean(PROPERTY_AUTOREG_BT, false)); + + String endpoint = client.getClientConfig().getConfiguration().getString(PROPERTY_LISTENURL); + String kd = client.getClientConfig().getConfiguration().getString(PROPERTY_KEYDOMAIN); + String key = client.getClientConfig().getConfiguration().getString(PROPERTY_AUTOREG_SERVICE_KEY); + String sbs = client.getClientConfig().getConfiguration().getString(PROPERTY_SIGNATURE_BEHAVIOR); + SignatureBehavior sb = SignatureBehavior.DoNothing; + try { + sb = SignatureBehavior.valueOf(sbs); + } catch (Exception ex) { + log.warn("Unable to parse config setting for SignatureBehavior, defaulting to DoNothing", ex); + } + return start(client, cfg_node_name, endpoint, kd, reg, key, sb); + } catch (ConfigurationException ex) { + throw new ConfigurationException("failed to some critical settings from the juddi client config file. I won't be able to fire up the subscription callback endpoint ", ex); } - return start(client, cfg_node_name, endpoint, kd, reg, key, sb); } private static String callback = null; @@ -308,7 +318,7 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub * config parameter */ public static final String PROPERTY_LISTENURL = "client.subscriptionCallbacks.listenUrl"; - /** + /** * config parameter, if not defined, default will be used */ public static final String PROPERTY_NODE = "client.subscriptionCallbacks.node"; @@ -547,10 +557,11 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub /** * This effectively stops the endpoint address and notifies all * ISubscriptionCallback clients that the endpoint as been stopped. - * After it has been stopped, all ISubscriptionCallback are removed - * from the callback list. If the configuration file is set to automatically - * register binding templates, the binding template will be unregistered from - * the UDDI server + * After it has been stopped, all ISubscriptionCallback are removed from + * the callback list. If the configuration file is set to automatically + * register binding templates, the binding template will be unregistered + * from the UDDI server + * * @param client * @param cfg_node_name * @param bindingKey @@ -569,7 +580,7 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub } unregisterAllCallbacks(); if (client.getClientConfig().getConfiguration().getBoolean(PROPERTY_AUTOREG_BT, false) && bindingKey != null) { - + try { UDDIClerk clerk = client.getClerk(cfg_node_name); Transport tp = client.getTransport(cfg_node_name); @@ -585,7 +596,7 @@ public class SubscriptionCallbackListener implements org.uddi.v3_service.UDDISub } } - //TODO optionally kill the subscription? + //TODO optionally kill the subscription? //get all subscriptions from the uddi node, //loop through and deduce which ones are pointed at this endpoint //then remove them http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java ---------------------------------------------------------------------- diff --git a/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java b/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java index 1c6da05..1593e64 100644 --- a/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java +++ b/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java @@ -79,7 +79,10 @@ public class JAXWSTransport extends Transport { inquiryService = service.getUDDIInquiryPort(); } Map<String, Object> requestContext = ((BindingProvider) inquiryService).getRequestContext(); + if (endpointURL != null) { + requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); + } setCredentials(requestContext); } catch (Exception e) { throw new TransportException(e.getMessage(), e); @@ -123,6 +126,7 @@ public class JAXWSTransport extends Transport { publishService = service.getUDDIPublicationPort(); } Map<String, Object> requestContext = ((BindingProvider) publishService).getRequestContext(); + if (endpointURL != null) requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); setCredentials(requestContext); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SimpleBrowse.java ---------------------------------------------------------------------- diff --git a/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SimpleBrowse.java b/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SimpleBrowse.java new file mode 100644 index 0000000..0bd8085 --- /dev/null +++ b/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SimpleBrowse.java @@ -0,0 +1,359 @@ +/* + * Copyright 2001-2010 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.example.browse; + +import java.util.List; +import org.apache.juddi.api_v3.AccessPointType; +import org.apache.juddi.v3.client.UDDIConstants; +import org.apache.juddi.v3.client.config.UDDIClient; +import org.apache.juddi.v3.client.transport.Transport; +import org.uddi.api_v3.AuthToken; +import org.uddi.api_v3.BindingTemplates; +import org.uddi.api_v3.BusinessDetail; +import org.uddi.api_v3.BusinessInfos; +import org.uddi.api_v3.BusinessList; +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; +import org.uddi.api_v3.GetServiceDetail; +import org.uddi.api_v3.KeyedReference; +import org.uddi.api_v3.Name; +import org.uddi.api_v3.ServiceDetail; +import org.uddi.api_v3.ServiceInfos; +import org.uddi.v3_service.UDDIInquiryPortType; +import org.uddi.v3_service.UDDISecurityPortType; + +/** + * A Simple UDDI Browser that dumps basic information to console + * + * @author <a href="mailto:[email protected]">Alex O'Ree</a> + */ +public class SimpleBrowse { + + 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 { + // 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"); + // 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(); + } + } + + /** + * 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()); + } + } + + } + + 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) { + 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("................"); + + } + } +} http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-rest-cxf/pom.xml ---------------------------------------------------------------------- diff --git a/juddi-rest-cxf/pom.xml b/juddi-rest-cxf/pom.xml index 9ca8f09..fe06a91 100644 --- a/juddi-rest-cxf/pom.xml +++ b/juddi-rest-cxf/pom.xml @@ -24,7 +24,7 @@ </parent> <groupId>org.apache.juddi</groupId> <artifactId>juddi-rest-cxf</artifactId> - <packaging>bundle</packaging> + <packaging>jar</packaging> <name>jUDDI REST Services using Apache CXF</name> <dependencies> <dependency> http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 5b6a4c3..11e79b9 100644 --- a/pom.xml +++ b/pom.xml @@ -299,6 +299,7 @@ under the License. <module>uddi-ws</module> <module>uddi-tck-base</module> <module>juddi-client</module> + <module>juddi-client-cli</module> <module>juddi-client-plugins</module> <module>uddi-migration-tool</module> <module>juddi-core</module> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
