juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r963108 - in /webservices/juddi/trunk: juddi-client/src/main/java/org/apache/juddi/v3/client/config/ juddi-core/src/main/java/org/apache/juddi/api/impl/
Date Sun, 11 Jul 2010 16:39:55 GMT
Author: kstam
Date: Sun Jul 11 16:39:55 2010
New Revision: 963108

URL: http://svn.apache.org/viewvc?rev=963108&view=rev
Log:
JUDDI-380, Adding more XRegistration functionality

Modified:
    webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
    webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/XRegistration.java
    webservices/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/XRegisterHelper.java

Modified: webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java?rev=963108&r1=963107&r2=963108&view=diff
==============================================================================
--- webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
(original)
+++ webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
Sun Jul 11 16:39:55 2010
@@ -42,11 +42,14 @@ import org.uddi.api_v3.BusinessEntity;
 import org.uddi.api_v3.BusinessService;
 import org.uddi.api_v3.DeleteBinding;
 import org.uddi.api_v3.DispositionReport;
+import org.uddi.api_v3.FindRelatedBusinesses;
 import org.uddi.api_v3.GetAuthToken;
 import org.uddi.api_v3.GetBindingDetail;
 import org.uddi.api_v3.GetBusinessDetail;
 import org.uddi.api_v3.GetServiceDetail;
+import org.uddi.api_v3.RelatedBusinessesList;
 import org.uddi.api_v3.Result;
+import org.uddi.api_v3.SaveBinding;
 import org.uddi.api_v3.SaveBusiness;
 import org.uddi.api_v3.SaveService;
 import org.uddi.api_v3.ServiceDetail;
@@ -107,6 +110,31 @@ public class UDDIClerk implements Serial
 		this.managerName = managerName;
 	}
 	/**
+	 * Register a service binding.
+	 * 
+	 */
+	public BindingTemplate register(BindingTemplate binding, Node node) {
+		
+		BindingTemplate bindingTemplate=null;
+		log.info("Registering bindingTemplate with key " + binding.getBindingKey());
+		try {
+			String authToken = getAuthToken(node.getSecurityUrl());
+			SaveBinding saveBinding = new SaveBinding();
+			saveBinding.setAuthInfo(authToken);
+			saveBinding.getBindingTemplate().add(binding);
+			BindingDetail bindingDetail = getUDDINode().getTransport().getUDDIPublishService(node.getPublishUrl()).saveBinding(saveBinding);
+			bindingTemplate = bindingDetail.getBindingTemplate().get(0);
+		} catch (Exception e) {
+			log.error("Unable to register template binding " + bindingTemplate.getBindingKey()
+					+ " ." + e.getMessage(),e);
+		} catch (Throwable t) {
+			log.error("Unable to register template binding " + bindingTemplate.getBindingKey()
+					+ " ." + t.getMessage(),t);
+		}
+		log.info("Registering template binding " + binding.getBindingKey() + " completed.");
+		return bindingTemplate;
+	}
+	/**
 	 * Register a service.
 	 * 
 	 */
@@ -254,6 +282,37 @@ public class UDDIClerk implements Serial
 		return null;
 	}
 	
