EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
UddiEntityPublisher publisher = this.getEntityPublisher(em, authInfo);
new ValidatePublish(publisher).validateSetPublisherAssertions(em, publisherAssertion);
List<?> businessKeysFound = null;
businessKeysFound = FindBusinessByPublisherQuery.select(em, null, publisher, businessKeysFound);
// First, wipe out all previous assertions associated with this publisher
DeletePublisherAssertionByBusinessQuery.delete(em, businessKeysFound);
// Slate is clean for all assertions involving this publisher, now we simply need to add the new ones (and they will all be "new").
List<org.uddi.api_v3.PublisherAssertion> apiPubAssertionList = publisherAssertion.value;
for (org.uddi.api_v3.PublisherAssertion apiPubAssertion : apiPubAssertionList) {
org.apache.juddi.model.PublisherAssertion modelPubAssertion = new org.apache.juddi.model.PublisherAssertion();
MappingApiToModel.mapPublisherAssertion(apiPubAssertion, modelPubAssertion);
org.apache.juddi.model.BusinessEntity beFrom = em.find(org.apache.juddi.model.BusinessEntity.class, modelPubAssertion.getId().getFromKey());
org.apache.juddi.model.BusinessEntity beTo = em.find(org.apache.juddi.model.BusinessEntity.class, modelPubAssertion.getId().getToKey());
modelPubAssertion.setBusinessEntityByFromKey(beFrom);
modelPubAssertion.setBusinessEntityByToKey(beTo);
modelPubAssertion.setFromCheck("false");
modelPubAssertion.setToCheck("false");
em.persist(modelPubAssertion);
if (publisher.isOwner(modelPubAssertion.getBusinessEntityByFromKey()))
modelPubAssertion.setFromCheck("true");
if (publisher.isOwner(modelPubAssertion.getBusinessEntityByToKey()))
modelPubAssertion.setToCheck("true");
}
tx.commit();