You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2015/03/27 12:40:39 UTC
[5/5] juddi git commit: JUDDI-931 CLI client
JUDDI-931 CLI client
Project: http://git-wip-us.apache.org/repos/asf/juddi/repo
Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/9dafe4e8
Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/9dafe4e8
Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/9dafe4e8
Branch: refs/heads/master
Commit: 9dafe4e83e9068c2ce8afc8869ed433be885dde7
Parents: bcd3c07
Author: Alex <al...@apache.org>
Authored: Fri Mar 27 07:40:25 2015 -0400
Committer: Alex <al...@apache.org>
Committed: Fri Mar 27 07:40:25 2015 -0400
----------------------------------------------------------------------
juddi-client-cli/.gitignore | 6 +
juddi-client-cli/README.txt | 12 +
juddi-client-cli/keystore.jks | Bin 0 -> 2253 bytes
juddi-client-cli/pom.xml | 139 +++
.../cli/CompareByTModelInstanceInfoQOS.java | 125 ++
.../apache/juddi/v3/client/cli/EntryPoint.java | 209 ++++
.../v3/client/cli/EntryPointSingleNode.java | 604 ++++++++++
.../juddi/v3/client/cli/EntryPoitMultiNode.java | 132 +++
.../v3/client/cli/FindBusinessBugHunt.java | 208 ++++
.../juddi/v3/client/cli/JuddiAdminService.java | 1076 ++++++++++++++++++
.../apache/juddi/v3/client/cli/SearchByQos.java | 272 +++++
.../juddi/v3/client/cli/SimpleBrowse.java | 489 ++++++++
.../juddi/v3/client/cli/UddiCreatebulk.java | 210 ++++
.../v3/client/cli/UddiCustodyTransfer.java | 166 +++
.../cli/UddiDigitalSignatureBusiness.java | 196 ++++
.../v3/client/cli/UddiDigitalSignatureFile.java | 160 +++
.../client/cli/UddiDigitalSignatureSearch.java | 130 +++
.../client/cli/UddiDigitalSignatureService.java | 189 +++
.../client/cli/UddiDigitalSignatureTmodel.java | 173 +++
.../juddi/v3/client/cli/UddiFindBinding.java | 106 ++
.../juddi/v3/client/cli/UddiFindEndpoints.java | 78 ++
.../v3/client/cli/UddiGetServiceDetails.java | 95 ++
.../juddi/v3/client/cli/UddiKeyGenerator.java | 104 ++
.../v3/client/cli/UddiRelatedBusinesses.java | 154 +++
.../juddi/v3/client/cli/UddiReplication.java | 134 +++
.../juddi/v3/client/cli/UddiSubscribe.java | 244 ++++
.../cli/UddiSubscribeAssertionStatus.java | 163 +++
.../v3/client/cli/UddiSubscribeValidate.java | 137 +++
.../client/cli/UddiSubscriptionManagement.java | 149 +++
.../apache/juddi/v3/client/cli/WadlImport.java | 197 ++++
.../apache/juddi/v3/client/cli/WsdlImport.java | 214 ++++
.../apache/juddi/v3/client/cli/testStrings.java | 73 ++
.../resources/META-INF/simple-publish-uddi.xml | 149 +++
juddi-client-cli/truststore.jks | Bin 0 -> 965 bytes
.../v3/client/ext/wsdm/WSDMQosConstants.java | 39 +
.../juddi/v3/client/mapping/wsdl/ReadWSDL.java | 5 +-
.../SubscriptionCallbackListener.java | 69 +-
.../v3/client/transport/JAXWSTransport.java | 4 +
.../org/apache/juddi/samples/SimpleBrowse.java | 359 ++++++
juddi-rest-cxf/pom.xml | 2 +-
pom.xml | 1 +
41 files changed, 6941 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/.gitignore
----------------------------------------------------------------------
diff --git a/juddi-client-cli/.gitignore b/juddi-client-cli/.gitignore
new file mode 100644
index 0000000..c1a69fd
--- /dev/null
+++ b/juddi-client-cli/.gitignore
@@ -0,0 +1,6 @@
+target
+**/target/*
+**/derby.log
+**/.project
+**/.classpath
+**/.settings/*
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/README.txt
----------------------------------------------------------------------
diff --git a/juddi-client-cli/README.txt b/juddi-client-cli/README.txt
new file mode 100644
index 0000000..262be41
--- /dev/null
+++ b/juddi-client-cli/README.txt
@@ -0,0 +1,12 @@
+This example is a command line demonstration of how to interact with JUDDI and how to use
+annotate items in UDDI for service or software versioning.
+
+1. Start the jUDDI-server (juddi-tomcat or juddi-bundle)
+
+2. Check the settings of the META-INF/simple-publish-uddi.xml, to make sure the serverName and serverPort are set correctly.
+
+Note: This is an interactive program. Do not run this from a headless server or from CI/Buildbot/Jenkins
+
+3. mvn clean install -Pinteractive
+
+Follow the onscreen prompts
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/keystore.jks
----------------------------------------------------------------------
diff --git a/juddi-client-cli/keystore.jks b/juddi-client-cli/keystore.jks
new file mode 100644
index 0000000..4367476
Binary files /dev/null and b/juddi-client-cli/keystore.jks differ
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/pom.xml
----------------------------------------------------------------------
diff --git a/juddi-client-cli/pom.xml b/juddi-client-cli/pom.xml
new file mode 100644
index 0000000..77af99d
--- /dev/null
+++ b/juddi-client-cli/pom.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0"?>
+<!--
+* Copyright 2001-2009 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.
+*
+*/ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>juddi-parent</artifactId>
+ <version>3.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>juddi-client-cli</artifactId>
+ <version>3.3.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>jUDDI CLI Client</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>juddi-client</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <!-- a lorem ipsum generator MIT license-->
+ <dependency>
+ <groupId>de.sven-jacobs</groupId>
+ <artifactId>loremipsum</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+
+ </dependencies>
+ <build>
+ <plugins>
+ <!-- examples are not very useful from a maven repo, so don't put it there -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.juddi.samples.EntryPoint</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id> <!-- this is used for inheritance merges -->
+ <phase>package</phase> <!-- bind to the packaging phase -->
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>interactive</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.apache.juddi.samples.EntryPoint</mainClass>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/CompareByTModelInstanceInfoQOS.java
----------------------------------------------------------------------
diff --git a/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/CompareByTModelInstanceInfoQOS.java b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/CompareByTModelInstanceInfoQOS.java
new file mode 100644
index 0000000..b7dc4d9
--- /dev/null
+++ b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/CompareByTModelInstanceInfoQOS.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 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 org.apache.juddi.api_v3.AccessPointType;
+import org.apache.juddi.v3.client.config.UDDIClient;
+import org.apache.juddi.v3.client.ext.wsdm.WSDMQosConstants;
+import org.apache.juddi.v3.client.compare.TModelInstanceDetailsComparator;
+import org.uddi.api_v3.AccessPoint;
+import org.uddi.api_v3.BindingTemplate;
+import org.uddi.api_v3.BindingTemplates;
+import org.uddi.api_v3.BusinessEntity;
+import org.uddi.api_v3.BusinessService;
+import org.uddi.api_v3.BusinessServices;
+import org.uddi.api_v3.Contact;
+import org.uddi.api_v3.Contacts;
+import org.uddi.api_v3.Description;
+import org.uddi.api_v3.DiscoveryURL;
+import org.uddi.api_v3.DiscoveryURLs;
+import org.uddi.api_v3.InstanceDetails;
+import org.uddi.api_v3.Name;
+import org.uddi.api_v3.PersonName;
+import org.uddi.api_v3.TModelInstanceDetails;
+import org.uddi.api_v3.TModelInstanceInfo;
+
+/**
+ * doesn't make changes to a remote server, just creates a few businesses and compares the two by qos parameters
+ * @author Alex O'Ree
+ */
+public class CompareByTModelInstanceInfoQOS {
+
+
+ public static void main(String[] args) throws Exception {
+ BusinessEntity mary = CreateMary();
+ BindingTemplate bt1 = mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0);
+ BindingTemplate bt2 = mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1);
+
+ TModelInstanceDetailsComparator tidc = new TModelInstanceDetailsComparator(WSDMQosConstants.METRIC_FAULT_COUNT_KEY, true, false, false);
+ int compare = tidc.compare(bt1.getTModelInstanceDetails(), bt2.getTModelInstanceDetails());
+ if (compare > 0)
+ System.out.println(mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue() +
+ " is greater than " + mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1).getAccessPoint().getValue());
+ if (compare < 0)
+ System.out.println(mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue() +
+ " is less than " + mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1).getAccessPoint().getValue());
+ if (compare== 0)
+ System.out.println(mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue() +
+ " is equal to " + mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1).getAccessPoint().getValue());
+
+ }
+
+
+
+ /**
+ * creates a business, service, bt with tmodel instance details with qos
+ * parameters
+ *
+ * @param rootAuthToken
+ * @throws Exception
+ */
+ private static BusinessEntity CreateMary() throws Exception {
+ BusinessEntity be = new BusinessEntity();
+ be.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
+ be.setDiscoveryURLs(new DiscoveryURLs());
+ be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("home", "http://www.marybusinessone.com"));
+ be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("serviceList", "http://www.marybusinessone.com/services"));
+ be.getName().add(new Name("Mary Doe Enterprises", "en"));
+ be.getName().add(new Name("Maria Negocio Uno", "es"));
+ be.getDescription().add(new Description("This is the description for Mary Business One.", "en"));
+ be.setContacts(new Contacts());
+ Contact c = new Contact();
+ c.setUseType("administrator");
+ c.getPersonName().add(new PersonName("Mary Doe", "en"));
+ c.getPersonName().add(new PersonName("Juan Doe", "es"));
+ c.getDescription().add(new Description("This is the administrator of the service offerings.", "en"));
+ be.getContacts().getContact().add(c);
+ be.setBusinessServices(new BusinessServices());
+ BusinessService bs = new BusinessService();
+ bs.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
+ bs.setServiceKey("uddi:uddi.marypublisher.com:marybusinessoneservice");
+ bs.getName().add(new Name("name!", "en"));
+ bs.setBindingTemplates(new BindingTemplates());
+ BindingTemplate bt = new BindingTemplate();
+ bt.setAccessPoint(new AccessPoint("http://localhost/endpoint1BAD", AccessPointType.WSDL_DEPLOYMENT.toString()));
+ bt.setTModelInstanceDetails(new TModelInstanceDetails());
+ TModelInstanceInfo tii = new TModelInstanceInfo();
+ tii.setTModelKey(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
+
+ tii.setInstanceDetails(new InstanceDetails());
+ tii.getInstanceDetails().setInstanceParms("400");
+ bt = UDDIClient.addSOAPtModels(bt);
+ bt.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
+ bs.getBindingTemplates().getBindingTemplate().add(bt);
+
+ bt = new BindingTemplate();
+ bt.setAccessPoint(new AccessPoint("http://localhost/endpoint2BETTER", AccessPointType.WSDL_DEPLOYMENT.toString()));
+ bt.setTModelInstanceDetails(new TModelInstanceDetails());
+ tii = new TModelInstanceInfo();
+ tii.setTModelKey(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
+
+ tii.setInstanceDetails(new InstanceDetails());
+ tii.getInstanceDetails().setInstanceParms("4");
+ bt = UDDIClient.addSOAPtModels(bt);
+ bt.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
+ bs.getBindingTemplates().getBindingTemplate().add(bt);
+
+
+ be.getBusinessServices().getBusinessService().add(bs);
+
+ return be;
+ }
+}
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPoint.java
----------------------------------------------------------------------
diff --git a/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPoint.java b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPoint.java
new file mode 100644
index 0000000..0fbd720
--- /dev/null
+++ b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPoint.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright 2014 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 org.apache.juddi.v3.client.config.UDDIClient;
+import org.apache.juddi.v3.client.config.UDDINode;
+
+/**
+ *
+ * @author Alex O'Ree
+ */
+public class EntryPoint {
+
+ public static void main(String[] args) throws Exception {
+
+ if (System.getProperty("javax.net.ssl.trustStore") == null) {
+ File f = new File("../../juddi-tomcat/truststore.jks");
+ if (f.exists()) {
+ System.setProperty("javax.net.ssl.trustStore", f.getAbsolutePath());
+
+ } else {
+ f = new File("../juddi-tomcat/truststore.jks");
+ if (f.exists()) {
+ System.setProperty("javax.net.ssl.trustStore", f.getAbsolutePath());
+
+ } else {
+ f = new File("./juddi-tomcat/truststore.jks");
+ if (f.exists()) {
+ System.setProperty("javax.net.ssl.trustStore", f.getAbsolutePath());
+
+ }
+ }
+ }
+
+ System.setProperty("javax.net.ssl.trustStorePassword", "password");
+ //System.setProperty("javax.net.ssl.keyStore", "keystore.jks");
+
+ //System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
+ }
+ //set up trust store
+
+ String trustStore = System.getProperty("javax.net.ssl.trustStore");
+ if (trustStore == null) {
+ System.out.println("javax.net.ssl.trustStore is not defined");
+ } else {
+ System.out.println("javax.net.ssl.trustStore = " + trustStore);
+ }
+
+ if (System.getProperty("javax.net.ssl.keyStore") == null) {
+ File f = new File("../../juddi-tomcat/keystore.jks");
+ if (f.exists()) {
+ System.setProperty("javax.net.ssl.keyStore", f.getAbsolutePath());
+
+ } else {
+ f = new File("../juddi-tomcat/keyStore.jks");
+ if (f.exists()) {
+ System.setProperty("javax.net.ssl.keyStore", f.getAbsolutePath());
+
+ } else {
+ f = new File("./juddi-tomcat/keystore.jks");
+ if (f.exists()) {
+ System.setProperty("javax.net.ssl.keyStore", f.getAbsolutePath());
+
+ }
+ }
+ }
+
+ System.setProperty("javax.net.ssl.keyStorePassword", "password");
+ //System.setProperty("javax.net.ssl.keyStore", "keystore.jks");
+
+ //System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
+ }
+ //set up trust store
+
+ String keyStore = System.getProperty("javax.net.ssl.trustStore");
+ if (keyStore == null) {
+ System.out.println("javax.net.ssl.keyStore is not defined");
+ } else {
+ System.out.println("javax.net.ssl.keyStore = " + trustStore);
+ }
+ //first menu
+ //connect to a node and do work on it
+ //multinode
+ String input = null;
+ do {
+ System.out.println("____________________________");
+ System.out.println("jUDDI Interactive Command Line Interface");
+ System.out.println("____________________________");
+ System.out.println(" 1) Connect and login to a Node");
+ System.out.println(" 2) Multinode and Replication commands");
+ System.out.println(" 3) Offline code examples");
+ System.out.println("- [ jUDDI Client (this app) configuration ] -");
+ //local config management
+ System.out.println(" 4) Quick add the jUDDI cloud node to *this's configuration file");
+ System.out.println(" 5) Add a node to *this's configuration file");
+ System.out.println(" 6) View all registered nodes for this client");
+ System.out.println(" q) Quit/exit");
+ System.out.print("jUDDI Main# ");
+ input = System.console().readLine();
+ if ("1".equals(input)) {
+ goSingleNode();
+ } else if ("2".equals(input)) {
+ goMultiNode();
+ } else if ("3".equals(input)) {
+ goOfflineExamples();
+ } else if (input.equals("4")) {
+ //System.out.println("31) Quick add the jUDDI cloud node to *this's configuration file");
+ new JuddiAdminService(new UDDIClient(), null).quickRegisterLocalCloud();
+ } else if (input.equals("5")) {
+ // System.out.println("32) Add a node to *this's configuration file");
+ UDDIClient clerkManager = new UDDIClient();
+ UDDINode node = new UDDINode();
+ System.out.print("Name (must be unique: ");
+ node.setClientName(System.console().readLine());
+ node.setName(node.getClientName());
+ System.out.print("Description: ");
+ node.setDescription(System.console().readLine());
+
+ node.setHomeJUDDI(false);
+ System.out.print("Inquiry URL: ");
+ node.setInquiryUrl(System.console().readLine());
+
+ System.out.print("Inquiry REST URL (optional): ");
+ node.setInquiryRESTUrl(System.console().readLine());
+
+ System.out.print("jUDDI API URL (optional): ");
+ node.setJuddiApiUrl(System.console().readLine());
+ System.out.print("Custody Transfer URL: ");
+ node.setCustodyTransferUrl(System.console().readLine());
+ System.out.print("Publish URL: ");
+ node.setPublishUrl(System.console().readLine());
+ System.out.print("Replication URL: ");
+ node.setReplicationUrl(System.console().readLine());
+ System.out.print("Security URL: ");
+ node.setSecurityUrl(System.console().readLine());
+ System.out.print("Subscription URL: ");
+ node.setSubscriptionUrl(System.console().readLine());
+
+ System.out.print("Subscription Listener URL: ");
+ node.setSubscriptionListenerUrl(System.console().readLine());
+
+ System.out.print("Transport (defaults to JAXWS): ");
+ node.setProxyTransport(System.console().readLine());
+ if (node.getProxyTransport() == null || node.getProxyTransport().trim().equalsIgnoreCase("")) {
+ node.setProxyTransport(org.apache.juddi.v3.client.transport.JAXWSTransport.class.getCanonicalName());
+ }
+ System.out.print("Factory Initial (optional): ");
+ node.setFactoryInitial(System.console().readLine());
+ System.out.print("Factory Naming Provider (optional): ");
+ node.setFactoryNamingProvider(System.console().readLine());
+ System.out.print("Factory URL Packages (optional): ");
+ node.setFactoryURLPkgs(System.console().readLine());
+
+ clerkManager.getClientConfig().addUDDINode(node);
+ clerkManager.getClientConfig().saveConfig();
+ System.out.println("Saved.");
+ }
+ } while (!"q".equalsIgnoreCase(input));
+ }
+
+ static void goMultiNode() throws Exception {
+ EntryPoitMultiNode.goMultiNode();
+ }
+
+ static void goSingleNode() throws Exception {
+ EntryPointSingleNode.goSingleNode();
+
+ }
+
+ private static void goOfflineExamples() throws Exception {
+ String input = null;
+ do {
+ System.out.println("____________________________");
+ System.out.println("Offline/Code Examples (you'll want to look at the source for some of these");
+ System.out.println("____________________________");
+ System.out.println(" 1) Compare Two Binding/tModelInstanceInfo - QOS Code Example");
+ System.out.println("2) Digitally sign a UDDI entity from a file.");
+ System.out.println(" q) Quit/exit");
+ System.out.print("#");
+ input = System.console().readLine();
+ processOffline(input);
+ } while (!"q".equalsIgnoreCase(input));
+
+ }
+
+ private static void processOffline(String input) throws Exception {
+ if (input.equals("1")) {
+ CompareByTModelInstanceInfoQOS.main(null);
+ }
+ if (input.equals("2")) {
+ new UddiDigitalSignatureFile().Fire(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/EntryPointSingleNode.java
----------------------------------------------------------------------
diff --git a/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPointSingleNode.java b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPointSingleNode.java
new file mode 100644
index 0000000..309e525
--- /dev/null
+++ b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPointSingleNode.java
@@ -0,0 +1,604 @@
+/*
+ * Copyright 2015 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.List;
+import org.apache.juddi.api_v3.Node;
+import org.apache.juddi.v3.client.UDDIConstants;
+import org.apache.juddi.v3.client.config.UDDIClient;
+import org.apache.juddi.v3.client.config.UDDINode;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.uddi.api_v3.BusinessList;
+import org.uddi.api_v3.DeleteBusiness;
+import org.uddi.api_v3.DeleteService;
+import org.uddi.api_v3.DeleteTModel;
+import org.uddi.api_v3.DiscardAuthToken;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.FindQualifiers;
+import org.uddi.api_v3.FindService;
+import org.uddi.api_v3.FindTModel;
+import org.uddi.api_v3.GetAuthToken;
+import org.uddi.api_v3.Name;
+import org.uddi.api_v3.ServiceList;
+import org.uddi.api_v3.TModelList;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+/**
+ *
+ * @author alex
+ */
+public class EntryPointSingleNode {
+
+ static void goSingleNode() throws Exception {
+ String currentNode = "default";
+ UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+
+ List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
+ System.out.println();
+
+ System.out.println("Nodes:");
+ for (int i = 0; i < uddiNodeList.size(); i++) {
+ System.out.println((i + 1) + ") Node name: " + uddiNodeList.get(i).getName());
+ }
+ System.out.print("Destination Node: ");
+ int index = Integer.parseInt(System.console().readLine()) - 1;
+
+ currentNode = uddiNodeList.get(index).getName();
+ Transport transport = clerkManager.getTransport(currentNode);
+ authtoken = login(currentNode, transport);
+ String input = null;
+ do {
+ System.out.println(" 1) Login");
+ System.out.println(" 2) Print auth token");
+ System.out.println(" 3) Logout (discard auth token)");
+
+ System.out.println("- [ Searching and Browsing ] -");
+ System.out.println(" 4) List all Businesses (XML)");
+ System.out.println(" 5) List all Businesses (Human readable)");
+ System.out.println(" 6) List all Services (XML)");
+ System.out.println(" 7) List all Services (Human readable)");
+ System.out.println(" 8) List all tModels (XML)");
+ System.out.println(" 9) List all tModels (Human readable)");
+ System.out.println("10) Find a Business");
+ System.out.println("11) Find a Service");
+ System.out.println("12) Find a tModel");
+
+ System.out.println("13) Find Binding by QOS Parameters (Binding/tModelInstanceInfo)");
+ System.out.println("14) Find Business by QOS Parameters (Binding/tModelInstanceInfo)");
+ System.out.println("15) Find Service by QOS Parameters (Binding/tModelInstanceInfo)");
+ System.out.println("16) Find a Binding, lists all bindings for all services");
+ System.out.println("17) Find Endpoints of a service (given the key)");
+ System.out.println("18) Get the details of a service");
+ System.out.println("19) UDDI Digital Signatures - Search for Signed Items");
+
+ System.out.println("- [ Publishing ] -");
+ System.out.println("20) Make a Key Generator tModel");
+ System.out.println("21) UDDI Create Bulk (makes N business with N services) (create for load testing)");
+ System.out.println("22) WSDL2UDDI - Register a service from a WSDL document (business key required)");
+ System.out.println("23) WADL2UDDI - Register a service from a WADL document (business key required)");
+ System.out.println("24) UDDI Custody Transfer (within a single node)");
+
+ System.out.println("25) UDDI Digital Signatures - Sign a Business");
+ System.out.println("26) UDDI Digital Signatures - Sign a Service");
+ System.out.println("27) UDDI Digital Signatures - Sign a tModel");
+
+ System.out.println("28) Create a Business Relationship Between two users and two Businesses(Publisher Assertion)");
+
+ System.out.println("- [ Subscriptions ] -");
+ System.out.println("29) Subscriptions - Asynchronous, listens for all changes (req stored credentials)");
+ System.out.println("30) Subscriptions - Synchronous");
+ System.out.println("31) Print Subscriptions");
+ System.out.println("32) Delete a subscription");
+ System.out.println("33) Delete all subscriptions");
+ System.out.println("34) Subscriptions - Asynchronous, publisher assertion subscriptions");
+
+ System.out.println("- [ Replication ] -");
+ System.out.println("35) Replication - do_ping");
+ System.out.println("36) Replication - get high watermarks");
+ System.out.println("37) Replication - get change records");
+ System.out.println("38) Replication - get failed change records (jUDDI only)");
+
+ //remote config management - juddi only
+ System.out.println("- [ jUDDI Configuration Management ] -");
+ System.out.println("39) Quick register the jUDDI cloud node to the current node");
+ System.out.println("40) Register the a locally defined node to another jUDDI server");
+ System.out.println("41) View all registered remote nodes on a jUDDI server");
+ System.out.println("42) UnRegister a node on a jUDDI server");
+
+ //juddi only
+ System.out.println("43) View the replication config from the current jUDDI server");
+ System.out.println("44) Set the replication config on a remote jUDDI server");
+ System.out.println("45) Prints the current replication status of a given node");
+ System.out.println("46) Periodic publisher, 1biz+1svc every 5 seconds");
+
+ //deleters
+ System.out.println("47) Bulk delete business");
+ System.out.println("48) Bulk delete services");
+ System.out.println("49) Bulk delete tModels");
+
+ System.out.println("q) quit");
+ System.out.print(username + "@" + currentNode + "# ");
+ input = System.console().readLine();
+ try {
+ processInput(input, currentNode, transport, clerkManager);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ } while (!input.equalsIgnoreCase("q"));
+ }
+ private static String authtoken = null;
+ static String password;
+ static String username;
+
+ private static String login(String currentNode, Transport transport) throws Exception {
+ System.out.println("Options:");
+ System.out.println("1) Enter a username/password for auth token");
+ System.out.println("2) Enter a username/password for HTTP based logins");
+ System.out.println("3) Enter a username/password for use stored credentials");
+ System.out.print("Login Method: ");
+ String input = System.console().readLine();
+ if ("1".equalsIgnoreCase(input)) {
+ UDDISecurityPortType security = null;
+ security = transport.getUDDISecurityService();
+ System.out.print(currentNode + "# username: ");
+ username = System.console().readLine();
+ char passwordArray[] = System.console().readPassword(currentNode + "# password: ");
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(username);
+ password = new String(passwordArray);
+ getAuthTokenRoot.setCred((password));
+ String lauthtoken = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+ System.out.println("Success!");
+ return lauthtoken;
+ } else if ("2".equalsIgnoreCase(input)) {
+ System.out.println("not implemented yet!");
+
+ } else if ("3".equalsIgnoreCase(input)) {
+ System.out.println("not implemented yet!");
+ } else {
+ System.out.println("Aborted!");
+ }
+ return null;
+
+ }
+
+ private static void processInput(final String input, final String currentNode, final Transport transport, UDDIClient client) throws Exception {
+ if (input == null) {
+ return;
+ }
+ if (input.equals("1")) {
+ authtoken = login(currentNode, transport);
+ } else if (input.equals("2")) {
+ System.out.println("Token info: " + authtoken);
+ } else if (input.equals("3")) {
+ if (authtoken != null) {
+ UDDISecurityPortType security = null;
+ security = transport.getUDDISecurityService();
+ DiscardAuthToken getAuthTokenRoot = new DiscardAuthToken();
+ getAuthTokenRoot.setAuthInfo(authtoken);
+ security.discardAuthToken(getAuthTokenRoot);
+ System.out.println("Success!");
+ }
+ } else if (input.equals("4")) {
+ new SimpleBrowse(transport).printBusinessList(authtoken, null, true);
+ } else if (input.equals("5")) {
+ new SimpleBrowse(transport).printBusinessList(authtoken, null, false);
+ } else if (input.equals("6")) {
+ new SimpleBrowse(transport).printServiceList(authtoken, null, true);
+ } else if (input.equals("7")) {
+ new SimpleBrowse(transport).printServiceList(authtoken, null, false);
+ } else if (input.equals("8")) {
+ new SimpleBrowse(transport).printTModelList(authtoken, null, true);
+ } else if (input.equals("9")) {
+ new SimpleBrowse(transport).printTModelList(authtoken, null, false);
+ } else if (input.equals("10")) {
+ System.out.print("Tip: (use % for wildcard searches)");
+ System.out.print("Name to search for: ");
+ String url = (System.console().readLine());
+ new SimpleBrowse(transport).printBusinessList(authtoken, url, false);
+ } else if (input.equals("11")) {
+ System.out.print("Tip: (use % for wildcard searches)");
+ System.out.print("Name to search for: ");
+ String url = (System.console().readLine());
+ new SimpleBrowse(transport).printServiceList(authtoken, url, false);
+ } else if (input.equals("12")) {
+ System.out.print("Tip: (use % for wildcard searches)");
+ System.out.print("Name to search for: ");
+ String url = (System.console().readLine());
+ new SimpleBrowse(transport).printTModelList(authtoken, url, false);
+ } else if (input.equals("13")) {
+ SearchByQos.doFindBinding(authtoken, transport);
+ } else if (input.equals("14")) {
+ SearchByQos.doFindBusiness(authtoken, transport);
+ } else if (input.equals("15")) {
+ SearchByQos.doFindService(authtoken, transport);
+ } else if (input.equals("16")) {
+ new UddiFindBinding().Fire(authtoken);
+ } else if (input.equals("17")) {
+ System.out.print("Service key to parse the endpoints: ");
+ String key = (System.console().readLine());
+ new UddiFindEndpoints().Fire(authtoken, key);
+ } else if (input.equals("18")) {
+ System.out.print("Service key: ");
+ String key = (System.console().readLine());
+ new UddiGetServiceDetails().Fire(authtoken, key);
+ } else if (input.equals("19")) {
+ new UddiDigitalSignatureSearch().Fire(authtoken);
+ } else if (input.equals("20")) {
+ System.out.print("Get FQDN: ");
+ String key = (System.console().readLine());
+ new UddiKeyGenerator().Fire(authtoken, key);
+ } else if (input.equals("21")) {
+
+ System.out.print("businesses: ");
+ int biz = Integer.parseInt(System.console().readLine());
+ System.out.print("servicesPerBusiness: ");
+ int svc = Integer.parseInt(System.console().readLine());
+ new UddiCreatebulk(transport, false, currentNode).publishBusiness(authtoken, biz, svc, username);
+ } else if (input.equals("22")) {
+ System.out.print("Path or URL to WSDL file: ");
+ String url = (System.console().readLine());
+ System.out.print("Business key to attach to: ");
+ String key = (System.console().readLine());
+ new WsdlImport().Fire(url, key, authtoken, transport);
+ } else if (input.equals("23")) {
+ System.out.print("Path or URL to WADL file: ");
+ String url = (System.console().readLine());
+ System.out.print("Business key to attach to: ");
+ String key = (System.console().readLine());
+ new WadlImport().Fire(url, key, authtoken, transport);
+ } else if (input.equals("24")) {
+ UDDISecurityPortType security = null;
+ security = transport.getUDDISecurityService();
+
+ System.out.print("Transfer from username: ");
+ String uname = (System.console().readLine());
+ char passwordArray[] = System.console().readPassword("password: ");
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(uname);
+ getAuthTokenRoot.setCred(new String(passwordArray));
+ String authtokenFrom = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+ System.out.println("Success!");
+
+ System.out.print("Transfer to username: ");
+ String uname2 = (System.console().readLine());
+ char passwordArray2[] = System.console().readPassword("password: ");
+ getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(uname2);
+ getAuthTokenRoot.setCred(new String(passwordArray2));
+ String authtokenFrom2 = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+ System.out.println("Success!");
+ System.out.print("business/tModel key to transfer: ");
+ String key = (System.console().readLine());
+ new UddiCustodyTransfer().TransferBusiness(uname, authtokenFrom, uname2, authtokenFrom2, key);
+ } else if (input.equals("25")) {
+ System.out.print("Business key to sign: ");
+ String key = (System.console().readLine());
+ new UddiDigitalSignatureBusiness().Fire(authtoken, key);
+ } else if (input.equals("26")) {
+ System.out.print("Service key to sign: ");
+ String key = (System.console().readLine());
+ new UddiDigitalSignatureService().Fire(authtoken, key);
+ } else if (input.equals("27")) {
+ System.out.print("tModel key to sign: ");
+ String key = (System.console().readLine());
+ new UddiDigitalSignatureTmodel().Fire(authtoken, key);
+ } else if (input.equals("28")) {
+ UDDISecurityPortType security = null;
+
+ security = transport.getUDDISecurityService();
+
+ System.out.print("1st Business username: ");
+ String uname = (System.console().readLine());
+ char passwordArray[] = System.console().readPassword("password: ");
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(uname);
+ getAuthTokenRoot.setCred(new String(passwordArray));
+ String authtokenFrom = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+ System.out.println("Success!");
+
+ System.out.print(uname + "'s business : ");
+ String key = (System.console().readLine());
+
+ System.out.print("2st Business username: ");
+ String uname2 = (System.console().readLine());
+ char passwordArray2[] = System.console().readPassword("password: ");
+ getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(uname2);
+ getAuthTokenRoot.setCred(new String(passwordArray2));
+ String authtokenFrom2 = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+ System.out.println("Success!");
+
+ System.out.print(uname2 + "'s business : ");
+ String key2 = (System.console().readLine());
+
+ System.out.print("relationship (parent-child, peer-peer,or identity) : ");
+ String relationship = (System.console().readLine());
+ new UddiRelatedBusinesses().Fire(key, authtokenFrom, key2, authtokenFrom2, relationship);
+ } else if (input.equals("29")) {
+ new UddiSubscribe(client, currentNode, transport).Fire();
+
+ } else if (input.equals("30")) {
+ System.out.print("Subscription key: ");
+ String key = (System.console().readLine());
+ System.out.println("Fetching results for the past 30 days...");
+ new UddiSubscribeValidate(transport).go(authtoken, input);
+ } else if (input.equals("31")) {
+ new UddiSubscriptionManagement(transport).PrintSubscriptions(authtoken);
+ } else if (input.equals("32")) {
+ System.out.print("Subscription key: ");
+ String key2 = (System.console().readLine());
+ new UddiSubscriptionManagement(transport).DeleteSubscription(authtoken, key2);
+ } else if (input.equals("33")) {
+ new UddiSubscriptionManagement(transport).DeleteAllSubscriptions(authtoken);
+ } else if (input.equals("34")) {
+ new UddiSubscribeAssertionStatus(transport).Fire(currentNode);
+
+ } else if (input.equals("35")) {
+
+ new UddiReplication(client, currentNode).DoPing();
+
+ } else if (input.equals("36")) {
+ //System.out.println("28) Replication - get high watermarks");
+ new UddiReplication(client, currentNode).GetHighWatermarks();
+
+ } else if (input.equals("37")) {
+ //System.out.println("29) Replication - get change records");
+
+ System.out.print("Change ID to fetch: ");
+ String id = (System.console().readLine());
+
+ System.out.print("Node id of something in the replication graph: ");
+ String src = (System.console().readLine());
+
+ new UddiReplication(client, currentNode).GetChangeRecords(Long.parseLong(id), src);
+
+ } else if ("38".equals(input)) {
+ new JuddiAdminService(client, transport).dumpFailedReplicationRecords(authtoken);
+ } else if (input.equals("39")) {
+
+ new JuddiAdminService(client, transport).quickRegisterRemoteCloud(authtoken);
+ } else if (input.equals("40")) {
+
+ //System.out.println("32) Register a *this node to a jUDDI server");
+ UDDIClient clerkManager = new UDDIClient();
+ List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
+ System.out.println();
+
+ System.out.println("Locally defined nodes:");
+ for (int i = 0; i < uddiNodeList.size(); i++) {
+ System.out.println("________________________________________________________________________________");
+ System.out.println((i + 1) + ") Node name: " + uddiNodeList.get(i).getName());
+ System.out.println((i + 1) + ") Node description: " + uddiNodeList.get(i).getDescription());
+ System.out.println((i + 1) + ") Transport: " + uddiNodeList.get(i).getProxyTransport());
+ System.out.println((i + 1) + ") jUDDI URL: " + uddiNodeList.get(i).getJuddiApiUrl());
+ }
+ System.out.println("Local Source Node: ");
+ int index = Integer.parseInt(System.console().readLine()) - 1;
+
+ System.out.println("Remote Destination(s):");
+ for (int i = 0; i < uddiNodeList.size(); i++) {
+ System.out.println("________________________________________________________________________________");
+ System.out.println((i + 1) + ") Node name: " + uddiNodeList.get(i).getName());
+ System.out.println((i + 1) + ") Node description: " + uddiNodeList.get(i).getDescription());
+ System.out.println((i + 1) + ") Transport: " + uddiNodeList.get(i).getProxyTransport());
+ System.out.println((i + 1) + ") jUDDI URL: " + uddiNodeList.get(i).getJuddiApiUrl());
+ }
+ System.out.println("Remote Destination Node to publish to: ");
+ int index2 = Integer.parseInt(System.console().readLine()) - 1;
+
+ new JuddiAdminService(client, transport).registerLocalNodeToRemoteNode(authtoken, uddiNodeList.get(index), uddiNodeList.get(index2));
+
+ } else if (input.equals("41")) {
+
+ // System.out.println("33) View all register remote nodes on a jUDDI server");
+ new JuddiAdminService(client, transport).viewRemoteNodes(authtoken);
+ } /* if (input.equals("35")) {
+ UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
+ for (int i = 0; i < uddiNodeList.size(); i++) {
+ System.out.println("________________________________________________________________________________");
+ System.out.println("Client name: " + uddiNodeList.get(i).getClientName());
+ System.out.println("Node name: " + uddiNodeList.get(i).getName());
+ System.out.println("Node description: " + uddiNodeList.get(i).getDescription());
+ System.out.println("Transport: " + uddiNodeList.get(i).getProxyTransport());
+ System.out.println(i + ") jUDDI URL: " + uddiNodeList.get(i).getJuddiApiUrl());
+
+ }
+
+ }*/ else if (input.equals("42")) {
+
+ new JuddiAdminService(client, transport).viewRemoveRemoteNode(authtoken);
+ //System.out.println("35) UnRegister a node on a jUDDI server");
+ } else if (input.equals("43")) {
+ new JuddiAdminService(client, transport).viewReplicationConfig(authtoken, currentNode);
+ } else if (input.equals("44")) {
+ new JuddiAdminService(client, transport).setReplicationConfig(authtoken);
+ } else if (input.equals("45")) {
+ new JuddiAdminService(client, transport).printStatus(transport, authtoken);
+ } else if (input.equals("46")) {
+ //TODO current counts
+ UDDIInquiryPortType uddiInquiryService = transport.getUDDIInquiryService();
+ FindBusiness fb = new FindBusiness();
+ fb.setAuthInfo(authtoken);
+ fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fb.setMaxRows(1);
+ fb.setListHead(0);
+ BusinessList findBusiness = uddiInquiryService.findBusiness(fb);
+ System.out.println("current business counts "
+ + findBusiness.getListDescription().getActualCount() + " "
+ + findBusiness.getListDescription().getIncludeCount() + " "
+ + findBusiness.getListDescription().getListHead());
+ FindService fs = new FindService();
+ fs.setAuthInfo(authtoken);
+ fs.getName().add(new Name(UDDIConstants.WILDCARD, null));
+ fs.setFindQualifiers(new FindQualifiers());
+ fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fs.setMaxRows(1);
+ fs.setListHead(0);
+ ServiceList findService = uddiInquiryService.findService(fs);
+ System.out.println("current service counts "
+ + findService.getListDescription().getActualCount() + " "
+ + findService.getListDescription().getIncludeCount() + " "
+ + findService.getListDescription().getListHead());
+
+ running = true;
+ createdServices = 0;
+ createdBusinesses = 0;
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ UddiCreatebulk uddiCreatebulk = new UddiCreatebulk(transport, false, currentNode);
+ while (running) {
+ try {
+ uddiCreatebulk.publishBusiness(authtoken, 1, 1, username);
+ createdBusinesses++;
+ createdServices++;
+ Thread.sleep(5000);
+ } catch (Exception ex) {
+ System.out.println("eception caught, assuming it's an expired token, attempting to reauthenticate " + ex.getMessage());
+ //potentially an expired token, reauthenticate
+ try {
+ UDDISecurityPortType security = null;
+ security = transport.getUDDISecurityService();
+
+ GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ getAuthTokenRoot.setUserID(username);
+ getAuthTokenRoot.setCred((password));
+ authtoken = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+ } catch (Exception x) {
+ System.out.println("unable to reauthenticate, aborting!");
+ ex.printStackTrace();
+ running = false;
+ }
+
+ }
+ }
+ }
+ }).start();
+ System.out.println("Started, press <Enter> to stop!");
+ System.console().readLine();
+ running = false;
+
+ System.out.println("before business counts "
+ + findBusiness.getListDescription().getActualCount());
+
+ fb.setAuthInfo(authtoken);
+ BusinessList afterfindBusiness = uddiInquiryService.findBusiness(fb);
+ System.out.println("after business counts "
+ + afterfindBusiness.getListDescription().getActualCount());
+ System.out.println("actual created " + createdBusinesses);
+ System.out.println("Delta = " + (afterfindBusiness.getListDescription().getActualCount() - findBusiness.getListDescription().getActualCount()));
+
+ System.out.println("before service counts "
+ + findService.getListDescription().getActualCount());
+
+ fs.setAuthInfo(authtoken);
+ ServiceList afterfindService = uddiInquiryService.findService(fs);
+ System.out.println("after service counts "
+ + afterfindService.getListDescription().getActualCount());
+ System.out.println("actual created " + createdServices);
+ System.out.println("delta = " + (afterfindService.getListDescription().getActualCount() - findService.getListDescription().getActualCount()));
+ if ((afterfindService.getListDescription().getActualCount() - findService.getListDescription().getActualCount()) == createdServices) {
+ System.out.println("success");
+ } else {
+ System.out.println("failure!");
+ }
+
+ } else if (input.equals("47")) {
+ System.out.println("We'll run a search first, then the results will be deleted (after confirmation). Use % as a wild card");
+ System.out.print("Search query: ");
+ String key = (System.console().readLine());
+ FindBusiness fb = new FindBusiness();
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fb.getName().add(new Name(key, null));
+ BusinessList findBusiness = transport.getUDDIInquiryService().findBusiness(fb);
+
+ DeleteBusiness db = new DeleteBusiness();
+ db.setAuthInfo(authtoken);
+ for (int i = 0; i < findBusiness.getBusinessInfos().getBusinessInfo().size(); i++) {
+ db.getBusinessKey().add(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey());
+ System.out.println(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey() + " " + findBusiness.getBusinessInfos().getBusinessInfo().get(i).getName().get(0).getValue());
+ }
+ System.out.print("The above businesses will be deleted, are you sure? (y/n) : ");
+ key = (System.console().readLine());
+ if ("y".equalsIgnoreCase(key.trim().toLowerCase())) {
+ transport.getUDDIPublishService().deleteBusiness(db);
+ System.out.println("done.");
+ }else
+ System.out.println("aborted.");
+ }
+ else if (input.equals("48")) {
+ System.out.println("We'll run a search first, then the results will be deleted (after confirmation). Use % as a wild card");
+ System.out.print("Search query: ");
+ String key = (System.console().readLine());
+
+ FindService fb = new FindService();
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fb.getName().add(new Name(key, null));
+ ServiceList findBusiness = transport.getUDDIInquiryService().findService(fb);
+
+ DeleteService db = new DeleteService();
+ db.setAuthInfo(authtoken);
+ for (int i = 0; i < findBusiness.getServiceInfos().getServiceInfo().size(); i++) {
+ db.getServiceKey().add(findBusiness.getServiceInfos().getServiceInfo().get(i).getServiceKey());
+ System.out.println(findBusiness.getServiceInfos().getServiceInfo().get(i).getServiceKey() + " " + findBusiness.getServiceInfos().getServiceInfo().get(i).getName().get(0).getValue());
+ }
+ System.out.print("The above services will be deleted, are you sure? (y/n) : ");
+ key = (System.console().readLine());
+ if ("y".equalsIgnoreCase(key.trim().toLowerCase())) {
+ transport.getUDDIPublishService().deleteService(db);
+ System.out.println("done.");
+ }else
+ System.out.println("aborted.");
+ }
+ else if (input.equals("49")) {
+ System.out.println("We'll run a search first, then the results will be deleted (after confirmation). Use % as a wild card");
+ System.out.print("Search query: ");
+ String key = (System.console().readLine());
+ FindTModel fb = new FindTModel();
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fb.setName(new Name(key, null));
+ TModelList findBusiness = transport.getUDDIInquiryService().findTModel(fb);
+
+ DeleteTModel db = new DeleteTModel();
+ db.setAuthInfo(authtoken);
+ for (int i = 0; i < findBusiness.getTModelInfos().getTModelInfo().size(); i++) {
+ db.getTModelKey().add(findBusiness.getTModelInfos().getTModelInfo().get(i).getTModelKey());
+ System.out.println(findBusiness.getTModelInfos().getTModelInfo().get(i).getTModelKey() + " " + findBusiness.getTModelInfos().getTModelInfo().get(i).getName().getValue());
+ }
+ System.out.print("The above tModels will be deleted, are you sure? (y/n) : ");
+ key = (System.console().readLine());
+ if ("y".equalsIgnoreCase(key.trim().toLowerCase())) {
+ transport.getUDDIPublishService().deleteTModel(db);
+ System.out.println("done.");
+ }else
+ System.out.println("aborted.");
+ }
+
+ }
+ static boolean running = true;
+ static int createdServices = 0;
+ static int createdBusinesses = 0;
+
+}
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPoitMultiNode.java
----------------------------------------------------------------------
diff --git a/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPoitMultiNode.java b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPoitMultiNode.java
new file mode 100644
index 0000000..fbb5808
--- /dev/null
+++ b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/EntryPoitMultiNode.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2015 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.List;
+import org.apache.juddi.api_v3.Node;
+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.BusinessList;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.FindQualifiers;
+import org.uddi.api_v3.FindService;
+import org.uddi.api_v3.FindTModel;
+import org.uddi.api_v3.Name;
+import org.uddi.api_v3.ServiceList;
+import org.uddi.api_v3.TModelList;
+import org.uddi.v3_service.UDDIInquiryPortType;
+
+/**
+ *
+ * @author alex
+ */
+public class EntryPoitMultiNode {
+
+ static void goMultiNode() throws Exception {
+ String currentNode = "default";
+ UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+
+ List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
+ String input = null;
+ do {
+ System.out.println("1) Sets undirected replication two instances of jUDDI");
+ System.out.println("2) Sets undirected replication 3 instances of jUDDI");
+ System.out.println("3) Sets directed replication between 3 instances of jUDDI");
+ System.out.println("4) Prints the replication status for all nodes");
+ System.out.println("5) Prints the business, service, and tmodels counts");
+ System.out.println("6) Ping all nodes");
+
+ System.out.println("q) quit");
+ System.out.print("Selection: ");
+ input = System.console().readLine();
+
+ processInput(input, clerkManager);
+
+ } while (!input.equalsIgnoreCase("q"));
+ }
+
+ private static void processInput(String input, UDDIClient clerkManager) throws Exception {
+ if (input.equals("1")) {
+
+ new JuddiAdminService(clerkManager, null).autoMagic();
+ List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
+ for (int i = 0; i < uddiNodeList.size(); i++) {
+ new UddiCreatebulk(uddiNodeList.get(i).getName()).publishBusiness(null, 1, 1, "root@" + uddiNodeList.get(i).getName());
+ }
+ //new UddiCreatebulk("uddi:another.juddi.apache.org:node2").publishBusiness(null, 1, 1);
+ } else if (input.equals("2")) {
+
+ new JuddiAdminService(clerkManager, null).autoMagic3();
+ List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
+ for (int i = 0; i < uddiNodeList.size(); i++) {
+ new UddiCreatebulk(uddiNodeList.get(i).getName()).publishBusiness(null, 1, 1, "root@" + uddiNodeList.get(i).getName());
+ }
+ //new UddiCreatebulk("uddi:another.juddi.apache.org:node2").publishBusiness(null, 1, 1);
+ } else if (input.equals("3")) {
+ new JuddiAdminService(clerkManager, null).autoMagicDirected();
+
+ List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
+ for (int i = 0; i < uddiNodeList.size(); i++) {
+ new UddiCreatebulk(uddiNodeList.get(i).getName()).publishBusiness(null, 1, 1, "root@" + uddiNodeList.get(i).getName());
+ }
+ } else if (input.equals("4")) {
+ new JuddiAdminService(clerkManager, null).printStatus();
+ } else if (input.equals("5")) {
+ List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
+ for (Node n : uddiNodeList) {
+ UDDIInquiryPortType uddiInquiryService = clerkManager.getTransport(n.getName()).getUDDIInquiryService();
+
+ FindBusiness fb = new FindBusiness();
+
+ fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
+ fb.setFindQualifiers(new FindQualifiers());
+ fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fb.setMaxRows(1);
+ fb.setListHead(0);
+ BusinessList findBusiness = uddiInquiryService.findBusiness(fb);
+ System.out.println(n.getName() + " business count "
+ + findBusiness.getListDescription().getActualCount());
+ FindService fs = new FindService();
+
+ fs.getName().add(new Name(UDDIConstants.WILDCARD, null));
+ fs.setFindQualifiers(new FindQualifiers());
+ fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fs.setMaxRows(1);
+ fs.setListHead(0);
+ ServiceList findService = uddiInquiryService.findService(fs);
+ System.out.println(n.getName() + " service count "
+ + findService.getListDescription().getActualCount());
+
+ FindTModel ft = new FindTModel();
+ ft.setName(new Name(UDDIConstants.WILDCARD, null));
+ ft.setFindQualifiers(new FindQualifiers());
+ ft.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ ft.setMaxRows(1);
+ ft.setListHead(0);
+ TModelList findTModel = uddiInquiryService.findTModel(ft);
+ System.out.println(n.getName() + " tModel count "
+ + findTModel.getListDescription().getActualCount());
+
+ }
+ System.out.println();
+ } else if (input.equals("6")) {
+ new JuddiAdminService(clerkManager, null).pingAll();
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/juddi/blob/9dafe4e8/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/FindBusinessBugHunt.java
----------------------------------------------------------------------
diff --git a/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/FindBusinessBugHunt.java b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/FindBusinessBugHunt.java
new file mode 100644
index 0000000..834b4b1
--- /dev/null
+++ b/juddi-client-cli/src/main/java/org/apache/juddi/v3/client/cli/FindBusinessBugHunt.java
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+package org.apache.juddi.v3.client.cli;
+
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.juddi.jaxb.PrintUDDI;
+import org.apache.juddi.v3.client.UDDIConstants;
+import org.apache.juddi.v3.client.config.UDDIClerk;
+import org.apache.juddi.v3.client.config.UDDIClient;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.apache.juddi.v3_service.JUDDIApiPortType;
+import org.uddi.api_v3.BusinessDetail;
+import org.uddi.api_v3.BusinessEntity;
+import org.uddi.api_v3.BusinessInfos;
+import org.uddi.api_v3.BusinessList;
+import org.uddi.api_v3.Contact;
+import org.uddi.api_v3.Contacts;
+import org.uddi.api_v3.DeleteBusiness;
+import org.uddi.api_v3.Description;
+import org.uddi.api_v3.DiscoveryURL;
+import org.uddi.api_v3.DiscoveryURLs;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.GetAuthToken;
+import org.uddi.api_v3.GetBusinessDetail;
+import org.uddi.api_v3.Name;
+import org.uddi.api_v3.PersonName;
+import org.uddi.api_v3.SaveBusiness;
+import org.uddi.api_v3.SaveTModel;
+import org.uddi.api_v3.TModel;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+/**
+ *
+ * @author Alex O'Ree
+ */
+public class FindBusinessBugHunt {
+
+ 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;
+ private static UDDIInquiryPortType inquiry;
+
+ public static void main(String[] args) throws Exception {
+
+ // 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");
+ UDDIClerk clerk = clerkManager.getClerk("default");
+ // a ClerkManager 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 = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ publish = transport.getUDDIPublishService();
+ inquiry = transport.getUDDIInquiryService();
+ //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.
+ String rootAuthToken = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
+ String uddi = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+
+ System.out.println("killing mary's business if it exists");
+ //first check is Mary's business exists and delete
+ DeleteIfExists("uddi:uddi.marypublisher.com:marybusinessone", uddi);
+
+ System.out.println("making mary's tmodel key gen");
+ //make the key gen since our test case uses some custom keys
+ TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi.marypublisher.com", "mary key gen", "en");
+ //clerk.register(createKeyGenator);
+ System.out.println("saving...");
+ SaveTM(createKeyGenator, uddi);
+
+
+ System.out.println("fetching business list");
+ BusinessList before = getBusinessList(uddi);
+ if (before.getBusinessInfos() == null) {
+ System.out.println("before no businesses returned!");
+ before.setBusinessInfos(new BusinessInfos());
+ } else {
+ System.out.println(before.getBusinessInfos().getBusinessInfo().size() + " businesses returned before");
+ }
+
+ System.out.println("saving mary");
+ SaveMary(uddi);
+
+ BusinessList after = getBusinessList(uddi);
+ if (after.getBusinessInfos() == null) {
+ System.out.println("after no businesses returned!");
+ after.setBusinessInfos(new BusinessInfos());
+ } else {
+ System.out.println(after.getBusinessInfos().getBusinessInfo().size() + " businesses returned after");
+ }
+ PrintUDDI<BusinessList> p = new PrintUDDI<BusinessList>();
+ if (before.getBusinessInfos().getBusinessInfo().size()
+ < after.getBusinessInfos().getBusinessInfo().size()) {
+ System.out.println("hey it worked as advertised, double checking");
+ if (CheckFor(after, "uddi:uddi.marypublisher.com:marybusinessone")) {
+ System.out.println("ok!");
+ } else {
+ System.out.println("no good!");
+ }
+ } else {
+
+ System.out.println("something's not right, here's the before service listing");
+ System.out.println(p.print(before));
+ System.out.println(p.print(after));
+ }
+
+ }
+
+ private static void DeleteIfExists(String key, String authInfo) {
+ GetBusinessDetail gbd = new GetBusinessDetail();
+ gbd.setAuthInfo(authInfo);
+ gbd.getBusinessKey().add(key);
+ boolean found = false;
+ try {
+ BusinessDetail businessDetail = inquiry.getBusinessDetail(gbd);
+ if (businessDetail != null
+ && !businessDetail.getBusinessEntity().isEmpty()
+ && businessDetail.getBusinessEntity().get(0).getBusinessKey().equals(key)) {
+ found = true;
+ }
+ } catch (Exception ex) {
+ }
+ if (found) {
+ DeleteBusiness db = new DeleteBusiness();
+ db.setAuthInfo(authInfo);
+ db.getBusinessKey().add(key);
+ try {
+ publish.deleteBusiness(db);
+ } catch (Exception ex) {
+ Logger.getLogger(FindBusinessBugHunt.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+ private static 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);
+ fb.getName().add((new Name(UDDIConstants.WILDCARD, null)));
+ return inquiry.findBusiness(fb);
+ }
+
+ private static void SaveMary(String rootAuthToken) throws Exception {
+ BusinessEntity be = new BusinessEntity();
+ be.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
+ be.setDiscoveryURLs(new DiscoveryURLs());
+ be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("home", "http://www.marybusinessone.com"));
+ be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("serviceList", "http://www.marybusinessone.com/services"));
+ be.getName().add(new Name("Mary Doe Enterprises", "en"));
+ be.getName().add(new Name("Maria Negocio Uno", "es"));
+ be.getDescription().add(new Description("This is the description for Mary Business One.", "en"));
+ be.setContacts(new Contacts());
+ Contact c = new Contact();
+ c.setUseType("administrator");
+ c.getPersonName().add(new PersonName("Mary Doe", "en"));
+ c.getPersonName().add(new PersonName("Juan Doe", "es"));
+ c.getDescription().add(new Description("This is the administrator of the service offerings.", "en"));
+ be.getContacts().getContact().add(c);
+ SaveBusiness sb = new SaveBusiness();
+ sb.setAuthInfo(rootAuthToken);
+ sb.getBusinessEntity().add(be);
+ publish.saveBusiness(sb);
+ }
+
+ private static boolean CheckFor(BusinessList list, String key) {
+ for (int i = 0; i < list.getBusinessInfos().getBusinessInfo().size(); i++) {
+ if (list.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey().equalsIgnoreCase(key)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void SaveTM(TModel createKeyGenator, String uddi) throws Exception {
+ SaveTModel stm = new SaveTModel();
+ stm.setAuthInfo(uddi);
+ stm.getTModel().add(createKeyGenator);
+ publish.saveTModel(stm);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org