+	/**
+	 * Looks up the BusinessEntiry in the registry, will return null if is not found.
+	 * 
+	 * @param businessKey - the key we are looking for
+	 * @param node - the node which is going to be queried
+	 * @return BusinessEntity is found, or null if not found.
+	 * @throws RemoteException
+	 * @throws TransportException
+	 * @throws ConfigurationException
+	 */
+	public RelatedBusinessesList findRelatedBusinesses(String businessKey, Node node) throws
RemoteException, 
+			TransportException, ConfigurationException  {
+		FindRelatedBusinesses findRelatedBusinesses = new FindRelatedBusinesses();
+		findRelatedBusinesses.setBusinessKey(businessKey);
+		findRelatedBusinesses.setAuthInfo(node.getSecurityUrl());
+		try {
+			RelatedBusinessesList rbl = getUDDINode().getTransport().getUDDIInquiryService(node.getInquiryUrl()).findRelatedBusinesses(findRelatedBusinesses);
+			return rbl;
+		} catch (DispositionReportFaultMessage dr) {
+			DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
+			checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
+		} catch (SOAPFaultException sfe) {
+			DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
+			checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
+		} catch (UndeclaredThrowableException ute) {
+			DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
+			checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
+		}
+		return null;
+	}
+	
 	private void checkForErrorInDispositionReport(DispositionReport report, String Error, String
entityKey) {
 		
 		if (report!=null &&report.countainsErrorCode(DispositionReport.E_INVALID_KEY_PASSED))
{

Modified: webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/XRegistration.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/XRegistration.java?rev=963108&r1=963107&r2=963108&view=diff
==============================================================================
--- webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/XRegistration.java
(original)
+++ webservices/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/XRegistration.java
Sun Jul 11 16:39:55 2010
@@ -66,7 +66,7 @@ public class XRegistration {
 		try {
 			businessEntity = fromClerk.findBusiness(entityKey,fromClerk.getUDDINode().getApiNode());
 			log.info("xregister business " + businessEntity.getName().get(0).getValue() + " + from
"
-					+ fromClerk.getName() + " to " + toClerk.getName());
+					+ fromClerk.getName() + " to " + toClerk.getName() + ".");
 			//not bringing over the services. They need to be explicitly copied using xRegisterService.
 			businessEntity.setBusinessServices(null);
 			toClerk.register(businessEntity,toClerk.getUDDINode().getApiNode());
@@ -75,25 +75,42 @@ public class XRegistration {
 		}
 	}
 	
+	/**
+	 * Copies the BusinessInformation from one UDDI to another UDDI.
+	 */
+	public void xRegisterBusinessAndServices() {
+		BusinessEntity businessEntity;
+		try {
+			businessEntity = fromClerk.findBusiness(entityKey,fromClerk.getUDDINode().getApiNode());
+			log.info("xregister business " + businessEntity.getName().get(0).getValue() + " + from
"
+					+ fromClerk.getName() + " to " + toClerk.getName() + " including all services owned
by this business.");
+			toClerk.register(businessEntity,toClerk.getUDDINode().getApiNode());
+		} catch (Exception e) {
+			log.error("Could not " + toString() + ". " + e.getMessage() + " " + e.getCause(),e);
+		}
+	}
+	/**
+	 * Copies the Service from one UDDI to another UDDI.
+	 */
 	public void xRegisterService() {
 		BusinessService businessService;
 		try {
 			businessService = fromClerk.findService(entityKey,fromClerk.getUDDINode().getApiNode());
 			log.info("xregister service " + businessService.getName().get(0).getValue() + " + from
"
 					+ fromClerk.getName() + " to " + toClerk.getName());
+			businessService.setBindingTemplates(null);
 			toClerk.register(businessService,toClerk.getUDDINode().getApiNode());
 		} catch (Exception e) {
 			log.error("Could not " + toString() + ". " + e.getMessage() + " " + e.getCause(),e);
 		}
 	}
-	
-	public void xRegisterServiceBinding() {
+	/**
+	 * Copies the Service from one UDDI to another UDDI along with all the bindingTemplates.
+	 */
+	public void xRegisterServiceAndBindings() {
 		BusinessService businessService;
 		try {
-			BindingTemplate bindingTemplate = fromClerk.findServiceBinding(entityKey,fromClerk.getUDDINode().getApiNode());
-			businessService = fromClerk.findService(bindingTemplate.getServiceKey(),fromClerk.getUDDINode().getApiNode());
-			businessService.getBindingTemplates().getBindingTemplate().clear();
-			businessService.getBindingTemplates().getBindingTemplate().add(bindingTemplate);
+			businessService = fromClerk.findService(entityKey,fromClerk.getUDDINode().getApiNode());
 			log.info("xregister service " + businessService.getName().get(0).getValue() + " + from
"
 					+ fromClerk.getName() + " to " + toClerk.getName());
 			toClerk.register(businessService,toClerk.getUDDINode().getApiNode());
@@ -101,6 +118,19 @@ public class XRegistration {
 			log.error("Could not " + toString() + ". " + e.getMessage() + " " + e.getCause(),e);
 		}
 	}
+	/**
+	 * Copies the TemplateBinding from one UDDI to another UDDI.
+	 */
+	public void xRegisterServiceBinding() {
+		try {
+			BindingTemplate bindingTemplate = fromClerk.findServiceBinding(entityKey,fromClerk.getUDDINode().getApiNode());
+			log.info("xregister binding " + bindingTemplate.getBindingKey()+ " + from "
+					+ fromClerk.getName() + " to " + toClerk.getName());
+			toClerk.register(bindingTemplate,toClerk.getUDDINode().getApiNode());
+		} catch (Exception e) {
+			log.error("Could not " + toString() + ". " + e.getMessage() + " " + e.getCause(),e);
+		}
+	}
 	
 	public String toString() {
 		return " xregister entityKey: " + entityKey + " + from " + fromClerk.getName() + " to "
+ toClerk.getName(); 

Modified: webservices/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/XRegisterHelper.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/XRegisterHelper.java?rev=963108&r1=963107&r2=963108&view=diff
==============================================================================
--- webservices/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/XRegisterHelper.java
(original)
+++ webservices/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/XRegisterHelper.java
Sun Jul 11 16:39:55 2010
@@ -20,7 +20,13 @@ import org.apache.juddi.api_v3.Clerk;
 import org.apache.juddi.v3.client.config.UDDIClerk;
 import org.apache.juddi.v3.client.config.XRegistration;
 import org.apache.log4j.Logger;
+import org.uddi.api_v3.BindingDetail;
+import org.uddi.api_v3.BindingTemplate;
+import org.uddi.api_v3.BusinessDetail;
 import org.uddi.api_v3.BusinessEntity;
+import org.uddi.api_v3.BusinessInfo;
+import org.uddi.api_v3.BusinessService;
+import org.uddi.api_v3.ServiceDetail;
 import org.uddi.api_v3.ServiceInfo;
 import org.uddi.sub_v3.SubscriptionResultsList;
 
@@ -35,25 +41,137 @@ public class XRegisterHelper {
 
 	public static void handle(Clerk fromClerk, Clerk toClerk, SubscriptionResultsList list)
{
 
+		UDDIClerk uddiToClerk = new UDDIClerk(toClerk);
+		UDDIClerk uddiFromClerk = new UDDIClerk(fromClerk);
+		//SERVICE LIST
 		if (list.getServiceList()!=null) {
-
+			log.info("Subscription result for ServiceList with subscription key=" + list.getSubscription().getSubscriptionKey());
 			for (ServiceInfo serviceInfo : list.getServiceList().getServiceInfos().getServiceInfo()
) {
-				UDDIClerk uddiToClerk = new UDDIClerk(toClerk);
+				
+				BusinessEntity existingBusinessEntity = null;
 				try {
-					BusinessEntity existingEntity = uddiToClerk.findBusiness(serviceInfo.getBusinessKey(),
toClerk.getNode());
-					if (existingEntity!=null) {
-						log.info("Found business with key " +  existingEntity.getBusinessKey() + ". No need
to add it again");
+					if (existingBusinessEntity==null) {
+						existingBusinessEntity = uddiToClerk.findBusiness(serviceInfo.getBusinessKey(), toClerk.getNode());
+					}
+					if (existingBusinessEntity!=null) {
+						log.debug("Found business with key " +  existingBusinessEntity.getBusinessKey() + ".
No need to add it again");
 					} else {
 						log.info("Business was not found in the destination UDDI " + toClerk.getNode().getName()

 								+ ", going to add it in.");
 						new XRegistration(serviceInfo.getBusinessKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterBusiness();
 					}
-					new XRegistration(serviceInfo.getServiceKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterService();
+					new XRegistration(serviceInfo.getServiceKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterServiceAndBindings();
+				} catch (Exception e) {
+					log.error(e.getMessage(),e);	
+				}
+			}
+		}
+		//SERVICE DETAIL
+		if (list.getServiceDetail()!=null) {
+			log.info("Subscription result for ServiceDetail with subscription key=" + list.getSubscription().getSubscriptionKey());
+			ServiceDetail serviceDetail = list.getServiceDetail();
+			if (serviceDetail.isTruncated()) {
+				log.info("The serviceDetail is truncated, the maxEntries must have been hit. The number
of services is " + serviceDetail.getBusinessService().size());
+			}
+			for (BusinessService service : serviceDetail.getBusinessService()) {
+				BusinessEntity existingBusinessEntity = null;
+				try {
+					if (existingBusinessEntity==null) {
+						existingBusinessEntity = uddiToClerk.findBusiness(service.getBusinessKey(), toClerk.getNode());
+					}
+					if (existingBusinessEntity!=null) {
+						log.debug("Found business with key " +  existingBusinessEntity.getBusinessKey() + ".
No need to add it again");
+					} else {
+						log.info("Business was not found in the destination UDDI " + toClerk.getNode().getName()

+								+ ", going to add it in.");
+						new XRegistration(service.getBusinessKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterBusiness();
+					}
+					new XRegistration(service.getServiceKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterServiceAndBindings();
+				} catch (Exception e) {
+					log.error(e.getMessage(),e);	
+				}
+			}
+		}
+		
+		//BUSINESS LIST
+		if (list.getBusinessList()!=null) {
+			log.info("Subscription result for BusinessList with subscription key=" + list.getSubscription().getSubscriptionKey());
+			for (BusinessInfo businessInfo : list.getBusinessList().getBusinessInfos().getBusinessInfo())
{
+				new XRegistration(businessInfo.getBusinessKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterBusinessAndServices();
+			}
+		}
+		
+		//BUSINESS DETAIL
+		if (list.getBusinessDetail()!=null) {
+			log.info("Subscription result for BusinessDetail with subscription key=" + list.getSubscription().getSubscriptionKey());
+			BusinessDetail businessDetail = list.getBusinessDetail();
+			if (businessDetail.isTruncated()) {
+				log.info("The businessDetail is truncated, the maxEntries must have been hit. The number
of businesses is " + businessDetail.getBusinessEntity().size());
+			}
+			for (BusinessEntity businessEntity : businessDetail.getBusinessEntity()) {
+				new XRegistration(businessEntity.getBusinessKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterBusinessAndServices();
+			}
+		}
+		
+		//KEY BAG, NOT IMPLEMENTED
+		if (list.getKeyBag()!=null) {
+			log.info("Returning results when a 'brief' format is selected, please do not use 'brief'
results when using the XRegistration functionality");
+		}
+		
+		//BINDING DETAIL
+		if (list.getBindingDetail()!=null) {
+			log.info("Subscription result for BindingDetail with subscription key=" + list.getSubscription().getSubscriptionKey());
+			BindingDetail bindingDetail = list.getBindingDetail();
+			if (bindingDetail.isTruncated()) {
+				log.info("The bindingDetail is truncated, the maxEntries must have been hit. The number
of bindings is " + bindingDetail.getBindingTemplate().size());
+			}
+			for (BindingTemplate bindingTemplate : bindingDetail.getBindingTemplate()) {
+				try {
+					//check if the service exist
+					BusinessService existingToService = uddiToClerk.findService(bindingTemplate.getServiceKey(),
toClerk.getNode());
+					if (existingToService!=null) {
+						log.debug("Found service with key " +  existingToService.getServiceKey() + ". No need
to add it again");
+					} else {
+						BusinessService fromService = uddiFromClerk.findService(bindingTemplate.getServiceKey(),
fromClerk.getNode());
+						fromService.getBusinessKey();
+						//check if the business exist
+						BusinessEntity existingBusinessEntity = uddiToClerk.findBusiness(fromService.getBusinessKey(),
toClerk.getNode());
+						if (existingBusinessEntity!=null) {
+							log.debug("Found business with key " +  existingBusinessEntity.getBusinessKey() +
". No need to add it again");
+						} else {
+							log.info("Business was not found in the destination UDDI " + toClerk.getNode().getName()

+									+ ", going to add it in.");
+							new XRegistration(fromService.getBusinessKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterBusiness();
+						}
+						log.info("Service was not found in the destination UDDI " + toClerk.getNode().getName()

+								+ ", going to add it in.");
+						new XRegistration(fromService.getServiceKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterService();
+					} 
+					//now the service exists in the toNode and we can add this binding
+					new XRegistration(bindingTemplate.getBindingKey(), new UDDIClerk(fromClerk), new UDDIClerk(toClerk)).xRegisterServiceBinding();
 				} catch (Exception e) {
 					log.error(e.getMessage(),e);	
 				}
 			}
 		}
+		
+		//RELATED BUSINESSES
+		if (list.getRelatedBusinessesList()!=null) {
+			log.info("Subscription result for RelatedBusinesses with subscription key=" + list.getSubscription().getSubscriptionKey());
+			log.info("The jUDDI Listener is not doing anything with this subscription at this moment");
+		}
+		
+		//ASSERTION STATUS REPORT
+		if (list.getAssertionStatusReport()!=null) {
+			log.info("Subscription result for AssertionStatusReport with subscription key=" + list.getSubscription().getSubscriptionKey());
+			log.info("The jUDDI Listener is not doing anything with this subscription at this moment");
+		}
+		
+		//TMODELS
+		if (list.getTModelList()!=null ){
+			log.info("Subscription result for tModelList with subscription key=" + list.getSubscription().getSubscriptionKey());
+			log.info("The jUDDI Listener is not doing anything with this subscription at this moment");
+		}
 	}
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org


Mime
View raw message