You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2011/05/23 19:00:17 UTC

svn commit: r1126582 - in /juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client: config/ClientConfig.java config/Property.java config/UDDIClerk.java mapping/BPEL2UDDI.java

Author: kstam
Date: Mon May 23 17:00:16 2011
New Revision: 1126582

URL: http://svn.apache.org/viewvc?rev=1126582&view=rev
Log:
JUDDI-475, adding support for BPEL

Modified:
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/BPEL2UDDI.java

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java?rev=1126582&r1=1126581&r2=1126582&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java Mon May 23 17:00:16 2011
@@ -187,7 +187,7 @@ public class ClientConfig 
 	throws ConfigurationException {
 		String[] entityKeys = config.getStringArray("manager.clerks.xregister." + entityType + "[@entityKey]");
 		Set<XRegistration> xRegistrations = new HashSet<XRegistration>();
-		log.info("XRegistration " + entityKeys.length + " " + entityType + "Keys");
+		if (entityKeys.length > 0) log.info("XRegistration " + entityKeys.length + " " + entityType + "Keys");
 		for (int i=0; i<entityKeys.length; i++) {
 			XRegistration xRegistration = new XRegistration();
 			xRegistration.setEntityKey(config.getString("manager.clerks.xregister." + entityType + "(" + i + ")[@entityKey]"));

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java?rev=1126582&r1=1126581&r2=1126582&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java Mon May 23 17:00:16 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.juddi.v3.client.config;
 
+import java.net.URL;
 import java.util.Properties;
 
 import javax.xml.namespace.QName;
@@ -37,6 +38,7 @@ public class Property 
 	public static final String SERVICE_KEY_FORMAT               = "bpelServiceKeyFormat";
 	public static final String BUSINESS_KEY_FORMAT              = "businessKeyFormat";
 	public static final String BINDING_KEY_FORMAT               = "bindingKeyFormat";
+	public static final String SUBSCRIPTION_KEY_FORMAT          = "subscriptionKeyFormat";
 	public static final String SERVICE_DESCRIPTION              = "serviceDescription";
 	public static final String BINDING_DESCRIPTION              = "bindingDescription";
 	public static final String SERVICE_CATEGORY_BAG             = "serviceCategoryBag";
@@ -44,9 +46,10 @@ public class Property 
 	
 	//Default Values
 	public static final String DEFAULT_LANG                     = "en:";
-	public static final String DEFAULT_BUSINESS_KEY_FORMAT      = "uddi:${keyDomain}:${businessName}";
-	public static final String DEFAULT_SERVICE_KEY_FORMAT       = "uddi:${keyDomain}:${serviceName}";
-	public static final String DEFAULT_BINDING_KEY_FORMAT       = "uddi:${keyDomain}:${nodeName}_${serviceName}_${portName}";
+	public static final String DEFAULT_BUSINESS_KEY_FORMAT      = "uddi:${keyDomain}:business_${businessName}";
+	public static final String DEFAULT_SERVICE_KEY_FORMAT       = "uddi:${keyDomain}:service_${serviceName}";
+	public static final String DEFAULT_SUBSCRIPTION_KEY_FORMAT  = "uddi:${keyDomain}:service_cache_${nodeName}";
+	public static final String DEFAULT_BINDING_KEY_FORMAT       = "uddi:${keyDomain}:binding_${nodeName}_${serviceName}_${portName}_${port}";
 	public static final String DEFAULT_SERVICE_DESCRIPTION      = "Default service description when no <wsdl:document> element is defined inside the <wsdl:service> element.";
 	public static final String DEFAULT_BINDING_DESCRIPTION      = "Default binding description when no <wsdl:document> element is defined inside the <wsdl:binding> element.";
 	/**
@@ -62,6 +65,12 @@ public class Property 
 		String businessKey = TokenResolver.replaceTokens(keyFormat, properties).toLowerCase();
 		return businessKey;
 	}
+	
+	public static String getSubscriptionKey(Properties properties) {
+		String keyFormat = properties.getProperty(SUBSCRIPTION_KEY_FORMAT, DEFAULT_SUBSCRIPTION_KEY_FORMAT);
+		String subscriptionKey = TokenResolver.replaceTokens(keyFormat, properties).toLowerCase();
+		return subscriptionKey;
+	}
 	/**
 	 * Constructs the serviceKey based on the serviceKeyFormat specified in the properties. When no
 	 * serviceKeyFormat is specific the default format of uddi:${keyDomain}:${serviceName} is used.
@@ -70,10 +79,10 @@ public class Property 
 	 * @param serviceName
 	 * @return the serviceKey
 	 */
-	public static String getServiceKey(Properties properties, QName serviceName) {
+	public static String getServiceKey(Properties properties, QName serviceQName) {
 		Properties tempProperties = new Properties();
 		tempProperties.putAll(properties);
-		tempProperties.put("serviceName", serviceName.getLocalPart());
+		tempProperties.put("serviceName", serviceQName.getLocalPart());
 		//Constructing the serviceKey
 		String keyFormat = tempProperties.getProperty(SERVICE_KEY_FORMAT, DEFAULT_SERVICE_KEY_FORMAT);
 		String serviceKey = TokenResolver.replaceTokens(keyFormat, tempProperties).toLowerCase();
@@ -88,11 +97,20 @@ public class Property 
 	 * @param portName
 	 * @return the bindingKey
 	 */
-	public static String getBindingKey(Properties properties, QName serviceName, String portName) {
+	public static String getBindingKey(Properties properties, QName serviceName, String portName, URL bindingUrl) {
 		Properties tempProperties = new Properties();
 		tempProperties.putAll(properties);
 		tempProperties.put("serviceName", serviceName.getLocalPart());
 		tempProperties.put("portName", portName);
+		int port = bindingUrl.getPort();
+		if (port==-1) {
+			if ("http".equals(bindingUrl.getProtocol())) {
+				port = 80;
+			} else if ("https".equals(bindingUrl.getProtocol())) {
+				port = 443;
+			}
+		}
+		tempProperties.put("port", port);
 		//Constructing the binding Key
 		String keyFormat = properties.getProperty(BINDING_KEY_FORMAT, DEFAULT_BINDING_KEY_FORMAT);
 		String bindingKey = TokenResolver.replaceTokens(keyFormat, tempProperties).toLowerCase();

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java?rev=1126582&r1=1126581&r2=1126582&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java Mon May 23 17:00:16 2011
@@ -19,11 +19,14 @@ package org.apache.juddi.v3.client.confi
 import java.io.Serializable;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import javax.xml.ws.Holder;
 import javax.xml.ws.soap.SOAPFaultException;
 
 import org.apache.commons.configuration.ConfigurationException;
@@ -44,6 +47,7 @@ import org.uddi.api_v3.BusinessService;
 import org.uddi.api_v3.DeleteBinding;
 import org.uddi.api_v3.DeleteService;
 import org.uddi.api_v3.DeleteTModel;
+import org.uddi.api_v3.DiscardAuthToken;
 import org.uddi.api_v3.DispositionReport;
 import org.uddi.api_v3.FindRelatedBusinesses;
 import org.uddi.api_v3.FindTModel;
@@ -62,6 +66,8 @@ import org.uddi.api_v3.ServiceDetail;
 import org.uddi.api_v3.TModel;
 import org.uddi.api_v3.TModelDetail;
 import org.uddi.api_v3.TModelList;
+import org.uddi.sub_v3.DeleteSubscription;
+import org.uddi.sub_v3.Subscription;
 import org.uddi.v3_service.DispositionReportFaultMessage;
 
 public class UDDIClerk implements Serializable {
@@ -74,6 +80,7 @@ public class UDDIClerk implements Serial
 	protected String publisher;
 	protected String password;
 	
+	private Date tokenBirthDate;
 	private String authToken;
 	private String[] classWithAnnotations;
 	private String managerName;
@@ -118,6 +125,35 @@ public class UDDIClerk implements Serial
 	public void setManagerName(String managerName) {
 		this.managerName = managerName;
 	}
+	
+	public Subscription register(Subscription subscription) {
+		return register(subscription, this.getUDDINode().getApiNode());
+	}
+	/**
+	 * Register a Subscription.
+	 */
+	public Subscription register(Subscription subscription, Node node) {
+		
+		log.info("Registering subscription with key " + subscription.getSubscriptionKey());
+		Holder<List<Subscription>> holder = new Holder<List<Subscription>>();
+		try {
+			String authToken = getAuthToken(node.getSecurityUrl());
+			
+			List<Subscription> subscriptions = new ArrayList<Subscription>();
+			subscriptions.add(subscription);
+			holder.value = subscriptions;
+			getUDDINode().getTransport().getUDDISubscriptionService(node.getSubscriptionUrl()).saveSubscription(authToken, holder);
+		} catch (Exception e) {
+			log.error("Unable to register subscription " +  subscription.getSubscriptionKey()
+					+ " ." + e.getMessage(),e);
+		} catch (Throwable t) {
+			log.error("Unable to register subscriptionl " +  subscription.getSubscriptionKey()
+					+ " ." + t.getMessage(),t);
+		}
+		log.info("Registering subscription " +  subscription.getSubscriptionKey() + " completed.");
+		subscription = holder.value.get(0);
+		return subscription;
+	}
 	/**
 	 * Register a tModel, using the node of current clerk ('this').
 	 * 
@@ -309,6 +345,25 @@ public class UDDIClerk implements Serial
 		}
 	}
 	
+	public void unRegisterSubscription(String subscriptionKey) {
+		unRegisterSubscription(subscriptionKey, this.getUDDINode().getApiNode());
+	}
+	
+	public void unRegisterSubscription(String subscriptionKey, Node node) {
+		log.info("UnRegistering subscription with key " + subscriptionKey);
+		try {
+			String authToken = getAuthToken(node.getSecurityUrl());
+			DeleteSubscription deleteSubscription = new DeleteSubscription();
+			deleteSubscription.setAuthInfo(authToken);
+			deleteSubscription.getSubscriptionKey().add(subscriptionKey);
+			getUDDINode().getTransport().getUDDISubscriptionService(node.getSubscriptionUrl()).deleteSubscription(deleteSubscription);
+		} catch (Exception e) {
+			log.error("Unable to unregister subscription key " + subscriptionKey
+					+ " ." + e.getMessage(),e);
+		}
+	}
+	
+	
 	public TModelList findTModel(FindTModel findTModel) throws RemoteException, ConfigurationException, TransportException {
 		return findTModel(findTModel, this.getUDDINode().getApiNode());
 	}
@@ -333,6 +388,12 @@ public class UDDIClerk implements Serial
 		return null;
 	}
 	
+	public TModelDetail getTModelDetail(String tModelKey) throws RemoteException, ConfigurationException, TransportException {
+		GetTModelDetail getTModelDetail = new GetTModelDetail();
+		getTModelDetail.getTModelKey().add(tModelKey);
+		return getTModelDetail(getTModelDetail);
+	}
+	
 	public TModelDetail getTModelDetail(GetTModelDetail getTModelDetail) throws RemoteException, ConfigurationException, TransportException {
 		return getTModelDetail(getTModelDetail, this.getUDDINode().getApiNode());
 	}
@@ -496,7 +557,15 @@ public class UDDIClerk implements Serial
 	}
 	
 	private String getAuthToken(String endpointURL) throws TransportException, DispositionReportFaultMessage, RemoteException {
+		//if the token is older then 10 minutes discard it, and create a new one.
+		if (tokenBirthDate !=null && System.currentTimeMillis() > tokenBirthDate.getTime() + 600000 ) {
+			DiscardAuthToken discardAuthToken = new DiscardAuthToken();
+			discardAuthToken.setAuthInfo(authToken);
+			getUDDINode().getTransport().getUDDISecurityService(endpointURL).discardAuthToken(discardAuthToken);
+			authToken=null;
+		}
 		if (authToken==null) {
+			tokenBirthDate = new Date();
 			GetAuthToken getAuthToken = new GetAuthToken();
 			getAuthToken.setUserID(getPublisher());
 			getAuthToken.setCred(getPassword());

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/BPEL2UDDI.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/BPEL2UDDI.java?rev=1126582&r1=1126581&r2=1126582&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/BPEL2UDDI.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/BPEL2UDDI.java Mon May 23 17:00:16 2011
@@ -102,7 +102,7 @@ public class BPEL2UDDI extends Annotatio
 		this.businessKey = Property.getBusinessKey(properties);
 		this.lang = properties.getProperty(Property.LANG,Property.DEFAULT_LANG);
 		
-		this.wsdl2UDDI = new WSDL2UDDI(properties);
+		this.wsdl2UDDI = new WSDL2UDDI(clerk, urlLocalizer, properties);
 	}
 	
 	public String getKeyDomainURI() {
@@ -155,7 +155,7 @@ public class BPEL2UDDI extends Annotatio
 	 * @throws RemoteException 
 	 */
 	@SuppressWarnings("unchecked")
-	public void register(QName serviceName, String portName, URL serviceUrl, Definition wsdlDefinition) 
+	public BindingTemplate register(QName serviceName, String portName, URL serviceUrl, Definition wsdlDefinition) 
 		throws WSDLException, MalformedURLException, RemoteException, ConfigurationException, TransportException 
 	{
 		String targetNamespace = wsdlDefinition.getTargetNamespace();
@@ -187,15 +187,16 @@ public class BPEL2UDDI extends Annotatio
 		//Add the BindingTemplate to this Service
 		BindingTemplate binding = createBPELBinding(serviceName, portName, serviceUrl, wsdlDefinition);
 		// Register BindingTemplate
-		clerk.register(binding); 
+		clerk.register(binding);
+		return binding;
 	}
 	
-	public void unRegister(QName serviceName, String portName) throws RemoteException, ConfigurationException, TransportException {
+	public String unRegister(QName serviceName, String portName, URL serviceUrl) throws RemoteException, ConfigurationException, TransportException {
 		
 		String serviceKey = Property.getServiceKey(properties, serviceName);
 		BusinessService service = lookupService(serviceKey);
 		boolean isRemoveServiceIfNoTemplates = true; 
-		String bindingKey = Property.getBindingKey(properties, serviceName, portName);
+		String bindingKey = Property.getBindingKey(properties, serviceName, portName, serviceUrl);
 		//check if this bindingKey is in the service's binding templates
 		for (BindingTemplate bindingTemplate : service.getBindingTemplates().getBindingTemplate()) {
 			if (bindingKey.equals(bindingTemplate.getBindingKey())) {
@@ -247,19 +248,12 @@ public class BPEL2UDDI extends Annotatio
  								}
 							}
 						}
-						
-						System.out.println("done");
-						
 					}
-					
-					//also unRegister the related tModels
-					//first obtain the wsdl for this binding/service, so that we can derive the tModelKeys
-					//or know to run a find tModels
 				}
 				break;
 			}
 		}
-			
+		return service.getServiceKey();	
 	}
 	/**
 	 * Perform a lookup by serviceKey, and will return null if not found.
@@ -395,7 +389,7 @@ public class BPEL2UDDI extends Annotatio
 		// Set BusinessService Key
 		bindingTemplate.setServiceKey(Property.getServiceKey(properties, serviceName));
 		// Set Binding Key
-		String bindingKey = Property.getBindingKey(properties, serviceName, portName);
+		String bindingKey = Property.getBindingKey(properties, serviceName, portName, serviceUrl);
 		bindingTemplate.setBindingKey(bindingKey);
 		// Set AccessPoint
 		AccessPoint accessPoint = new AccessPoint();
@@ -538,7 +532,7 @@ public class BPEL2UDDI extends Annotatio
     /**
      * Find all portTypes used in the given process. This should return the 
      * tModel registration for the process tModel. The tModelKeys for the 
-     * portTypes used in the process can be obtained from the process tModelÕs 
+     * portTypes used in the process can be obtained from the process tModels 
      * categoryBag, and passed into the second call.
      * 
      * @param processKey



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