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/13 17:17:48 UTC
svn commit: r1102787 - in /juddi/trunk/juddi-client/src:
main/java/org/apache/juddi/v3/client/config/
main/java/org/apache/juddi/v3/client/mapping/
test/java/org/apache/juddi/v3/client/mapping/ test/resources/bpel/
Author: kstam
Date: Fri May 13 15:17:43 2011
New Revision: 1102787
URL: http://svn.apache.org/viewvc?rev=1102787&view=rev
Log:
JUDDI-475 adding mapping from BPEL to UDDI
Added:
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/BPEL2UDDI.java
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizer.java
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizerImpl.java
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/BPEL2UDDITest.java
juddi/trunk/juddi-client/src/test/resources/bpel/
juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.bpel
juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.wsdl
juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.bpel
juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.wsdl
Modified:
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/config/UDDIClerkManager.java
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClientContainer.java
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=1102787&r1=1102786&r2=1102787&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 Fri May 13 15:17:43 2011
@@ -43,18 +43,25 @@ import org.uddi.api_v3.BusinessEntity;
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.DispositionReport;
import org.uddi.api_v3.FindRelatedBusinesses;
+import org.uddi.api_v3.FindTModel;
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.GetTModelDetail;
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.SaveTModel;
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.v3_service.DispositionReportFaultMessage;
public class UDDIClerk implements Serializable {
@@ -112,7 +119,46 @@ public class UDDIClerk implements Serial
this.managerName = managerName;
}
/**
- * Register a service binding.
+ * Register a tModel, using the node of current clerk ('this').
+ *
+ * @param tModel
+ * @return the TModelDetail of the newly registered TModel
+ */
+ public TModelDetail register(TModel tModel) {
+ return register(tModel, this.getUDDINode().getApiNode());
+ }
+ /**
+ * Register a tModel.
+ */
+ public TModelDetail register(TModel tModel, Node node) {
+ TModelDetail tModelDetail = null;
+ log.info("Registering tModel with key " + tModel.getTModelKey());
+ try {
+ String authToken = getAuthToken(node.getSecurityUrl());
+ SaveTModel saveTModel = new SaveTModel();
+ saveTModel.setAuthInfo(authToken);
+ saveTModel.getTModel().add(tModel);
+ tModelDetail = getUDDINode().getTransport().getUDDIPublishService(node.getPublishUrl()).saveTModel(saveTModel);
+ } catch (Exception e) {
+ log.error("Unable to register tModel " + tModel.getTModelKey()
+ + " ." + e.getMessage(),e);
+ } catch (Throwable t) {
+ log.error("Unable to register tModel " + tModel.getTModelKey()
+ + " ." + t.getMessage(),t);
+ }
+ log.info("Registering tModel " + tModel.getTModelKey() + " completed.");
+ return tModelDetail;
+ }
+
+ /**
+ * Register a BindingTemplate, using the node of current clerk ('this').
+ *
+ */
+ public BindingTemplate register(BindingTemplate binding) {
+ return register(binding, this.getUDDINode().getApiNode());
+ }
+ /**
+ * Register a BindingTemplate.
*
*/
public BindingTemplate register(BindingTemplate binding, Node node) {
@@ -137,6 +183,13 @@ public class UDDIClerk implements Serial
return bindingTemplate;
}
/**
+ * Register a service, using the node of current clerk ('this').
+ *
+ */
+ public BusinessService register(BusinessService service) {
+ return register(service, this.getUDDINode().getApiNode());
+ }
+ /**
* Register a service.
*
*/
@@ -162,6 +215,9 @@ public class UDDIClerk implements Serial
log.info("Registering service " + service.getName().get(0).getValue() + " completed.");
return businessService;
}
+ public BusinessEntity register(BusinessEntity business) {
+ return register(business, this.getUDDINode().getApiNode());
+ }
/**
* Register a service.
*
@@ -188,25 +244,9 @@ public class UDDIClerk implements Serial
log.info("Registering businessEntity " + businessEntity.getName().get(0).getValue() + " completed.");
return businessEntity;
}
- /**
- * Unregisters the BindingTemplates for this service.
- * @param service
- * @deprecated use {@link UDDIClerk.unRegisterService}
- */
- public void unRegister(BusinessService service, Node node) {
- log.info("UnRegistering binding for service " + service.getName().get(0).getValue());
- try {
- String authToken = getAuthToken(node.getSecurityUrl());
- DeleteBinding deleteBinding = new DeleteBinding();
- deleteBinding.setAuthInfo(authToken);
- for (BindingTemplate binding : service.getBindingTemplates().getBindingTemplate()) {
- deleteBinding.getBindingKey().add(binding.getBindingKey());
- }
- getUDDINode().getTransport().getUDDIPublishService(node.getPublishUrl()).deleteBinding(deleteBinding);
- } catch (Exception e) {
- log.error("Unable to register service " + service.getName().get(0).getValue()
- + " ." + e.getMessage(),e);
- }
+
+ public void unRegisterService(String serviceKey) {
+ unRegisterService(serviceKey, this.getUDDINode().getApiNode());
}
/**
* Unregisters the service with specified serviceKey.
@@ -225,7 +265,9 @@ public class UDDIClerk implements Serial
+ " ." + e.getMessage(),e);
}
}
-
+ public void unRegisterBinding(String bindingKey) {
+ unRegisterBinding(bindingKey, this.getUDDINode().getApiNode());
+ }
/**
* Unregisters the BindingTemplate with specified bindingKey.
* @param bindingTemplate
@@ -244,7 +286,81 @@ public class UDDIClerk implements Serial
+ " ." + e.getMessage(),e);
}
}
-
+
+ public void unRegisterTModel(String tModelKey) {
+ unRegisterTModel(tModelKey, this.getUDDINode().getApiNode());
+ }
+ /**
+ * Unregisters the BindingTemplate with specified bindingKey.
+ * @param bindingTemplate
+ * @param node
+ */
+ public void unRegisterTModel(String tModelKey, Node node) {
+ log.info("UnRegistering tModel key " + tModelKey);
+ try {
+ String authToken = getAuthToken(node.getSecurityUrl());
+ DeleteTModel deleteTModel = new DeleteTModel();
+ deleteTModel.setAuthInfo(authToken);
+ deleteTModel.getTModelKey().add(tModelKey);
+ getUDDINode().getTransport().getUDDIPublishService(node.getPublishUrl()).deleteTModel(deleteTModel);
+ } catch (Exception e) {
+ log.error("Unable to unregister tModelkey " + tModelKey
+ + " ." + e.getMessage(),e);
+ }
+ }
+
+ public TModelList findTModel(FindTModel findTModel) throws RemoteException, ConfigurationException, TransportException {
+ return findTModel(findTModel, this.getUDDINode().getApiNode());
+ }
+
+ public TModelList findTModel(FindTModel findTModel, Node node) throws RemoteException,
+ TransportException, ConfigurationException {
+
+ findTModel.setAuthInfo(getAuthToken(node.getSecurityUrl()));
+ try {
+ TModelList tModelList = getUDDINode().getTransport().getUDDIInquiryService(node.getInquiryUrl()).findTModel(findTModel);
+ return tModelList;
+ } catch (DispositionReportFaultMessage dr) {
+ DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
+ checkForErrorInDispositionReport(report, null, null);
+ } catch (SOAPFaultException sfe) {
+ DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
+ checkForErrorInDispositionReport(report, null, null);
+ } catch (UndeclaredThrowableException ute) {
+ DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
+ checkForErrorInDispositionReport(report, null, null);
+ }
+ return null;
+ }
+
+ public TModelDetail getTModelDetail(GetTModelDetail getTModelDetail) throws RemoteException, ConfigurationException, TransportException {
+ return getTModelDetail(getTModelDetail, this.getUDDINode().getApiNode());
+ }
+
+ public TModelDetail getTModelDetail(GetTModelDetail getTModelDetail, Node node) throws RemoteException,
+ TransportException, ConfigurationException {
+
+ getTModelDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));
+ try {
+ TModelDetail tModelDetail = getUDDINode().getTransport().getUDDIInquiryService(node.getInquiryUrl()).getTModelDetail(getTModelDetail);
+ return tModelDetail;
+ } catch (DispositionReportFaultMessage dr) {
+ DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
+ checkForErrorInDispositionReport(report, null, null);
+ } catch (SOAPFaultException sfe) {
+ DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
+ checkForErrorInDispositionReport(report, null, null);
+ } catch (UndeclaredThrowableException ute) {
+ DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
+ checkForErrorInDispositionReport(report, null, null);
+ }
+ return null;
+ }
+
+ public BusinessService findService(String serviceKey) throws RemoteException,
+ TransportException, ConfigurationException {
+ return findService(serviceKey, this.getUDDINode().getApiNode());
+ }
public BusinessService findService(String serviceKey, Node node) throws RemoteException,
TransportException, ConfigurationException {
@@ -269,6 +385,11 @@ public class UDDIClerk implements Serial
return null;
}
+ public BindingTemplate findServiceBinding(String bindingKey) throws DispositionReportFaultMessage, RemoteException,
+ TransportException, ConfigurationException {
+ return findServiceBinding(bindingKey, this.getUDDINode().getApiNode());
+ }
+
public BindingTemplate findServiceBinding(String bindingKey, Node node) throws DispositionReportFaultMessage, RemoteException,
TransportException, ConfigurationException {
GetBindingDetail getBindingDetail = new GetBindingDetail();
@@ -291,6 +412,12 @@ public class UDDIClerk implements Serial
}
return null;
}
+
+ public BusinessEntity findBusiness(String businessKey) throws RemoteException,
+ TransportException, ConfigurationException {
+ return findBusiness(businessKey, this.getUDDINode().getApiNode());
+ }
+
/**
* Looks up the BusinessEntiry in the registry, will return null if is not found.
*
@@ -355,7 +482,7 @@ public class UDDIClerk implements Serial
private void checkForErrorInDispositionReport(DispositionReport report, String Error, String entityKey) {
- if (report!=null &&report.countainsErrorCode(DispositionReport.E_INVALID_KEY_PASSED)) {
+ if (entityKey!=null && report!=null && report.countainsErrorCode(DispositionReport.E_INVALID_KEY_PASSED)) {
log.info("entityKey " + entityKey + " was not found in the registry");
} else {
if (report == null) {
Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerkManager.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerkManager.java?rev=1102787&r1=1102786&r2=1102787&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerkManager.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerkManager.java Fri May 13 15:17:43 2011
@@ -78,16 +78,17 @@ public class UDDIClerkManager {
*/
public void start() throws ConfigurationException {
- UDDIClientContainer.addClerkManager(this);
- //If running in embedded mode
- if (InVMTransport.class.getCanonicalName().equals(getClientConfig().getHomeNode().getProxyTransport())) {
- log.info("Starting embedded Server");
- startEmbeddedServer();
+ if (UDDIClientContainer.addClerkManager(this)) {
+ //If running in embedded mode
+ if (InVMTransport.class.getCanonicalName().equals(getClientConfig().getHomeNode().getProxyTransport())) {
+ log.info("Starting embedded Server");
+ startEmbeddedServer();
+ }
+
+ Runnable runnable = new BackGroundRegistration(this);
+ Thread thread = new Thread(runnable);
+ thread.start();
}
-
- Runnable runnable = new BackGroundRegistration(this);
- Thread thread = new Thread(runnable);
- thread.start();
}
protected void startEmbeddedServer() throws ConfigurationException {
@@ -257,6 +258,7 @@ public class UDDIClerkManager {
return clientConfig.getManagerName();
}
/**
+ * @deprecated, use the getTransport(String nodeName) instead.
* Returns the "default" jUDDI nodes Transport.
*
* @return
Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClientContainer.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClientContainer.java?rev=1102787&r1=1102786&r2=1102787&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClientContainer.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClientContainer.java Fri May 13 15:17:43 2011
@@ -49,8 +49,13 @@ public class UDDIClientContainer {
}
}
- public static void addClerkManager(UDDIClerkManager manager) {
- managers.put(manager.getClientConfig().getManagerName(), manager);
+ public static boolean addClerkManager(UDDIClerkManager manager) {
+ if (!managers.containsKey(manager.getClientConfig().getManagerName())) {
+ managers.put(manager.getClientConfig().getManagerName(), manager);
+ return true;
+ } else {
+ return false;
+ }
}
public static void removeClerkManager(String managerName)
Added: 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=1102787&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/BPEL2UDDI.java (added)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/BPEL2UDDI.java Fri May 13 15:17:43 2011
@@ -0,0 +1,578 @@
+/*
+ * Copyright 2001-2011 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.juddi.v3.client.mapping;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.api_v3.AccessPointType;
+import org.apache.juddi.jaxb.PrintUDDI;
+import org.apache.juddi.v3.annotations.AnnotationProcessor;
+import org.apache.juddi.v3.client.config.Property;
+import org.apache.juddi.v3.client.config.UDDIClerk;
+import org.apache.juddi.v3.client.transport.TransportException;
+import org.uddi.api_v3.AccessPoint;
+import org.uddi.api_v3.BindingTemplate;
+import org.uddi.api_v3.BusinessService;
+import org.uddi.api_v3.CategoryBag;
+import org.uddi.api_v3.Description;
+import org.uddi.api_v3.FindBinding;
+import org.uddi.api_v3.FindTModel;
+import org.uddi.api_v3.GetTModelDetail;
+import org.uddi.api_v3.InstanceDetails;
+import org.uddi.api_v3.KeyedReference;
+import org.uddi.api_v3.Name;
+import org.uddi.api_v3.OverviewDoc;
+import org.uddi.api_v3.OverviewURL;
+import org.uddi.api_v3.TModel;
+import org.uddi.api_v3.TModelBag;
+import org.uddi.api_v3.TModelDetail;
+import org.uddi.api_v3.TModelInfo;
+import org.uddi.api_v3.TModelInstanceDetails;
+import org.uddi.api_v3.TModelInstanceInfo;
+import org.uddi.api_v3.TModelList;
+import org.w3c.dom.Element;
+
+
+/**
+ * BPEL4WS abstract processes describe the observable behavior of Web services. They
+ * complement abstract WSDL interfaces (port types and operations) and the UDDI model
+ * by defining dependencies between service operations in the context of a message
+ * exchange. The technical note 'uddi-spec-tc-tn-bpel' describes the relationships
+ * between the three models and suggests how BPEL4WS abstract processes can be used
+ * in a UDDI Registry. This class implements the registrations suggestions as put
+ * forward in the technote.
+ *
+ * * @author Kurt T Stam <ku...@apache.org>
+ *
+ */
+public class BPEL2UDDI extends AnnotationProcessor {
+
+ private Log log = LogFactory.getLog(this.getClass());
+
+ private String keyDomainURI;
+ private UDDIClerk clerk;
+ private String lang;
+ private URLLocalizer urlLocalizer;
+ private String businessKey;
+ private Properties properties = new Properties();
+
+ private WSDL2UDDI wsdl2UDDI;
+
+ public BPEL2UDDI(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties) {
+ super();
+
+ this.clerk = clerk;
+ this.urlLocalizer = urlLocalizer;
+ this.properties = properties;
+
+ //Obtaining values from the properties
+ this.keyDomainURI = "uddi:" + properties.getProperty("keyDomain") + ":";
+ this.businessKey = Property.getBusinessKey(properties);
+ this.lang = properties.getProperty(Property.LANG,Property.DEFAULT_LANG);
+
+ this.wsdl2UDDI = new WSDL2UDDI(properties);
+ }
+
+ public String getKeyDomainURI() {
+ return keyDomainURI;
+ }
+
+ public void setKeyDomainURI(String keyDomainURI) {
+ this.keyDomainURI = keyDomainURI;
+ }
+
+ public UDDIClerk getClerk() {
+ return clerk;
+ }
+
+ public void setClerk(UDDIClerk clerk) {
+ this.clerk = clerk;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(String lang) {
+ this.lang = lang;
+ }
+
+ public URLLocalizer getUrlLocalizer() {
+ return urlLocalizer;
+ }
+
+ public void setUrlLocalizer(URLLocalizer urlLocalizer) {
+ this.urlLocalizer = urlLocalizer;
+ }
+
+ /**
+ * 1. Register PortType tModels
+ * 2. Register WSDL BPEL4WS Process
+ * 3. Register WSDL Port
+ * 4. Register Process Service
+ * 5. Register Binding
+ *
+ * @param serviceName - QName of the service
+ * @param portName - portName of the service
+ * @param serviceUrl - URL at which the service can be invoked
+ * @param wsdlDefinition - WSDL Definition of the Web Service
+ * @throws WSDLException
+ * @throws MalformedURLException
+ * @throws TransportException
+ * @throws ConfigurationException
+ * @throws RemoteException
+ */
+ @SuppressWarnings("unchecked")
+ public void register(QName serviceName, String portName, URL serviceUrl, Definition wsdlDefinition)
+ throws WSDLException, MalformedURLException, RemoteException, ConfigurationException, TransportException
+ {
+ String targetNamespace = wsdlDefinition.getTargetNamespace();
+ String genericWSDLURL = wsdlDefinition.getDocumentBaseURI(); //TODO maybe point to repository version
+ String bpelOverviewURL = "http://localhost:8080/bpel-console/"; //TODO maybe point to bpel in console
+
+ String serviceKey = Property.getServiceKey(properties, serviceName);
+ BusinessService service = lookupService(serviceKey);
+ if (service==null) {
+ List<TModel> tModels = new ArrayList<TModel>();
+ // Create the PortType tModels
+ Map<QName,PortType> portTypes = (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
+ tModels.addAll(createWSDLPortTypeTModels(genericWSDLURL, portTypes));
+ // Create the Binding tModels
+ Map<QName,Binding> bindings = (Map<QName,Binding>) wsdlDefinition.getAllBindings();
+ tModels.addAll(createWSDLBindingTModels(genericWSDLURL, bindings));
+ // Create the BPEL4WS tModel
+ TModel bpel4WSTModel = createBPEL4WSProcessTModel(serviceName, targetNamespace, portTypes, bpelOverviewURL);
+ tModels.add(bpel4WSTModel);
+ // Register these tModels
+ for (TModel tModel : tModels) {
+ clerk.register(tModel);
+ }
+ // BPEL Service
+ service = createBusinessService(serviceName, wsdlDefinition);
+ // Register this BPEL Service
+ clerk.register(service);
+ }
+ //Add the BindingTemplate to this Service
+ BindingTemplate binding = createBPELBinding(serviceName, portName, serviceUrl, wsdlDefinition);
+ // Register BindingTemplate
+ clerk.register(binding);
+ }
+
+ public void unRegister(QName serviceName, String portName) throws RemoteException, ConfigurationException, TransportException {
+
+ String serviceKey = Property.getServiceKey(properties, serviceName);
+ BusinessService service = lookupService(serviceKey);
+ boolean isRemoveServiceIfNoTemplates = true;
+ String bindingKey = Property.getBindingKey(properties, serviceName, portName);
+ //check if this bindingKey is in the service's binding templates
+ for (BindingTemplate bindingTemplate : service.getBindingTemplates().getBindingTemplate()) {
+ if (bindingKey.equals(bindingTemplate.getBindingKey())) {
+ clerk.unRegisterBinding(bindingKey);
+ //if this is the last binding for this service, and
+ if (service.getBindingTemplates().getBindingTemplate().size()==1 && isRemoveServiceIfNoTemplates) {
+ clerk.unRegisterService(serviceKey);
+
+ FindTModel findTmodelForProcessName = createFindTModelForProcessName(serviceName);
+ TModelList tModelList = clerk.findTModel(findTmodelForProcessName);
+ if (tModelList!=null && tModelList.getTModelInfos()!=null && tModelList.getTModelInfos().getTModelInfo()!=null) {
+ TModelInfo tModelInfo = tModelList.getTModelInfos().getTModelInfo().get(0);
+ String bpel4WSTModelKey = tModelInfo.getTModelKey();
+ clerk.unRegisterTModel(bpel4WSTModelKey);
+ // now use this key to find the portType TModels
+ GetTModelDetail findAllPortTypesForProcess = createFindAllPortTypesForProcess_1(bpel4WSTModelKey);
+ TModelDetail tModelDetail = clerk.getTModelDetail(findAllPortTypesForProcess);
+ if (tModelDetail!=null) {
+ List<TModel> tModelPortTypeList = tModelDetail.getTModel();
+ if (tModelPortTypeList!=null && tModelPortTypeList.size()>0) {
+ TModel bpel4WSTModel = tModelPortTypeList.get(0);
+ CategoryBag categoryBag = bpel4WSTModel.getCategoryBag();
+ if (categoryBag!=null && categoryBag.getKeyedReference()!=null) {
+ List<KeyedReference> portTypeTModelKeys = new ArrayList<KeyedReference>();
+ KeyedReference namespaceRef = null;
+ for (KeyedReference keyedReference : categoryBag.getKeyedReference()) {
+ if ("uddi:uddi.org:wsdl:porttypereference".equals(keyedReference.getTModelKey()) ) {
+ portTypeTModelKeys.add(keyedReference);
+ }
+ if ("uddi:uddi.org:xml:namespace".equals(keyedReference.getTModelKey()) ) {
+ namespaceRef = keyedReference;
+ }
+ }
+ String namespace = null;
+ if (namespaceRef!=null) namespace = namespaceRef.getKeyValue();
+ //find the bindingTModel
+ for (KeyedReference keyedReference : portTypeTModelKeys) {
+ FindTModel findBindingTModel = wsdl2UDDI.createFindBindingTModelForPortType(keyedReference.getKeyValue(), namespace);
+ TModelList bindingTmodels = clerk.findTModel(findBindingTModel);
+ if (bindingTmodels!=null && bindingTmodels.getTModelInfos()!=null && bindingTmodels.getTModelInfos().getTModelInfo()!=null) {
+ for (TModelInfo bindingTModelInfo : bindingTmodels.getTModelInfos().getTModelInfo()) {
+ //delete the Binding TModel
+ clerk.unRegisterTModel(bindingTModelInfo.getTModelKey());
+ }
+ }
+ //delete the PortType TModel
+ clerk.unRegisterTModel(keyedReference.getKeyValue());
+ }
+ }
+ }
+ }
+
+ 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;
+ }
+ }
+
+ }
+ /**
+ * Perform a lookup by serviceKey, and will return null if not found.
+ * @param serviceKey
+ * @return
+ * @throws RemoteException
+ * @throws ConfigurationException
+ * @throws TransportException
+ */
+ public BusinessService lookupService(String serviceKey) throws RemoteException, ConfigurationException, TransportException {
+
+ //Checking if this serviceKey already exist
+ BusinessService service = clerk.findService(serviceKey);
+ return service;
+ }
+ /**
+ * Registers the Service into UDDI.
+ *
+ * @param serviceName
+ * @param wsldDefinition
+ * @return
+ */
+ public BusinessService createBusinessService(QName serviceName, Definition wsdlDefinition) {
+
+ log.debug("Constructing Service UDDI Information for " + serviceName);
+ BusinessService service = new BusinessService();
+ // BusinessKey
+ service.setBusinessKey(businessKey);
+ // ServiceKey
+ service.setServiceKey(Property.getServiceKey(properties, serviceName));
+ // Description
+ String serviceDescription = properties.getProperty(Property.SERVICE_DESCRIPTION, Property.DEFAULT_SERVICE_DESCRIPTION);
+ // Override with the service description from the WSDL if present
+ Element docElement = wsdlDefinition.getService(serviceName).getDocumentationElement();
+ if (docElement!=null && docElement.getTextContent()!=null) {
+ serviceDescription = docElement.getTextContent();
+ }
+ Description description = new Description();
+ description.setLang(lang);
+ description.setValue(serviceDescription);
+ service.getDescription().add(description);
+ // Service name
+ Name sName = new Name();
+ sName.setLang(lang);
+ sName.setValue(serviceName.getLocalPart());
+ service.getName().add(sName);
+
+ //customization to add KeyedReferences into the categoryBag of the service
+ if (properties.containsKey(Property.SERVICE_CATEGORY_BAG)) {
+ String serviceCategoryBag = properties.getProperty(Property.SERVICE_CATEGORY_BAG);
+ log.info("Adding KeyedReferences '" + serviceCategoryBag + "' to service " + serviceName.getLocalPart());
+ CategoryBag categoryBag = parseCategoryBag(serviceCategoryBag);
+ service.setCategoryBag(categoryBag);
+ }
+
+ return service;
+ }
+
+ public Set<TModel> createWSDLPortTypeTModels(String wsdlURL, Map<QName,PortType> portTypes) throws WSDLException
+ {
+ return wsdl2UDDI.createWSDLPortTypeTModels(wsdlURL, portTypes);
+ }
+
+ public Set<TModel> createWSDLBindingTModels(String wsdlURL, Map<QName,Binding> bindings) throws WSDLException
+ {
+ return wsdl2UDDI.createWSDLBindingTModels(wsdlURL, bindings);
+ }
+
+ /**
+ * BPEL4WS abstract processes are published as separate UDDI tModels. They are named with the BPEL4WS process
+ * name. They are categorized as BPEL4WS process definitions, using a category system defined in this
+ * technical note. Their overviewDoc references an external BPEL4WS document that contains the process definition.
+ * All WSDL portTypes that are used in the BPEL4WS process definition (via the referenced BPEL4WS partnerLinkTypes)
+ * are published as portType tModels according to [WSDL2UDDI]. The process tModel references all such WSDL portType
+ * tModels, using the WSDL portType Reference tModel defined in [WSDL2UDDI]. Note that it is a characteristic
+ * of the BPEL4WS process that it defines a conversation based on WSDL portTypes. Thus, the relationship
+ * between process tModel and portType tModel is to be published by the process tModel publisher, not by
+ * the portType tModel publisher, which may be a different person.
+ *
+ * In the current implementation it is all registered by the same publisher.
+ *
+ * @param serviceName
+ * @param targetNamespace
+ * @param portTypes
+ * @param bpelOverviewURL
+ * @return
+ */
+ public TModel createBPEL4WSProcessTModel(QName serviceName, String targetNamespace, Map<QName,PortType> portTypes, String bpelOverviewURL) {
+ TModel tModel = new TModel();
+ // Set the Key
+ tModel.setTModelKey(keyDomainURI + serviceName.getLocalPart() + "Process");
+ // Set the Name
+ Name name = new Name();
+ name.setLang("en");
+ name.setValue(serviceName.getLocalPart());
+ tModel.setName(name);
+ // Set the OverviewURL
+ OverviewURL overviewURL = new OverviewURL();
+ overviewURL.setValue("http://localhost:8080/bpel-console/"); //should point to the bpel of this process, maybe in guvnor
+ OverviewDoc overviewDoc = new OverviewDoc();
+ overviewDoc.setOverviewURL(overviewURL);
+ tModel.getOverviewDoc().add(overviewDoc);
+ // Set the categoryBag
+ CategoryBag categoryBag = new CategoryBag();
+
+ if (targetNamespace!=null) {
+ KeyedReference namespaceReference = wsdl2UDDI.newKeyedReference(
+ "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", targetNamespace);
+ categoryBag.getKeyedReference().add(namespaceReference);
+ }
+ KeyedReference typesReference = wsdl2UDDI.newKeyedReference(
+ "uddi:uddi.org:bpel:types", "uddi-org:bpel:types", "process");
+ categoryBag.getKeyedReference().add(typesReference);
+ for (QName qName : portTypes.keySet()) {
+ String portTypeKey = keyDomainURI + qName.getLocalPart();
+ KeyedReference portTypeReference = wsdl2UDDI.newKeyedReference(
+ "uddi:uddi.org:wsdl:porttypereference", "uddi-org:wsdl:portTypeReference", portTypeKey);
+ categoryBag.getKeyedReference().add(portTypeReference);
+ }
+
+ tModel.setCategoryBag(categoryBag);
+
+ if (log.isInfoEnabled()) {
+ System.out.println(new PrintUDDI<TModel>().print(tModel));
+ }
+
+ return tModel;
+ }
+
+ public BindingTemplate createBPELBinding(QName serviceName, String portName, URL serviceUrl, Definition wsdlDefinition) {
+
+ BindingTemplate bindingTemplate = new BindingTemplate();
+ // Set BusinessService Key
+ bindingTemplate.setServiceKey(Property.getServiceKey(properties, serviceName));
+ // Set Binding Key
+ String bindingKey = Property.getBindingKey(properties, serviceName, portName);
+ bindingTemplate.setBindingKey(bindingKey);
+ // Set AccessPoint
+ AccessPoint accessPoint = new AccessPoint();
+ accessPoint.setUseType(AccessPointType.END_POINT.toString());
+ accessPoint.setValue(urlLocalizer.rewrite(serviceUrl));
+ bindingTemplate.setAccessPoint(accessPoint);
+
+ Service service = wsdlDefinition.getService(serviceName);
+
+ if (service!=null) {
+ TModelInstanceDetails tModelInstanceDetails = new TModelInstanceDetails();
+
+ Port port = service.getPort(portName);
+ if (port!=null) {
+ Binding binding = port.getBinding();
+ // Set the Binding Description
+ String bindingDescription = properties.getProperty(Property.BINDING_DESCRIPTION, Property.DEFAULT_BINDING_DESCRIPTION);
+ // Override with the service description from the WSDL if present
+ Element docElement = binding.getDocumentationElement();
+ if (docElement!=null && docElement.getTextContent()!=null) {
+ bindingDescription = docElement.getTextContent();
+ }
+ Description description = new Description();
+ description.setLang(lang);
+ description.setValue(bindingDescription);
+ bindingTemplate.getDescription().add(description);
+
+ // reference wsdl:binding tModel
+ TModelInstanceInfo tModelInstanceInfoBinding = new TModelInstanceInfo();
+ tModelInstanceInfoBinding.setTModelKey(keyDomainURI + binding.getQName().getLocalPart());
+ InstanceDetails instanceDetails = new InstanceDetails();
+ instanceDetails.setInstanceParms(portName);
+ tModelInstanceInfoBinding.setInstanceDetails(instanceDetails);
+ Description descriptionB = new Description();
+ descriptionB.setLang(lang);
+ descriptionB.setValue("The wsdl:binding that this wsdl:port implements. " + bindingDescription +
+ " The instanceParms specifies the port local name.");
+ tModelInstanceInfoBinding.getDescription().add(descriptionB);
+ tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoBinding);
+
+ // reference wsdl:portType tModel
+ PortType portType = binding.getPortType();
+ TModelInstanceInfo tModelInstanceInfoPortType = new TModelInstanceInfo();
+ tModelInstanceInfoPortType.setTModelKey(keyDomainURI + portType.getQName().getLocalPart());
+ String portTypeDescription = "";
+ docElement = portType.getDocumentationElement();
+ if (docElement!=null && docElement.getTextContent()!=null) {
+ portTypeDescription = docElement.getTextContent();
+ }
+ Description descriptionPT = new Description();
+ descriptionPT.setLang(lang);
+ descriptionPT.setValue("The wsdl:portType that this wsdl:port implements." + portTypeDescription );
+ tModelInstanceInfoPortType.getDescription().add(descriptionPT);
+ tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoPortType);
+
+ //reference bpel:process tModel
+ TModelInstanceInfo tModelInstanceInfoBPEL = new TModelInstanceInfo();
+ tModelInstanceInfoBPEL.setTModelKey(keyDomainURI + service.getQName().getLocalPart() + "Process");
+ Description descriptionBPEL = new Description();
+ // Description
+ String serviceDescription = properties.getProperty(Property.SERVICE_DESCRIPTION, Property.DEFAULT_SERVICE_DESCRIPTION);
+ // Override with the service description from the WSDL if present
+ docElement = wsdlDefinition.getService(serviceName).getDocumentationElement();
+ if (docElement!=null && docElement.getTextContent()!=null) {
+ serviceDescription = docElement.getTextContent();
+ }
+ descriptionBPEL.setLang(lang);
+ descriptionBPEL.setValue("The bpel:process this wsdl:port supports." + serviceDescription);
+ tModelInstanceInfoBPEL.getDescription().add(descriptionBPEL);
+ tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoBPEL);
+
+ bindingTemplate.setTModelInstanceDetails(tModelInstanceDetails);
+ } else {
+ log.error("Could not find Port with portName: " + portName);
+ }
+ } else {
+ log.error("Could not find Service with serviceName: " + serviceName.getLocalPart());
+ }
+
+ if (log.isInfoEnabled()) {
+ System.out.println(new PrintUDDI<BindingTemplate>().print(bindingTemplate));
+ }
+
+ return bindingTemplate;
+ }
+
+ /** Finds and returns ALL the tModels related to the process, so that i.e. they
+ * can be removed on undeployment of the service.
+ *
+ * @param processName
+ * @return
+ */
+ public FindTModel createFindTModelForProcessName (QName serviceName) {
+
+ FindTModel findTModel = new FindTModel();
+ Name name = new Name();
+ //name.setLang(lang);
+ name.setValue(serviceName.getLocalPart());
+ findTModel.setName(name);
+ CategoryBag categoryBag = new CategoryBag();
+
+ String namespace = serviceName.getNamespaceURI();
+ if (namespace!=null && namespace!="") {
+ KeyedReference namespaceReference = wsdl2UDDI.newKeyedReference(
+ "uddi:uddi.org:xml:namespace", namespace);
+ categoryBag.getKeyedReference().add(namespaceReference);
+ }
+ KeyedReference typesReference = wsdl2UDDI.newKeyedReference(
+ "uddi:uddi.org:bpel:types", "process");
+ categoryBag.getKeyedReference().add(typesReference);
+ findTModel.setCategoryBag(categoryBag);
+
+ if (log.isInfoEnabled()) {
+ System.out.println(new PrintUDDI<FindTModel>().print(findTModel));
+ }
+ return findTModel;
+ }
+ /**
+ * Find all processes that use the given portType.
+ *
+ * @param portTypeKey
+ * @return
+ */
+ public FindTModel createFindProcessesForPortTypes(String portTypeKey) {
+ FindTModel findTModel = new FindTModel();
+ CategoryBag categoryBag = new CategoryBag();
+
+ KeyedReference typesReference = wsdl2UDDI.newKeyedReference(
+ "uddi:uddi.org:bpel:types", "process");
+ categoryBag.getKeyedReference().add(typesReference);
+
+ KeyedReference portTypeReference = wsdl2UDDI.newKeyedReference(
+ "uddi:uddi.org:wsdl:porttypereference", portTypeKey);
+ categoryBag.getKeyedReference().add(portTypeReference);
+
+ findTModel.setCategoryBag(categoryBag);
+
+ return findTModel;
+ }
+ /**
+ * 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
+ * categoryBag, and passed into the second call.
+ *
+ * @param processKey
+ * @return GetTModelDetail
+ */
+ public GetTModelDetail createFindAllPortTypesForProcess_1(String processKey) {
+ GetTModelDetail getTModelDetail = new GetTModelDetail();
+ getTModelDetail.getTModelKey().add(processKey);
+ return getTModelDetail;
+ }
+ /**
+ * Once retrieved, the second call is made to get the tModel registrations
+ * for the portTypes with the keys found in the first step.
+ *
+ * @param tModelKeys - List of portType tModels found in the first step.
+ * @return GetTModelDetail
+ */
+ public GetTModelDetail createFindAllPortTypesForProcess_2(List<String> portTypeTModelKeys) {
+ GetTModelDetail getTModelDetail = new GetTModelDetail();
+ for (String tModelKey : portTypeTModelKeys) {
+ getTModelDetail.getTModelKey().add(tModelKey);
+ }
+ return getTModelDetail;
+ }
+ /**
+ * Find all implementations of the given process.
+ * @param processKey
+ * @return FindBinding
+ */
+ public FindBinding createFindImplementationsForProcess(String processKey) {
+ FindBinding findBinding = new FindBinding();
+ TModelBag tModelBag = new TModelBag();
+ tModelBag.getTModelKey().add(processKey);
+ return findBinding;
+ }
+
+}
Added: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizer.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizer.java?rev=1102787&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizer.java (added)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizer.java Fri May 13 15:17:43 2011
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2001-2011 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.juddi.v3.client.mapping;
+
+import java.net.URL;
+
+public interface URLLocalizer {
+
+ public String rewrite (URL urlIn);
+ public String rewriteToWSDLURL (URL urlIn);
+}
Added: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizerImpl.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizerImpl.java?rev=1102787&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizerImpl.java (added)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/URLLocalizerImpl.java Fri May 13 15:17:43 2011
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2001-2011 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.juddi.v3.client.mapping;
+
+import java.net.URL;
+
+public class URLLocalizerImpl implements URLLocalizer {
+
+ public String rewrite (URL urlIn) {
+ return urlIn.toExternalForm();
+ }
+
+ public String rewriteToWSDLURL (URL urlIn) {
+ return urlIn.toExternalForm() + "?wsdl";
+ }
+}
Added: juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/BPEL2UDDITest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/BPEL2UDDITest.java?rev=1102787&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/BPEL2UDDITest.java (added)
+++ juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/BPEL2UDDITest.java Fri May 13 15:17:43 2011
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.v3.client.mapping;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+
+import org.apache.juddi.jaxb.PrintUDDI;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.uddi.api_v3.BindingTemplate;
+import org.uddi.api_v3.FindTModel;
+import org.uddi.api_v3.TModel;
+
+/**
+ * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
+ */
+public class BPEL2UDDITest {
+
+
+ static BPEL2UDDI bpel2UDDI;
+ PrintUDDI<TModel> pTModel = new PrintUDDI<TModel>();
+ PrintUDDI<FindTModel> pFindTModel = new PrintUDDI<FindTModel>();
+ PrintUDDI<BindingTemplate> pBinding = new PrintUDDI<BindingTemplate>();
+ ReadWSDL rw = new ReadWSDL();
+
+ @BeforeClass
+ public static void before() throws JAXBException {
+ Properties properties = new Properties();
+ properties.put("keyDomain", "juddi.apache.org");
+ properties.put("nodeName", "localhost");
+ URLLocalizer urlLocalizer = new URLLocalizerImpl();
+
+ bpel2UDDI = new BPEL2UDDI(null, urlLocalizer, properties);
+ }
+
+ @Test
+ public void testTN_WSDLPortTypeModels() throws WSDLException, JAXBException {
+
+ // Reading the WSDL
+ Definition wsdlDefinition = rw.readWSDL("bpel/bpel-technote.wsdl");
+ @SuppressWarnings("unchecked")
+ Map<QName,PortType> portTypes= (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
+ Set<TModel> portTypeTModels = bpel2UDDI.createWSDLPortTypeTModels(wsdlDefinition.getDocumentBaseURI(), portTypes);
+ for (TModel tModel : portTypeTModels) {
+ System.out.println("***** UDDI PortType TModel: " + tModel.getName().getValue());
+ System.out.println(pTModel.print(tModel));
+ }
+ Assert.assertEquals(2,portTypeTModels.size());
+ }
+
+ @Test
+ public void testTN_BPEL4WSProcessTModel() throws WSDLException, JAXBException {
+
+ // Obtained from the .bpel file:
+ String targetNamespace = "http://example.com/travelagent";
+ QName serviceName = new QName (targetNamespace, "ReservationAndBookingTickets");
+ String bpelOverViewUrl = "http://localhost/registry/" + serviceName.getLocalPart() + ".bpel";
+
+ // Reading the WSDL
+ Definition wsdlDefinition = rw.readWSDL("bpel/bpel-technote.wsdl");
+
+ @SuppressWarnings("unchecked")
+ Map<QName,PortType> portTypes= (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
+ TModel bpel4WSTModel = bpel2UDDI.createBPEL4WSProcessTModel(serviceName, targetNamespace, portTypes, bpelOverViewUrl);
+
+ System.out.println("***** BPEL4WS Process TModel: " + bpel4WSTModel.getName().getValue());
+ System.out.println(pTModel.print(bpel4WSTModel));
+
+ Assert.assertNotNull(bpel4WSTModel);
+ }
+
+ @Test
+ public void testTN_FindTModelForProcessName() throws JAXBException {
+
+ QName processName = new QName("http://example.com/travelagent","ReservationAndBookingTickets");
+
+ FindTModel findTModel = bpel2UDDI.createFindTModelForProcessName(processName);
+
+ System.out.println("***** Find TModel For ProcessName: " + processName);
+ System.out.println(pFindTModel.print(findTModel));
+
+ Assert.assertNotNull(findTModel.getCategoryBag());
+ }
+
+ @Test
+ public void testHelloWorld_WSDLPortTypeModels() throws WSDLException, JAXBException {
+
+ // Reading the WSDL
+ Definition wsdlDefinition = rw.readWSDL("bpel/HelloWorld.wsdl");
+ @SuppressWarnings("unchecked")
+ Map<QName,PortType> portTypes= (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
+ Set<TModel> portTypeTModels = bpel2UDDI.createWSDLPortTypeTModels(wsdlDefinition.getDocumentBaseURI(), portTypes);
+
+ for (TModel tModel : portTypeTModels) {
+ System.out.println("***** UDDI PortType TModel: " + tModel.getName().getValue());
+ System.out.println(pTModel.print(tModel));
+ }
+ Assert.assertEquals(1,portTypeTModels.size());
+ }
+
+ @Test
+ public void testHelloWorld_UDDIBindingModel() throws WSDLException, JAXBException {
+
+ // Reading the WSDL
+ Definition wsdlDefinition = rw.readWSDL("bpel/HelloWorld.wsdl");
+ @SuppressWarnings("unchecked")
+ Map<QName,Binding> bindings = (Map<QName,Binding>) wsdlDefinition.getAllBindings();
+ Set<TModel> bindingTModels = bpel2UDDI.createWSDLBindingTModels(wsdlDefinition.getDocumentBaseURI(), bindings);
+
+ for (TModel tModel : bindingTModels) {
+ System.out.println("***** UDDI Binding TModel: " + tModel.getName().getValue());
+ System.out.println(pTModel.print(tModel));
+ }
+ Assert.assertEquals(1,bindingTModels.size());
+ }
+
+ @Test
+ public void testHelloWorld_BPEL4WSProcessTModel() throws WSDLException, JAXBException {
+
+ //Obtained from the .bpel file:
+ String targetNamespace = "http://www.jboss.org/bpel/examples";
+ QName serviceName = new QName (targetNamespace, "HelloWorld");
+ String bpelOverViewUrl = "http://localhost/registry/" + serviceName.getLocalPart() + ".bpel";
+
+ // Reading the WSDL
+ Definition wsdlDefinition = rw.readWSDL("bpel/HelloWorld.wsdl");
+
+ @SuppressWarnings("unchecked")
+ Map<QName,PortType> portTypes= (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
+ TModel bpel4WSTModel = bpel2UDDI.createBPEL4WSProcessTModel(serviceName, targetNamespace, portTypes, bpelOverViewUrl);
+
+ System.out.println("***** BPEL4WS Process TModel: " + bpel4WSTModel.getName().getValue());
+ System.out.println(pTModel.print(bpel4WSTModel));
+
+ Assert.assertNotNull(bpel4WSTModel);
+ }
+
+ @Test
+ public void testHelloWorld_BPELBinding() throws WSDLException, JAXBException, MalformedURLException {
+
+ //Obtained from the .bpel file:
+ String portName = "HelloPort";
+ QName serviceName = new QName ("http://www.jboss.org/bpel/examples/wsdl", "HelloService");
+ URL serviceUrl = new URL("http://localhost/sample");
+
+ // Reading the WSDL
+ Definition wsdlDefinition = rw.readWSDL("bpel/HelloWorld.wsdl");
+ BindingTemplate binding = bpel2UDDI.createBPELBinding(serviceName, portName, serviceUrl, wsdlDefinition);
+
+ System.out.println("***** WSDL Port BindingTemplate: " + binding.getBindingKey());
+ System.out.println(pBinding.print(binding));
+
+ Assert.assertNotNull(binding.getTModelInstanceDetails());
+ }
+
+ @Test
+ public void testHelloWorld_FindTModelForProcessName() throws JAXBException {
+
+ QName processName = new QName("http://www.jboss.org/bpel/examples/wsdl","HelloWorld");
+
+ FindTModel findTModel = bpel2UDDI.createFindTModelForProcessName(processName);
+
+ System.out.println("***** Find TModel For ProcessName: " + processName);
+ System.out.println(pFindTModel.print(findTModel));
+
+ Assert.assertNotNull(findTModel.getCategoryBag());
+ }
+}
Added: juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.bpel
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.bpel?rev=1102787&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.bpel (added)
+++ juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.bpel Fri May 13 15:17:43 2011
@@ -0,0 +1,68 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://www.jboss.org/bpel/examples"
+ xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:tns="http://www.jboss.org/bpel/examples"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:intf="http://www.jboss.org/bpel/examples/wsdl"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="HelloWorld.wsdl"
+ namespace="http://www.jboss.org/bpel/examples/wsdl"
+ importType="http://schemas.xmlsoap.org/wsdl/" />
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink"
+ partnerLinkType="intf:HelloPartnerLinkType"
+ myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="myVar" messageType="intf:HelloMessage"/>
+ <variable name="mesgVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="intf:HelloPortType"
+ operation="hello"
+ variable="myVar"
+ createInstance="yes"/>
+
+ <assign name="assignHelloMesg">
+ <copy>
+ <from variable="myVar" part="TestPart"/>
+ <to variable="mesgVar"/>
+ </copy>
+ <copy>
+ <from>concat($mesgVar,' World')</from>
+ <to variable="myVar" part="TestPart"/>
+ </copy>
+ </assign>
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="intf:HelloPortType"
+ operation="hello"
+ variable="myVar"/>
+ </sequence>
+</process>
Added: juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.wsdl
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.wsdl?rev=1102787&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.wsdl (added)
+++ juddi/trunk/juddi-client/src/test/resources/bpel/HelloWorld.wsdl Fri May 13 15:17:43 2011
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<wsdl:definitions
+ targetNamespace="http://www.jboss.org/bpel/examples/wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://www.jboss.org/bpel/examples/wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part name="TestPart" type="xsd:string"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <soap:operation soapAction="" style="rpc"/>
+ <wsdl:input>
+ <soap:body
+ namespace="http://www.jboss.org/bpel/examples/wsdl"
+ use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body
+ namespace="http://www.jboss.org/bpel/examples/wsdl"
+ use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8080/Quickstart_bpel_hello_worldWS"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
+
Added: juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.bpel
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.bpel?rev=1102787&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.bpel (added)
+++ juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.bpel Fri May 13 15:17:43 2011
@@ -0,0 +1,69 @@
+<process name="ReservationAndBookingTickets"
+ targetNamespace="http://example.com/travelagent"
+ xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
+ xmlns:taw="http://example.com/travelagent/wsdl"
+ abstractProcess="yes">
+ <partnerLinks>
+ <partnerLink name="TravelAgency"
+ partnerLinkType="taw:TravelAgencyService"
+ partnerRole="Customer"
+ myRole="TravelAgent"/>
+ </partnerLinks>
+ <correlationSets>
+ <correlationSet name="reservationCorrelation"
+ properties=Ótaw:reservationIDÓ/>
+ </correlationSets>
+ <sequence>
+ <receive partnerLink="TravelAgency"
+ portType="taw:InterfaceOfTravelAgent"
+ operation="OrderTrip"
+ createInstance="yes">
+ <correlations>
+ <correlation set="reservationCorrelation"
+ initiate="yes"/>
+ </correlations>
+ </receive>
+ <pick>
+ <onAlarm duration="P0Y0M1D">
+ <invoke partnerLink="TravelAgency"
+ portType="taw:InterfaceOfCustomer"
+ operation="NotificationOfTimeout">
+ <correlations>
+ <correlation set="reservationCorrelation"
+ pattern="out"/>
+ </correlations>
+ </invoke>
+ </onAlarm>
+ <onMessage partnerLink="TravelAgency"
+ portType="taw:InterfaceOfTravelAgent"
+ operation="CancelReservation">
+ <correlations>
+ <correlation set="reservationCorrelation"/>
+ </correlations>
+ <invoke partnerLink="TravelAgency"
+ portType="taw:InterfaceOfCustomer"
+ operation="NotificationOfCancellation">
+ <correlations>
+ <correlation set="reservationCorrelation"
+ pattern="out"/>
+ </correlations>
+ </invoke>
+ </onMessage>
+ <onMessage partnerLink="TravelAgency"
+ portType="taw:InterfaceOfTravelAgent"
+ operation="PerformBooking">
+ <correlations>
+ <correlation set="reservationCorrelation"/>
+ </correlations>
+ <invoke partnerLink="TravelAgency"
+ portType="taw:InterfaceOfCustomer"
+ operation="ReceiveStatement">
+ <correlations>
+ <correlation set="reservationCorrelation"
+ pattern="out"/>
+ </correlations>
+ </invoke>
+ </onMessage>
+ </pick>
+ </sequence>
+</process>
Added: juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.wsdl
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.wsdl?rev=1102787&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.wsdl (added)
+++ juddi/trunk/juddi-client/src/test/resources/bpel/bpel-technote.wsdl Fri May 13 15:17:43 2011
@@ -0,0 +1,47 @@
+<?xml version="1.0" ?>
+<definitions name="TravelAgent"
+ targetNamespace="http://example.com/travelagent/wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/">
+ <!-- data type definitions and message definitions are omitted -->
+ <!-- port type definitions -->
+ <portType name="InterfaceOfTravelAgent">
+ <operation name="OrderTrip">
+ <input message="orderRequest" />
+ <output message="orderAcknowledgement" />
+ </operation>
+ <operation name="CancelReservation">
+ <input message="cancellationRequest" />
+ </operation>
+ <operation name="PerformBooking">
+ <input message="bookingRequest" />
+ <output message="bookingConfirmation" />
+ </operation>
+ </portType>
+ <portType name="InterfaceOfCustomer">
+ <operation name="NotificationOfCancellation">
+ <input message="cancellationResponse" />
+ </operation>
+ <operation name="NotificationOfTimeout">
+ <input message="timeoutMsg" />
+ </operation>
+ <operation name="ReceiveStatement">
+ <input message="statement" />
+ </operation>
+ </portType>
+ <!-- partner link type definitions -->
+ <plnk:partnerLinkType name="TravelAgentService">
+ <plnk:role name="TravelAgent">
+ <plnk:portType name="InterfaceOfTravelAgent" />
+ </plnk:role>
+ <plnk:role name="Customer">
+ <plnk:portTYpe name="InterfaceOfCustomer" />
+ </plnk:role>
+ </plnk:partnerLinkType>
+ <!-- definition of properties -->
+ <bpws:property name="reservationID" type="xsd:string" />
+ <!-- property aliases are omitted -->
+
+
+</definitions>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org