This project has retired. For details please refer to its
Attic page.
JuddiAdminService 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.io.FileInputStream;
19 import java.math.BigInteger;
20 import java.rmi.RemoteException;
21 import java.security.KeyStore;
22 import java.util.List;
23 import javax.net.ssl.KeyManagerFactory;
24 import javax.net.ssl.SSLContext;
25 import javax.xml.bind.JAXB;
26 import javax.xml.ws.BindingProvider;
27 import org.apache.commons.configuration.ConfigurationException;
28 import org.apache.juddi.api_v3.DeleteNode;
29 import org.apache.juddi.api_v3.GetFailedReplicationChangeRecordsMessageRequest;
30 import org.apache.juddi.api_v3.GetFailedReplicationChangeRecordsMessageResponse;
31 import org.apache.juddi.api_v3.Node;
32 import org.apache.juddi.api_v3.NodeDetail;
33 import org.apache.juddi.api_v3.NodeList;
34 import org.apache.juddi.api_v3.SaveNode;
35 import org.apache.juddi.jaxb.PrintJUDDI;
36 import org.apache.juddi.v3.client.UDDIService;
37 import org.apache.juddi.v3.client.config.UDDIClient;
38 import org.apache.juddi.v3.client.config.UDDINode;
39 import org.apache.juddi.v3.client.cryptor.TransportSecurityHelper;
40 import org.apache.juddi.v3.client.transport.Transport;
41 import org.apache.juddi.v3.client.transport.TransportException;
42 import org.apache.juddi.v3_service.JUDDIApiPortType;
43 import org.uddi.api_v3.Contact;
44 import org.uddi.api_v3.Description;
45 import org.uddi.api_v3.DispositionReport;
46 import org.uddi.api_v3.Email;
47 import org.uddi.api_v3.GetAuthToken;
48 import org.uddi.api_v3.PersonName;
49 import org.uddi.api_v3.Phone;
50 import org.uddi.repl_v3.ChangeRecordIDType;
51 import org.uddi.repl_v3.CommunicationGraph;
52 import org.uddi.repl_v3.CommunicationGraph.Edge;
53 import org.uddi.repl_v3.DoPing;
54 import org.uddi.repl_v3.Operator;
55 import org.uddi.repl_v3.OperatorStatusType;
56 import org.uddi.repl_v3.ReplicationConfiguration;
57 import org.uddi.v3_service.UDDIReplicationPortType;
58 import org.uddi.v3_service.UDDISecurityPortType;
59
60
61
62
63
64 public class JuddiAdminService {
65
66 private JUDDIApiPortType juddi = null;
67 private UDDIClient clerkManager = null;
68
69 public JuddiAdminService(UDDIClient client, Transport transport) {
70 try {
71 clerkManager = client;
72 if (transport != null)
73 {
74 transport = clerkManager.getTransport();
75 juddi = transport.getJUDDIApiService();
76 }
77
78
79 } catch (Exception e) {
80 e.printStackTrace();
81 }
82 }
83
84 static Node getCloudInstance() {
85 Node n = new Node();
86 n.setClientName("juddicloud");
87 n.setName("juddicloud");
88 n.setCustodyTransferUrl("http://uddi-jbossoverlord.rhcloud.com/services/custody-transfer");
89 n.setDescription("juddicloud");
90 n.setProxyTransport("org.apache.juddi.v3.client.transport.JAXWSTransport");
91 n.setInquiryUrl("http://uddi-jbossoverlord.rhcloud.com/services/inquiry");
92 n.setJuddiApiUrl("http://uddi-jbossoverlord.rhcloud.com/services/juddi-api");
93 n.setPublishUrl("http://uddi-jbossoverlord.rhcloud.com/services/publish");
94 n.setSecurityUrl("http://uddi-jbossoverlord.rhcloud.com/services/security");
95 n.setSubscriptionListenerUrl("http://uddi-jbossoverlord.rhcloud.com/services/subscription-listener");
96 n.setSubscriptionUrl("http://uddi-jbossoverlord.rhcloud.com/services/subscription");
97 n.setReplicationUrl("uddi-jbossoverlord.rhcloud.com/services/replication");
98 return n;
99 }
100
101 JuddiAdminService(UDDIClient client, Transport transport, String currentNode) {
102 curentnode = currentNode;
103 try {
104 clerkManager = client;
105 if (transport == null)
106
107
108
109
110 {
111 transport = clerkManager.getTransport();
112 }
113
114
115
116 juddi = transport.getJUDDIApiService();
117 } catch (Exception e) {
118 e.printStackTrace();
119 }
120 }
121
122 String curentnode = "default";
123
124
125
126
127
128
129 public void quickRegisterRemoteCloud(String token) {
130 try {
131
132
133 SaveNode node = new SaveNode();
134 node.setAuthInfo(token);
135
136 node.getNode().add(getCloudInstance());
137
138 PrintJUDDI<SaveNode> p = new PrintJUDDI<SaveNode>();
139 System.out.println("Before sending");
140 System.out.println(p.print(node));
141 juddi.saveNode(node);
142 System.out.println("Saved");
143
144 } catch (Exception e) {
145 e.printStackTrace();
146 }
147 }
148
149 void setupReplication() {
150 throw new UnsupportedOperationException("Not supported yet.");
151 }
152
153 void viewRemoteNodes(String authtoken) throws ConfigurationException, TransportException, RemoteException {
154
155 List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
156 System.out.println();
157 System.out.println("Select a node (from *this config)");
158 for (int i = 0; i < uddiNodeList.size(); i++) {
159 System.out.print(i + 1);
160 System.out.println(") " + uddiNodeList.get(i).getName() + uddiNodeList.get(i).getDescription());
161 }
162 System.out.println("Node #: ");
163 int index = Integer.parseInt(System.console().readLine()) - 1;
164 String node = uddiNodeList.get(index).getName();
165 Transport transport = clerkManager.getTransport(node);
166
167 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
168
169 NodeList allNodes = juddiApiService.getAllNodes(authtoken);
170 if (allNodes == null || allNodes.getNode().isEmpty()) {
171 System.out.println("No nodes registered!");
172 } else {
173 for (int i = 0; i < allNodes.getNode().size(); i++) {
174 System.out.println("_______________________________________________________________________________");
175 System.out.println("Name :" + allNodes.getNode().get(i).getName());
176 System.out.println("Inquiry :" + allNodes.getNode().get(i).getInquiryUrl());
177 System.out.println("Publish :" + allNodes.getNode().get(i).getPublishUrl());
178 System.out.println("Securit :" + allNodes.getNode().get(i).getSecurityUrl());
179 System.out.println("Replication :" + allNodes.getNode().get(i).getReplicationUrl());
180 System.out.println("Subscription :" + allNodes.getNode().get(i).getSubscriptionUrl());
181 System.out.println("Custody Xfer :" + allNodes.getNode().get(i).getCustodyTransferUrl());
182
183 }
184 }
185
186 }
187
188 void quickRegisterLocalCloud() throws ConfigurationException {
189 UDDINode node = new UDDINode(getCloudInstance());
190 clerkManager.getClientConfig().addUDDINode(node);
191 clerkManager.getClientConfig().saveConfig();
192 System.out.println();
193 System.out.println("Added and saved.");
194 }
195
196 void registerLocalNodeToRemoteNode(String authtoken, Node cfg, Node publishTo) throws Exception {
197
198 Transport transport = clerkManager.getTransport(publishTo.getName());
199
200 UDDISecurityPortType security2 = transport.getUDDISecurityService();
201 System.out.print("username: ");
202 String uname = System.console().readLine();
203 char passwordArray[] = System.console().readPassword("password: ");
204 GetAuthToken getAuthTokenRoot = new GetAuthToken();
205 getAuthTokenRoot.setUserID(uname);
206 getAuthTokenRoot.setCred(new String(passwordArray));
207 authtoken = security2.getAuthToken(getAuthTokenRoot).getAuthInfo();
208 System.out.println("Success!");
209
210 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
211 SaveNode sn = new SaveNode();
212 sn.setAuthInfo(authtoken);
213 sn.getNode().add(cfg);
214 NodeDetail saveNode = juddiApiService.saveNode(sn);
215 JAXB.marshal(saveNode, System.out);
216 System.out.println("Success.");
217
218 }
219
220 void viewReplicationConfig(String authtoken, String node) throws Exception {
221
222 Transport transport = clerkManager.getTransport(node);
223
224 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
225 ReplicationConfiguration replicationNodes = juddiApiService.getReplicationNodes(authtoken);
226
227 System.out.println("Current Config:");
228 JAXB.marshal(replicationNodes, System.out);
229
230 }
231
232 void setReplicationConfig(String authtoken) throws Exception {
233 List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
234 System.out.println();
235 System.out.println("Select a node (from *this config)");
236 for (int i = 0; i < uddiNodeList.size(); i++) {
237 System.out.print(i + 1);
238 System.out.println(") " + uddiNodeList.get(i).getName() + uddiNodeList.get(i).getDescription());
239 }
240 System.out.println("Node #: ");
241 int index = Integer.parseInt(System.console().readLine()) - 1;
242 String node = uddiNodeList.get(index).getName();
243 Transport transport = clerkManager.getTransport(node);
244
245 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
246 System.out.println("fetching...");
247
248 ReplicationConfiguration replicationNodes = null;
249 try {
250 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
251 } catch (Exception ex) {
252 System.out.println("Error getting replication config");
253 ex.printStackTrace();
254 replicationNodes = new ReplicationConfiguration();
255
256 }
257 String input = "";
258 while (!"d".equalsIgnoreCase(input) && !"q".equalsIgnoreCase(input)) {
259 System.out.println("Current Config:");
260 JAXB.marshal(replicationNodes, System.out);
261 System.out.println("1) Remove a replication node");
262 System.out.println("2) Add a replication node");
263 System.out.println("3) Remove an Edge");
264 System.out.println("4) Add an Edge");
265 System.out.println("5) Set Registry Contact");
266 System.out.println("6) Add Operator info");
267 System.out.println("7) Remove Operator info");
268 System.out.println("d) Done, save changes");
269 System.out.println("q) Quit and abandon changes");
270
271 input = System.console().readLine();
272 if (input.equalsIgnoreCase("1")) {
273 menu_RemoveReplicationNode(replicationNodes);
274 } else if (input.equalsIgnoreCase("2")) {
275 menu_AddReplicationNode(replicationNodes, juddiApiService, authtoken);
276 } else if (input.equalsIgnoreCase("d")) {
277 if (replicationNodes.getCommunicationGraph() == null) {
278 replicationNodes.setCommunicationGraph(new CommunicationGraph());
279 }
280 if (replicationNodes.getRegistryContact() == null) {
281 replicationNodes.setRegistryContact(new ReplicationConfiguration.RegistryContact());
282 }
283 if (replicationNodes.getRegistryContact().getContact() == null) {
284 replicationNodes.getRegistryContact().setContact(new Contact());
285 replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null));
286 }
287
288 replicationNodes.setSerialNumber(0L);
289 replicationNodes.setTimeOfConfigurationUpdate("");
290 replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE);
291 replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE);
292
293 JAXB.marshal(replicationNodes, System.out);
294 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
295 }
296
297 }
298 if (input.equalsIgnoreCase("d")) {
299
300 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
301 System.out.println("Saved!, dumping config from the server");
302 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
303 JAXB.marshal(replicationNodes, System.out);
304
305 } else {
306
307 System.out.println("aborting!");
308 }
309
310 }
311
312 void viewRemoveRemoteNode(String authtoken) throws Exception {
313 List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
314 System.out.println();
315 System.out.println("Select a node (from *this config)");
316 for (int i = 0; i < uddiNodeList.size(); i++) {
317 System.out.print(i + 1);
318 System.out.println(") " + uddiNodeList.get(i).getName() + uddiNodeList.get(i).getDescription());
319 }
320 System.out.println("Node #: ");
321 int index = Integer.parseInt(System.console().readLine()) - 1;
322 String node = uddiNodeList.get(index).getName();
323 Transport transport = clerkManager.getTransport(node);
324
325 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
326
327 NodeList allNodes = juddiApiService.getAllNodes(authtoken);
328 if (allNodes == null || allNodes.getNode().isEmpty()) {
329 System.out.println("No nodes registered!");
330 } else {
331 for (int i = 0; i < allNodes.getNode().size(); i++) {
332 System.out.println("_______________________________________________________________________________");
333 System.out.println("(" + i + ") Name :" + allNodes.getNode().get(i).getName());
334 System.out.println("(" + i + ") Inquiry :" + allNodes.getNode().get(i).getInquiryUrl());
335
336 }
337
338 System.out.println("Node to remove from : ");
339 int nodenum = Integer.parseInt(System.console().readLine());
340 juddiApiService.deleteNode(new DeleteNode(authtoken, allNodes.getNode().get(nodenum).getName()));
341
342 }
343 }
344
345 private void menu_RemoveReplicationNode(ReplicationConfiguration replicationNodes) {
346 if (replicationNodes.getCommunicationGraph() == null) {
347 replicationNodes.setCommunicationGraph(new CommunicationGraph());
348 }
349 for (int i = 0; i < replicationNodes.getCommunicationGraph().getNode().size(); i++) {
350 System.out.println((i + 1) + ") " + replicationNodes.getCommunicationGraph().getNode().get(i));
351 }
352 System.out.println("Node #: ");
353 int index = Integer.parseInt(System.console().readLine()) - 1;
354 replicationNodes.getCommunicationGraph().getNode().remove(index);
355
356 }
357
358 private void menu_AddReplicationNode(ReplicationConfiguration replicationNodes, JUDDIApiPortType juddiApiService, String authtoken) throws Exception {
359
360 if (replicationNodes.getCommunicationGraph() == null) {
361 replicationNodes.setCommunicationGraph(new CommunicationGraph());
362 }
363
364 Operator op = new Operator();
365 System.out.println("The Operator Node id should be the UDDI Node ID of the new node to replicate with. It should also match the root business key in"
366 + " the new registry.");
367 System.out.print("Operator Node id: ");
368 op.setOperatorNodeID(System.console().readLine().trim());
369
370 System.out.print("Replication URL: ");
371 op.setSoapReplicationURL(System.console().readLine().trim());
372 op.setOperatorStatus(OperatorStatusType.NEW);
373 System.out.println("The replication node requires at least one point of contact");
374 System.out.print("Number of contacts: ");
375 int index = Integer.parseInt(System.console().readLine());
376 for (int i = 0; i < index; i++) {
377 System.out.println("_______________________");
378 System.out.println("Info for contact # " + (i + 1));
379 op.getContact().add(getContactInfo());
380 }
381 System.out.println("_______________________");
382 System.out.println("Current Operator:");
383 System.out.println("_______________________");
384 JAXB.marshal(op, System.out);
385
386 System.out.print("Confirm adding? (y/n) :");
387 if (System.console().readLine().trim().equalsIgnoreCase("y")) {
388 replicationNodes.getOperator().add(op);
389 replicationNodes.getCommunicationGraph().getNode().add(op.getOperatorNodeID());
390
391 }
392 }
393
394 private Contact getContactInfo() {
395 Contact c = new Contact();
396 System.out.print("Use Type (i.e. primary): ");
397 c.setUseType(System.console().readLine().trim());
398 if (c.getUseType().trim().equalsIgnoreCase("")) {
399 c.setUseType("primary");
400 }
401
402 c.getPersonName().add(getPersonName());
403
404 while (true) {
405 System.out.println("Thus far:");
406 JAXB.marshal(c, System.out);
407 System.out.println("Options:");
408 System.out.println("\t1) Add PersonName");
409 System.out.println("\t2) Add Email address");
410 System.out.println("\t3) Add Phone number");
411 System.out.println("\t4) Add Description");
412 System.out.println("\t<enter> Finish and return");
413
414 System.out.print("> ");
415 String input = System.console().readLine();
416 if (input.trim().equalsIgnoreCase("")) {
417 break;
418 } else if (input.trim().equalsIgnoreCase("1")) {
419 c.getPersonName().add(getPersonName());
420 } else if (input.trim().equalsIgnoreCase("2")) {
421 c.getEmail().add(getEmail());
422 } else if (input.trim().equalsIgnoreCase("3")) {
423 c.getPhone().add(getPhoneNumber());
424 } else if (input.trim().equalsIgnoreCase("4")) {
425 c.getDescription().add(getDescription());
426 }
427 }
428 return c;
429 }
430
431 private PersonName getPersonName() {
432 PersonName pn = new PersonName();
433 System.out.print("Name: ");
434 pn.setValue(System.console().readLine().trim());
435 System.out.print("Language (en): ");
436 pn.setLang(System.console().readLine().trim());
437 if (pn.getLang().equalsIgnoreCase("")) {
438 pn.setLang("en");
439 }
440
441 return pn;
442 }
443
444 private Email getEmail() {
445 Email pn = new Email();
446 System.out.print("Email address Value: ");
447
448 pn.setValue(System.console().readLine().trim());
449 System.out.print("Use type (i.e. primary): ");
450 pn.setUseType(System.console().readLine().trim());
451 return pn;
452 }
453
454 private Phone getPhoneNumber() {
455
456 Phone pn = new Phone();
457 System.out.print("Phone Value: ");
458
459 pn.setValue(System.console().readLine().trim());
460 System.out.print("Use type (i.e. primary): ");
461 pn.setUseType(System.console().readLine().trim());
462 return pn;
463 }
464
465 private Description getDescription() {
466 Description pn = new Description();
467 System.out.print("Value: ");
468
469 pn.setValue(System.console().readLine().trim());
470 System.out.print("Language (en): ");
471 pn.setLang(System.console().readLine().trim());
472 if (pn.getLang().equalsIgnoreCase("")) {
473 pn.setLang("en");
474 }
475 return pn;
476 }
477
478 void autoMagic123() throws Exception {
479
480 Transport transport = clerkManager.getTransport("default");
481 String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
482
483 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
484 System.out.println("fetching...");
485
486 ReplicationConfiguration replicationNodes = null;
487 try {
488 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
489 } catch (Exception ex) {
490 System.out.println("Error getting replication config");
491 ex.printStackTrace();
492 replicationNodes = new ReplicationConfiguration();
493
494 }
495 if (replicationNodes.getCommunicationGraph() == null) {
496 replicationNodes.setCommunicationGraph(new CommunicationGraph());
497 }
498 Operator op = new Operator();
499 op.setOperatorNodeID("uddi:juddi.apache.org:node1");
500 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("default").getReplicationUrl());
501 op.setOperatorStatus(OperatorStatusType.NORMAL);
502 op.getContact().add(new Contact());
503 op.getContact().get(0).getPersonName().add(new PersonName("bob", "en"));
504 op.getContact().get(0).setUseType("admin");
505 replicationNodes.getOperator().clear();
506 replicationNodes.getOperator().add(op);
507
508 op = new Operator();
509 op.setOperatorNodeID("uddi:another.juddi.apache.org:node2");
510 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:another.juddi.apache.org:node2").getReplicationUrl());
511 op.setOperatorStatus(OperatorStatusType.NORMAL);
512 op.getContact().add(new Contact());
513 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
514 op.getContact().get(0).setUseType("admin");
515 replicationNodes.getOperator().add(op);
516 op = new Operator();
517
518 op.setOperatorNodeID("uddi:yet.another.juddi.apache.org:node3");
519 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:yet.another.juddi.apache.org:node3").getReplicationUrl());
520 op.setOperatorStatus(OperatorStatusType.NORMAL);
521 op.getContact().add(new Contact());
522 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
523 op.getContact().get(0).setUseType("admin");
524 replicationNodes.getOperator().add(op);
525
526 replicationNodes.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2");
527 replicationNodes.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1");
528 replicationNodes.getCommunicationGraph().getNode().add("uddi:yet.another.juddi.apache.org:node3");
529 replicationNodes.setSerialNumber(0L);
530 replicationNodes.setTimeOfConfigurationUpdate("");
531 replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE);
532 replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE);
533
534 if (replicationNodes.getRegistryContact().getContact() == null) {
535 replicationNodes.getRegistryContact().setContact(new Contact());
536 replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null));
537 }
538
539 JAXB.marshal(replicationNodes, System.out);
540 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
541
542 transport = clerkManager.getTransport("uddi:another.juddi.apache.org:node2");
543 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
544
545 juddiApiService = transport.getJUDDIApiService();
546 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
547
548 transport = clerkManager.getTransport("uddi:yet.another.juddi.apache.org:node3");
549 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
550
551 juddiApiService = transport.getJUDDIApiService();
552 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
553
554 }
555
556 void autoMagicDirected() throws Exception {
557
558 Transport transport = clerkManager.getTransport("default");
559 String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
560
561 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
562 System.out.println("fetching...");
563
564 ReplicationConfiguration replicationNodes = null;
565 try {
566 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
567 } catch (Exception ex) {
568 System.out.println("Error getting replication config");
569 ex.printStackTrace();
570 replicationNodes = new ReplicationConfiguration();
571
572 }
573 if (replicationNodes.getCommunicationGraph() == null) {
574 replicationNodes.setCommunicationGraph(new CommunicationGraph());
575 }
576 Operator op = new Operator();
577 op.setOperatorNodeID("uddi:juddi.apache.org:node1");
578 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("default").getReplicationUrl());
579 op.setOperatorStatus(OperatorStatusType.NORMAL);
580 op.getContact().add(new Contact());
581 op.getContact().get(0).getPersonName().add(new PersonName("bob", "en"));
582 op.getContact().get(0).setUseType("admin");
583 replicationNodes.getOperator().clear();
584 replicationNodes.getOperator().add(op);
585
586 op = new Operator();
587 op.setOperatorNodeID("uddi:another.juddi.apache.org:node2");
588 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:another.juddi.apache.org:node2").getReplicationUrl());
589 op.setOperatorStatus(OperatorStatusType.NORMAL);
590 op.getContact().add(new Contact());
591 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
592 op.getContact().get(0).setUseType("admin");
593 replicationNodes.getOperator().add(op);
594 op = new Operator();
595
596 op.setOperatorNodeID("uddi:yet.another.juddi.apache.org:node3");
597 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:yet.another.juddi.apache.org:node3").getReplicationUrl());
598 op.setOperatorStatus(OperatorStatusType.NORMAL);
599 op.getContact().add(new Contact());
600 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
601 op.getContact().get(0).setUseType("admin");
602 replicationNodes.getOperator().add(op);
603 replicationNodes.getCommunicationGraph().getNode().clear();
604 replicationNodes.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2");
605 replicationNodes.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1");
606 replicationNodes.getCommunicationGraph().getNode().add("uddi:yet.another.juddi.apache.org:node3");
607 replicationNodes.getCommunicationGraph().getEdge().clear();
608 Edge e = new CommunicationGraph.Edge();
609 e.setMessageSender("uddi:juddi.apache.org:node1");
610 e.setMessageReceiver("uddi:another.juddi.apache.org:node2");
611 replicationNodes.getCommunicationGraph().getEdge().add(e);
612
613 e = new CommunicationGraph.Edge();
614 e.setMessageSender("uddi:another.juddi.apache.org:node2");
615 e.setMessageReceiver("uddi:yet.another.juddi.apache.org:node3");
616 replicationNodes.getCommunicationGraph().getEdge().add(e);
617
618 e = new CommunicationGraph.Edge();
619 e.setMessageSender("uddi:yet.another.juddi.apache.org:node3");
620 e.setMessageReceiver("uddi:juddi.apache.org:node1");
621 replicationNodes.getCommunicationGraph().getEdge().add(e);
622
623 replicationNodes.setSerialNumber(0L);
624 replicationNodes.setTimeOfConfigurationUpdate("");
625 replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE);
626 replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE);
627
628 if (replicationNodes.getRegistryContact().getContact() == null) {
629 replicationNodes.getRegistryContact().setContact(new Contact());
630 replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null));
631 }
632
633 JAXB.marshal(replicationNodes, System.out);
634
635 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
636 System.out.println("Saved to node1");
637 testEquals(replicationNodes, juddiApiService.getReplicationNodes(authtoken));
638
639 transport = clerkManager.getTransport("uddi:another.juddi.apache.org:node2");
640 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
641 juddiApiService = transport.getJUDDIApiService();
642 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
643 System.out.println("Saved to node2");
644 testEquals(replicationNodes, juddiApiService.getReplicationNodes(authtoken));
645
646 transport = clerkManager.getTransport("uddi:yet.another.juddi.apache.org:node3");
647 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
648 juddiApiService = transport.getJUDDIApiService();
649 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
650 System.out.println("Saved to node3");
651 testEquals(replicationNodes, juddiApiService.getReplicationNodes(authtoken));
652
653 }
654
655
656
657
658
659
660
661 void autoMagic() throws Exception {
662
663 Transport transport = clerkManager.getTransport("default");
664
665 String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
666
667 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
668 System.out.println("fetching...");
669
670 ReplicationConfiguration replicationNodes = null;
671 try {
672 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
673 } catch (Exception ex) {
674 System.out.println("Error getting replication config");
675 ex.printStackTrace();
676 replicationNodes = new ReplicationConfiguration();
677
678 }
679
680 replicationNodes.setCommunicationGraph(new CommunicationGraph());
681
682 Operator op = new Operator();
683 op.setOperatorNodeID("uddi:juddi.apache.org:node1");
684 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("default").getReplicationUrl());
685 op.setOperatorStatus(OperatorStatusType.NORMAL);
686 op.getContact().add(new Contact());
687 op.getContact().get(0).getPersonName().add(new PersonName("bob", "en"));
688 op.getContact().get(0).setUseType("admin");
689 replicationNodes.getOperator().clear();
690 replicationNodes.getOperator().add(op);
691
692 op = new Operator();
693 op.setOperatorNodeID("uddi:another.juddi.apache.org:node2");
694 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:another.juddi.apache.org:node2").getReplicationUrl());
695 op.setOperatorStatus(OperatorStatusType.NORMAL);
696 op.getContact().add(new Contact());
697 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
698 op.getContact().get(0).setUseType("admin");
699 replicationNodes.getOperator().add(op);
700 replicationNodes.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2");
701 replicationNodes.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1");
702 replicationNodes.setSerialNumber(0L);
703 replicationNodes.setTimeOfConfigurationUpdate("");
704 replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE);
705 replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE);
706
707 if (replicationNodes.getRegistryContact().getContact() == null) {
708 replicationNodes.getRegistryContact().setContact(new Contact());
709 replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null));
710 }
711
712 JAXB.marshal(replicationNodes, System.out);
713 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
714
715
716 transport = clerkManager.getTransport("uddi:another.juddi.apache.org:node2");
717 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
718
719 juddiApiService = transport.getJUDDIApiService();
720 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
721
722 }
723
724
725
726
727
728
729 void autoMagic3() throws Exception {
730
731 Transport transport = clerkManager.getTransport("default");
732
733 String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
734
735 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
736 System.out.println("fetching...");
737
738 ReplicationConfiguration replicationNodes = null;
739 try {
740 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
741 } catch (Exception ex) {
742 System.out.println("Error getting replication config");
743 ex.printStackTrace();
744 replicationNodes = new ReplicationConfiguration();
745
746 }
747 if (replicationNodes.getCommunicationGraph() == null) {
748 replicationNodes.setCommunicationGraph(new CommunicationGraph());
749 }
750 Operator op = new Operator();
751 op.setOperatorNodeID("uddi:juddi.apache.org:node1");
752 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("default").getReplicationUrl());
753 op.setOperatorStatus(OperatorStatusType.NORMAL);
754 op.getContact().add(new Contact());
755 op.getContact().get(0).getPersonName().add(new PersonName("bob", "en"));
756 op.getContact().get(0).setUseType("admin");
757 replicationNodes.getOperator().clear();
758 replicationNodes.getOperator().add(op);
759
760 op = new Operator();
761 op.setOperatorNodeID("uddi:another.juddi.apache.org:node2");
762 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:another.juddi.apache.org:node2").getReplicationUrl());
763 op.setOperatorStatus(OperatorStatusType.NORMAL);
764 op.getContact().add(new Contact());
765 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
766 op.getContact().get(0).setUseType("admin");
767 replicationNodes.getOperator().add(op);
768
769 op = new Operator();
770 op.setOperatorNodeID("uddi:yet.another.juddi.apache.org:node3");
771 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:yet.another.juddi.apache.org:node3").getReplicationUrl());
772 op.setOperatorStatus(OperatorStatusType.NORMAL);
773 op.getContact().add(new Contact());
774 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
775 op.getContact().get(0).setUseType("admin");
776 replicationNodes.getOperator().add(op);
777
778 replicationNodes.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2");
779 replicationNodes.getCommunicationGraph().getNode().add("uddi:yet.another.juddi.apache.org:node3");
780 replicationNodes.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1");
781 replicationNodes.setSerialNumber(0L);
782 replicationNodes.setTimeOfConfigurationUpdate("");
783 replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE);
784 replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE);
785
786 if (replicationNodes.getRegistryContact().getContact() == null) {
787 replicationNodes.getRegistryContact().setContact(new Contact());
788 replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null));
789 }
790
791 JAXB.marshal(replicationNodes, System.out);
792 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
793
794
795 transport = clerkManager.getTransport("uddi:another.juddi.apache.org:node2");
796 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
797
798 juddiApiService = transport.getJUDDIApiService();
799 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
800
801
802 transport = clerkManager.getTransport("uddi:yet.another.juddi.apache.org:node3");
803 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
804
805 juddiApiService = transport.getJUDDIApiService();
806 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
807
808 }
809
810
811
812
813
814
815
816
817 void printStatus(Transport transport, String authtoken) throws Exception {
818
819 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
820 System.out.println("fetching...");
821
822 ReplicationConfiguration replicationNodes = null;
823 try {
824 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
825 } catch (Exception ex) {
826 System.out.println("Error getting replication config");
827 ex.printStackTrace();
828 replicationNodes = new ReplicationConfiguration();
829
830 }
831 UDDIReplicationPortType uddiReplicationPort = new UDDIService().getUDDIReplicationPort();
832
833 for (Operator o : replicationNodes.getOperator()) {
834 System.out.println("*******************\n\rstats for node " + o.getOperatorNodeID());
835 ((BindingProvider) uddiReplicationPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, o.getSoapReplicationURL());
836
837 List<ChangeRecordIDType> highWaterMarks = uddiReplicationPort.getHighWaterMarks();
838 for (ChangeRecordIDType cr : highWaterMarks) {
839 JAXB.marshal(cr, System.out);
840 }
841 }
842 }
843
844 void printStatus() throws Exception {
845
846
847 Transport transport = clerkManager.getTransport("default");
848 String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
849
850 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
851 System.out.println("fetching...");
852
853 ReplicationConfiguration replicationNodes = null;
854 try {
855 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
856 } catch (Exception ex) {
857 System.out.println("Error getting replication config");
858 ex.printStackTrace();
859 replicationNodes = new ReplicationConfiguration();
860
861 }
862 UDDIReplicationPortType uddiReplicationPort = new UDDIService().getUDDIReplicationPort();
863
864 for (Operator o : replicationNodes.getOperator()) {
865 System.out.println("*******************\n\rstats for node " + o.getOperatorNodeID());
866 ((BindingProvider) uddiReplicationPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, o.getSoapReplicationURL());
867
868 List<ChangeRecordIDType> highWaterMarks = uddiReplicationPort.getHighWaterMarks();
869 for (ChangeRecordIDType cr : highWaterMarks) {
870 JAXB.marshal(cr, System.out);
871 }
872 }
873
874 }
875
876 private void testEquals(ReplicationConfiguration setter, ReplicationConfiguration getter) {
877 if (getter == null) {
878 l("null getter");
879 return;
880 }
881 if (setter == null) {
882 l("null setter");
883 return;
884 }
885 if (getter.getOperator().size() != setter.getOperator().size()) {
886 l("operator size mismatch");
887 return;
888 }
889 if (getter.getCommunicationGraph().getNode().size() != setter.getCommunicationGraph().getNode().size()) {
890 l("comm/node size mismatch");
891 return;
892 }
893 if (getter.getCommunicationGraph().getEdge().size() != setter.getCommunicationGraph().getEdge().size()) {
894 l("comm/node size mismatch");
895 return;
896 }
897
898 }
899
900 private void l(String msg) {
901 System.out.println(msg);
902 }
903
904 void dumpFailedReplicationRecords(String authtoken) throws Exception {
905 GetFailedReplicationChangeRecordsMessageRequest req = new GetFailedReplicationChangeRecordsMessageRequest();
906 req.setAuthInfo(authtoken);
907 req.setMaxRecords(20);
908 req.setOffset(0);
909 GetFailedReplicationChangeRecordsMessageResponse failedReplicationChangeRecords = juddi.getFailedReplicationChangeRecords(req);
910 while (failedReplicationChangeRecords != null
911 && failedReplicationChangeRecords.getChangeRecords() != null
912 && !failedReplicationChangeRecords.getChangeRecords().getChangeRecord().isEmpty()) {
913 for (int i = 0; i < failedReplicationChangeRecords.getChangeRecords().getChangeRecord().size(); i++) {
914 JAXB.marshal(failedReplicationChangeRecords.getChangeRecords().getChangeRecord().get(i), System.out);
915 }
916 req.setOffset(req.getOffset() + failedReplicationChangeRecords.getChangeRecords().getChangeRecord().size());
917 failedReplicationChangeRecords = juddi.getFailedReplicationChangeRecords(req);
918 }
919 }
920
921 void printStatusSingleNode(Transport transport, String authtoken) throws Exception {
922 String replicationUrl = clerkManager.getClientConfig().getUDDINode(curentnode).getReplicationUrl();
923
924 SSLContext sc = SSLContext.getInstance("SSLv3");
925
926 KeyManagerFactory kmf
927 = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
928
929 KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
930 FileInputStream fis = null;
931 try {
932 fis = new FileInputStream(System.getProperty("javax.net.ssl.keyStore"));
933 ks.load(fis, System.getProperty("javax.net.ssl.keyStorePassword").toCharArray());
934 } catch (Exception ex) {
935 ex.printStackTrace();
936 } finally {
937 if (fis != null) {
938 fis.close();
939 }
940 }
941 kmf.init(ks, System.getProperty("javax.net.ssl.keyStorePassword").toCharArray());
942
943 sc.init(kmf.getKeyManagers(), null, null);
944
945 UDDIReplicationPortType uddiReplicationPort = new UDDIService().getUDDIReplicationPort();
946 ((BindingProvider) uddiReplicationPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, replicationUrl);
947 ((BindingProvider) uddiReplicationPort).getRequestContext()
948 .put(
949 "com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory",
950 sc.getSocketFactory());
951
952
953
954
955
956 String doPing = uddiReplicationPort.doPing(new DoPing());
957 System.out.println(doPing + ".., success");
958
959 }
960
961 void autoMagicDirectedSSL() throws Exception {
962
963 Transport transport = clerkManager.getTransport("default");
964 String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
965
966 JUDDIApiPortType juddiApiService = transport.getJUDDIApiService();
967 System.out.println("fetching...");
968
969 ReplicationConfiguration replicationNodes = null;
970 try {
971 replicationNodes = juddiApiService.getReplicationNodes(authtoken);
972 } catch (Exception ex) {
973 System.out.println("Error getting replication config");
974 ex.printStackTrace();
975 replicationNodes = new ReplicationConfiguration();
976
977 }
978
979 replicationNodes.setCommunicationGraph(new CommunicationGraph());
980
981 Operator op = new Operator();
982 op.setOperatorNodeID("uddi:juddi.apache.org:node1");
983 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("default").getReplicationUrl());
984 op.setOperatorStatus(OperatorStatusType.NORMAL);
985 op.getContact().add(new Contact());
986 op.getContact().get(0).getPersonName().add(new PersonName("bob", "en"));
987 op.getContact().get(0).setUseType("admin");
988 replicationNodes.getOperator().clear();
989 replicationNodes.getOperator().add(op);
990
991 op = new Operator();
992 op.setOperatorNodeID("uddi:another.juddi.apache.org:node2");
993 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:another.juddi.apache.org:node2").getReplicationUrl());
994 op.setOperatorStatus(OperatorStatusType.NORMAL);
995 op.getContact().add(new Contact());
996 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
997 op.getContact().get(0).setUseType("admin");
998 replicationNodes.getOperator().add(op);
999 op = new Operator();
1000
1001 op.setOperatorNodeID("uddi:yet.another.juddi.apache.org:node3");
1002 op.setSoapReplicationURL(clerkManager.getClientConfig().getUDDINode("uddi:yet.another.juddi.apache.org:node3").getReplicationUrl());
1003 op.setOperatorStatus(OperatorStatusType.NORMAL);
1004 op.getContact().add(new Contact());
1005 op.getContact().get(0).getPersonName().add(new PersonName("mary", "en"));
1006 op.getContact().get(0).setUseType("admin");
1007 replicationNodes.getOperator().add(op);
1008 replicationNodes.getCommunicationGraph().getNode().clear();
1009 replicationNodes.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2");
1010 replicationNodes.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1");
1011 replicationNodes.getCommunicationGraph().getNode().add("uddi:yet.another.juddi.apache.org:node3");
1012 replicationNodes.getCommunicationGraph().getEdge().clear();
1013 Edge e = new CommunicationGraph.Edge();
1014 e.setMessageSender("uddi:juddi.apache.org:node1");
1015 e.setMessageReceiver("uddi:another.juddi.apache.org:node2");
1016 replicationNodes.getCommunicationGraph().getEdge().add(e);
1017
1018 e = new CommunicationGraph.Edge();
1019 e.setMessageSender("uddi:another.juddi.apache.org:node2");
1020 e.setMessageReceiver("uddi:yet.another.juddi.apache.org:node3");
1021 replicationNodes.getCommunicationGraph().getEdge().add(e);
1022
1023 e = new CommunicationGraph.Edge();
1024 e.setMessageSender("uddi:yet.another.juddi.apache.org:node3");
1025 e.setMessageReceiver("uddi:juddi.apache.org:node1");
1026 replicationNodes.getCommunicationGraph().getEdge().add(e);
1027
1028 replicationNodes.setSerialNumber(0L);
1029 replicationNodes.setTimeOfConfigurationUpdate("");
1030 replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE);
1031 replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE);
1032
1033 if (replicationNodes.getRegistryContact().getContact() == null) {
1034 replicationNodes.getRegistryContact().setContact(new Contact());
1035 replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null));
1036 }
1037
1038 JAXB.marshal(replicationNodes, System.out);
1039
1040 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
1041 System.out.println("Saved to node1");
1042 testEquals(replicationNodes, juddiApiService.getReplicationNodes(authtoken));
1043
1044 transport = clerkManager.getTransport("uddi:another.juddi.apache.org:node2");
1045 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
1046 juddiApiService = transport.getJUDDIApiService();
1047 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
1048 System.out.println("Saved to node2");
1049 testEquals(replicationNodes, juddiApiService.getReplicationNodes(authtoken));
1050
1051 transport = clerkManager.getTransport("uddi:yet.another.juddi.apache.org:node3");
1052 authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo();
1053 juddiApiService = transport.getJUDDIApiService();
1054 juddiApiService.setReplicationNodes(authtoken, replicationNodes);
1055 System.out.println("Saved to node3");
1056 testEquals(replicationNodes, juddiApiService.getReplicationNodes(authtoken));
1057 }
1058
1059 void pingAll() throws Exception {
1060 List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
1061
1062 UDDIReplicationPortType uddiReplicationPort = new UDDIService().getUDDIReplicationPort();
1063 TransportSecurityHelper.applyTransportSecurity((BindingProvider) uddiReplicationPort);
1064
1065 for (Node currenteNode : uddiNodeList) {
1066 try {
1067 String replicationUrl = clerkManager.getClientConfig().getUDDINode(currenteNode.getName()).getReplicationUrl();
1068 ((BindingProvider) uddiReplicationPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, replicationUrl);
1069 long now = System.currentTimeMillis();
1070 String doPing = uddiReplicationPort.doPing(new DoPing());
1071 System.out.println(replicationUrl + " " + currenteNode.getName() + " says it's node id is " + doPing + " (took " + (System.currentTimeMillis() - now) + "ms)");
1072 } catch (Exception ex) {
1073 System.out.println("Error! " + currenteNode.getName() + " " + currenteNode.getReplicationUrl());
1074 ex.printStackTrace();
1075 }
1076
1077 }
1078
1079 }
1080
1081 }