http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java b/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java index e2e11ca..132c530 100644 --- a/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java +++ b/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java @@ -16,6 +16,7 @@ */ package org.apache.juddi.replication; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Queue; @@ -25,6 +26,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; import javax.persistence.Query; +import javax.xml.bind.JAXB; import javax.xml.ws.BindingProvider; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.logging.Log; @@ -41,6 +43,7 @@ import org.uddi.repl_v3.ChangeRecordIDType; import org.uddi.repl_v3.CommunicationGraph; import org.uddi.repl_v3.HighWaterMarkVectorType; import org.uddi.repl_v3.NotifyChangeRecordsAvailable; +import org.uddi.repl_v3.Operator; import org.uddi.v3_service.UDDIReplicationPortType; /** @@ -104,6 +107,7 @@ public class ReplicationNotifier extends TimerTask { tx = em.getTransaction(); tx.begin(); + em.persist(j); tx.commit(); } catch (Exception ex) { @@ -111,6 +115,7 @@ public class ReplicationNotifier extends TimerTask { if (tx != null && tx.isActive()) { tx.rollback(); } + JAXB.marshal(MappingModelToApi.mapChangeRecord(j), System.out); } finally { em.close(); } @@ -121,7 +126,7 @@ public class ReplicationNotifier extends TimerTask { //TODO figure out what this statement means 7.5.3 /** * In the absence of a communicationGraph element from the - * Replication Configuration Structure, all nodes listed in the + * Replication Configuration Structure (although it's mandatory in the xsd), all nodes listed in the * node element MAY send any and all messages to any other node * of the registry. */ @@ -130,37 +135,60 @@ public class ReplicationNotifier extends TimerTask { return; } + List<String> destinationUrls = new ArrayList<String>(); + + for (Operator o:repcfg.getOperator()) + { + //no need to tell myself about a change at myself + if (!o.getOperatorNodeID().equalsIgnoreCase(node)) + destinationUrls.add(o.getSoapReplicationURL()); + } + /* + Iterator<String> iterator = repcfg.getCommunicationGraph().getNode().iterator(); + while (iterator.hasNext()) { + String next = iterator.next(); + + Node destinationNode = getNode(next); + if (destinationNode == null) { + log.warn(next + " node was not found, cannot deliver replication messages"); + } else { + destinationUrls.add(destinationNode.getReplicationUrl()); + } + } Iterator<CommunicationGraph.Edge> it = repcfg.getCommunicationGraph().getEdge().iterator(); while (it.hasNext()) { //send each change set to the replication node in the graph - UDDIReplicationPortType x = new UDDIService().getUDDIReplicationPort(); + CommunicationGraph.Edge next = it.next(); //next.getMessageReceiver(); //Node ID - Node destinationNode = getNode(next.getMessageSender()); + Node destinationNode = getNode(next.getMessageReceiver()); if (destinationNode == null) { - log.warn(next.getMessageSender() + " node was not found, cannot deliver replication messages"); + log.warn(next.getMessageReceiver() + " node was not found, cannot deliver replication messages"); } else { - //TODO the spec talks about control messages, should we even support it? seems pointless - ((BindingProvider) x).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, destinationNode.getReplicationUrl()); - NotifyChangeRecordsAvailable req = new NotifyChangeRecordsAvailable(); - - req.setNotifyingNode(node); - HighWaterMarkVectorType highWaterMarkVectorType = new HighWaterMarkVectorType(); - - highWaterMarkVectorType.getHighWaterMark().add(new ChangeRecordIDType(node, j.getId())); - req.setChangesAvailable(highWaterMarkVectorType); - - try { - x.notifyChangeRecordsAvailable(req); - log.info("Successfully sent change record available message to " + destinationNode.getName()); - } catch (Exception ex) { - log.warn("Unable to send change notification to " + destinationNode.getName(), ex); - } + destinationUrls.add(destinationNode.getReplicationUrl()); } - } + }*/ + for (String s : destinationUrls) { + //TODO the spec talks about control messages, should we even support it? seems pointless + UDDIReplicationPortType x = new UDDIService().getUDDIReplicationPort(); + ((BindingProvider) x).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, s); + NotifyChangeRecordsAvailable req = new NotifyChangeRecordsAvailable(); + + req.setNotifyingNode(node); + HighWaterMarkVectorType highWaterMarkVectorType = new HighWaterMarkVectorType(); + highWaterMarkVectorType.getHighWaterMark().add(new ChangeRecordIDType(node, j.getId())); + req.setChangesAvailable(highWaterMarkVectorType); + + try { + x.notifyChangeRecordsAvailable(req); + log.info("Successfully sent change record available message to " + s); + } catch (Exception ex) { + log.warn("Unable to send change notification to " + s, ex); + } + } } public synchronized void run() { @@ -193,19 +221,19 @@ public class ReplicationNotifier extends TimerTask { try { tx = em.getTransaction(); tx.begin(); - Query q = em.createQuery("SELECT item FROM ReplicationConfiguration item"); + Query q = em.createQuery("SELECT item FROM ReplicationConfiguration item order by item.serialNumber DESC"); q.setMaxResults(1); - List<ReplicationConfiguration> results = (List<ReplicationConfiguration>) q.getResultList(); + ReplicationConfiguration results = (ReplicationConfiguration) q.getSingleResult(); // ReplicationConfiguration find = em.find(ReplicationConfiguration.class, null); - if (results != null && !results.isEmpty()) { - MappingModelToApi.mapReplicationConfiguration(results.get(0), item); - } else { - item = null; + if (results != null) { + MappingModelToApi.mapReplicationConfiguration(results, item); } + tx.commit(); return item; } catch (Exception ex) { - log.error("error", ex); + //log.error("error", ex); + //no config available if (tx != null && tx.isActive()) { tx.rollback(); }
http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java index 07fe653..573f39b 100644 --- a/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java +++ b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java @@ -87,7 +87,7 @@ public class ValidateNode extends ValidateUDDIApi { throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoPUB")); } if (node.getSubscriptionListenerUrl() == null || node.getSubscriptionListenerUrl().length() == 0 || node.getSubscriptionListenerUrl().length() > 255) { - throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSUBL")); + // throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSUBL")); } if (node.getReplicationUrl() == null || node.getReplicationUrl().length() == 0 || node.getReplicationUrl().length() > 255) { //throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSUBL")); @@ -96,6 +96,9 @@ public class ValidateNode extends ValidateUDDIApi { if (node.getSubscriptionUrl() == null || node.getSubscriptionUrl().length() == 0 || node.getSubscriptionUrl().length() > 255) { throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSUB")); } + if (node.getSecurityUrl()== null || node.getSecurityUrl().length() == 0 || node.getSecurityUrl().length() > 255) { + throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSec")); + } if (node.getProxyTransport() == null || node.getProxyTransport().length() == 0 || node.getProxyTransport().length() > 255) { throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoProxy")); } else { http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java index 6ede348..97da3ff 100644 --- a/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java +++ b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java @@ -17,6 +17,7 @@ package org.apache.juddi.validation; import java.math.BigInteger; +import java.util.List; import javax.persistence.EntityManager; import javax.xml.ws.WebServiceContext; import org.apache.juddi.model.Node; @@ -28,6 +29,7 @@ import org.apache.juddi.v3.error.ValueNotAllowedException; import org.uddi.repl_v3.CommunicationGraph.Edge; import org.uddi.repl_v3.HighWaterMarkVectorType; import org.uddi.repl_v3.NotifyChangeRecordsAvailable; +import org.uddi.repl_v3.Operator; import org.uddi.repl_v3.ReplicationConfiguration; import org.uddi.v3_service.DispositionReportFaultMessage; @@ -115,31 +117,46 @@ public class ValidateReplication extends ValidateUDDIApi { return false; } - public void validateSetReplicationNodes(ReplicationConfiguration replicationConfiguration, EntityManager em) throws DispositionReportFaultMessage { + public void validateSetReplicationNodes(ReplicationConfiguration replicationConfiguration, EntityManager em, String thisnode) throws DispositionReportFaultMessage { if (replicationConfiguration == null) { throw new InvalidValueException(new ErrorMessage("errors.replication.configNull")); } + if (replicationConfiguration.getCommunicationGraph() == null) { + throw new InvalidValueException(new ErrorMessage("errors.replication.configNull")); + } + if (replicationConfiguration.getRegistryContact() == null) { + throw new InvalidValueException(new ErrorMessage("errors.replication.contactNull")); + } + if (replicationConfiguration.getRegistryContact().getContact() == null) { + throw new InvalidValueException(new ErrorMessage("errors.replication.contactNull")); + } + if (replicationConfiguration.getRegistryContact().getContact().getPersonName().get(0) == null) { + throw new InvalidValueException(new ErrorMessage("errors.replication.contactNull")); + } + if (replicationConfiguration.getCommunicationGraph() != null) { for (String s : replicationConfiguration.getCommunicationGraph().getNode()) { - Node find = em.find(org.apache.juddi.model.Node.class, s); - if (find == null) { + if (!Contains(replicationConfiguration.getOperator(), s)) { throw new InvalidValueException(new ErrorMessage("errors.replication.configNodeNotFound")); } } for (Edge s : replicationConfiguration.getCommunicationGraph().getEdge()) { - Node find = em.find(org.apache.juddi.model.Node.class, s.getMessageReceiver()); - if (find == null) { + //TODO revisit this for correctness + //Node find = null; + //if (!thisnode.equalsIgnoreCase(s.getMessageReceiver())) { + if (!Contains(replicationConfiguration.getOperator(), s.getMessageReceiver())) { throw new InvalidValueException(new ErrorMessage("errors.replication.configNodeNotFound")); + //} } - find = null; - find = em.find(org.apache.juddi.model.Node.class, s.getMessageSender()); - if (find == null) { + //find = null; + //if (!thisnode.equalsIgnoreCase(s.getMessageSender())) { + if (!Contains(replicationConfiguration.getOperator(), s.getMessageSender())) { throw new InvalidValueException(new ErrorMessage("errors.replication.configNodeNotFound")); + //} } for (String id : s.getMessageReceiverAlternate()) { - find = em.find(org.apache.juddi.model.Node.class, id); - if (find == null) { + if (!Contains(replicationConfiguration.getOperator(), id)) { throw new InvalidValueException(new ErrorMessage("errors.replication.configNodeNotFound")); } } @@ -148,4 +165,16 @@ public class ValidateReplication extends ValidateUDDIApi { } } + private boolean Contains(List<Operator> operator, String s) { + if (operator == null) { + return false; + } + for (Operator o : operator) { + if (o.getOperatorNodeID().equalsIgnoreCase(s)) { + return true; + } + } + return false; + } + } http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/main/resources/messages.properties ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/resources/messages.properties b/juddi-core/src/main/resources/messages.properties index 0a23c78..95d98ce 100644 --- a/juddi-core/src/main/resources/messages.properties +++ b/juddi-core/src/main/resources/messages.properties @@ -243,6 +243,7 @@ errors.node.NoPUB=A publish url was not specified errors.node.NoIN=A inquiry url was not specified errors.node.NoSUBL=A subscription listener url was not specified errors.node.NoSUB=A subscription url was not specified +errors.node.NoSec=A security url was not specified errors.node.NoProxy=A transport proxy class must be specified. If you're not sure, use 'org.apache.juddi.v3.client.transport.JAXWSTransport' errors.node.illegalProxyTransport=The transport proxy class is invalid. If you're not sure, use 'org.apache.juddi.v3.client.transport.JAXWSTransport' errors.node.NoRMIData=When using org.apache.juddi.v3.client.transport.RMITransport the factory settings must be specified @@ -291,6 +292,7 @@ errors.replication.bothLimitsSpecified=responseLimitCount or responseLimitVector errors.replication.negativeLimit=The specified response limit is either 0 or a negative number. errors.replication.limitVectorNull=The high water mark vector limit specified OriginatingUSN is null or invalid errors.replication.limitVectorNoNode=No node name was specified -errors.replication.configNodeNotFound=No specified node name is not currently registered as a node. Use the jUDDI Service API to register it. Node id: +errors.replication.configNodeNotFound=No specified node name is not currently listed as a Operator. Add it to the list and try again. Id: errors.replication.configNull=No replication config was present in the message +errors.replication.contactNull=No replication contact was present in the message errors.deleteNode.InReplicationConfig=The node to be deleted is currently referenced in the replication configuration. You must revise the configuration before deleting the node, http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/test/java/org/apache/juddi/api/impl/API_160_ReplicationTest.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/test/java/org/apache/juddi/api/impl/API_160_ReplicationTest.java b/juddi-core/src/test/java/org/apache/juddi/api/impl/API_160_ReplicationTest.java index f64512f..98bdb0b 100644 --- a/juddi-core/src/test/java/org/apache/juddi/api/impl/API_160_ReplicationTest.java +++ b/juddi-core/src/test/java/org/apache/juddi/api/impl/API_160_ReplicationTest.java @@ -19,6 +19,7 @@ import java.math.BigInteger; import java.rmi.RemoteException; import java.util.List; import java.util.UUID; +import javax.xml.bind.JAXB; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -40,12 +41,16 @@ import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import org.uddi.api_v3.Contact; import org.uddi.api_v3.DispositionReport; +import org.uddi.api_v3.PersonName; import org.uddi.repl_v3.ChangeRecord; import org.uddi.repl_v3.ChangeRecordIDType; import org.uddi.repl_v3.CommunicationGraph; import org.uddi.repl_v3.DoPing; import org.uddi.repl_v3.HighWaterMarkVectorType; +import org.uddi.repl_v3.Operator; +import org.uddi.repl_v3.OperatorStatusType; import org.uddi.repl_v3.ReplicationConfiguration; import org.uddi.v3_service.DispositionReportFaultMessage; import org.uddi.v3_service.UDDIReplicationPortType; @@ -126,8 +131,8 @@ public class API_160_ReplicationTest { } /** - * add a clerk and node, delete the clerk, then check that the node is still there - * it should have been deleted + * add a clerk and node, delete the clerk, then check that the node is + * still there it should have been deleted * * @throws Exception */ @@ -177,13 +182,13 @@ public class API_160_ReplicationTest { //TODO revise cascade deletes on nodes and clerks Assert.fail("node unexpectedly deleted"); } - - + /** * add clerk + node, try to delete the node - * @throws Exception + * + * @throws Exception */ - @Test + @Test public void testAddClerkNodeThenDelete2() throws Exception { SaveClerk sc = new SaveClerk(); sc.setAuthInfo(authInfoRoot); @@ -210,8 +215,7 @@ public class API_160_ReplicationTest { juddi.deleteNode(new DeleteNode(authInfoRoot, c.getNode().getName())); //this should success - - + //the clerk should be gone too ClerkList allNodes = juddi.getAllClerks(authInfoRoot); boolean found = false; @@ -227,10 +231,10 @@ public class API_160_ReplicationTest { NodeList allNodes1 = juddi.getAllNodes(authInfoRoot); for (int i = 0; i < allNodes1.getNode().size(); i++) { if (allNodes1.getNode().get(i).getName().equals(c.getNode().getName())) { - Assert.fail("node is still there!"); + Assert.fail("node is still there!"); } } - + } @Test @@ -264,14 +268,12 @@ public class API_160_ReplicationTest { juddi.saveNode(saveNode); juddi.saveClerk(sc); - + //success - - //delete it - juddi.deleteClerk(new DeleteClerk(authInfoRoot,c.getName())); - System.out.println(c.getName()+" deleted"); - + juddi.deleteClerk(new DeleteClerk(authInfoRoot, c.getName())); + System.out.println(c.getName() + " deleted"); + juddi.deleteNode(new DeleteNode(authInfoRoot, c.getNode().getName())); //confirm it's gone NodeList allNodes = juddi.getAllNodes(authInfoRoot); @@ -288,30 +290,23 @@ public class API_160_ReplicationTest { @Test public void setReplicationConfig() throws Exception { - Node node = new Node(); - node.setName("test_node"); - node.setClientName("test_client"); - node.setProxyTransport(org.apache.juddi.v3.client.transport.JAXWSTransport.class.getCanonicalName()); - node.setCustodyTransferUrl("http://localhost"); - node.setDescription("http://localhost"); - node.setInquiryUrl("http://localhost"); - node.setPublishUrl("http://localhost"); - node.setReplicationUrl("http://localhost"); - node.setSecurityUrl("http://localhost"); - node.setSubscriptionListenerUrl("http://localhost"); - node.setSubscriptionUrl("http://localhost"); - - SaveNode saveNode = new SaveNode(); - saveNode.setAuthInfo(authInfoRoot); - saveNode.getNode().add(node); - - juddi.saveNode(saveNode); + ReplicationConfiguration r = new ReplicationConfiguration(); + Operator op = new Operator(); + op.setOperatorNodeID("test_node"); + op.setSoapReplicationURL("http://localhost"); + op.setOperatorStatus(OperatorStatusType.NORMAL); + + r.getOperator().add(op); r.setCommunicationGraph(new CommunicationGraph()); - // r.getCommunicationGraph().getEdge().add(new CommunicationGraph.Edge()); + r.setRegistryContact(new ReplicationConfiguration.RegistryContact()); + r.getRegistryContact().setContact(new Contact()); + r.getRegistryContact().getContact().getPersonName().add(new PersonName("test", null)); + // r.getCommunicationGraph().getEdge().add(new CommunicationGraph.Edge()); r.getCommunicationGraph().getNode().add("test_node"); + JAXB.marshal(r, System.out); DispositionReport setReplicationNodes = juddi.setReplicationNodes(authInfoRoot, r); ReplicationConfiguration replicationNodes = juddi.getReplicationNodes(authInfoRoot); @@ -323,17 +318,20 @@ public class API_160_ReplicationTest { Assert.assertNotNull(replicationNodes.getTimeOfConfigurationUpdate()); Assert.assertNotNull(replicationNodes.getSerialNumber()); long firstcommit = replicationNodes.getSerialNumber(); - - - - r = new ReplicationConfiguration(); + + r = new ReplicationConfiguration(); + r.getOperator().add(op); r.setCommunicationGraph(new CommunicationGraph()); - // r.getCommunicationGraph().getEdge().add(new CommunicationGraph.Edge()); + r.setRegistryContact(new ReplicationConfiguration.RegistryContact()); + r.getRegistryContact().setContact(new Contact()); + r.getRegistryContact().getContact().getPersonName().add(new PersonName("test", null)); + // r.getCommunicationGraph().getEdge().add(new CommunicationGraph.Edge()); r.getCommunicationGraph().getNode().add("test_node"); - setReplicationNodes = juddi.setReplicationNodes(authInfoRoot, r); + JAXB.marshal(r, System.out); + setReplicationNodes = juddi.setReplicationNodes(authInfoRoot, r); - replicationNodes = juddi.getReplicationNodes(authInfoRoot); + replicationNodes = juddi.getReplicationNodes(authInfoRoot); Assert.assertNotNull(replicationNodes.getCommunicationGraph()); Assert.assertNotNull(replicationNodes.getCommunicationGraph().getNode()); Assert.assertEquals("test_node", replicationNodes.getCommunicationGraph().getNode().get(0)); @@ -344,4 +342,60 @@ public class API_160_ReplicationTest { Assert.assertTrue(firstcommit < replicationNodes.getSerialNumber()); } + + @Test + public void setReplicationConfig2() throws Exception { + + + + ReplicationConfiguration r = new ReplicationConfiguration(); + Operator op = new Operator(); + op.setOperatorNodeID("test_node"); + op.setSoapReplicationURL("http://localhost"); + op.setOperatorStatus(OperatorStatusType.NORMAL); + + r.getOperator().add(op); + r.setCommunicationGraph(new CommunicationGraph()); + r.setRegistryContact(new ReplicationConfiguration.RegistryContact()); + r.getRegistryContact().setContact(new Contact()); + r.getRegistryContact().getContact().getPersonName().add(new PersonName("test", null)); + // r.getCommunicationGraph().getEdge().add(new CommunicationGraph.Edge()); + r.getCommunicationGraph().getNode().add("test_node"); + r.getCommunicationGraph().getControlledMessage().add("doPing"); + r.getCommunicationGraph().getEdge().add(new CommunicationGraph.Edge()); + r.getCommunicationGraph().getEdge().get(0).setMessageReceiver("test_node"); + r.getCommunicationGraph().getEdge().get(0).setMessageSender("test_node"); + r.getCommunicationGraph().getEdge().get(0).getMessage().add("doPing"); + r.getCommunicationGraph().getEdge().get(0).getMessageReceiverAlternate().add("test_node"); + + DispositionReport setReplicationNodes = juddi.setReplicationNodes(authInfoRoot, r); + + ReplicationConfiguration replicationNodes = juddi.getReplicationNodes(authInfoRoot); + Assert.assertNotNull(replicationNodes.getCommunicationGraph()); + Assert.assertNotNull(replicationNodes.getCommunicationGraph().getNode()); + Assert.assertEquals("test_node", replicationNodes.getCommunicationGraph().getNode().get(0)); + Assert.assertNotNull(replicationNodes.getMaximumTimeToGetChanges()); + Assert.assertNotNull(replicationNodes.getMaximumTimeToSyncRegistry()); + Assert.assertNotNull(replicationNodes.getTimeOfConfigurationUpdate()); + Assert.assertNotNull(replicationNodes.getSerialNumber()); + + } + + //TODO edges can be listed only once and must be unique + //TODO In the absence of a communicationGraph element from the Replication Configuration Structure, all nodes listed in the node element MAY send any and all messages to any other node of the registry. + //implies that communicationGraph may be null or empty ,despite the xsd + @Test + public void getReplicationConfigMandatoryItems() throws Exception { + + ReplicationConfiguration replicationNodes = juddi.getReplicationNodes(authInfoRoot); + Assert.assertNotNull(replicationNodes); + Assert.assertNotNull(replicationNodes.getCommunicationGraph()); + Assert.assertNotNull(replicationNodes.getTimeOfConfigurationUpdate()); + Assert.assertNotNull(replicationNodes.getMaximumTimeToGetChanges()); + Assert.assertNotNull(replicationNodes.getMaximumTimeToSyncRegistry()); + Assert.assertNotNull(replicationNodes.getRegistryContact()); + Assert.assertNotNull(replicationNodes.getRegistryContact().getContact()); + Assert.assertNotNull(replicationNodes.getRegistryContact().getContact().getPersonName().get(0)); + + } } http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/test/java/org/apache/juddi/api/runtime/CLIServerTest.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/test/java/org/apache/juddi/api/runtime/CLIServerTest.java b/juddi-core/src/test/java/org/apache/juddi/api/runtime/CLIServerTest.java new file mode 100644 index 0000000..4c172b9 --- /dev/null +++ b/juddi-core/src/test/java/org/apache/juddi/api/runtime/CLIServerTest.java @@ -0,0 +1,119 @@ +/* + * 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.api.runtime; + +import java.math.BigInteger; +import java.util.Random; +import javax.xml.ws.BindingProvider; +import javax.xml.ws.Endpoint; +import junit.framework.Assert; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.juddi.v3.client.JUDDIApiService; +import org.apache.juddi.v3_service.JUDDIApiPortType; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.uddi.repl_v3.HighWaterMarkVectorType; +import org.uddi.repl_v3.ReplicationConfiguration; +import org.uddi.v3_service.UDDIReplicationPortType; +import org.apache.juddi.v3.client.UDDIService; +import org.uddi.api_v3.Contact; +import org.uddi.api_v3.PersonName; +import org.uddi.repl_v3.CommunicationGraph; +import org.uddi.repl_v3.DoPing; + +/** + * + * @author alex + */ +public class CLIServerTest { + + @AfterClass + public static void stopManager() throws ConfigurationException { + replication.stop(); + replication = null; + juddiapi.stop(); + juddiapi = null; + } + + static Endpoint replication = null; + static Endpoint juddiapi = null; + static String replUrl = null; + static String juddiUrl = null; + static boolean sink = false; + static replicantImpl repl= new replicantImpl(); + static juddiTestimpl jude= new juddiTestimpl(); + + @BeforeClass + public static void startManager() throws Exception { + + Random r = new Random(System.currentTimeMillis()); + replUrl = "http://localhost:" + (7000 + r.nextInt(1000)) + "/repl"; + replication = Endpoint.publish(replUrl, repl); + + juddiUrl = "http://localhost:" + (7000 + r.nextInt(1000)) + "/juddi"; + juddiapi = Endpoint.publish(juddiUrl, jude); + System.out.println("Endpoint up at " + replUrl); + System.out.println("Endpoint up at " + juddiUrl); + } + + @Test + public void testGetReplicationConfig() throws Exception { + + JUDDIApiPortType juddiApiService = new JUDDIApiService().getJUDDIApiImplPort(); + ((BindingProvider) juddiApiService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, juddiUrl); + juddiApiService.getReplicationNodes(null); + Assert.assertTrue(sink); + sink = false; + } + + @Test + public void testSetReplicationConfig() throws Exception { + + JUDDIApiPortType juddiApiService = new JUDDIApiService().getJUDDIApiImplPort(); + ((BindingProvider) juddiApiService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, juddiUrl); + ReplicationConfiguration replicationConfiguration = new ReplicationConfiguration(); + replicationConfiguration.setCommunicationGraph(new CommunicationGraph()); + replicationConfiguration.setRegistryContact(new ReplicationConfiguration.RegistryContact()); + replicationConfiguration.getRegistryContact().setContact(new Contact()); + replicationConfiguration.getRegistryContact().getContact().getPersonName().add(new PersonName("name", null)); + + juddiApiService.setReplicationNodes(null, replicationConfiguration); + Assert.assertTrue(sink); + sink = false; + } + + @Test + public void testReplicationGetChanges() throws Exception { + + UDDIReplicationPortType juddiApiService = new UDDIService().getUDDIReplicationPort(); + ((BindingProvider) juddiApiService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, replUrl); + juddiApiService.getChangeRecords(null, new HighWaterMarkVectorType(), BigInteger.ONE, new HighWaterMarkVectorType()); + Assert.assertTrue(sink); + sink = false; + } + @Test + public void testReplicationPing() throws Exception { + + UDDIReplicationPortType juddiApiService = new UDDIService().getUDDIReplicationPort(); + ((BindingProvider) juddiApiService).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, replUrl); + juddiApiService.doPing(new DoPing());//null, new HighWaterMarkVectorType(), BigInteger.ONE, new HighWaterMarkVectorType()); + Assert.assertTrue(sink); + sink = false; + } + + +} http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/test/java/org/apache/juddi/api/runtime/juddiTestimpl.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/test/java/org/apache/juddi/api/runtime/juddiTestimpl.java b/juddi-core/src/test/java/org/apache/juddi/api/runtime/juddiTestimpl.java new file mode 100644 index 0000000..c127137 --- /dev/null +++ b/juddi-core/src/test/java/org/apache/juddi/api/runtime/juddiTestimpl.java @@ -0,0 +1,188 @@ +/* + * 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.api.runtime; + +import java.rmi.RemoteException; +import java.util.List; +import javax.jws.WebService; +import javax.xml.ws.Holder; +import org.apache.juddi.api_v3.AdminSaveBusinessWrapper; +import org.apache.juddi.api_v3.AdminSaveTModelWrapper; +import org.apache.juddi.api_v3.ClerkDetail; +import org.apache.juddi.api_v3.ClerkList; +import org.apache.juddi.api_v3.ClientSubscriptionInfoDetail; +import org.apache.juddi.api_v3.DeleteClerk; +import org.apache.juddi.api_v3.DeleteClientSubscriptionInfo; +import org.apache.juddi.api_v3.DeleteNode; +import org.apache.juddi.api_v3.DeletePublisher; +import org.apache.juddi.api_v3.GetAllPublisherDetail; +import org.apache.juddi.api_v3.GetPublisherDetail; +import org.apache.juddi.api_v3.NodeDetail; +import org.apache.juddi.api_v3.NodeList; +import org.apache.juddi.api_v3.PublisherDetail; +import org.apache.juddi.api_v3.SaveClerk; +import org.apache.juddi.api_v3.SaveClientSubscriptionInfo; +import org.apache.juddi.api_v3.SaveNode; +import org.apache.juddi.api_v3.SavePublisher; +import org.apache.juddi.api_v3.SubscriptionWrapper; +import org.apache.juddi.api_v3.SyncSubscription; +import org.apache.juddi.api_v3.SyncSubscriptionDetail; +import org.apache.juddi.v3_service.JUDDIApiPortType; +import org.uddi.api_v3.Contact; +import org.uddi.api_v3.DeleteTModel; +import org.uddi.api_v3.DispositionReport; +import org.uddi.api_v3.PersonName; +import org.uddi.repl_v3.CommunicationGraph; +import org.uddi.repl_v3.ReplicationConfiguration; +import org.uddi.sub_v3.Subscription; +import org.uddi.v3_service.DispositionReportFaultMessage; + +/** + * + * @author alex + */ + +@WebService(serviceName = "JUDDIApiService", + endpointInterface = "org.apache.juddi.v3_service.JUDDIApiPortType", + targetNamespace = "urn:juddi-apache-org:v3_service") +public class juddiTestimpl implements JUDDIApiPortType { + + + @Override + public PublisherDetail getPublisherDetail(GetPublisherDetail parameters) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public void deleteClientSubscriptionInfo(DeleteClientSubscriptionInfo body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + } + + @Override + public PublisherDetail getAllPublisherDetail(GetAllPublisherDetail body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public ClerkDetail saveClerk(SaveClerk body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public void deletePublisher(DeletePublisher body) throws DispositionReportFaultMessage, RemoteException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public NodeDetail saveNode(SaveNode body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public PublisherDetail savePublisher(SavePublisher body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public void adminDeleteTModel(DeleteTModel body) throws DispositionReportFaultMessage, RemoteException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public ClientSubscriptionInfoDetail saveClientSubscriptionInfo(SaveClientSubscriptionInfo body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public SyncSubscriptionDetail invokeSyncSubscription(SyncSubscription syncSubscription) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public NodeList getAllNodes(String authInfo) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public ClerkList getAllClerks(String authInfo) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public void deleteNode(DeleteNode body) throws DispositionReportFaultMessage, RemoteException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void deleteClerk(DeleteClerk request) throws DispositionReportFaultMessage, RemoteException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public DispositionReport adminSaveBusiness(String authInfo, List<AdminSaveBusinessWrapper> values) throws DispositionReportFaultMessage, RemoteException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public DispositionReport adminSaveTModel(String authInfo, List<AdminSaveTModelWrapper> values) throws DispositionReportFaultMessage, RemoteException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public ReplicationConfiguration getReplicationNodes(String authInfo) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + ReplicationConfiguration replicationConfiguration = new ReplicationConfiguration(); + replicationConfiguration.setCommunicationGraph(new CommunicationGraph()); + replicationConfiguration.setRegistryContact(new ReplicationConfiguration.RegistryContact()); + replicationConfiguration.getRegistryContact().setContact(new Contact()); + replicationConfiguration.getRegistryContact().getContact().getPersonName().add(new PersonName("name", null)); + + + return replicationConfiguration; + } + + @Override + public DispositionReport setReplicationNodes(String authInfo, ReplicationConfiguration replicationConfiguration) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public List<SubscriptionWrapper> getAllClientSubscriptionInfo(String authInfo) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public void adminDeleteSubscription(String authInfo, List<String> subscriptionKey) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + } + + @Override + public void adminSaveSubscription(String authInfo, String publisherOrUsername, Holder<List<Subscription>> subscriptions) throws DispositionReportFaultMessage { + CLIServerTest.sink = true; + } + +} http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/test/java/org/apache/juddi/api/runtime/replicantImpl.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/test/java/org/apache/juddi/api/runtime/replicantImpl.java b/juddi-core/src/test/java/org/apache/juddi/api/runtime/replicantImpl.java new file mode 100644 index 0000000..f984747 --- /dev/null +++ b/juddi-core/src/test/java/org/apache/juddi/api/runtime/replicantImpl.java @@ -0,0 +1,70 @@ +/* + * 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.api.runtime; + +import java.math.BigInteger; +import java.rmi.RemoteException; +import java.util.List; +import javax.jws.WebService; +import org.uddi.repl_v3.ChangeRecord; +import org.uddi.repl_v3.ChangeRecordIDType; +import org.uddi.repl_v3.DoPing; +import org.uddi.repl_v3.HighWaterMarkVectorType; +import org.uddi.repl_v3.NotifyChangeRecordsAvailable; +import org.uddi.repl_v3.TransferCustody; +import org.uddi.v3_service.DispositionReportFaultMessage; +import org.uddi.v3_service.UDDIReplicationPortType; + +/** + * + * @author alex + */ +@WebService(serviceName = "UDDI_Replication_PortType", targetNamespace = "urn:uddi-org:repl_v3_portType", + endpointInterface = "org.uddi.v3_service.UDDIReplicationPortType") + public class replicantImpl implements UDDIReplicationPortType { + + public replicantImpl(){ + } + + @Override + public List<ChangeRecord> getChangeRecords(String requestingNode, HighWaterMarkVectorType changesAlreadySeen, BigInteger responseLimitCount, HighWaterMarkVectorType responseLimitVector) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public void notifyChangeRecordsAvailable(NotifyChangeRecordsAvailable body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + } + + @Override + public String doPing(DoPing body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public List<ChangeRecordIDType> getHighWaterMarks() throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + return null; + } + + @Override + public void transferCustody(TransferCustody body) throws DispositionReportFaultMessage, RemoteException { + CLIServerTest.sink = true; + } + +} http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/test/java/org/apache/juddi/replication/ReplicationNotifierTest.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/test/java/org/apache/juddi/replication/ReplicationNotifierTest.java b/juddi-core/src/test/java/org/apache/juddi/replication/ReplicationNotifierTest.java index 0931f76..a348134 100644 --- a/juddi-core/src/test/java/org/apache/juddi/replication/ReplicationNotifierTest.java +++ b/juddi-core/src/test/java/org/apache/juddi/replication/ReplicationNotifierTest.java @@ -22,14 +22,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.juddi.Registry; import org.apache.juddi.api.impl.API_141_JIRATest; import org.apache.juddi.api.impl.UDDIReplicationImpl; -import org.apache.juddi.model.ChangeRecord; import org.junit.AfterClass; import org.junit.Test; -import static org.junit.Assert.*; import org.junit.BeforeClass; -import org.uddi.api_v3.BusinessEntity; -import org.uddi.api_v3.Name; -import org.uddi.api_v3.SaveBusiness; import org.uddi.v3_service.UDDIReplicationPortType; /** http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/test/resources/META-INF/persistence.xml ---------------------------------------------------------------------- diff --git a/juddi-core/src/test/resources/META-INF/persistence.xml b/juddi-core/src/test/resources/META-INF/persistence.xml index adc4a7e..105b67d 100644 --- a/juddi-core/src/test/resources/META-INF/persistence.xml +++ b/juddi-core/src/test/resources/META-INF/persistence.xml @@ -73,6 +73,9 @@ <class>org.apache.juddi.model.ReplicationConfiguration</class> <class>org.apache.juddi.model.Edge</class> <class>org.apache.juddi.model.ControlMessage</class> + <class>org.apache.juddi.model.ReplicationConfigurationNode</class> + <class>org.apache.juddi.model.EdgeReceiverAlternate</class> + <properties> <property name="hibernate.archive.autodetection" value="class"/> <property name="hibernate.hbm2ddl.auto" value="update"/> http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-core/src/test/resources/META-INF/uddi.xml ---------------------------------------------------------------------- diff --git a/juddi-core/src/test/resources/META-INF/uddi.xml b/juddi-core/src/test/resources/META-INF/uddi.xml index 633da90..f2e993a 100644 --- a/juddi-core/src/test/resources/META-INF/uddi.xml +++ b/juddi-core/src/test/resources/META-INF/uddi.xml @@ -27,6 +27,30 @@ <subscriptionListenerUrl>org.apache.juddi.api.impl.UDDISubscriptionListenerImpl</subscriptionListenerUrl> <juddiApiUrl>org.apache.juddi.api.impl.JUDDIApiImpl</juddiApiUrl> </node> + <node> + <!-- required 'default' node --> + <name>jaxws</name> + <description>e</description> + <properties> + <property name="serverName" value="localhost" /> + <property name="serverPort" value="8080" /> + <!-- for UDDI nodes that use HTTP u/p, using the following + <property name="basicAuthUsername" value="root" /> + <property name="basicAuthPassword" value="password" /> + <property name="basicAuthPasswordIsEncrypted" value="false" /> + <property name="basicAuthPasswordCryptoProvider" value="org.apache.juddi.v3.client.crypto.AES128Cryptor (an example)" />--> + </properties> + <!-- In VM Transport Settings --> + <proxyTransport>org.apache.juddi.v3.client.transport.JAXWSTransport�</proxyTransport> + <custodyTransferUrl>org.apache.juddi.api.impl.UDDICustodyTransferImpl</custodyTransferUrl> + <inquiryUrl>org.apache.juddi.api.impl.UDDIInquiryImpl</inquiryUrl> + <inquiryRESTUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiryRest</inquiryRESTUrl> + <publishUrl>org.apache.juddi.api.impl.UDDIPublicationImpl</publishUrl> + <securityUrl>org.apache.juddi.api.impl.UDDISecurityImpl</securityUrl> + <subscriptionUrl>org.apache.juddi.api.impl.UDDISubscriptionImpl</subscriptionUrl> + <subscriptionListenerUrl>org.apache.juddi.api.impl.UDDISubscriptionListenerImpl</subscriptionListenerUrl> + <juddiApiUrl>org.apache.juddi.api.impl.JUDDIApiImpl</juddiApiUrl> + </node> </nodes> <clerks registerOnStartup="false"> <clerk name="joe" node="default" publisher="joepublisher" password="joepublisher" isPasswordEncrypted="false" cryptoProvider=""> http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-examples/hello-world-embedded/src/main/resources/META-INF/persistence.xml ---------------------------------------------------------------------- diff --git a/juddi-examples/hello-world-embedded/src/main/resources/META-INF/persistence.xml b/juddi-examples/hello-world-embedded/src/main/resources/META-INF/persistence.xml index aa08feb..225f6b2 100644 --- a/juddi-examples/hello-world-embedded/src/main/resources/META-INF/persistence.xml +++ b/juddi-examples/hello-world-embedded/src/main/resources/META-INF/persistence.xml @@ -78,7 +78,8 @@ <class>org.apache.juddi.model.ReplicationConfiguration</class> <class>org.apache.juddi.model.Edge</class> <class>org.apache.juddi.model.ControlMessage</class> - <class>org.apache.juddi.model.ReplicationMessage</class> + <class>org.apache.juddi.model.ReplicationConfigurationNode</class> + <class>org.apache.juddi.model.EdgeReceiverAlternate</class> <properties> http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/EntryPoint.java ---------------------------------------------------------------------- diff --git a/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/EntryPoint.java b/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/EntryPoint.java index 2f9f032..3d0dacd 100644 --- a/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/EntryPoint.java +++ b/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/EntryPoint.java @@ -17,6 +17,7 @@ package org.apache.juddi.samples; import java.util.List; import org.apache.juddi.api_v3.Node; +import static org.apache.juddi.samples.JuddiAdminService.clerkManager; import org.apache.juddi.v3.client.config.UDDIClient; import org.apache.juddi.v3.client.config.UDDINode; import org.apache.juddi.v3.client.transport.Transport; @@ -73,6 +74,7 @@ public class EntryPoint { System.out.println("35) View all registered nodes for this client"); System.out.println("36) UnRegister a node on a jUDDI server"); System.out.println("37) Fetch the replication config from a jUDDI server"); + System.out.println("38) Set the replication config on a remote jUDDI server"); System.out.println("q) quit"); System.out.print("Selection: "); @@ -93,7 +95,17 @@ public class EntryPoint { if (input.equals("1")) { UDDISecurityPortType security = null; UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml"); - Transport transport = clerkManager.getTransport(); + List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList(); + System.out.println(); + System.out.println("Select a node (from *this config)"); + for (int i = 0; i < uddiNodeList.size(); i++) { + System.out.print(i + 1); + System.out.println(") " + uddiNodeList.get(i).getName() + uddiNodeList.get(i).getDescription()); + } + System.out.println("Node #: "); + int index = Integer.parseInt(System.console().readLine()) - 1; + String node = uddiNodeList.get(index).getName(); + Transport transport = clerkManager.getTransport(node); security = transport.getUDDISecurityService(); System.out.print("username: "); String uname = System.console().readLine(); @@ -297,8 +309,11 @@ public class EntryPoint { 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().GetChangeRecords(key2, Long.parseLong(id)); + new UddiReplication().GetChangeRecords(key2, Long.parseLong(id),src); } if (input.equals("30")) { @@ -316,6 +331,7 @@ public class EntryPoint { 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()); @@ -338,9 +354,13 @@ public class EntryPoint { 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) { + 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): "); @@ -354,38 +374,37 @@ public class EntryPoint { clerkManager.getClientConfig().saveConfig(); System.out.println("Saved."); } - if (input.equals("32")) { + if (input.equals("33")) { //System.out.println("32) Register a *this node to a jUDDI server"); UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml"); 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 + ") Node name: " + uddiNodeList.get(i).getName()); - System.out.println(i + ") Node description: " + uddiNodeList.get(i).getDescription()); - System.out.println(i + ") Transport: " + uddiNodeList.get(i).getProxyTransport()); - System.out.println(i + ") jUDDI URL: " + uddiNodeList.get(i).getJuddiApiUrl()); + 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 Node to publish to remote jUDDI instance: "); - int index=Integer.parseInt(System.console().readLine()); - - System.out.println("Pick a node (remote jUDDI instance) to publish the selected node information to"); + 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 + ") Node name: " + uddiNodeList.get(i).getName()); - System.out.println(i + ") Node description: " + uddiNodeList.get(i).getDescription()); - System.out.println(i + ") Transport: " + uddiNodeList.get(i).getProxyTransport()); - System.out.println(i + ") jUDDI URL: " + uddiNodeList.get(i).getJuddiApiUrl()); + 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("Node to publish to remote jUDDI instance: "); - int index2=Integer.parseInt(System.console().readLine()); - - - new JuddiAdminService().registerLocalNodeToRemoteNode(authtoken, uddiNodeList.get(index), uddiNodeList.get(index2)); - + System.out.println("Remote Destination Node to publish to: "); + int index2 = Integer.parseInt(System.console().readLine()) - 1; + + new JuddiAdminService().registerLocalNodeToRemoteNode(authtoken, uddiNodeList.get(index), uddiNodeList.get(index2)); + } if (input.equals("34")) { @@ -412,9 +431,31 @@ public class EntryPoint { new JuddiAdminService().viewRemoveRemoteNode(authtoken); //System.out.println("35) UnRegister a node on a jUDDI server"); } - if (input.equals("37")){ + if (input.equals("37")) { new JuddiAdminService().viewReplicationConfig(authtoken); } + if (input.equals("38")) { + new JuddiAdminService().setReplicationConfig(authtoken); + } + if (input.equals("magic")) { + //secret menu, setups up replication between juddi8080 and 9080 and adds a record or two on 8080 + UDDISecurityPortType security = null; + UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml"); + + Transport transport = clerkManager.getTransport("default"); + security = transport.getUDDISecurityService(); + + String uname = "root"; + + GetAuthToken getAuthTokenRoot = new GetAuthToken(); + getAuthTokenRoot.setUserID(uname); + getAuthTokenRoot.setCred("root"); + authtoken = security.getAuthToken(getAuthTokenRoot).getAuthInfo(); + System.out.println("Success!"); + new JuddiAdminService().autoMagic(); + + new UddiCreatebulk().publishBusiness(authtoken, 1, 1); + } } } http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java ---------------------------------------------------------------------- diff --git a/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java b/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java index f87c637..9cf086f 100644 --- a/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java +++ b/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java @@ -15,6 +15,7 @@ */ package org.apache.juddi.samples; +import java.math.BigInteger; import java.rmi.RemoteException; import java.util.List; import javax.xml.bind.JAXB; @@ -33,9 +34,16 @@ import org.apache.juddi.v3.client.transport.Transport; import org.apache.juddi.v3.client.transport.TransportException; import org.apache.juddi.v3_service.JUDDIApiPortType; import org.uddi.api_v3.AuthToken; +import org.uddi.api_v3.Contact; +import org.uddi.api_v3.Description; import org.uddi.api_v3.DispositionReport; +import org.uddi.api_v3.Email; import org.uddi.api_v3.GetAuthToken; +import org.uddi.api_v3.PersonName; +import org.uddi.api_v3.Phone; import org.uddi.repl_v3.CommunicationGraph; +import org.uddi.repl_v3.Operator; +import org.uddi.repl_v3.OperatorStatusType; import org.uddi.repl_v3.ReplicationConfiguration; import org.uddi.v3_service.UDDIPublicationPortType; import org.uddi.v3_service.UDDISecurityPortType; @@ -157,6 +165,16 @@ public class JuddiAdminService { Transport transport = clerkManager.getTransport(publishTo.getName()); + UDDISecurityPortType security2 = transport.getUDDISecurityService(); + System.out.print("username: "); + String uname = System.console().readLine(); + char passwordArray[] = System.console().readPassword("password: "); + GetAuthToken getAuthTokenRoot = new GetAuthToken(); + getAuthTokenRoot.setUserID(uname); + getAuthTokenRoot.setCred(new String(passwordArray)); + authtoken = security2.getAuthToken(getAuthTokenRoot).getAuthInfo(); + System.out.println("Success!"); + JUDDIApiPortType juddiApiService = transport.getJUDDIApiService(); SaveNode sn = new SaveNode(); sn.setAuthInfo(authtoken); @@ -202,9 +220,17 @@ public class JuddiAdminService { Transport transport = clerkManager.getTransport(node); JUDDIApiPortType juddiApiService = transport.getJUDDIApiService(); + System.out.println("fetching..."); + //NodeList allNodes = juddiApiService.getAllNodes(authtoken); + ReplicationConfiguration replicationNodes = null; + try { + replicationNodes = juddiApiService.getReplicationNodes(authtoken); + } catch (Exception ex) { + System.out.println("Error getting replication config"); + ex.printStackTrace(); + replicationNodes = new ReplicationConfiguration(); - ReplicationConfiguration replicationNodes = juddiApiService.getReplicationNodes(authtoken); - + } String input = ""; while (!"d".equalsIgnoreCase(input) && !"q".equalsIgnoreCase(input)) { System.out.println("Current Config:"); @@ -216,11 +242,33 @@ public class JuddiAdminService { System.out.println("5) Set Registry Contact"); System.out.println("6) Add Operator info"); System.out.println("7) Remove Operator info"); + System.out.println("d) Done, save changes"); + System.out.println("q) Quit and abandon changes"); + input = System.console().readLine(); if (input.equalsIgnoreCase("1")) { menu_RemoveReplicationNode(replicationNodes); } else if (input.equalsIgnoreCase("2")) { menu_AddReplicationNode(replicationNodes, juddiApiService, authtoken); + } else if (input.equalsIgnoreCase("d")) { + if (replicationNodes.getCommunicationGraph() == null) { + replicationNodes.setCommunicationGraph(new CommunicationGraph()); + } + if (replicationNodes.getRegistryContact() == null) { + replicationNodes.setRegistryContact(new ReplicationConfiguration.RegistryContact()); + } + if (replicationNodes.getRegistryContact().getContact() == null) { + replicationNodes.getRegistryContact().setContact(new Contact()); + replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null)); + } + + replicationNodes.setSerialNumber(0L); + replicationNodes.setTimeOfConfigurationUpdate(""); + replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE); + replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE); + + JAXB.marshal(replicationNodes, System.out); + juddiApiService.setReplicationNodes(authtoken, replicationNodes); } } @@ -286,19 +334,184 @@ public class JuddiAdminService { private void menu_AddReplicationNode(ReplicationConfiguration replicationNodes, JUDDIApiPortType juddiApiService, String authtoken) throws Exception { - NodeList allNodes = juddiApiService.getAllNodes(authtoken); - if (allNodes == null || allNodes.getNode().isEmpty()) { - System.out.println("No nodes registered!"); - } else { - for (int i = 0; i < allNodes.getNode().size(); i++) { - System.out.println((i + 1) + ") Name :" + allNodes.getNode().get(i).getName()); - System.out.println((i + 1) + ") Replication :" + allNodes.getNode().get(i).getReplicationUrl()); + if (replicationNodes.getCommunicationGraph() == null) { + replicationNodes.setCommunicationGraph(new CommunicationGraph()); + } + + Operator op = new Operator(); + 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" + + " the new registry."); + System.out.print("Operator Node id: "); + op.setOperatorNodeID(System.console().readLine().trim()); + + System.out.print("Replication URL: "); + op.setSoapReplicationURL(System.console().readLine().trim()); + op.setOperatorStatus(OperatorStatusType.NEW); + System.out.println("The replication node requires at least one point of contact"); + System.out.print("Number of contacts: "); + int index = Integer.parseInt(System.console().readLine()); + for (int i = 0; i < index; i++) { + System.out.println("_______________________"); + System.out.println("Info for contact # " + (i + 1)); + op.getContact().add(getContactInfo()); + } + System.out.println("_______________________"); + System.out.println("Current Operator:"); + System.out.println("_______________________"); + JAXB.marshal(op, System.out); + + System.out.print("Confirm adding? (y/n) :"); + if (System.console().readLine().trim().equalsIgnoreCase("y")) { + replicationNodes.getOperator().add(op); + replicationNodes.getCommunicationGraph().getNode().add(op.getOperatorNodeID()); + + } + } + private Contact getContactInfo() { + Contact c = new Contact(); + System.out.print("Use Type (i.e. primary): "); + c.setUseType(System.console().readLine().trim()); + if (c.getUseType().trim().equalsIgnoreCase("")) { + c.setUseType("primary"); + } + + c.getPersonName().add(getPersonName()); + + while (true) { + System.out.println("Thus far:"); + JAXB.marshal(c, System.out); + System.out.println("Options:"); + System.out.println("\t1) Add PersonName"); + System.out.println("\t2) Add Email address"); + System.out.println("\t3) Add Phone number"); + System.out.println("\t4) Add Description"); + System.out.println("\t<enter> Finish and return"); + + System.out.print("> "); + String input = System.console().readLine(); + if (input.trim().equalsIgnoreCase("")) { + break; + } else if (input.trim().equalsIgnoreCase("1")) { + c.getPersonName().add(getPersonName()); + } else if (input.trim().equalsIgnoreCase("2")) { + c.getEmail().add(getEmail()); + } else if (input.trim().equalsIgnoreCase("3")) { + c.getPhone().add(getPhoneNumber()); + } else if (input.trim().equalsIgnoreCase("4")) { + c.getDescription().add(getDescription()); } - System.out.println("Node #: "); - int index = Integer.parseInt(System.console().readLine()) - 1; - replicationNodes.getCommunicationGraph().getNode().add(allNodes.getNode().get(index).getName()); } + return c; + } + + private PersonName getPersonName() { + PersonName pn = new PersonName(); + System.out.print("Name: "); + pn.setValue(System.console().readLine().trim()); + System.out.print("Language (en): "); + pn.setLang(System.console().readLine().trim()); + if (pn.getLang().equalsIgnoreCase("")) { + pn.setLang("en"); + } + + return pn; + } + + private Email getEmail() { + Email pn = new Email(); + System.out.print("Email address Value: "); + + pn.setValue(System.console().readLine().trim()); + System.out.print("Use type (i.e. primary): "); + pn.setUseType(System.console().readLine().trim()); + return pn; + } + + private Phone getPhoneNumber() { + + Phone pn = new Phone(); + System.out.print("Phone Value: "); + + pn.setValue(System.console().readLine().trim()); + System.out.print("Use type (i.e. primary): "); + pn.setUseType(System.console().readLine().trim()); + return pn; + } + + private Description getDescription() { + Description pn = new Description(); + System.out.print("Value: "); + + pn.setValue(System.console().readLine().trim()); + System.out.print("Language (en): "); + pn.setLang(System.console().readLine().trim()); + if (pn.getLang().equalsIgnoreCase("")) { + pn.setLang("en"); + } + return pn; + } + + void autoMagic() throws Exception { + + List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList(); + + Transport transport = clerkManager.getTransport("default"); + String authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo(); + + JUDDIApiPortType juddiApiService = transport.getJUDDIApiService(); + System.out.println("fetching..."); + + ReplicationConfiguration replicationNodes = null; + try { + replicationNodes = juddiApiService.getReplicationNodes(authtoken); + } catch (Exception ex) { + System.out.println("Error getting replication config"); + ex.printStackTrace(); + replicationNodes = new ReplicationConfiguration(); + + } + if (replicationNodes.getCommunicationGraph() == null) { + replicationNodes.setCommunicationGraph(new CommunicationGraph()); + } + Operator op = new Operator(); + op.setOperatorNodeID("uddi:juddi.apache.org:node1"); + op.setSoapReplicationURL("http://localhost:8080/juddiv3/services/replication"); + op.setOperatorStatus(OperatorStatusType.NORMAL); + op.getContact().add(new Contact()); + op.getContact().get(0).getPersonName().add(new PersonName("bob", "en")); + op.getContact().get(0).setUseType("admin"); + replicationNodes.getOperator().add(op); + + op = new Operator(); + op.setOperatorNodeID("uddi:another.juddi.apache.org:node2"); + op.setSoapReplicationURL("http://localhost:9080/juddiv3/services/replication"); + op.setOperatorStatus(OperatorStatusType.NORMAL); + op.getContact().add(new Contact()); + op.getContact().get(0).getPersonName().add(new PersonName("mary", "en")); + op.getContact().get(0).setUseType("admin"); + replicationNodes.getOperator().add(op); + replicationNodes.getCommunicationGraph().getNode().add("uddi:another.juddi.apache.org:node2"); + replicationNodes.getCommunicationGraph().getNode().add("uddi:juddi.apache.org:node1"); + replicationNodes.setSerialNumber(0L); + replicationNodes.setTimeOfConfigurationUpdate(""); + replicationNodes.setMaximumTimeToGetChanges(BigInteger.ONE); + replicationNodes.setMaximumTimeToSyncRegistry(BigInteger.ONE); + + if (replicationNodes.getRegistryContact().getContact() == null) { + replicationNodes.getRegistryContact().setContact(new Contact()); + replicationNodes.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null)); + } + + JAXB.marshal(replicationNodes, System.out); + juddiApiService.setReplicationNodes(authtoken, replicationNodes); + + transport = clerkManager.getTransport("uddi:another.juddi.apache.org:node2"); + authtoken = transport.getUDDISecurityService().getAuthToken(new GetAuthToken("root", "root")).getAuthInfo(); + + juddiApiService = transport.getJUDDIApiService(); + juddiApiService.setReplicationNodes(authtoken, replicationNodes); + } } http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiReplication.java ---------------------------------------------------------------------- diff --git a/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiReplication.java b/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiReplication.java index 4878202..2e62348 100644 --- a/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiReplication.java +++ b/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiReplication.java @@ -67,7 +67,7 @@ class UddiReplication { } } - void GetChangeRecords(String key2, Long record) { + void GetChangeRecords(String key2, Long record, String sourcenode) { try { UDDIReplicationPortType uddiReplicationPort = new UDDIService().getUDDIReplicationPort(); HighWaterMarkVectorType highWaterMarkVectorType = new HighWaterMarkVectorType(); @@ -75,7 +75,7 @@ class UddiReplication { highWaterMarkVectorType.getHighWaterMark().add(new ChangeRecordIDType(DoPing(key2), record)); ((BindingProvider) uddiReplicationPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, key2); - List<ChangeRecord> changeRecords = uddiReplicationPort.getChangeRecords("random", null, BigInteger.valueOf(100), highWaterMarkVectorType); + List<ChangeRecord> changeRecords = uddiReplicationPort.getChangeRecords(sourcenode, highWaterMarkVectorType, BigInteger.valueOf(100), null); System.out.println("Success...." + changeRecords.size() + " records returned"); System.out.println("Node, USN, type"); for (int i = 0; i < changeRecords.size(); i++) { http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-examples/more-uddi-samples/src/main/resources/META-INF/simple-publish-uddi.xml ---------------------------------------------------------------------- diff --git a/juddi-examples/more-uddi-samples/src/main/resources/META-INF/simple-publish-uddi.xml b/juddi-examples/more-uddi-samples/src/main/resources/META-INF/simple-publish-uddi.xml index 1f8be39..c78a3d0 100644 --- a/juddi-examples/more-uddi-samples/src/main/resources/META-INF/simple-publish-uddi.xml +++ b/juddi-examples/more-uddi-samples/src/main/resources/META-INF/simple-publish-uddi.xml @@ -4,7 +4,7 @@ <reloadDelay>5000</reloadDelay> <client name="example-client"> <nodes> - <node> + <node isHomeJUDDI="true"> <!-- required 'default' node --> <name>default</name> <properties> @@ -28,6 +28,31 @@ <subscriptionListenerUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription-listener</subscriptionListenerUrl> <juddiApiUrl>http://${serverName}:${serverPort}/juddiv3/services/juddi-api</juddiApiUrl> </node> + <node> + <!-- required 'default' node --> + <name>uddi:another.juddi.apache.org:node2</name> + <properties> + <property name="serverName" value="localhost"/> + <property name="serverPort" value="9080"/> + <!-- for UDDI nodes that use HTTP u/p, using the following + <property name="basicAuthUsername" value="root" /> + <property name="basicAuthPassword" value="password" /> + <property name="basicAuthPasswordIsEncrypted" value="false" /> + <property name="basicAuthPasswordCryptoProvider" value="org.apache.juddi.v3.client.crypto.AES128Cryptor (an example)" />--> + </properties> + <description>juddi node on 9080</description> + <!-- JAX-WS Transport --> + <proxyTransport>org.apache.juddi.v3.client.transport.JAXWSTransport</proxyTransport> + <custodyTransferUrl>http://${serverName}:${serverPort}/juddiv3/services/custody-transfer</custodyTransferUrl> + <inquiryUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiry</inquiryUrl> + <inquiryRESTUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiryRest</inquiryRESTUrl> + <publishUrl>http://${serverName}:${serverPort}/juddiv3/services/publish</publishUrl> + <securityUrl>http://${serverName}:${serverPort}/juddiv3/services/security</securityUrl> + <subscriptionUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription</subscriptionUrl> + <subscriptionListenerUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription-listener</subscriptionListenerUrl> + <juddiApiUrl>http://${serverName}:${serverPort}/juddiv3/services/juddi-api</juddiApiUrl> + <replicationUrl>http://${serverName}:${serverPort}/juddiv3/services/replication</replicationUrl> + </node> </nodes> <clerks registerOnStartup="false"> <clerk name="default" node="default" publisher="uddi" password="uddi" isPasswordEncrypted="false" cryptoProvider=""/> http://git-wip-us.apache.org/repos/asf/juddi/blob/22a846dd/juddi-rest-cxf/src/test/resources/META-INF/persistence.xml ---------------------------------------------------------------------- diff --git a/juddi-rest-cxf/src/test/resources/META-INF/persistence.xml b/juddi-rest-cxf/src/test/resources/META-INF/persistence.xml index afb2de7..36f93b9 100644 --- a/juddi-rest-cxf/src/test/resources/META-INF/persistence.xml +++ b/juddi-rest-cxf/src/test/resources/META-INF/persistence.xml @@ -78,7 +78,8 @@ <class>org.apache.juddi.model.ReplicationConfiguration</class> <class>org.apache.juddi.model.Edge</class> <class>org.apache.juddi.model.ControlMessage</class> - <class>org.apache.juddi.model.ReplicationMessage</class> + <class>org.apache.juddi.model.ReplicationConfigurationNode</class> + <class>org.apache.juddi.model.EdgeReceiverAlternate</class> <properties> <property name="hibernate.archive.autodetection" value="class"/> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
