You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2015/01/13 14:57:29 UTC
juddi git commit: JUDDI-906 more test case enhancements, business,
tmodel and publisher assertions save and delete are confirmed
replication JUDDI-913 code is included but comment out due to failing tests
(jpa issues)
Repository: juddi
Updated Branches:
refs/heads/master 31c146102 -> b2179ec4b
JUDDI-906 more test case enhancements, business, tmodel and publisher assertions save and delete are confirmed replication
JUDDI-913 code is included but comment out due to failing tests (jpa issues)
Project: http://git-wip-us.apache.org/repos/asf/juddi/repo
Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/b2179ec4
Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/b2179ec4
Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/b2179ec4
Branch: refs/heads/master
Commit: b2179ec4b8add7bedb5b34d7f05e7e88f47fcf18
Parents: 31c1461
Author: Alex <al...@apache.org>
Authored: Tue Jan 13 08:57:22 2015 -0500
Committer: Alex <al...@apache.org>
Committed: Tue Jan 13 08:57:22 2015 -0500
----------------------------------------------------------------------
.../juddi/api/impl/AuthenticatedService.java | 2 -
.../juddi/api/impl/UDDICustodyTransferImpl.java | 1 -
.../juddi/api/impl/UDDIPublicationImpl.java | 12 +-
.../juddi/api/impl/UDDIReplicationImpl.java | 303 +++++++++++--------
.../apache/juddi/mapping/MappingApiToModel.java | 13 +-
.../apache/juddi/mapping/MappingModelToApi.java | 7 +
.../org/apache/juddi/model/BusinessEntity.java | 2 +-
.../apache/juddi/model/PublisherAssertion.java | 16 +
.../java/org/apache/juddi/model/Signature.java | 15 +
.../juddi/replication/ReplicationNotifier.java | 2 +-
.../tck/JUDDI_300_MultiNodeIntegrationTest.java | 177 +++++++++--
11 files changed, 392 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/api/impl/AuthenticatedService.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/api/impl/AuthenticatedService.java b/juddi-core/src/main/java/org/apache/juddi/api/impl/AuthenticatedService.java
index fb0e00e..532d6eb 100644
--- a/juddi-core/src/main/java/org/apache/juddi/api/impl/AuthenticatedService.java
+++ b/juddi-core/src/main/java/org/apache/juddi/api/impl/AuthenticatedService.java
@@ -18,8 +18,6 @@
package org.apache.juddi.api.impl;
import java.util.Date;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java b/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java
index 8a3d862..352123c 100644
--- a/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java
+++ b/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java
@@ -73,7 +73,6 @@ import org.uddi.repl_v3.TransferCustody;
import org.uddi.v3_service.DispositionReportFaultMessage;
import org.uddi.v3_service.UDDICustodyTransferPortType;
import org.uddi.v3_service.UDDIReplicationPortType;
-import sun.util.BuddhistCalendar;
/**
* This implements the UDDI v3 Custody Transfer API web service
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java b/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
index 9e7c786..111fda0 100644
--- a/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
+++ b/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
@@ -57,6 +57,7 @@ import org.apache.juddi.query.util.FindQualifiers;
import org.apache.juddi.replication.ReplicationNotifier;
import org.apache.juddi.v3.error.ErrorMessage;
import org.apache.juddi.v3.error.FatalErrorException;
+import org.apache.juddi.v3.error.InvalidValueException;
import org.apache.juddi.validation.ValidatePublish;
import org.uddi.api_v3.AddPublisherAssertions;
import org.uddi.api_v3.AssertionStatusItem;
@@ -154,12 +155,15 @@ public class UDDIPublicationImpl extends AuthenticatedService implements UDDIPub
existingPubAssertion.setToCheck("true");
}
+ em.merge(existingPubAssertion);
persistNewAssertion = false;
+ changes.add(getChangeRecord_deletePublisherAssertion(apiPubAssertion, node, existingPubAssertion.getToCheck().equalsIgnoreCase("false"), existingPubAssertion.getFromCheck().equalsIgnoreCase("false"), System.currentTimeMillis()));
} else {
// Otherwise, it is a new relationship between these entities. Remove the old one so the new one can be added.
// TODO: the model only seems to allow one assertion per two business (primary key is fromKey and toKey). Spec seems to imply as
// many relationships as desired (the differentiator would be the keyedRef values).
em.remove(existingPubAssertion);
+ changes.add(getChangeRecord_deletePublisherAssertion(apiPubAssertion, node, true, true, System.currentTimeMillis()));
}
}
@@ -339,6 +343,8 @@ public class UDDIPublicationImpl extends AuthenticatedService implements UDDIPub
org.apache.juddi.model.PublisherAssertion existingPubAssertion = em.find(org.apache.juddi.model.PublisherAssertion.class,
modelPubAssertion.getId());
+ if (existingPubAssertion==null)
+ throw new InvalidValueException(new ErrorMessage("E_assertionNotFound"));
boolean fromkey = publisher.isOwner(em.find(BusinessEntity.class, entity.getFromKey()));
boolean tokey = publisher.isOwner(em.find(BusinessEntity.class, entity.getToKey()));
@@ -356,7 +362,7 @@ public class UDDIPublicationImpl extends AuthenticatedService implements UDDIPub
em.persist(existingPubAssertion);
}
- changes.add(getChangeRecord_deletePublisherAssertion(entity, node, fromkey, tokey, existingPubAssertion.getModified().getTime()));
+ changes.add(getChangeRecord_deletePublisherAssertion(entity, node, tokey,fromkey, existingPubAssertion.getModified().getTime()));
}
tx.commit();
@@ -398,7 +404,7 @@ public class UDDIPublicationImpl extends AuthenticatedService implements UDDIPub
modelPubAssertion.getId());
if (existingPubAssertion == null) {
- throw new FatalErrorException(new ErrorMessage("assertionNotFound"));
+ throw new FatalErrorException(new ErrorMessage("E_assertionNotFound"));
}
boolean fromkey = entity.isFromBusinessCheck();// publisher.isOwner(em.find(BusinessEntity.class, entity.getFromKey()));
boolean tokey = entity.isToBusinessCheck();// publisher.isOwner(em.find(BusinessEntity.class, entity.getToKey()));
@@ -410,9 +416,11 @@ public class UDDIPublicationImpl extends AuthenticatedService implements UDDIPub
}
if ("false".equalsIgnoreCase(existingPubAssertion.getToCheck())
&& "false".equalsIgnoreCase(existingPubAssertion.getFromCheck())) {
+ logger.info("!!!Deletion of publisher assertion from database via replication");
em.remove(existingPubAssertion);
} else {
existingPubAssertion.setModified(new Date());
+ logger.info("!!!Publisher assertion update database via replication");
em.persist(existingPubAssertion);
}
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIReplicationImpl.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIReplicationImpl.java b/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIReplicationImpl.java
index 7826cc5..c32f264 100644
--- a/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIReplicationImpl.java
+++ b/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIReplicationImpl.java
@@ -109,13 +109,13 @@ import org.uddi.v3_service.UDDIReplicationPortType;
org.uddi.policy_v3_instanceparms.ObjectFactory.class
})
public class UDDIReplicationImpl extends AuthenticatedService implements UDDIReplicationPortType {
-
+
static void notifyConfigurationChange(ReplicationConfiguration oldConfig, ReplicationConfiguration newConfig) {
//if the config is different
Set<String> oldnodes = getNodes(oldConfig);
Set<String> newNodes = getNodes(newConfig);
-
+
Set<String> addedNodes = diffNodeList(oldnodes, newNodes);
if (queue == null) {
queue = new ConcurrentLinkedQueue<String>();
@@ -128,9 +128,9 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
queue.add(s);
}
}
-
+
}
-
+
private static Set<String> getNodes(ReplicationConfiguration oldConfig) {
Set<String> ret = new HashSet<String>();
if (oldConfig == null) {
@@ -169,19 +169,19 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
if (!found) {
diff.add(lhs);
}
-
+
}
return diff;
}
-
+
private UDDIServiceCounter serviceCounter;
-
+
private static PullTimerTask timer = null;
private long startBuffer = 5000l;//AppConfig.getConfiguration().getLong(Property.JUDDI_NOTIFICATION_START_BUFFER, 20000l); // 20s startup delay default
private long interval = 5000l;// AppConfig.getConfiguration().getLong(Property.JUDDI_NOTIFICATION_INTERVAL, 300000l); //5 min default
private static UDDIPublicationImpl pub = null;
-
+
public UDDIReplicationImpl() {
super();
if (pub == null) {
@@ -195,17 +195,17 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
} catch (ConfigurationException ex) {
logger.fatal(ex);
}
-
+
}
-
+
private synchronized void Init() {
if (queue == null) {
queue = new ConcurrentLinkedQueue<String>();
}
timer = new PullTimerTask();
-
+
}
-
+
private boolean Excluded(HighWaterMarkVectorType changesAlreadySeen, ChangeRecord r) {
if (changesAlreadySeen != null) {
for (int i = 0; i < changesAlreadySeen.getHighWaterMark().size(); i++) {
@@ -223,18 +223,18 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
* available
*/
private class PullTimerTask extends TimerTask {
-
+
private Timer timer = null;
-
+
public PullTimerTask() {
super();
timer = new Timer(true);
timer.scheduleAtFixedRate(this, startBuffer, interval);
}
-
+
@Override
public void run() {
-
+
if (!queue.isEmpty()) {
logger.info("Replication change puller thread started. Queue size: " + queue.size());
}
@@ -260,10 +260,10 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
GetChangeRecords body = new GetChangeRecords();
body.setRequestingNode(node);
body.setResponseLimitCount(BigInteger.valueOf(20));
-
+
body.setChangesAlreadySeen(getLastChangeRecordFrom(poll));
logger.info("fetching updates from " + poll + " since " + body.getChangesAlreadySeen().getHighWaterMark().get(0).getOriginatingUSN() + " items still in the queue: " + queue.size());
-
+
List<ChangeRecord> records
= replicationClient.getChangeRecords(body).getChangeRecord();
//ok now we need to persist the change records
@@ -275,7 +275,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
recordsreturned = records.size();
}
} catch (Exception ex) {
- logger.error("Error caught fetching replication changes from " + poll + " @" + ((BindingProvider)replicationClient).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY), ex);
+ logger.error("Error caught fetching replication changes from " + poll + " @" + ((BindingProvider) replicationClient).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY), ex);
}
}
} else {
@@ -283,7 +283,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
}
}
}
-
+
@Override
public boolean cancel() {
timer.cancel();
@@ -300,9 +300,9 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
if (rec == null) {
return;
}
- logger.debug("_______________________Remote change request " + rec.getChangeID().getNodeID() + ":" + rec.getChangeID().getOriginatingUSN());
-
- if (rec.getChangeID().getNodeID().equalsIgnoreCase(node)){
+ logger.debug("_______________________Remote change request " + rec.getChangeID().getNodeID() + ":" + rec.getChangeID().getOriginatingUSN());
+
+ if (rec.getChangeID().getNodeID().equalsIgnoreCase(node)) {
logger.info("Just received a change record that i created, ignoring....");
return;
}
@@ -317,8 +317,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
* a USN is less than the USN specified in the
* changesAlreadySeen highWaterMarkVector.
*/
-
-
+
try {
tx.begin();
//the change record rec must also be persisted!!
@@ -326,11 +325,11 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
mapChangeRecord.setId(null);
em.persist(mapChangeRecord);
tx.commit();
- logger.debug("Remote CR saved, it was from " + mapChangeRecord.getNodeID() +
- " USN:" + mapChangeRecord.getOriginatingUSN() +
- " Type:" + mapChangeRecord.getRecordType().name() +
- " Key:"+mapChangeRecord.getEntityKey() +
- " Local id:"+mapChangeRecord.getId());
+ logger.debug("Remote CR saved, it was from " + mapChangeRecord.getNodeID()
+ + " USN:" + mapChangeRecord.getOriginatingUSN()
+ + " Type:" + mapChangeRecord.getRecordType().name()
+ + " Key:" + mapChangeRecord.getEntityKey()
+ + " Local id:" + mapChangeRecord.getId());
tx = em.getTransaction();
tx.begin();
//<editor-fold defaultstate="collapsed" desc="delete a record">
@@ -372,14 +371,16 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
//<editor-fold defaultstate="collapsed" desc="New Data">
if (rec.getChangeRecordNewData() != null) {
- if (rec.getChangeRecordNewData().getOperationalInfo().getNodeID() == null) {
- throw new Exception("Inbound replication data is missiong node id!");
- }
-
//The operationalInfo element MUST contain the operational information associated with the indicated new data.
if (rec.getChangeRecordNewData().getOperationalInfo() == null) {
logger.warn("Inbound replication data does not have the required OperationalInfo element and is NOT spec compliant. Data will be ignored");
} else {
+ if (rec.getChangeRecordNewData().getOperationalInfo().getNodeID() == null) {
+ throw new Exception("Inbound replication data is missiong node id! Change will not be applied");
+ }
+ if (rec.getChangeRecordNewData().getOperationalInfo().getNodeID().equalsIgnoreCase(node)) {
+ logger.warn("Inbound replication data is modifying locally owned data. This is not allowed");
+ }
if (rec.getChangeRecordNewData().getBindingTemplate() != null) {
//fetch the binding template if it exists already
//if it exists,
@@ -390,10 +391,11 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
if (model == null) {
logger.error("Replication error, attempting to insert a binding where the service doesn't exist yet");
} else {
- ValidateNodeIdMatches(model.getNodeId(), rec.getChangeRecordNewData().getOperationalInfo());
-
+ ValidateNodeIdMatches(rec.getChangeRecordNewData().getOperationalInfo().getNodeID(), model.getNodeId());
+
org.apache.juddi.model.BindingTemplate bt = em.find(org.apache.juddi.model.BindingTemplate.class, rec.getChangeRecordNewData().getBindingTemplate().getBindingKey());
if (bt != null) {
+ //ValidateNodeIdMatches(node, bt.getNodeId());
em.remove(bt);
}
bt = new BindingTemplate();
@@ -402,12 +404,12 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
// MappingApiToModel.mapOperationalInfoIncludingChildren(model, rec.getChangeRecordNewData().getOperationalInfo());
em.persist(bt);
}
-
+
} else if (rec.getChangeRecordNewData().getBusinessEntity() != null) {
-
+
BusinessEntity model = em.find(org.apache.juddi.model.BusinessEntity.class, rec.getChangeRecordNewData().getBusinessEntity().getBusinessKey());
if (model != null) {
- ValidateNodeIdMatches(model.getNodeId(), rec.getChangeRecordNewData().getOperationalInfo());
+ ValidateNodeIdMatches(rec.getChangeRecordNewData().getOperationalInfo().getNodeID(), model.getNodeId());
//em.remove(model);
MappingApiToModel.mapBusinessEntity(rec.getChangeRecordNewData().getBusinessEntity(), model);
MappingApiToModel.mapOperationalInfoIncludingChildren(model, rec.getChangeRecordNewData().getOperationalInfo());
@@ -424,39 +426,39 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
if (find == null) {
logger.error("Replication error, attempting to insert a service where the business doesn't exist yet");
} else {
-
+
org.apache.juddi.model.BusinessService model = null;
model = em.find(org.apache.juddi.model.BusinessService.class, rec.getChangeRecordNewData().getBusinessService().getServiceKey());
if (model != null) {
- ValidateNodeIdMatches(model.getNodeId(), rec.getChangeRecordNewData().getOperationalInfo());
+ ValidateNodeIdMatches(rec.getChangeRecordNewData().getOperationalInfo().getNodeID(), model.getNodeId());
em.remove(model);
}
-
+
model = new org.apache.juddi.model.BusinessService();
MappingApiToModel.mapBusinessService(rec.getChangeRecordNewData().getBusinessService(), model, find);
MappingApiToModel.mapOperationalInfo(model, rec.getChangeRecordNewData().getOperationalInfo());
MappingApiToModel.mapOperationalInfoIncludingChildren(model, rec.getChangeRecordNewData().getOperationalInfo());
-
+
em.persist(model);
}
-
+
} else if (rec.getChangeRecordNewData().getTModel() != null) {
-
+
Tmodel model = em.find(org.apache.juddi.model.Tmodel.class, rec.getChangeRecordNewData().getTModel().getTModelKey());
if (model != null) {
- ValidateNodeIdMatches(model.getNodeId(), rec.getChangeRecordNewData().getOperationalInfo());
+ ValidateNodeIdMatches(rec.getChangeRecordNewData().getOperationalInfo().getNodeID(), model.getNodeId());
em.remove(model);
}
model = new Tmodel();
MappingApiToModel.mapTModel(rec.getChangeRecordNewData().getTModel(), model);
-
+
MappingApiToModel.mapOperationalInfo(model, rec.getChangeRecordNewData().getOperationalInfo());
-
+
em.persist(model);
}
-
+
}
-
+
}
//</editor-fold>
@@ -484,19 +486,61 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
//<editor-fold defaultstate="collapsed" desc="changeRecordPublisherAssertion">
if (rec.getChangeRecordPublisherAssertion() != null) {
-
+
+ logger.info("Repl CR Publisher Assertion");
//TODO are publisher assertions owned by a given node?
PublisherAssertionId paid = new PublisherAssertionId(rec.getChangeRecordPublisherAssertion().getPublisherAssertion().getFromKey(), rec.getChangeRecordPublisherAssertion().getPublisherAssertion().getToKey());
org.apache.juddi.model.PublisherAssertion model = em.find(org.apache.juddi.model.PublisherAssertion.class, paid);
if (model != null) {
- //permission check?
+ logger.info("Repl CR Publisher Assertion - Existing");
+
+ if (rec.getChangeRecordPublisherAssertion().isFromBusinessCheck()) {
+ model.setFromCheck("true");
+ } else {
+ model.setFromCheck("false");
+ }
+
+ if (rec.getChangeRecordPublisherAssertion().isToBusinessCheck()) {
+ model.setToCheck("true");
+ } else {
+ model.setToCheck("false");
+ }
+
+ model.setKeyName(rec.getChangeRecordPublisherAssertion().getPublisherAssertion().getKeyedReference().getKeyName());
+ model.setKeyValue(rec.getChangeRecordPublisherAssertion().getPublisherAssertion().getKeyedReference().getKeyValue());
+ model.setTmodelKey(rec.getChangeRecordPublisherAssertion().getPublisherAssertion().getKeyedReference().getTModelKey());
+ model.setModified(rec.getChangeRecordPublisherAssertion().getModified().toGregorianCalendar().getTime());
+ //model.setSignatures(MappingApiToModel.mapApiSignaturesToModelSignatures(rec.getChangeRecordPublisherAssertion().getPublisherAssertion().getSignature()));
+ if ("false".equalsIgnoreCase(model.getFromCheck())
+ && "false".equalsIgnoreCase(model.getToCheck())) {
+ logger.warn("!!!New publisher assertion is both false and false, strange. no need to save it then!");
+ em.remove(model);
+ }
+ em.merge(model);
+ } else {
+ logger.info("Repl CR Publisher Assertion - new PA");
+
+ model = new PublisherAssertion();
+ MappingApiToModel.mapPublisherAssertion(rec.getChangeRecordPublisherAssertion().getPublisherAssertion(), model);
+ model.setBusinessEntityByFromKey(null);
+ model.setBusinessEntityByToKey(null);
+ model.setBusinessEntityByFromKey(em.find(BusinessEntity.class, rec.getChangeRecordPublisherAssertion().getPublisherAssertion().getFromKey()));
+ model.setBusinessEntityByToKey(em.find(BusinessEntity.class, rec.getChangeRecordPublisherAssertion().getPublisherAssertion().getToKey()));
+
+ if (rec.getChangeRecordPublisherAssertion().isFromBusinessCheck()) {
+ model.setFromCheck("true");
+ } else {
+ model.setFromCheck("false");
+ }
+
+ if (rec.getChangeRecordPublisherAssertion().isToBusinessCheck()) {
+ model.setToCheck("true");
+ } else {
+ model.setToCheck("false");
+ }
+ model.setModified(rec.getChangeRecordPublisherAssertion().getModified().toGregorianCalendar().getTime());
+ em.persist(model);
}
- model = new PublisherAssertion();
-
- MappingApiToModel.mapPublisherAssertion(rec.getChangeRecordPublisherAssertion().getPublisherAssertion(), model);
- model.setModified(rec.getChangeRecordPublisherAssertion().getModified().toGregorianCalendar().getTime());
- em.persist(model);
-
}
//</editor-fold>
@@ -508,7 +552,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
ReplicationNotifier.Enqueue(MappingApiToModel.mapChangeRecord(posack));
}
if (rec.getChangeRecordNewDataConditional() != null) {
-
+
if (rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo().getNodeID() == null) {
throw new Exception("Inbound replication data is missiong node id!");
}
@@ -527,10 +571,11 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
if (model == null) {
logger.error("Replication error, attempting to insert a binding where the service doesn't exist yet");
} else {
- ValidateNodeIdMatches(model.getNodeId(), rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
-
+
org.apache.juddi.model.BindingTemplate bt = em.find(org.apache.juddi.model.BindingTemplate.class, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getBindingTemplate().getBindingKey());
if (bt != null) {
+ ValidateNodeIdMatches(rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo().getNodeID(), bt.getNodeId());
+
em.remove(bt);
}
bt = new BindingTemplate();
@@ -539,12 +584,12 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
// MappingApiToModel.mapOperationalInfoIncludingChildren(model, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
em.persist(bt);
}
-
+
} else if (rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getBusinessEntity() != null) {
-
+
BusinessEntity model = em.find(org.apache.juddi.model.BusinessEntity.class, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getBusinessEntity().getBusinessKey());
if (model != null) {
- ValidateNodeIdMatches(model.getNodeId(), rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
+ ValidateNodeIdMatches(rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo().getNodeID(), model.getNodeId());
//TODO revisit access control rules
em.remove(model);
}
@@ -555,46 +600,46 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
MappingApiToModel.mapOperationalInfoIncludingChildren(model, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
logger.warn("Name size on save is " + model.getBusinessNames().size());
em.persist(model);
-
+
}
if (rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getBusinessService() != null) {
BusinessEntity find = em.find(org.apache.juddi.model.BusinessEntity.class, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getBusinessService().getBusinessKey());
if (find == null) {
logger.error("Replication error, attempting to insert a service where the business doesn't exist yet");
} else {
-
+
org.apache.juddi.model.BusinessService model = null;
model = em.find(org.apache.juddi.model.BusinessService.class, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getBusinessService().getServiceKey());
if (model != null) {
- ValidateNodeIdMatches(model.getNodeId(), rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
+ ValidateNodeIdMatches(rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo().getNodeID(), model.getNodeId());
em.remove(model);
}
-
+
model = new org.apache.juddi.model.BusinessService();
MappingApiToModel.mapBusinessService(rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getBusinessService(), model, find);
MappingApiToModel.mapOperationalInfo(model, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
MappingApiToModel.mapOperationalInfoIncludingChildren(model, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
-
+
em.persist(model);
}
-
+
} else if (rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getTModel() != null) {
-
+
Tmodel model = em.find(org.apache.juddi.model.Tmodel.class, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getTModel().getTModelKey());
if (model != null) {
- ValidateNodeIdMatches(model.getNodeId(), rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
+ ValidateNodeIdMatches(rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo().getNodeID(), model.getNodeId());
em.remove(model);
}
model = new Tmodel();
MappingApiToModel.mapTModel(rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getTModel(), model);
-
+
MappingApiToModel.mapOperationalInfo(model, rec.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo());
-
+
em.persist(model);
}
-
+
}
-
+
}
if (rec.getChangeRecordNull() != null) {
//No action required
@@ -609,7 +654,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
}
tx.commit();
-
+
} catch (Exception drfm) {
logger.warn("Error persisting change record!", drfm);
StringWriter sw = new StringWriter();
@@ -622,7 +667,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
em.close();
}
}
-
+
private HighWaterMarkVectorType getLastChangeRecordFrom(String notifyingNode) {
HighWaterMarkVectorType ret = new HighWaterMarkVectorType();
ChangeRecordIDType cid = new ChangeRecordIDType();
@@ -638,9 +683,9 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
} catch (Exception ex) {
logger.info(ex);
}
-
+
tx.rollback();
-
+
} catch (Exception drfm) {
logger.warn("error caught fetching newest record from node " + notifyingNode, drfm);
} finally {
@@ -649,22 +694,22 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
}
em.close();
}
-
+
ret.getHighWaterMark().add(cid);
-
+
return ret;
}
}
// private void ValidateDontChangeMyRecordsAtAnotherNode(String )
- private void ValidateNodeIdMatches(String modelNodeId, OperationalInfo newDataOperationalInfo) throws Exception {
- if (modelNodeId == null || newDataOperationalInfo == null) {
+ private void ValidateNodeIdMatches(String newNodeId, String currentOwningNode) throws Exception {
+ if (newNodeId == null || currentOwningNode == null) {
throw new Exception("either the local node ID is null or the inbound replication data's node id is null");
}
//only time this is allowed is custody transfer
- if (!modelNodeId.equals(newDataOperationalInfo.getNodeID())) {
+ if (!newNodeId.equals(currentOwningNode)) {
//throw new Exception("node id mismatch!");
- //logger.info("AUDIT, custory transfer from node, " + modelNodeId + " to " + newDataOperationalInfo.getNodeID() + "/" + newDataOperationalInfo.getAuthorizedName());
+ logger.info("AUDIT, custory transfer from node, " + currentOwningNode + " to " + newNodeId);
}
//if i already have a record and "own it" and the remote node has a record with the same key, reject the update
@@ -683,18 +728,18 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
* Custody and Ownership Transfer API.
*/
//so someone else attempted to update one of my records, reject it
- if (modelNodeId.equals(node)) {
+ if (newNodeId.equals(node)) {
//throw new Exception("node id mismatch! this node already has a record for key " + newDataOperationalInfo.getEntityKey() + " and I'm the authority for it.");
}
}
-
+
private synchronized UDDIReplicationPortType getReplicationClient(String node) {
if (cache.containsKey(node)) {
return cache.get(node);
}
UDDIService svc = new UDDIService();
UDDIReplicationPortType replicationClient = svc.getUDDIReplicationPort();
-
+
EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
@@ -703,7 +748,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
sql.toString();
Query qry = em.createQuery(sql.toString());
qry.setMaxResults(1);
-
+
org.apache.juddi.model.ReplicationConfiguration resultList = (org.apache.juddi.model.ReplicationConfiguration) qry.getSingleResult();
for (Operator o : resultList.getOperator()) {
if (o.getOperatorNodeID().equalsIgnoreCase(node)) {
@@ -713,7 +758,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
}
}
tx.rollback();
-
+
} catch (Exception ex) {
logger.fatal("Node not found!" + node, ex);
} finally {
@@ -724,7 +769,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
}
//em.close();
return null;
-
+
}
private Map<String, UDDIReplicationPortType> cache = new HashMap<String, UDDIReplicationPortType>();
@@ -738,11 +783,11 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
long startTime = System.currentTimeMillis();
long procTime = System.currentTimeMillis() - startTime;
serviceCounter.update(ReplicationQuery.DO_PING, QueryStatus.SUCCESS, procTime);
-
+
return node;
-
+
}
-
+
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@WebResult(name = "changeRecords", targetNamespace = "urn:uddi-org:repl_v3", partName = "body")
// @WebMethod(operationName = "get_changeRecords", action = "get_changeRecords")
@@ -755,7 +800,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
HighWaterMarkVectorType changesAlreadySeen = body.getChangesAlreadySeen();
BigInteger responseLimitCount = body.getResponseLimitCount();
HighWaterMarkVectorType responseLimitVector = body.getResponseLimitVector();
-
+
new ValidateReplication(null).validateGetChangeRecords(requestingNode, changesAlreadySeen, responseLimitCount, responseLimitVector, FetchEdges(), ctx);
//TODO should we validate that "requestingNode" is in the replication config?
@@ -788,7 +833,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
tx.begin();
Long firstrecord = 0L;
Long lastrecord = null;
-
+
if (changesAlreadySeen != null) {
//this is basically a lower limit (i.e. the newest record that was processed by the requestor
//therefore we want the oldest record stored locally to return to the requestor for processing
@@ -807,23 +852,23 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
}
}
}
-
+
logger.info("Query db for replication changes, lower index is " + (firstrecord) + " last index " + lastrecord + " record limit " + maxrecords);
Query createQuery = null;
- /*
- //this don't work
- if (lastrecord != null) {
- createQuery = em.createQuery("select e from ChangeRecord e where "
- + "((e.id > :inbound AND e.nodeID = :node AND e.id < :lastrecord) OR "
- + "(e.originatingUSN > :inbound AND e.nodeID <> :node AND e.originatingUSN < :lastrecord)) "
- + "order by e.id ASC");
- createQuery.setParameter("lastrecord", lastrecord);
- } else {
- createQuery = em.createQuery("select e from ChangeRecord e where "
- + "((e.id > :inbound AND e.nodeID = :node) OR "
- + "(e.originatingUSN > :inbound AND e.nodeID <> :node)) "
- + "order by e.id ASC");
- }*/
+ /*
+ //this don't work
+ if (lastrecord != null) {
+ createQuery = em.createQuery("select e from ChangeRecord e where "
+ + "((e.id > :inbound AND e.nodeID = :node AND e.id < :lastrecord) OR "
+ + "(e.originatingUSN > :inbound AND e.nodeID <> :node AND e.originatingUSN < :lastrecord)) "
+ + "order by e.id ASC");
+ createQuery.setParameter("lastrecord", lastrecord);
+ } else {
+ createQuery = em.createQuery("select e from ChangeRecord e where "
+ + "((e.id > :inbound AND e.nodeID = :node) OR "
+ + "(e.originatingUSN > :inbound AND e.nodeID <> :node)) "
+ + "order by e.id ASC");
+ }*/
if (lastrecord != null) {
createQuery = em.createQuery("select e from ChangeRecord e where "
+ "(e.id > :inbound AND e.nodeID = :node AND e.id < :lastrecord) "
@@ -837,7 +882,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
createQuery.setMaxResults(maxrecords);
createQuery.setParameter("inbound", firstrecord);
createQuery.setParameter("node", node);
-
+
List<org.apache.juddi.model.ChangeRecord> records = (List<org.apache.juddi.model.ChangeRecord>) createQuery.getResultList();
logger.info(records.size() + " CR records returned from query");
for (int i = 0; i < records.size(); i++) {
@@ -845,18 +890,18 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
if (!Excluded(changesAlreadySeen, r)) {
ret.add(r);
}
-
+
}
-
+
tx.rollback();
long procTime = System.currentTimeMillis() - startTime;
serviceCounter.update(ReplicationQuery.GET_CHANGERECORDS,
QueryStatus.SUCCESS, procTime);
-
+
} catch (Exception ex) {
logger.fatal("Error, this node is: " + node, ex);
throw new FatalErrorException(new ErrorMessage("E_fatalError", ex.getMessage()));
-
+
} finally {
if (tx.isActive()) {
tx.rollback();
@@ -884,12 +929,12 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
public List<ChangeRecordIDType> getHighWaterMarks()
throws DispositionReportFaultMessage {
long startTime = System.currentTimeMillis();
-
+
List<ChangeRecordIDType> ret = new ArrayList<ChangeRecordIDType>();
//fetch from database the highest known watermark
ReplicationConfiguration FetchEdges = FetchEdges();
-
+
EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
HashMap<String, Long> map = new HashMap<String, Long>();
@@ -912,7 +957,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
//per the spec
}
map.put(nextNode, id);
-
+
}
}
}
@@ -927,21 +972,21 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
x.setNodeID(node);
x.setOriginatingUSN(id);
ret.add(x);
-
+
tx.rollback();
long procTime = System.currentTimeMillis() - startTime;
serviceCounter.update(ReplicationQuery.GET_HIGHWATERMARKS, QueryStatus.SUCCESS, procTime);
-
+
} catch (Exception drfm) {
throw new FatalErrorException(new ErrorMessage("E_fatalError", drfm.getMessage()));
-
+
} finally {
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
-
+
Iterator<Map.Entry<String, Long>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Long> next = iterator.next();
@@ -965,7 +1010,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
//some other node just told us there's new records available, call
//getChangeRecords from the remote node asynch
new ValidateReplication(null).validateNotifyChangeRecordsAvailable(body, ctx);
-
+
logger.info(body.getNotifyingNode() + " just told me that there are change records available, enqueuing...size is " + queue.size());
if (!queue.contains(body.getNotifyingNode())) {
queue.add(body.getNotifyingNode());
@@ -1019,9 +1064,9 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
if (!ok) {
throw new TransferNotAllowedException(new ErrorMessage("E_transferNotAllowedUnknownNode"));
}
-
+
new ValidateReplication(null).validateTransfer(em, body);
-
+
TransferEntities te = new TransferEntities();
te.setKeyBag(body.getKeyBag());
te.setTransferToken(body.getTransferToken());
@@ -1031,7 +1076,7 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
//discard the token
logger.debug("request validated, processing transfer");
List<ChangeRecord> executeTransfer = new UDDICustodyTransferImpl().executeTransfer(te, em, body.getTransferOperationalInfo().getAuthorizedName(), body.getTransferOperationalInfo().getNodeID());
-
+
for (ChangeRecord c : executeTransfer) {
try {
c.setChangeID(new ChangeRecordIDType());
@@ -1096,5 +1141,5 @@ public class UDDIReplicationImpl extends AuthenticatedService implements UDDIRep
}
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java b/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
index ab814d6..0648a02 100644
--- a/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
+++ b/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
@@ -149,7 +149,7 @@ public class MappingApiToModel {
mapBusinessSignature(apiBusinessEntity.getSignature(), modelBusinessEntity);
}
- private static List<Signature> mapApiSignaturesToModelSignatures(List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures)
+ public static List<Signature> mapApiSignaturesToModelSignatures(List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures)
throws DispositionReportFaultMessage {
List<Signature> modelSignatures = new ArrayList<Signature>();
modelSignatures.clear();
@@ -975,7 +975,9 @@ public class MappingApiToModel {
}
/**
- *
+ * note that when using this, it does not reference the instance of the
+ * specific businesses, it will create new ones. be sure to overwrite them
+ * with the correct references
* @param apiPubAssertion
* @param modelPubAssertion
* @throws DispositionReportFaultMessage
@@ -1000,6 +1002,13 @@ public class MappingApiToModel {
modelPubAssertion.setKeyName(apiKeyedRef.getKeyName());
modelPubAssertion.setKeyValue(apiKeyedRef.getKeyValue());
}
+ if (!apiPubAssertion.getSignature().isEmpty())
+ {
+ /* modelPubAssertion.setSignatures(mapApiSignaturesToModelSignatures(apiPubAssertion.getSignature()));
+ for (Signature s : modelPubAssertion.getSignatures())
+ s.setPublisherAssertion(modelPubAssertion);
+ */
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java b/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
index 26e37aa..98d3ec9 100644
--- a/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
+++ b/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
@@ -60,6 +60,7 @@ import org.apache.juddi.model.KeyDataValue;
import org.apache.juddi.model.Node;
import org.apache.juddi.model.ReplicationConfiguration;
import org.apache.juddi.model.ReplicationConfigurationNode;
+import org.apache.juddi.model.Signature;
import org.apache.juddi.model.SignatureTransformDataValue;
import org.apache.juddi.subscription.TypeConvertor;
import org.apache.juddi.v3.error.ErrorMessage;
@@ -1017,7 +1018,13 @@ public class MappingModelToApi {
keyedRef.setKeyName(modelPublisherAssertion.getKeyName());
keyedRef.setKeyValue(modelPublisherAssertion.getKeyValue());
+ /* if (modelPublisherAssertion.getSignatures()!=null &&
+ !modelPublisherAssertion.getSignatures().isEmpty())
+ {
+ mapSignature(modelPublisherAssertion.getSignatures(), apiPublisherAssertion.getSignature());
+ }*/
apiPublisherAssertion.setKeyedReference(keyedRef);
+
}
public static void mapAssertionStatusItem(org.apache.juddi.model.PublisherAssertion modelPublisherAssertion,
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java b/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java
index 794e1b5..83ab88a 100644
--- a/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java
+++ b/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java
@@ -46,7 +46,7 @@ public class BusinessEntity extends UddiEntity implements java.io.Serializable {
private List<BusinessService> businessServices = new ArrayList<BusinessService>(0);
private List<BusinessDescr> businessDescrs = new ArrayList<BusinessDescr>(0);
private List<ServiceProjection> serviceProjections = new ArrayList<ServiceProjection>(0);
- private List<Signature> signatures = new ArrayList<Signature>(0);
+ private List<Signature> signatures = new ArrayList<Signature>(0);
public BusinessEntity() {
}
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/model/PublisherAssertion.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/model/PublisherAssertion.java b/juddi-core/src/main/java/org/apache/juddi/model/PublisherAssertion.java
index f0e1f03..3f9d592 100644
--- a/juddi-core/src/main/java/org/apache/juddi/model/PublisherAssertion.java
+++ b/juddi-core/src/main/java/org/apache/juddi/model/PublisherAssertion.java
@@ -15,15 +15,20 @@ package org.apache.juddi.model;
* limitations under the License.
*/
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
+import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@@ -45,6 +50,7 @@ public class PublisherAssertion implements java.io.Serializable {
private String fromCheck;
private String toCheck;
private Date modified;
+ private List<Signature> signatures = new ArrayList<Signature>(0);
public PublisherAssertion() {
}
@@ -163,4 +169,14 @@ public class PublisherAssertion implements java.io.Serializable {
PublisherAssertion rhs = (PublisherAssertion) compareto;
return (this.id.equals(rhs.id));
}
+
+ /*
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ public List<Signature> getSignatures() {
+ return signatures;
+ }
+
+ public void setSignatures(List<Signature> signatures) {
+ this.signatures = signatures;
+ }*/
}
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/juddi-core/src/main/java/org/apache/juddi/model/Signature.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/model/Signature.java b/juddi-core/src/main/java/org/apache/juddi/model/Signature.java
index ecea539..3b36265 100644
--- a/juddi-core/src/main/java/org/apache/juddi/model/Signature.java
+++ b/juddi-core/src/main/java/org/apache/juddi/model/Signature.java
@@ -24,6 +24,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
@@ -49,6 +50,7 @@ public class Signature implements java.io.Serializable {
private ReplicationConfiguration replConfig;
private Tmodel tmodel;
private String xmlID;
+ private PublisherAssertion assertion;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@@ -69,6 +71,19 @@ public class Signature implements java.io.Serializable {
public void setBindingTemplate(BindingTemplate bindingTemplate) {
this.bindingTemplate = bindingTemplate;
}
+
+ /*@ManyToOne
+ @JoinColumns({
+ @JoinColumn(name = "fromKey", nullable = true),
+ @JoinColumn(name = "toKey", nullable = true)
+ })
+ public PublisherAssertion getPublisherAssertion() {
+ return assertion;
+ }
+
+ public void setPublisherAssertion(PublisherAssertion item) {
+ this.assertion = item;
+ }*/
@ManyToOne
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/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 23a8845..8bd298c 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
@@ -111,7 +111,7 @@ public class ReplicationNotifier extends TimerTask {
tx.begin();
em.persist(j);
- log.debug("CR saved locally, it was from " + j.getNodeID()
+ log.info("CR saved locally, it was from " + j.getNodeID()
+ " USN:" + j.getOriginatingUSN()
+ " Type:" + j.getRecordType().name()
+ " Key:" + j.getEntityKey()
http://git-wip-us.apache.org/repos/asf/juddi/blob/b2179ec4/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java b/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
index 812d41b..177ba86 100644
--- a/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
+++ b/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
@@ -25,6 +25,7 @@ import org.junit.Assert;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.v3.client.UDDIConstants;
import org.apache.juddi.v3.client.UDDIService;
import org.apache.juddi.v3.client.config.UDDIClient;
import org.apache.juddi.v3.client.transport.Transport;
@@ -35,20 +36,26 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.uddi.api_v3.AccessPoint;
+import org.uddi.api_v3.AddPublisherAssertions;
+import org.uddi.api_v3.AssertionStatusItem;
import org.uddi.api_v3.BindingTemplate;
import org.uddi.api_v3.BindingTemplates;
import org.uddi.api_v3.BusinessDetail;
import org.uddi.api_v3.BusinessEntity;
import org.uddi.api_v3.BusinessService;
import org.uddi.api_v3.BusinessServices;
+import org.uddi.api_v3.CompletionStatus;
import org.uddi.api_v3.Contact;
+import org.uddi.api_v3.DeletePublisherAssertions;
import org.uddi.api_v3.DeleteTModel;
import org.uddi.api_v3.GetBusinessDetail;
import org.uddi.api_v3.GetOperationalInfo;
import org.uddi.api_v3.GetTModelDetail;
+import org.uddi.api_v3.KeyedReference;
import org.uddi.api_v3.Name;
import org.uddi.api_v3.OperationalInfos;
import org.uddi.api_v3.PersonName;
+import org.uddi.api_v3.PublisherAssertion;
import org.uddi.api_v3.SaveBusiness;
import org.uddi.api_v3.TModel;
import org.uddi.api_v3.TModelDetail;
@@ -457,16 +464,15 @@ public class JUDDI_300_MultiNodeIntegrationTest {
// TModel saveSamSyndicatorTmodel = samTModelNode2.saveSamSyndicatorTmodel(samTokenNode2);
BusinessEntity saveSamSyndicatorBusiness = samBizNode2.saveSamSyndicatorBusiness(samTokenNode2);
- // getReplicationStatus();//block until synched
-
+ // getReplicationStatus();//block until synched
//confirm mary's tmodel is on the other node
GetTModelDetail findTModel = new GetTModelDetail();
findTModel.setAuthInfo(samTokenNode2);
findTModel.getTModelKey().add(TckTModel.MARY_PUBLISHER_TMODEL_KEY);
TModelDetail tModelDetail = null;
-
- int timeout = TckPublisher.getSubscriptionTimeout();
-
+
+ int timeout = TckPublisher.getSubscriptionTimeout();
+
while (timeout > 0) {
logger.info("Waiting for the update...");
try {
@@ -475,13 +481,13 @@ public class JUDDI_300_MultiNodeIntegrationTest {
} catch (Exception ex) {
logger.warn(ex.getMessage());
tModelDetail = null;
-
+
}
timeout--;
Thread.sleep(1000);
}
-
+
Assert.assertNotNull(tModelDetail);
Assert.assertNotNull(tModelDetail.getTModel());
Assert.assertTrue(tModelDetail.getTModel().size() == 1);
@@ -490,39 +496,169 @@ public class JUDDI_300_MultiNodeIntegrationTest {
GetBusinessDetail gbd = new GetBusinessDetail();
gbd.setAuthInfo(samTokenNode2);
gbd.getBusinessKey().add(TckBusiness.MARY_BUSINESS_KEY);
-
+
//confirm mary's biz made it too
timeout = TckPublisher.getSubscriptionTimeout();
- BusinessDetail businessDetail =null;
+ BusinessDetail businessDetail = null;
while (timeout > 0) {
logger.info("Waiting for the update...");
try {
- businessDetail = inquirySam.getBusinessDetail(gbd);
+ businessDetail = inquirySam.getBusinessDetail(gbd);
break;
} catch (Exception ex) {
logger.warn(ex.getMessage());
businessDetail = null;
-
+
}
timeout--;
Thread.sleep(1000);
}
-
-
-
+ logger.info("Business replicated");
Assert.assertNotNull(businessDetail);
Assert.assertNotNull(businessDetail.getBusinessEntity());
Assert.assertTrue(businessDetail.getBusinessEntity().get(0).getBusinessKey().equals(TckBusiness.MARY_BUSINESS_KEY));
+ logger.info(">>> Saving a new publisher assertion on node 2 (sam)");
//setup a publisher assertion
+ PublisherAssertion pa = new PublisherAssertion();
+ pa.setFromKey(TckBusiness.SAM_BUSINESS_KEY);
+ pa.setToKey(TckBusiness.MARY_BUSINESS_KEY);
+ pa.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent-child", "child"));
+ AddPublisherAssertions apa = new AddPublisherAssertions();
+ apa.setAuthInfo(samTokenNode2);
+ apa.getPublisherAssertion().add(pa);
+ publishSam.addPublisherAssertions(apa);
+
+ logger.info("Confirming that the assertion is saved on node2 (sam, origin)");
+ List<AssertionStatusItem> assertionStatusReport = null;
+ boolean found = false;
+ assertionStatusReport = publishSam.getAssertionStatusReport(samTokenNode2, null);
+ logger.info("Publisher assertions returned: " + assertionStatusReport.size());
+ for (int x = 0; x < assertionStatusReport.size(); x++) {
+ JAXB.marshal(assertionStatusReport.get(x), System.out);
+ if (assertionStatusReport.get(x).getFromKey().equalsIgnoreCase(TckBusiness.SAM_BUSINESS_KEY)
+ && assertionStatusReport.get(x).getToKey().equalsIgnoreCase(TckBusiness.MARY_BUSINESS_KEY)
+ && assertionStatusReport.get(x).getKeyedReference().getTModelKey().equalsIgnoreCase(UDDIConstants.RELATIONSHIPS)
+ && assertionStatusReport.get(x).getKeyedReference().getKeyName().equalsIgnoreCase("parent-child")
+ && assertionStatusReport.get(x).getKeyedReference().getKeyValue().equalsIgnoreCase("child")) {
+ found = true;
+ break;
+ }
+
+ }
+ Assert.assertTrue("Assertion not found on Sam's node (2)!!", found);
+ logger.info("Ok it's saved.");
+ //wait for synch
+ timeout = TckPublisher.getSubscriptionTimeout();
+ logger.info("confirming that the assertion made it to node 1");
+ found = false;
+ while (timeout > 0) {
+ logger.info("Waiting for the update...");
+ try {
+ assertionStatusReport = publishMary.getAssertionStatusReport(maryTokenNode1, null);
+ logger.info("Publisher assertions returned: " + assertionStatusReport.size());
+ for (int x = 0; x < assertionStatusReport.size(); x++) {
+ JAXB.marshal(assertionStatusReport.get(x), System.out);
+ if (assertionStatusReport.get(x).getFromKey().equalsIgnoreCase(TckBusiness.SAM_BUSINESS_KEY)
+ && assertionStatusReport.get(x).getToKey().equalsIgnoreCase(TckBusiness.MARY_BUSINESS_KEY)
+ && assertionStatusReport.get(x).getKeyedReference().getTModelKey().equalsIgnoreCase(UDDIConstants.RELATIONSHIPS)
+ && assertionStatusReport.get(x).getKeyedReference().getKeyName().equalsIgnoreCase("parent-child")
+ && assertionStatusReport.get(x).getKeyedReference().getKeyValue().equalsIgnoreCase("child")) {
+ found = true;
+ break;
+ }
+
+ }
+ if (found) {
+ break;
+ }
+ } catch (Exception ex) {
+ logger.warn(ex.getMessage());
+ Assert.fail("Unexpected failure " + ex.getMessage());
+
+ }
+ timeout--;
+ Thread.sleep(1000);
+
+ }
+ Assert.assertTrue("Assertion wasn't replicated", found);
+ logger.info("Publisher Assertion replicated...");
+ logger.info("confirming the pa is still on node 2 origin (sam)");
+ found = false;
+ assertionStatusReport = publishSam.getAssertionStatusReport(samTokenNode2, null);
+ logger.info("Publisher assertions returned: " + assertionStatusReport.size());
+ for (int x = 0; x < assertionStatusReport.size(); x++) {
+ JAXB.marshal(assertionStatusReport.get(x), System.out);
+ if (assertionStatusReport.get(x).getFromKey().equalsIgnoreCase(TckBusiness.SAM_BUSINESS_KEY)
+ && assertionStatusReport.get(x).getToKey().equalsIgnoreCase(TckBusiness.MARY_BUSINESS_KEY)
+ && assertionStatusReport.get(x).getKeyedReference().getTModelKey().equalsIgnoreCase(UDDIConstants.RELATIONSHIPS)
+ && assertionStatusReport.get(x).getKeyedReference().getKeyName().equalsIgnoreCase("parent-child")
+ && assertionStatusReport.get(x).getKeyedReference().getKeyValue().equalsIgnoreCase("child")) {
+ found = true;
+ break;
+ }
+
+ }
+ Assert.assertTrue("The PA is not found on node 2(origin), very strange", found);
+
+ //delete the pa
+ DeletePublisherAssertions dpa = new DeletePublisherAssertions();
+ dpa.setAuthInfo(samTokenNode2);
+ dpa.getPublisherAssertion().add(pa);
+ String sam = TckCommon.DumpAllBusinesses(samTokenNode2, inquirySam);
+ String mary = TckCommon.DumpAllBusinesses(maryTokenNode1, inquiryMary);
+ logger.info("Publisher Assertion deletion...");
+ try {
+ publishSam.deletePublisherAssertions(dpa);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ logger.info("Sam's businesses " + sam);
+ logger.info("Mary's businesses " + mary);
+ Assert.fail("unable to delete the assertion on sam's node!");
+ }
+ //wait for synch
+ timeout = TckPublisher.getSubscriptionTimeout();
+
+ found = false;
+ while (timeout > 0) {
+ logger.info("Waiting for the update...");
+ try {
+ assertionStatusReport = publishMary.getAssertionStatusReport(maryTokenNode1, null);
+ found = false;
+ for (int x = 0; x < assertionStatusReport.size(); x++) {
+ JAXB.marshal(assertionStatusReport.get(x), System.out);
+ if (assertionStatusReport.get(x).getFromKey().equalsIgnoreCase(TckBusiness.SAM_BUSINESS_KEY)
+ && assertionStatusReport.get(x).getToKey().equalsIgnoreCase(TckBusiness.MARY_BUSINESS_KEY)
+ && assertionStatusReport.get(x).getKeyedReference().getTModelKey().equalsIgnoreCase(UDDIConstants.RELATIONSHIPS)
+ && assertionStatusReport.get(x).getKeyedReference().getKeyName().equalsIgnoreCase("parent-child")
+ && assertionStatusReport.get(x).getKeyedReference().getKeyValue().equalsIgnoreCase("child")) //still there
+ {
+ found = true;
+ }
+
+ }
+ if (!found) {
+ break;
+ }
+ } catch (Exception ex) {
+ logger.warn(ex.getMessage());
+ Assert.fail("Unexpected failure " + ex.getMessage());
+
+ }
+ timeout--;
+ Thread.sleep(1000);
+
+ }
+ Assert.assertFalse("Assertion deletion wasn't replicated", found);
+ logger.info("Publisher assertion deletion replicated");
//clean up
maryBizNode1.deleteMaryPublisherBusiness(maryTokenNode1);
maryTModelNode1.deleteMaryPublisherTmodel(maryTokenNode1);
//delete both
- timeout = TckPublisher.getSubscriptionTimeout();
+ timeout = TckPublisher.getSubscriptionTimeout();
businessDetail = null;
while (timeout > 0) {
logger.info("Waiting for the update...");
@@ -543,6 +679,7 @@ public class JUDDI_300_MultiNodeIntegrationTest {
if (businessDetail != null) {
Assert.fail(TckBusiness.MARY_BUSINESS_KEY + " wasn't deleted on node 2");
}
+ logger.info("Mary's business deletion was replicated");
tModelDetail = inquirySam.getTModelDetail(findTModel);
Assert.assertNotNull(tModelDetail);
@@ -550,14 +687,14 @@ public class JUDDI_300_MultiNodeIntegrationTest {
Assert.assertNotNull(tModelDetail.getTModel().get(0));
Assert.assertEquals(tModelDetail.getTModel().get(0).getTModelKey(), TckTModel.MARY_PUBLISHER_TMODEL_KEY);
Assert.assertEquals(tModelDetail.getTModel().get(0).isDeleted(), true);
+ logger.info("Mary's tModel was deleted(hidden) replicated");
+ // TckCommon.PrintMarker();
- TckCommon.PrintMarker();
-
} finally {
-
+
samBizNode2.deleteSamSyndicatorBusiness(samTokenNode2);
restTmodels();
-
+
}
//check node2 for a "hidden" tmodel should be accessible via getDetails
}
@@ -634,7 +771,7 @@ public class JUDDI_300_MultiNodeIntegrationTest {
}
private void restTmodels() {
-
+
logger.info("resting tmodels");
DeleteTModel dtm = new DeleteTModel();
dtm.setAuthInfo(rootNode1Token);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org