This project has retired. For details please refer to its
Attic page.
EntryPointSingleNode xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.v3.client.cli;
17
18 import java.util.List;
19 import org.apache.juddi.api_v3.Node;
20 import org.apache.juddi.v3.client.UDDIConstants;
21 import org.apache.juddi.v3.client.config.UDDIClient;
22 import org.apache.juddi.v3.client.transport.Transport;
23 import org.uddi.api_v3.BusinessList;
24 import org.uddi.api_v3.DeleteBusiness;
25 import org.uddi.api_v3.DeleteService;
26 import org.uddi.api_v3.DeleteTModel;
27 import org.uddi.api_v3.DiscardAuthToken;
28 import org.uddi.api_v3.FindBusiness;
29 import org.uddi.api_v3.FindQualifiers;
30 import org.uddi.api_v3.FindService;
31 import org.uddi.api_v3.FindTModel;
32 import org.uddi.api_v3.GetAuthToken;
33 import org.uddi.api_v3.Name;
34 import org.uddi.api_v3.ServiceList;
35 import org.uddi.api_v3.TModelList;
36 import org.uddi.v3_service.UDDIInquiryPortType;
37 import org.uddi.v3_service.UDDISecurityPortType;
38
39
40
41
42
43 public class EntryPointSingleNode {
44
45 static void goSingleNode() throws Exception {
46 String currentNode = "default";
47 UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
48
49 List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
50 System.out.println();
51
52 System.out.println("Nodes:");
53 for (int i = 0; i < uddiNodeList.size(); i++) {
54 System.out.println((i + 1) + ") Node name: " + uddiNodeList.get(i).getName());
55 }
56 System.out.print("Destination Node: ");
57 int index = Integer.parseInt(System.console().readLine()) - 1;
58
59 currentNode = uddiNodeList.get(index).getName();
60 Transport transport = clerkManager.getTransport(currentNode);
61 authtoken = login(currentNode, transport);
62 String input = null;
63 do {
64 System.out.println(" 1) Login");
65 System.out.println(" 2) Print auth token");
66 System.out.println(" 3) Logout (discard auth token)");
67
68 System.out.println("- [ Searching and Browsing ] -");
69 System.out.println(" 4) List all Businesses (XML)");
70 System.out.println(" 5) List all Businesses (Human readable)");
71 System.out.println(" 6) List all Services (XML)");
72 System.out.println(" 7) List all Services (Human readable)");
73 System.out.println(" 8) List all tModels (XML)");
74 System.out.println(" 9) List all tModels (Human readable)");
75 System.out.println("10) Find a Business");
76 System.out.println("11) Find a Service");
77 System.out.println("12) Find a tModel");
78
79 System.out.println("13) Find Binding by QOS Parameters (Binding/tModelInstanceInfo)");
80 System.out.println("14) Find Business by QOS Parameters (Binding/tModelInstanceInfo)");
81 System.out.println("15) Find Service by QOS Parameters (Binding/tModelInstanceInfo)");
82 System.out.println("16) Find a Binding, lists all bindings for all services");
83 System.out.println("17) Find Endpoints of a service (given the key)");
84 System.out.println("18) Get the details of a service");
85 System.out.println("19) UDDI Digital Signatures - Search for Signed Items");
86
87 System.out.println("- [ Publishing ] -");
88 System.out.println("20) Make a Key Generator tModel");
89 System.out.println("22) WSDL2UDDI - Register a service from a WSDL document (business key required)");
90 System.out.println("23) WADL2UDDI - Register a service from a WADL document (business key required)");
91 System.out.println("24) UDDI Custody Transfer (within a single node)");
92
93 System.out.println("25) UDDI Digital Signatures - Sign a Business");
94 System.out.println("26) UDDI Digital Signatures - Sign a Service");
95 System.out.println("27) UDDI Digital Signatures - Sign a tModel");
96
97 System.out.println("28) Create a Business Relationship Between two users and two Businesses(Publisher Assertion)");
98
99 System.out.println("- [ Subscriptions ] -");
100 System.out.println("29) Subscriptions - Asynchronous, listens for all changes (req stored credentials)");
101 System.out.println("30) Subscriptions - Synchronous");
102 System.out.println("31) Print Subscriptions");
103 System.out.println("32) Delete a subscription");
104 System.out.println("33) Delete all subscriptions");
105 System.out.println("34) Subscriptions - Asynchronous, publisher assertion subscriptions");
106
107 System.out.println("- [ Replication ] -");
108 System.out.println("35) Replication - do_ping");
109 System.out.println("36) Replication - get high watermarks");
110 System.out.println("37) Replication - get change records");
111 System.out.println("38) Replication - get failed change records (jUDDI only)");
112
113
114 System.out.println("- [ jUDDI Configuration Management ] -");
115 System.out.println("39) Quick register the jUDDI cloud node to the current node");
116 System.out.println("40) Register the a locally defined node to another jUDDI server");
117 System.out.println("41) View all registered remote nodes on a jUDDI server");
118 System.out.println("42) UnRegister a node on a jUDDI server");
119
120
121 System.out.println("43) View the replication config from the current jUDDI server");
122 System.out.println("44) Set the replication config on a remote jUDDI server");
123 System.out.println("45) Prints the current replication status of a given node");
124
125
126 System.out.println("47) Bulk delete business");
127 System.out.println("48) Bulk delete services");
128 System.out.println("49) Bulk delete tModels");
129
130 System.out.println("q) quit");
131 System.out.print(username + "@" + currentNode + "# ");
132 input = System.console().readLine();
133 try {
134 processInput(input, currentNode, transport, clerkManager);
135 } catch (Exception ex) {
136 ex.printStackTrace();
137 }
138 } while (!input.equalsIgnoreCase("q"));
139 }
140 private static String authtoken = null;
141 static String password;
142 static String username;
143
144 private static String login(String currentNode, Transport transport) throws Exception {
145 System.out.println("Options:");
146 System.out.println("1) Enter a username/password for auth token");
147 System.out.println("2) Enter a username/password for HTTP based logins");
148 System.out.println("3) Enter a username/password for use stored credentials");
149 System.out.print("Login Method: ");
150 String input = System.console().readLine();
151 if ("1".equalsIgnoreCase(input)) {
152 UDDISecurityPortType security = null;
153 security = transport.getUDDISecurityService();
154 System.out.print(currentNode + "# username: ");
155 username = System.console().readLine();
156 char passwordArray[] = System.console().readPassword(currentNode + "# password: ");
157 GetAuthToken getAuthTokenRoot = new GetAuthToken();
158 getAuthTokenRoot.setUserID(username);
159 password = new String(passwordArray);
160 getAuthTokenRoot.setCred((password));
161 String lauthtoken = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
162 System.out.println("Success!");
163 return lauthtoken;
164 } else if ("2".equalsIgnoreCase(input)) {
165 System.out.println("not implemented yet!");
166
167 } else if ("3".equalsIgnoreCase(input)) {
168 System.out.println("not implemented yet!");
169 } else {
170 System.out.println("Aborted!");
171 }
172 return null;
173
174 }
175
176 private static void processInput(final String input, final String currentNode, final Transport transport, UDDIClient client) throws Exception {
177 if (input == null) {
178 return;
179 }
180 if (input.equals("1")) {
181 authtoken = login(currentNode, transport);
182 } else if (input.equals("2")) {
183 System.out.println("Token info: " + authtoken);
184 } else if (input.equals("3")) {
185 if (authtoken != null) {
186 UDDISecurityPortType security = null;
187 security = transport.getUDDISecurityService();
188 DiscardAuthToken getAuthTokenRoot = new DiscardAuthToken();
189 getAuthTokenRoot.setAuthInfo(authtoken);
190 security.discardAuthToken(getAuthTokenRoot);
191 System.out.println("Success!");
192 }
193 } else if (input.equals("4")) {
194 new SimpleBrowse(transport).printBusinessList(authtoken, null, true);
195 } else if (input.equals("5")) {
196 new SimpleBrowse(transport).printBusinessList(authtoken, null, false);
197 } else if (input.equals("6")) {
198 new SimpleBrowse(transport).printServiceList(authtoken, null, true);
199 } else if (input.equals("7")) {
200 new SimpleBrowse(transport).printServiceList(authtoken, null, false);
201 } else if (input.equals("8")) {
202 new SimpleBrowse(transport).printTModelList(authtoken, null, true);
203 } else if (input.equals("9")) {
204 new SimpleBrowse(transport).printTModelList(authtoken, null, false);
205 } else if (input.equals("10")) {
206 System.out.print("Tip: (use % for wildcard searches)");
207 System.out.print("Name to search for: ");
208 String url = (System.console().readLine());
209 new SimpleBrowse(transport).printBusinessList(authtoken, url, false);
210 } else if (input.equals("11")) {
211 System.out.print("Tip: (use % for wildcard searches)");
212 System.out.print("Name to search for: ");
213 String url = (System.console().readLine());
214 new SimpleBrowse(transport).printServiceList(authtoken, url, false);
215 } else if (input.equals("12")) {
216 System.out.print("Tip: (use % for wildcard searches)");
217 System.out.print("Name to search for: ");
218 String url = (System.console().readLine());
219 new SimpleBrowse(transport).printTModelList(authtoken, url, false);
220 } else if (input.equals("13")) {
221 new SearchByQos().doFindBinding(authtoken, transport);
222 } else if (input.equals("14")) {
223 new SearchByQos().doFindBusiness(authtoken, transport);
224 } else if (input.equals("15")) {
225 new SearchByQos().doFindService(authtoken, transport);
226 } else if (input.equals("16")) {
227 new UddiFindBinding().fire(authtoken);
228 } else if (input.equals("17")) {
229 System.out.print("Service key to parse the endpoints: ");
230 String key = (System.console().readLine());
231 new UddiFindEndpoints().fire(authtoken, key);
232 } else if (input.equals("18")) {
233 System.out.print("Service key: ");
234 String key = (System.console().readLine());
235 new UddiGetServiceDetails().fire(authtoken, key);
236 } else if (input.equals("19")) {
237 new UddiDigitalSignatureSearch().fire(authtoken);
238 } else if (input.equals("20")) {
239 System.out.print("Get FQDN: ");
240 String key = (System.console().readLine());
241 new UddiKeyGenerator().fire(authtoken, key);
242 } else if (input.equals("22")) {
243 System.out.print("Path or URL to WSDL file: ");
244 String url = (System.console().readLine());
245 System.out.print("Business key to attach to: ");
246 String key = (System.console().readLine());
247 new WsdlImport().fire(url, key, authtoken, transport);
248 } else if (input.equals("23")) {
249 System.out.print("Path or URL to WADL file: ");
250 String url = (System.console().readLine());
251 System.out.print("Business key to attach to: ");
252 String key = (System.console().readLine());
253 new WadlImport().fire(url, key, authtoken, transport);
254 } else if (input.equals("24")) {
255 UDDISecurityPortType security = null;
256 security = transport.getUDDISecurityService();
257
258 System.out.print("Transfer from username: ");
259 String uname = (System.console().readLine());
260 char passwordArray[] = System.console().readPassword("password: ");
261 GetAuthToken getAuthTokenRoot = new GetAuthToken();
262 getAuthTokenRoot.setUserID(uname);
263 getAuthTokenRoot.setCred(new String(passwordArray));
264 String authtokenFrom = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
265 System.out.println("Success!");
266
267 System.out.print("Transfer to username: ");
268 String uname2 = (System.console().readLine());
269 char passwordArray2[] = System.console().readPassword("password: ");
270 getAuthTokenRoot = new GetAuthToken();
271 getAuthTokenRoot.setUserID(uname2);
272 getAuthTokenRoot.setCred(new String(passwordArray2));
273 String authtokenFrom2 = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
274 System.out.println("Success!");
275 System.out.print("business/tModel key to transfer: ");
276 String key = (System.console().readLine());
277 new UddiCustodyTransfer().transferBusiness(uname, authtokenFrom, uname2, authtokenFrom2, key);
278 } else if (input.equals("25")) {
279 System.out.print("Business key to sign: ");
280 String key = (System.console().readLine());
281 new UddiDigitalSignatureBusiness().fire(authtoken, key);
282 } else if (input.equals("26")) {
283 System.out.print("Service key to sign: ");
284 String key = (System.console().readLine());
285 new UddiDigitalSignatureService().fire(authtoken, key);
286 } else if (input.equals("27")) {
287 System.out.print("tModel key to sign: ");
288 String key = (System.console().readLine());
289 new UddiDigitalSignatureTmodel().fire(authtoken, key);
290 } else if (input.equals("28")) {
291 UDDISecurityPortType security = null;
292
293 security = transport.getUDDISecurityService();
294
295 System.out.print("1st Business username: ");
296 String uname = (System.console().readLine());
297 char passwordArray[] = System.console().readPassword("password: ");
298 GetAuthToken getAuthTokenRoot = new GetAuthToken();
299 getAuthTokenRoot.setUserID(uname);
300 getAuthTokenRoot.setCred(new String(passwordArray));
301 String authtokenFrom = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
302 System.out.println("Success!");
303
304 System.out.print(uname + "'s business : ");
305 String key = (System.console().readLine());
306
307 System.out.print("2st Business username: ");
308 String uname2 = (System.console().readLine());
309 char passwordArray2[] = System.console().readPassword("password: ");
310 getAuthTokenRoot = new GetAuthToken();
311 getAuthTokenRoot.setUserID(uname2);
312 getAuthTokenRoot.setCred(new String(passwordArray2));
313 String authtokenFrom2 = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
314 System.out.println("Success!");
315
316 System.out.print(uname2 + "'s business : ");
317 String key2 = (System.console().readLine());
318
319 System.out.print("relationship (parent-child, peer-peer,or identity) : ");
320 String relationship = (System.console().readLine());
321 new UddiRelatedBusinesses().fire(key, authtokenFrom, key2, authtokenFrom2, relationship);
322 } else if (input.equals("29")) {
323 new UddiSubscribe(client, currentNode, transport).fire();
324
325 } else if (input.equals("30")) {
326 System.out.print("Subscription key: ");
327 String key = (System.console().readLine());
328 System.out.println("Fetching results for the past 30 days...");
329 new UddiSubscribeValidate(transport).go(authtoken, input);
330 } else if (input.equals("31")) {
331 new UddiSubscriptionManagement(transport).printSubscriptions(authtoken);
332 } else if (input.equals("32")) {
333 System.out.print("Subscription key: ");
334 String key2 = (System.console().readLine());
335 new UddiSubscriptionManagement(transport).deleteSubscription(authtoken, key2);
336 } else if (input.equals("33")) {
337 new UddiSubscriptionManagement(transport).deleteAllSubscriptions(authtoken);
338 } else if (input.equals("34")) {
339 new UddiSubscribeAssertionStatus(transport).fire(currentNode);
340
341 } else if (input.equals("35")) {
342
343 new UddiReplication(client, currentNode).doPing();
344
345 } else if (input.equals("36")) {
346
347 new UddiReplication(client, currentNode).getHighWatermarks();
348
349 } else if (input.equals("37")) {
350
351
352 System.out.print("Change ID to fetch: ");
353 String id = (System.console().readLine());
354
355 System.out.print("Node id of something in the replication graph: ");
356 String src = (System.console().readLine());
357
358 new UddiReplication(client, currentNode).getChangeRecords(Long.parseLong(id), src);
359
360 } else if ("38".equals(input)) {
361 new JuddiAdminService(client, transport).dumpFailedReplicationRecords(authtoken);
362 } else if (input.equals("39")) {
363
364 new JuddiAdminService(client, transport).quickRegisterRemoteCloud(authtoken);
365 } else if (input.equals("40")) {
366
367
368 UDDIClient clerkManager = new UDDIClient();
369 List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
370 System.out.println();
371
372 System.out.println("Locally defined nodes:");
373 for (int i = 0; i < uddiNodeList.size(); i++) {
374 System.out.println("________________________________________________________________________________");
375 System.out.println((i + 1) + ") Node name: " + uddiNodeList.get(i).getName());
376 System.out.println((i + 1) + ") Node description: " + uddiNodeList.get(i).getDescription());
377 System.out.println((i + 1) + ") Transport: " + uddiNodeList.get(i).getProxyTransport());
378 System.out.println((i + 1) + ") jUDDI URL: " + uddiNodeList.get(i).getJuddiApiUrl());
379 }
380 System.out.println("Local Source Node: ");
381 int index = Integer.parseInt(System.console().readLine()) - 1;
382
383 System.out.println("Remote Destination(s):");
384 for (int i = 0; i < uddiNodeList.size(); i++) {
385 System.out.println("________________________________________________________________________________");
386 System.out.println((i + 1) + ") Node name: " + uddiNodeList.get(i).getName());
387 System.out.println((i + 1) + ") Node description: " + uddiNodeList.get(i).getDescription());
388 System.out.println((i + 1) + ") Transport: " + uddiNodeList.get(i).getProxyTransport());
389 System.out.println((i + 1) + ") jUDDI URL: " + uddiNodeList.get(i).getJuddiApiUrl());
390 }
391 System.out.println("Remote Destination Node to publish to: ");
392 int index2 = Integer.parseInt(System.console().readLine()) - 1;
393
394 new JuddiAdminService(client, transport).registerLocalNodeToRemoteNode(authtoken, uddiNodeList.get(index), uddiNodeList.get(index2));
395
396 } else if (input.equals("41")) {
397
398 new JuddiAdminService(client, transport).viewRemoteNodes(authtoken);
399 } else if (input.equals("42")) {
400
401 new JuddiAdminService(client, transport).viewRemoveRemoteNode(authtoken);
402
403 } else if (input.equals("43")) {
404 new JuddiAdminService(client, transport).viewReplicationConfig(authtoken, currentNode);
405 } else if (input.equals("44")) {
406 new JuddiAdminService(client, transport).setReplicationConfig(authtoken);
407 } else if (input.equals("45")) {
408 new JuddiAdminService(client, transport).printStatus(transport, authtoken);
409 } else if (input.equals("47")) {
410 System.out.println("We'll run a search first, then the results will be deleted (after confirmation). Use % as a wild card");
411 System.out.print("Search query: ");
412 String key = (System.console().readLine());
413 FindBusiness fb = new FindBusiness();
414 fb.setFindQualifiers(new FindQualifiers());
415 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
416 fb.getName().add(new Name(key, null));
417 BusinessList findBusiness = transport.getUDDIInquiryService().findBusiness(fb);
418
419 DeleteBusiness db = new DeleteBusiness();
420 db.setAuthInfo(authtoken);
421 for (int i = 0; i < findBusiness.getBusinessInfos().getBusinessInfo().size(); i++) {
422 db.getBusinessKey().add(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey());
423 System.out.println(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey() + " " + findBusiness.getBusinessInfos().getBusinessInfo().get(i).getName().get(0).getValue());
424 }
425 System.out.print("The above businesses will be deleted, are you sure? (y/n) : ");
426 key = (System.console().readLine());
427 if ("y".equalsIgnoreCase(key.trim().toLowerCase())) {
428 transport.getUDDIPublishService().deleteBusiness(db);
429 System.out.println("done.");
430 }else
431 System.out.println("aborted.");
432 }
433 else if (input.equals("48")) {
434 System.out.println("We'll run a search first, then the results will be deleted (after confirmation). Use % as a wild card");
435 System.out.print("Search query: ");
436 String key = (System.console().readLine());
437
438 FindService fb = new FindService();
439 fb.setFindQualifiers(new FindQualifiers());
440 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
441 fb.getName().add(new Name(key, null));
442 ServiceList findBusiness = transport.getUDDIInquiryService().findService(fb);
443
444 DeleteService db = new DeleteService();
445 db.setAuthInfo(authtoken);
446 for (int i = 0; i < findBusiness.getServiceInfos().getServiceInfo().size(); i++) {
447 db.getServiceKey().add(findBusiness.getServiceInfos().getServiceInfo().get(i).getServiceKey());
448 System.out.println(findBusiness.getServiceInfos().getServiceInfo().get(i).getServiceKey() + " " + findBusiness.getServiceInfos().getServiceInfo().get(i).getName().get(0).getValue());
449 }
450 System.out.print("The above services will be deleted, are you sure? (y/n) : ");
451 key = (System.console().readLine());
452 if ("y".equalsIgnoreCase(key.trim().toLowerCase())) {
453 transport.getUDDIPublishService().deleteService(db);
454 System.out.println("done.");
455 }else
456 System.out.println("aborted.");
457 }
458 else if (input.equals("49")) {
459 System.out.println("We'll run a search first, then the results will be deleted (after confirmation). Use % as a wild card");
460 System.out.print("Search query: ");
461 String key = (System.console().readLine());
462 FindTModel fb = new FindTModel();
463 fb.setFindQualifiers(new FindQualifiers());
464 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
465 fb.setName(new Name(key, null));
466 TModelList findBusiness = transport.getUDDIInquiryService().findTModel(fb);
467
468 DeleteTModel db = new DeleteTModel();
469 db.setAuthInfo(authtoken);
470 for (int i = 0; i < findBusiness.getTModelInfos().getTModelInfo().size(); i++) {
471 db.getTModelKey().add(findBusiness.getTModelInfos().getTModelInfo().get(i).getTModelKey());
472 System.out.println(findBusiness.getTModelInfos().getTModelInfo().get(i).getTModelKey() + " " + findBusiness.getTModelInfos().getTModelInfo().get(i).getName().getValue());
473 }
474 System.out.print("The above tModels will be deleted, are you sure? (y/n) : ");
475 key = (System.console().readLine());
476 if ("y".equalsIgnoreCase(key.trim().toLowerCase())) {
477 transport.getUDDIPublishService().deleteTModel(db);
478 System.out.println("done.");
479 }else
480 System.out.println("aborted.");
481 }
482
483 }
484 static boolean running = true;
485 static int createdServices = 0;
486 static int createdBusinesses = 0;
487
488 }