[federate-commits] Federate SVN: r25 - in trunk/federate-console: src/main/java/com/metamatrix and 11 other directories.
federate-commits at lists.jboss.org
federate-commits at lists.jboss.org
Fri Nov 21 11:16:10 EST 2008
Author: tjones
Date: 2008-11-21 11:16:10 -0500 (Fri, 21 Nov 2008)
New Revision: 25
Added:
trunk/federate-console/src/main/java/com/metamatrix/uddi/
trunk/federate-console/src/main/java/com/metamatrix/uddi/UddiPlugin.java
trunk/federate-console/src/main/java/com/metamatrix/uddi/exception/
trunk/federate-console/src/main/java/com/metamatrix/uddi/exception/MMUddiException.java
trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/
trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/PublishWSDL.java
trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/UnPublishWSDL.java
trunk/federate-console/src/main/java/com/metamatrix/uddi/query/
trunk/federate-console/src/main/java/com/metamatrix/uddi/query/FindBusiness.java
trunk/federate-console/src/main/java/com/metamatrix/uddi/query/GetWSDL.java
trunk/federate-console/src/main/java/com/metamatrix/uddi/util/
trunk/federate-console/src/main/java/com/metamatrix/uddi/util/MMUddiHelper.java
trunk/federate-console/src/main/java/com/metamatrix/uddi/util/MMUddiUtil.java
trunk/federate-console/src/main/java/com/metamatrix/uddi/util/UddiHelper.java
trunk/federate-console/src/main/resources/com/metamatrix/uddi/
trunk/federate-console/src/main/resources/com/metamatrix/uddi/i18n.properties
trunk/federate-console/src/test/java/com/metamatrix/uddi/
trunk/federate-console/src/test/java/com/metamatrix/uddi/publish/
trunk/federate-console/src/test/java/com/metamatrix/uddi/publish/SaveBusiness.java
trunk/federate-console/src/test/java/com/metamatrix/uddi/util/
trunk/federate-console/src/test/java/com/metamatrix/uddi/util/TestMMUddiHelper.java
Modified:
trunk/federate-console/pom.xml
Log:
FEDERATE-7: Migrated UDDI publish/unpublish code to Federate.
Modified: trunk/federate-console/pom.xml
===================================================================
--- trunk/federate-console/pom.xml 2008-11-20 17:19:30 UTC (rev 24)
+++ trunk/federate-console/pom.xml 2008-11-21 16:16:10 UTC (rev 25)
@@ -31,6 +31,36 @@
<artifactId>federate-metadata</artifactId>
</dependency>
+ <dependency>
+ <groupId>org</groupId>
+ <artifactId>uddi4j</artifactId>
+ <version>2.0.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis</groupId>
+ <artifactId>axis</artifactId>
+ <version>1.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>apache-discovery</groupId>
+ <artifactId>commons-discovery</artifactId>
+ <version>0.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml</groupId>
+ <artifactId>jaxrpc-api</artifactId>
+ <version>1.1</version>
+ </dependency>
+
</dependencies>
</project>
\ No newline at end of file
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/UddiPlugin.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/UddiPlugin.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/UddiPlugin.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2000-2007 MetaMatrix, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.uddi;
+
+import java.util.*;
+
+import com.metamatrix.core.BundleUtil;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class UddiPlugin {
+ /**
+ * The plug-in identifier of this plugin
+ * (value <code>"com.metamatrix.console"</code>).
+ */
+ public static final String PLUGIN_ID = "com.metamatrix.console" ; //$NON-NLS-1$
+
+ /**
+ * Provides access to the plugin's log and to it's resources.
+ */
+ private static final String BUNDLE_NAME = PLUGIN_ID + ".i18n"; //$NON-NLS-1$
+ public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,BUNDLE_NAME,ResourceBundle.getBundle(BUNDLE_NAME));
+}
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/exception/MMUddiException.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/exception/MMUddiException.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/exception/MMUddiException.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,26 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+package com.metamatrix.uddi.exception;
+
+/**
+ * This exception is thrown when an error occurs while publishing or un-publishing to/from an Uddi Registry.
+ */
+public class MMUddiException extends Exception {
+
+ public MMUddiException() {
+ }
+
+ public MMUddiException( String message ) {
+ super(message);
+ }
+
+ public MMUddiException( Throwable e ) {
+ super(e);
+ }
+
+ public MMUddiException( Throwable e,
+ String message ) {
+ super(message, e);
+ }
+}
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/PublishWSDL.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/PublishWSDL.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/PublishWSDL.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,66 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+package com.metamatrix.uddi.publish;
+
+import java.net.MalformedURLException;
+import java.security.InvalidParameterException;
+import java.util.Vector;
+
+import javax.xml.soap.SOAPException;
+
+import org.uddi4j.UDDIException;
+import org.uddi4j.client.UDDIProxy;
+import org.uddi4j.datatype.service.BusinessService;
+import org.uddi4j.response.AuthToken;
+import org.uddi4j.transport.TransportException;
+
+import com.metamatrix.uddi.util.MMUddiUtil;
+
+/**
+ * This class uses UDDI4j's API to publish WSDL.
+ */
+public class PublishWSDL {
+
+ public PublishWSDL() {
+ }
+
+ /**
+ * Publish WSDL via UDDI4j java API.
+ *
+ * @param user The user name for the UDDI Registry.
+ * @param password The password for the UDDI Registry
+ * @param businessKey The business key of the <@link BusinessEntity> for which to publish the WSDL
+ * @param url The url of the WSDL to publish
+ * @param inquiryUrl The inquiry url of the UDDI Registry
+ * @param publishUrl The publish url of the UDDI Registry
+ * @throws InvalidParameterException If the value is invalid.
+ * @throws UDDIException If the UDDI call fails with error.
+ * @throws SOAPException If the UDDI call fails with error.
+ * @since 5.6
+ */
+ public void publish( String user,
+ String password,
+ String businessKey,
+ String url,
+ String inquiryUrl,
+ String publishUrl )
+ throws UDDIException, InvalidParameterException, SOAPException, TransportException, MalformedURLException {
+
+ UDDIProxy proxy = MMUddiUtil.getUddiProxy(inquiryUrl, publishUrl);
+
+ // Pass in userid and password registered at the UDDI site
+ AuthToken token = proxy.get_authToken(user, password);
+
+ // Create a new business service using BindingTemplates default constructor.
+ // DefaultName is the service name. ServiceKey must be "" to save a new service
+ BusinessService businessService = new BusinessService(""); //$NON-NLS-1$
+ businessService.setDefaultNameString(url, null);
+ businessService.setBusinessKey(businessKey);
+ Vector services = new Vector();
+ services.addElement(businessService);
+
+ // Save a Business Service
+ proxy.save_service(token.getAuthInfoString(), services);
+ }
+}
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/UnPublishWSDL.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/UnPublishWSDL.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/publish/UnPublishWSDL.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,86 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+package com.metamatrix.uddi.publish;
+
+import java.net.MalformedURLException;
+import java.security.InvalidParameterException;
+import java.util.Vector;
+
+import javax.xml.soap.SOAPException;
+
+import org.uddi4j.UDDIException;
+import org.uddi4j.client.UDDIProxy;
+import org.uddi4j.datatype.Name;
+import org.uddi4j.response.AuthToken;
+import org.uddi4j.response.DispositionReport;
+import org.uddi4j.response.ServiceInfo;
+import org.uddi4j.response.ServiceList;
+import org.uddi4j.transport.TransportException;
+import org.uddi4j.util.FindQualifier;
+import org.uddi4j.util.FindQualifiers;
+
+import com.metamatrix.uddi.UddiPlugin;
+import com.metamatrix.uddi.exception.MMUddiException;
+import com.metamatrix.uddi.util.MMUddiUtil;
+
+/**
+ * Use UDDI4j's API to call unpublish WSDL. *
+ */
+public class UnPublishWSDL {
+
+ /**
+ * Creates and fills the Unpublish structure.
+ *
+ * @param user Username for UDDI Registry
+ * @param password Password for UDDI Registry
+ * @param businessKey Key for business entity
+ * @param inquiryUrl Inquiry URL for UDDI Registry
+ * @param publishUrl Publish URL for UDDI Registry
+ * @throws InvalidParameterException If the value is invalid.
+ * @since 5.6
+ */
+ public void unpublish( String user,
+ String password,
+ String businessKey,
+ String wsdlUrl,
+ String inquiryUrl,
+ String publishUrl )
+ throws MMUddiException, UDDIException, InvalidParameterException, SOAPException, TransportException, MalformedURLException {
+
+ UDDIProxy proxy = MMUddiUtil.getUddiProxy(inquiryUrl, publishUrl);
+
+ // Pass in userid and password registered at the UDDI site
+ AuthToken token = proxy.get_authToken(user, password);
+
+ // creating vector of Name Object
+ Vector names = new Vector();
+ names.add(new Name(wsdlUrl));
+
+ // Setting FindQualifiers to 'caseSensitiveMatch'
+ FindQualifiers findQualifiers = new FindQualifiers();
+ Vector qualifier = new Vector();
+ qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
+ findQualifiers.setFindQualifierVector(qualifier);
+
+ // **** Get the first instance of this service for the given business key
+ ServiceList serviceList = proxy.find_service(businessKey, names, null, null, findQualifiers, 1);
+
+ // Process the returned ServiceList object
+ Vector serviceInfoVector = serviceList.getServiceInfos().getServiceInfoVector();
+ ServiceInfo serviceInfo = new ServiceInfo();
+ for (int i = 0; i < serviceInfoVector.size(); i++) {
+ serviceInfo = (ServiceInfo)serviceInfoVector.elementAt(i);
+ }
+
+ // Try to delete saved Business Service. Delete will fail for services not created by this id
+ // **** Having service key, delete using the authToken
+ DispositionReport dr = proxy.delete_service(token.getAuthInfoString(), serviceInfo.getServiceKey());
+
+ if (!dr.success()) {
+ Object[] parms = new Object[] {dr.getOperator(), dr.getGeneric()};
+ String msg = UddiPlugin.Util.getString("UnPublishWSDL.UnpublishWsdl.ErrorDeletingService", parms); //$NON-NLS-1$
+ throw new MMUddiException(msg);
+ }
+ }
+}
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/query/FindBusiness.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/query/FindBusiness.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/query/FindBusiness.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,70 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+package com.metamatrix.uddi.query;
+
+import java.net.MalformedURLException;
+import java.security.InvalidParameterException;
+import java.util.Vector;
+import javax.xml.soap.SOAPException;
+import org.uddi4j.UDDIException;
+import org.uddi4j.client.UDDIProxy;
+import org.uddi4j.datatype.Name;
+import org.uddi4j.response.BusinessList;
+import org.uddi4j.transport.TransportException;
+import org.uddi4j.util.FindQualifier;
+import org.uddi4j.util.FindQualifiers;
+import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.uddi.util.MMUddiUtil;
+
+/**
+ * Uses UDDI4j's API to UDDI v2 call find_business.
+ */
+public class FindBusiness {
+
+ // The number of values that will be listed in the results of find calls
+ public static int max_rows = 0;
+
+ public static String host = StringUtil.Constants.EMPTY_STRING;
+ public static String port = StringUtil.Constants.EMPTY_STRING;
+
+ public FindBusiness() {
+ }
+
+ /**
+ * Find all businesses in a UDDI Registry via UDDI4J's API.
+ *
+ * @param inquiryUrl inquiry URL of the UDDI Registry
+ * @param publishUrl publish URL of the UDDI Registry
+ * @param searchString Business name search string.
+ * @param maxRows Maximum rows to be returned.
+ * @return List List of matching <@link BusinessEntity>s
+ * @throws Exception If the UDDI call fails with error.
+ * @since 5.6
+ */
+ public BusinessList findBusiness( String inquiryUrl,
+ String publishUrl,
+ String searchString,
+ int maxRows )
+ throws UDDIException, InvalidParameterException, SOAPException, TransportException, MalformedURLException {
+
+ UDDIProxy proxy = MMUddiUtil.getUddiProxy(inquiryUrl, publishUrl);
+
+ BusinessList businessList = null;
+
+ // creating vector of Name Object
+ Vector names = new Vector();
+ names.add(new Name(searchString));
+
+ // Setting FindQualifiers to 'caseSensitiveMatch'
+ FindQualifiers findQualifiers = new FindQualifiers();
+ Vector qualifier = new Vector();
+ qualifier.add(new FindQualifier(FindQualifier.caseSensitiveMatch));
+ findQualifiers.setFindQualifierVector(qualifier);
+
+ // Find businesses by name
+ businessList = proxy.find_business(names, null, null, null, null, findQualifiers, maxRows);
+
+ return businessList;
+ }
+}
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/query/GetWSDL.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/query/GetWSDL.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/query/GetWSDL.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,69 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+package com.metamatrix.uddi.query;
+
+import java.net.MalformedURLException;
+import java.util.Vector;
+import org.uddi4j.UDDIException;
+import org.uddi4j.client.UDDIProxy;
+import org.uddi4j.datatype.Name;
+import org.uddi4j.response.ServiceList;
+import org.uddi4j.transport.TransportException;
+import org.uddi4j.util.FindQualifier;
+import org.uddi4j.util.FindQualifiers;
+import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.uddi.exception.MMUddiException;
+import com.metamatrix.uddi.util.MMUddiUtil;
+
+/**
+ * Uses UDDI4j's UDDI v2 API to call get_wsdlServiceInfo WSDL. Used to determine if a given WSDL is published or not.
+ */
+public class GetWSDL {
+
+ public String uddiUrl = StringUtil.Constants.EMPTY_STRING;
+
+ /**
+ * @param user
+ * @param password
+ * @param businessKey
+ * @param url
+ * @param inquiryUrl
+ * @param publishUrl
+ * @return
+ * @throws SOAPException
+ * @since 5.6
+ */
+ public boolean isPublished( String user,
+ String password,
+ String businessKey,
+ String url,
+ String inquiryUrl,
+ String publishUrl )
+ throws TransportException, MMUddiException, UDDIException, MalformedURLException {
+
+ UDDIProxy proxy = MMUddiUtil.getUddiProxy(inquiryUrl, publishUrl);
+ boolean isPublished = false;
+
+ // creating vector of Name Object
+ Vector names = new Vector();
+ names.add(new Name(url));
+
+ // Setting FindQualifiers to 'exactNameMatch'
+ FindQualifiers findQualifiers = new FindQualifiers();
+ Vector qualifier = new Vector();
+ qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
+ findQualifiers.setFindQualifierVector(qualifier);
+
+ // **** Find the Business Service saved.
+ // And setting the maximum rows to be returned as 1.
+ ServiceList serviceList = proxy.find_service(businessKey, names, null, null, findQualifiers, 1);
+
+ // Process the returned ServiceList object
+ Vector serviceInfoVector = serviceList.getServiceInfos().getServiceInfoVector();
+ if (serviceInfoVector.size() > 0) {
+ isPublished = true;
+ }
+ return isPublished;
+ }
+}
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/util/MMUddiHelper.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/util/MMUddiHelper.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/util/MMUddiHelper.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,183 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+package com.metamatrix.uddi.util;
+
+import java.net.MalformedURLException;
+import java.security.InvalidParameterException;
+
+import javax.xml.soap.SOAPException;
+
+import org.uddi4j.UDDIException;
+import org.uddi4j.response.BusinessList;
+import org.uddi4j.transport.TransportException;
+
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.uddi.UddiPlugin;
+import com.metamatrix.uddi.exception.MMUddiException;
+import com.metamatrix.uddi.publish.PublishWSDL;
+import com.metamatrix.uddi.publish.UnPublishWSDL;
+import com.metamatrix.uddi.query.FindBusiness;
+import com.metamatrix.uddi.query.GetWSDL;
+
+/**
+ * Concrete implementation of UddiHelper.
+ *
+ * @since 5.6
+ */
+public class MMUddiHelper implements UddiHelper {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see com.metamatrix.uddi.util.UddiHelper#publish(java.lang.String, java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String, java.lang.String)
+ * @since 5.6
+ */
+ public void publish( String uddiUserName,
+ String uddiPassword,
+ String busKey,
+ String wsdlUrl,
+ String inquiryUrl,
+ String publishUrl ) throws MMUddiException {
+ PublishWSDL pubWSDL = new PublishWSDL();
+ try {
+ pubWSDL.publish(uddiUserName, uddiPassword, busKey, wsdlUrl, inquiryUrl, publishUrl);
+ } catch (TransportException err) {
+ processException(err, "PublishWSDL.TransportException_in_WSDL_publish"); //$NON-NLS-1$
+ } catch (MalformedURLException err) {
+ processException(err, "MMUddiHelper.MalformedURLException_in_WSDL_publish"); //$NON-NLS-1$
+ } catch (UDDIException err) {
+ processException(err, "MMUddiHelper.UDDIException_in_WSDL_publish"); //$NON-NLS-1$
+ } catch (InvalidParameterException err) {
+ processException(err, "MMUddiHelper.InvalidParameterException_in_WSDL_publish"); //$NON-NLS-1$
+ } catch (SOAPException err) {
+ processException(err, "MMUddiHelper.SOAPException_in_WSDL_publish"); //$NON-NLS-1$
+ }
+
+ }
+
+ /**
+ * @param err
+ * @throws MMUddiException
+ */
+ private void processException( final Exception err,
+ final String msgKey ) throws MMUddiException {
+ Object[] params = new Object[] {err};
+ String msg = UddiPlugin.Util.getString(msgKey, params);
+ LogManager.logError(this.getClass().getName(), msg);
+ throw new MMUddiException(err, msg);
+ }
+
+ /**
+ * @see com.metamatrix.uddi.util.UddiHelper#unPublish(java.lang.String, java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String)
+ * @since 5.6
+ */
+ public void unPublish( String UddiUserName,
+ String UddiPassword,
+ String busKey,
+ String wsdlUrl,
+ String inquiryUrl,
+ String publishUrl ) throws MMUddiException {
+ UnPublishWSDL pubWSDL = new UnPublishWSDL();
+ try {
+ pubWSDL.unpublish(UddiUserName, UddiPassword, busKey, wsdlUrl, inquiryUrl, publishUrl);
+ } catch (TransportException err) {
+ processException(err, "MMUddiHelper.TransportException_in_WSDL_unpublish"); //$NON-NLS-1$
+ } catch (MalformedURLException err) {
+ processException(err, "MMUddiHelper.MalformedURLException_in_WSDL_unpublish"); //$NON-NLS-1$
+ } catch (UDDIException err) {
+ processException(err, "MMUddiHelper.UDDIException_in_WSDL_unpublish"); //$NON-NLS-1$
+ } catch (InvalidParameterException err) {
+ processException(err, "MMUddiHelper.InvalidParameterException_in_WSDL_unpublish"); //$NON-NLS-1$
+ } catch (SOAPException err) {
+ processException(err, "MMUddiHelper.SOAPException_in_WSDL_publish"); //$NON-NLS-1$
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see com.metamatrix.uddi.util.UddiHelper#getAllBusinesses(java.lang.String, java.lang.String, int)
+ * @since 5.6
+ */
+ public BusinessList getAllBusinesses( String inquiryUrl,
+ String publishUrl,
+ int maxRows ) throws MMUddiException {
+ FindBusiness findBusiness = new FindBusiness();
+ BusinessList list = null;
+ try {
+ list = findBusiness.findBusiness(inquiryUrl, publishUrl, "%", maxRows); //$NON-NLS-1$
+ } catch (TransportException err) {
+ processException(err, "MMUddiHelper.TransportException_finding_businesses"); //$NON-NLS-1$
+ } catch (MalformedURLException err) {
+ processException(err, "MMUddiHelper.MalformedURLException_all_businesses"); //$NON-NLS-1$
+ } catch (UDDIException err) {
+ processException(err, "MMUddiHelper.UDDIException_finding_all_businesses"); //$NON-NLS-1$
+ } catch (InvalidParameterException err) {
+ processException(err, "MMUddiHelper.InvalidParameterException_finding_all_businesses"); //$NON-NLS-1$
+ } catch (SOAPException err) {
+ processException(err, "MMUddiHelper.SOAPException_finding_all_businesses"); //$NON-NLS-1$
+ }
+
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see com.metamatrix.uddi.util.UddiHelper#getBusinessByName(java.lang.String, java.lang.String, int)
+ * @since 5.6
+ */
+ public BusinessList getBusinessByName( String inquiryUrl,
+ String publishUrl,
+ String searchString,
+ int maxRows ) throws MMUddiException {
+ FindBusiness findBusiness = new FindBusiness();
+ BusinessList list = null;
+ try {
+ list = findBusiness.findBusiness(inquiryUrl, publishUrl, searchString, maxRows);
+ } catch (TransportException err) {
+ processException(err, "MMUddiHelper.TransportException_finding_businesses_by_name"); //$NON-NLS-1$
+ } catch (MalformedURLException err) {
+ processException(err, "MMUddiHelper.MalformedURLException_finding_businesses_by_name"); //$NON-NLS-1$
+ } catch (UDDIException err) {
+ processException(err, "MMUddiHelper.UDDIException_finding_businesses_by_name"); //$NON-NLS-1$
+ } catch (InvalidParameterException err) {
+ processException(err, "MMUddiHelper.InvalidParameterException_finding_businesses_by_name"); //$NON-NLS-1$
+ } catch (SOAPException err) {
+ processException(err, "MMUddiHelper.SOAPException_finding_businesses_by_name"); //$NON-NLS-1$
+ }
+
+ return list;
+ }
+
+ /**
+ * @see com.metamatrix.uddi.util.UddiHelper#isPublished(java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String)
+ * @since 5.6
+ */
+ public boolean isPublished( String UddiUserName,
+ String UddiPassword,
+ String busKey,
+ String wsdlUrl,
+ String inquiryUrl,
+ String publishUrl ) throws MMUddiException {
+ GetWSDL wsdl = new GetWSDL();
+ boolean published = false;
+ try {
+ published = wsdl.isPublished(UddiUserName, UddiPassword, busKey, wsdlUrl, inquiryUrl, publishUrl);
+ } catch (MalformedURLException err) {
+ processException(err, "MMUddiHelper.MalformedURLException_isPublished"); //$NON-NLS-1$
+ } catch (TransportException err) {
+ processException(err, "MMUddiHelper.TransportException_isPublished"); //$NON-NLS-1$
+ } catch (UDDIException err) {
+ processException(err, "MMUddiHelper.UDDIException_isPublished"); //$NON-NLS-1$
+ }
+
+ return published;
+ }
+
+}
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/util/MMUddiUtil.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/util/MMUddiUtil.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/util/MMUddiUtil.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,38 @@
+/*
+ *
+ */
+package com.metamatrix.uddi.util;
+
+import java.net.MalformedURLException;
+import java.util.Properties;
+import org.uddi4j.client.UDDIProxy;
+import org.uddi4j.transport.TransportFactory;
+
+/**
+ * This class provides utility methods to the UDDI
+ */
+public class MMUddiUtil {
+
+ static final String TRANSPORT = "org.uddi4j.transport.ApacheAxisTransport"; //$NON-NLS-1$
+
+ /**
+ * Creates an instance of UDDIProxy for a given inquiry/publish URL.
+ *
+ * @param inquiryUrl
+ * @param publishUrl
+ * @return
+ * @throws MalformedURLException
+ */
+ public static UDDIProxy getUddiProxy( final String inquiryUrl,
+ final String publishUrl ) throws MalformedURLException {
+ Properties props = new Properties();
+ props.put(TransportFactory.PROPERTY_NAME, TRANSPORT);
+ // Construct a UDDIProxy object
+ UDDIProxy proxy = null;
+ proxy = new UDDIProxy(props);
+ // Select the desired UDDI server node
+ proxy.setInquiryURL(inquiryUrl);
+ proxy.setPublishURL(publishUrl);
+ return proxy;
+ }
+}
Added: trunk/federate-console/src/main/java/com/metamatrix/uddi/util/UddiHelper.java
===================================================================
--- trunk/federate-console/src/main/java/com/metamatrix/uddi/util/UddiHelper.java (rev 0)
+++ trunk/federate-console/src/main/java/com/metamatrix/uddi/util/UddiHelper.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,99 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+package com.metamatrix.uddi.util;
+
+import org.uddi4j.response.BusinessList;
+import com.metamatrix.uddi.exception.MMUddiException;
+
+/**
+ * Interface to UDDI4j's API's for UDDI Registry.
+ */
+public interface UddiHelper {
+
+ /**
+ * Publish WSDL to the UDDI Registry.
+ *
+ * @param UddiUserName The username used to logon to the UDDI registry
+ * @param UddiPassword The password used to logon to the UDDI registry
+ * @param businessKey The key for the bsusiness entity this WSDL is associated with
+ * @param wsdlUrl The URL of the WSDL to publish
+ * @param inquiryUrl The inquiry url of the UDDI registry
+ * @param publishUrl The publish url of the UDDI registry
+ * @since 5.6
+ */
+ public void publish( String UddiUserName,
+ String UddiPassword,
+ String businessKey,
+ String wsdlUrl,
+ String inquiryUrl,
+ String publishUrl ) throws MMUddiException;
+
+ /**
+ * Un-Publish WSDL from the UDDI Registry.
+ *
+ * @param UddiUserName The username used to logon to the UDDI registry
+ * @param UddiPassword The password used to logon to the UDDI registry
+ * @param businessKey The key for the bsusiness entity this WSDL is associated with
+ * @param wsdlUrl The url for the WSDL to be un-published
+ * @param inquiryUrl The inquiry url of the UDDI registry
+ * @param publishUrl The publish url of the UDDI registry
+ * @since 5.6
+ */
+ public void unPublish( String UddiUserName,
+ String UddiPassword,
+ String businessKey,
+ String wsdlUrl,
+ String inquiryUrl,
+ String publishUrl ) throws MMUddiException;
+
+ /**
+ * Get all businesses from the UDDI Registry.
+ *
+ * @param inquiryUrl The inquiry url of the UDDI registry
+ * @param publishUrl The publish url of the UDDI registry
+ * @param maxRows Maximum rows to be returned.
+ * @return List List of matching <@link BusinessEntity>s
+ * @throws Exception If the UDDI call fails with error.
+ * @since 5.6
+ */
+ public BusinessList getAllBusinesses( String inquiryUrl,
+ String publishUrl,
+ int maxrows ) throws MMUddiException;
+
+ /**
+ * Get business by name from the UDDI Registry.
+ *
+ * @param inquiryUrl The inquiry url of the UDDI registry
+ * @param publishUrl The publish url of the UDDI registry
+ * @param searchString Business name search string.
+ * @param maxRows Maximum rows to be returned.
+ * @return List List of matching <@link BusinessEntity>s
+ * @throws Exception If the UDDI call fails with error.
+ * @since 5.6
+ */
+ public BusinessList getBusinessByName( String inquiryUrl,
+ String publishUrl,
+ String searchString,
+ int maxRows ) throws MMUddiException;
+
+ /**
+ * Determine if passed WSDL is published.
+ *
+ * @param user The user name for the UDDI Registry.
+ * @param password The password for the UDDI Registry
+ * @param wsdlUrl The url for the WSDL to search for
+ * @param inquiryUrl Inquiry URL of the UDDI Registry
+ * @param publishUrl The publish url of the UDDI registry
+ * @return boolean true (published) or false (not published)
+ * @throws Exception If the UDDI call fails with error.
+ * @since 5.6
+ */
+ public boolean isPublished( String UddiUserName,
+ String UddiPassword,
+ String busKey,
+ String wsdlUrl,
+ String inquiryUrl,
+ String publishUrl ) throws MMUddiException;
+
+}
Added: trunk/federate-console/src/main/resources/com/metamatrix/uddi/i18n.properties
===================================================================
--- trunk/federate-console/src/main/resources/com/metamatrix/uddi/i18n.properties (rev 0)
+++ trunk/federate-console/src/main/resources/com/metamatrix/uddi/i18n.properties 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,31 @@
+# Copyright © 2008 Varsity Gateway LLC. All rights reserved.
+MMUddiHelper.InvalidParameterException_in_Add_Business=InvalidParameterException while adding business: {0}
+
+MMUddiHelper.TransportException_in_WSDL_publish=TransportException while publishing WSDL: {0}
+MMUddiHelper.MalformedURLException_in_WSDL_publish=MalformedURLExceptrion while publishing WSDL: {0}
+MMUddiHelper.UDDIException_in_WSDL_publish=UDDIExceptrion while publishing WSDL: {0}
+MMUddiHelper.InvalidParameterException_in_WSDL_publish=InvalidParameterExceptrion while publishing WSDL: {0}
+MMUddiHelper.SOAPException_in_WSDL_publish=SOAPExceptrion while publishing WSDL: {0}
+
+MMUddiHelper.TransportException_in_WSDL_unpublish=TransportException while un-publishing WSDL: {0}
+MMUddiHelper.MalformedURLException_in_WSDL_unpublish=MalformedURLExceptrion while un-publishing WSDL: {0}
+MMUddiHelper.UDDIException_in_WSDL_unpublish=UDDIExceptrion while un-publishing WSDL: {0}
+MMUddiHelper.InvalidParameterException_in_WSDL_unpublish=InvalidParameterExceptrion while un-publishing WSDL: {0}
+MMUddiHelper.SOAPException_in_WSDL_unpublish=SOAPException while un-publishing WSDL: {0}
+
+MMUddiHelper.TransportException_isPublished=MMUddiHelper.TransportException in isPublished()" {0}
+MMUddiHelper.MalformedURLException_isPublished=MMUddiHelper. in isPublished()" {0}
+MMUddiHelper.UDDIException_isPublished=UDDIException in isPublished(): {0}
+
+MMUddiHelper.TransportException_finding_businesses_by_name=TransportException while finding business by name: {0}
+MMUddiHelper.MalformedURLException_finding_businesses_by_name=MalformedURLException while finding business by name: {0}
+MMUddiHelper.UDDIException_finding_businesses_by_name=UDDIException while finding business by name: {0}
+MMUddiHelper.InvalidParameterException_finding_businesses_by_name=InvalidParameterExceptrion while finding business by name: {0}
+MMUddiHelper.SOAPException_finding_businesses_by_name=SOAPException while finding business by name: {0}
+
+MMUddiHelper.TransportException_finding_all_businesses=TransportException while finding all businesses: {0}
+MMUddiHelper.MalformedURLException_finding_all_businesses=MalformedURLException while finding all businesses: {0}
+MMUddiHelper.UDDIException_finding_all_businesses=UDDIException while finding finding all businesses: {0}
+MMUddiHelper.InvalidParameterException_finding_all_businesses=InvalidParameterExceptrion while finding all businesses: {0}
+MMUddiHelper.SOAPException_finding_all_businesses=SOAPException while finding all businesses: {0}
+UnPublishWSDL.UnpublishWsdl.ErrorDeletingService=Error during deletion of Service operator: {0} generic: {1}
Added: trunk/federate-console/src/test/java/com/metamatrix/uddi/publish/SaveBusiness.java
===================================================================
--- trunk/federate-console/src/test/java/com/metamatrix/uddi/publish/SaveBusiness.java (rev 0)
+++ trunk/federate-console/src/test/java/com/metamatrix/uddi/publish/SaveBusiness.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,124 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+
+package com.metamatrix.uddi.publish;
+
+import java.net.MalformedURLException;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.uddi4j.UDDIException;
+import org.uddi4j.client.UDDIProxy;
+import org.uddi4j.datatype.Name;
+import org.uddi4j.datatype.business.BusinessEntity;
+import org.uddi4j.response.AuthToken;
+import org.uddi4j.response.BusinessInfo;
+import org.uddi4j.response.BusinessList;
+import org.uddi4j.response.DispositionReport;
+import org.uddi4j.response.Result;
+import org.uddi4j.transport.TransportFactory;
+import org.uddi4j.util.FindQualifier;
+import org.uddi4j.util.FindQualifiers;
+
+/**
+ * Attempts to save a businessEntity. This class is strictly for building test data.
+ * <OL>
+ * <LI>Sets up a UDDIProxy object
+ * <LI>Requests an authorization token
+ * <LI>Saves a businessEntity
+ * <LI>Lists businesses starting with the the first letter of the business's name. The new business should be in the list.
+ * </OL>
+ *
+ * @since 5.6
+ */
+public class SaveBusiness {
+
+ Properties config = null;
+
+ public void addBusiness( String user,
+ String password,
+ String businessName,
+ String publishUrl,
+ String inquiryUrl ) {
+ Properties props = new Properties();
+ props.put(TransportFactory.PROPERTY_NAME, "org.uddi4j.transport.ApacheAxisTransport"); //$NON-NLS-1$
+ // Construct a UDDIProxy object
+ UDDIProxy proxy = null;
+ try {
+ proxy = new UDDIProxy(props);
+ } catch (MalformedURLException err) {
+
+ }
+
+ try {
+
+ // Select the desired UDDI server node
+ proxy.setInquiryURL(inquiryUrl);
+ proxy.setPublishURL(publishUrl);
+
+ // Pass in userid and password registered at the UDDI site
+ AuthToken token = proxy.get_authToken(user, password);
+
+ // Create minimum required data objects
+ Vector entities = new Vector();
+
+ // Create a new business entity using required elements constructor
+ // Name is the business name. BusinessKey must be "" to save a new
+ // business
+ BusinessEntity be = new BusinessEntity("", businessName); //$NON-NLS-1$
+ be.setDefaultDescriptionString("This company rocks!!"); //$NON-NLS-1$
+ entities.addElement(be);
+
+ // Save business
+ proxy.save_business(token.getAuthInfo().getText(), entities);
+
+ // Find all businesses that start with that particular letter e.g. 'S' for 'Sample Business'.
+ String businessNameLeadingSubstring = (businessName.substring(0, 1));
+
+ // creating vector of Name Object
+ Vector names = new Vector();
+ names.add(new Name(businessNameLeadingSubstring));
+
+ // Setting FindQualifiers to 'caseSensitiveMatch'
+ FindQualifiers findQualifiers = new FindQualifiers();
+ Vector qualifier = new Vector();
+ qualifier.add(new FindQualifier("caseSensitiveMatch")); //$NON-NLS-1$
+ findQualifiers.setFindQualifierVector(qualifier);
+
+ // Find businesses by name
+ // And setting the maximum rows to be returned as 0 or all.
+ BusinessList businessList = proxy.find_business(names, null, null, null, null, findQualifiers, 0);
+
+ Vector businessInfoVector = businessList.getBusinessInfos().getBusinessInfoVector();
+ for (int i = 0; i < businessInfoVector.size(); i++) {
+ BusinessInfo businessInfo = (BusinessInfo)businessInfoVector.elementAt(i);
+ System.out.println(businessInfo.getDefaultNameString());
+ }
+ }
+ // Handle possible errors
+ catch (UDDIException e) {
+ DispositionReport dr = e.getDispositionReport();
+ if (dr != null) {
+ System.out.println("UDDIException faultCode:" + e.getFaultCode() + "\n operator:" + dr.getOperator() //$NON-NLS-1$ //$NON-NLS-2$
+ + "\n generic:" + dr.getGeneric()); //$NON-NLS-1$
+
+ Vector results = dr.getResultVector();
+ for (int i = 0; i < results.size(); i++) {
+ Result r = (Result)results.elementAt(i);
+ System.out.println("\n errno:" + r.getErrno()); //$NON-NLS-1$
+ if (r.getErrInfo() != null) {
+ System.out.println("\n errCode:" + r.getErrInfo().getErrCode() + "\n errInfoText:" //$NON-NLS-1$ //$NON-NLS-2$
+ + r.getErrInfo().getText());
+ }
+ }
+ }
+
+ e.printStackTrace();
+ }
+ // Catch any other exception that may occur
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/federate-console/src/test/java/com/metamatrix/uddi/util/TestMMUddiHelper.java
===================================================================
--- trunk/federate-console/src/test/java/com/metamatrix/uddi/util/TestMMUddiHelper.java (rev 0)
+++ trunk/federate-console/src/test/java/com/metamatrix/uddi/util/TestMMUddiHelper.java 2008-11-21 16:16:10 UTC (rev 25)
@@ -0,0 +1,306 @@
+/*
+ * (c) 2008 Varsity Gateway LLC. All rights reserved.
+ */
+package com.metamatrix.uddi.util;
+
+import java.security.InvalidParameterException;
+import java.util.Vector;
+import junit.framework.TestCase;
+import org.uddi4j.UDDIException;
+import org.uddi4j.client.UDDIProxy;
+import org.uddi4j.response.AuthToken;
+import org.uddi4j.response.BusinessInfo;
+import org.uddi4j.response.BusinessInfos;
+import org.uddi4j.response.BusinessList;
+import org.uddi4j.response.DispositionReport;
+import org.uddi4j.response.Result;
+import com.metamatrix.uddi.exception.MMUddiException;
+import com.metamatrix.uddi.publish.SaveBusiness;
+
+/**
+ * Concrete example of UddiHelper.
+ *
+ * @since 5.5.3
+ */
+public class TestMMUddiHelper extends TestCase {
+ private final static String user = "juddi"; //$NON-NLS-1$
+
+ private final static String password = "password"; //$NON-NLS-1$
+
+ private final static String businessName = "MetaMatrix"; //$NON-NLS-1$
+
+ private final static String url = "http://slntdb07.mm.atl2.redhat.com:8080/juddi/SqlQueryWebService.wsdl"; //$NON-NLS-1$
+
+ private final static String uddiHost = "slntdb07.mm.atl2.redhat.com"; //$NON-NLS-1$
+
+ private final static String uddiPort = "8080"; //$NON-NLS-1$
+
+ private final static String scheme = "http://"; //$NON-NLS-1$
+
+ private final static String colon = ":"; //$NON-NLS-1$
+
+ private final static String inquiryUrl = scheme + uddiHost + colon
+ + uddiPort + "/juddi/inquiry"; //$NON-NLS-1$
+
+ private final static String publishUrl = scheme + uddiHost + colon
+ + uddiPort + "/juddi/publish"; //$NON-NLS-1$
+
+ private MMUddiHelper helper = new MMUddiHelper();
+
+ /*
+ * @see TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ // cleanRegistry();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Delete all BusinessEntities from the test UDDI registry
+ */
+ public void testCleanRegistry() throws Exception {
+
+ System.out.println("Cleaning registry..."); //$NON-NLS-1$
+
+ UDDIProxy proxy = MMUddiUtil.getUddiProxy(inquiryUrl, publishUrl);
+
+ try {
+
+ // Pass in userid and password registered at the UDDI site
+ AuthToken token = proxy.get_authToken(user, password);
+
+ // Find businesses by Business name
+ // And setting the maximum rows to be returned as 5.
+ BusinessList businessList = helper.getAllBusinesses(inquiryUrl,
+ publishUrl, 100);
+
+ Vector businessInfoVector = businessList.getBusinessInfos()
+ .getBusinessInfoVector();
+
+ // Try to delete any businesses with this name. Multiple businesses
+ // with the same
+ // name may have been created by different userids. Delete will fail
+ // for businesses
+ // not created by this id
+ for (int i = 0; i < businessInfoVector.size(); i++) {
+ BusinessInfo bi = (BusinessInfo) businessInfoVector
+ .elementAt(i);
+ System.out.println("Found business key:" + bi.getBusinessKey()); //$NON-NLS-1$
+
+ // Have found the matching business key, delete using the
+ // authToken
+ DispositionReport dr = proxy.delete_business(token
+ .getAuthInfoString(), bi.getBusinessKey());
+
+ if (dr.success()) {
+ System.out.println("Business successfully deleted"); //$NON-NLS-1$
+ } else {
+ System.out
+ .println(" Error during deletion of Business\n" + "\n operator:" + dr.getOperator() + "\n generic:" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + dr.getGeneric());
+
+ Vector results = dr.getResultVector();
+ for (int j = 0; j < results.size(); j++) {
+ Result r = (Result) results.elementAt(j);
+ System.out.println("\n errno:" + r.getErrno()); //$NON-NLS-1$
+ if (r.getErrInfo() != null) {
+ System.out
+ .println("\n errCode:" + r.getErrInfo().getErrCode() + "\n errInfoText:" //$NON-NLS-1$ //$NON-NLS-2$
+ + r.getErrInfo().getText());
+ }
+ }
+ }
+ }
+ }
+ // Handle possible errors
+ catch (UDDIException e) {
+ DispositionReport dr = e.getDispositionReport();
+ if (dr != null) {
+ System.out
+ .println("UDDIException faultCode:" + e.getFaultCode() + "\n operator:" + dr.getOperator() //$NON-NLS-1$ //$NON-NLS-2$
+ + "\n generic:" + dr.getGeneric()); //$NON-NLS-1$
+
+ Vector results = dr.getResultVector();
+ for (int i = 0; i < results.size(); i++) {
+ Result r = (Result) results.elementAt(i);
+ System.out.println("\n errno:" + r.getErrno()); //$NON-NLS-1$
+ if (r.getErrInfo() != null) {
+ System.out
+ .println("\n errCode:" + r.getErrInfo().getErrCode() + "\n errInfoText:" //$NON-NLS-1$ //$NON-NLS-2$
+ + r.getErrInfo().getText());
+ }
+ }
+ }
+ e.printStackTrace();
+ }
+ // Catch any other exception that may occur
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Finished cleaning registry!"); //$NON-NLS-1$
+ }
+
+ /**
+ * Test the addBusiness() method of MMUddiHelper
+ *
+ * @since 5.6
+ */
+ public void testAddBusiness() {
+
+ try {
+ addBusiness(user, password, businessName, inquiryUrl, publishUrl);
+ } catch (MMUddiException err) {
+ err.printStackTrace();
+ }
+ }
+
+ /**
+ * Test the publish() method of MMUddiHelper
+ *
+ * @since 5.6
+ */
+ public void testPublish() {
+
+ try {
+
+ helper.publish(user, password, getBusinessKeyHelper(), url,
+ inquiryUrl, publishUrl);
+
+ } catch (MMUddiException err) {
+ err.printStackTrace();
+ fail(err.getMessage());
+ }
+ }
+
+ /**
+ * @see com.metamatrix.uddi.util.UddiHelper#getAllBusinesses(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String)
+ * @since 5.6
+ */
+ public void testIsPublished() {
+ boolean published = false;
+
+ try {
+ published = helper.isPublished(user, password,
+ getBusinessKeyHelper(), url, inquiryUrl, publishUrl);
+ } catch (MMUddiException err) {
+ err.printStackTrace();
+ fail(err.getMessage());
+ }
+
+ assertEquals(true, published);
+ }
+
+ /**
+ * @return
+ * @throws MMUddiException
+ */
+ private String getBusinessKeyHelper() throws MMUddiException {
+ String businessKey = ""; //$NON-NLS-1$
+ BusinessList businessList = helper.getBusinessByName(inquiryUrl,
+ publishUrl, businessName, 1);
+
+ BusinessInfos businessInfos = businessList.getBusinessInfos();
+ // Take first business key we find
+ for (int i = 0; i < businessInfos.size(); i++) {
+ BusinessInfo entity = businessInfos.get(i);
+ businessKey = entity.getBusinessKey();
+ break;
+ }
+ return businessKey;
+ }
+
+ /**
+ * @see com.metamatrix.uddi.util.UddiHelper#getAllBusinesses(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String)
+ * @since 5.6
+ */
+ public void testGetAllBusinesses() {
+ BusinessList businessList = new BusinessList();
+ try {
+ businessList = helper.getAllBusinesses(inquiryUrl, publishUrl, 10);
+ } catch (MMUddiException err) {
+ err.printStackTrace();
+ fail(err.getMessage());
+ }
+ BusinessInfos businessInfos = businessList.getBusinessInfos();
+ for (int i = 0; i < businessInfos.size(); i++) {
+ BusinessInfo entity = businessInfos.get(i);
+ System.out.println(entity.getDefaultNameString());
+ }
+ }
+
+ /**
+ * @see com.metamatrix.uddi.util.UddiHelper#getBusinessByName(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String)
+ * @since 5.6
+ */
+ public void testGetBusinessByName() {
+
+ String searchString = "%" + businessName.substring(2, 3) + "%"; //$NON-NLS-1$ //$NON-NLS-2$
+ BusinessList businessList = new BusinessList();
+ try {
+ businessList = helper.getBusinessByName(inquiryUrl, publishUrl,
+ searchString, 10); //$NON-NLS-1$
+ } catch (MMUddiException err) {
+ err.printStackTrace();
+ }
+ BusinessInfos businessInfos = businessList.getBusinessInfos();
+ for (int i = 0; i < businessInfos.size(); i++) {
+ BusinessInfo entity = businessInfos.get(i);
+ System.out.println(entity.getDefaultNameString());
+ }
+ }
+
+ /**
+ * Test the unPublish() method of MMUddiHelper
+ *
+ * @since 5.6
+ */
+ public void testUnPublish() {
+ try {
+ String businessKey = getBusinessKeyHelper();
+ helper.unPublish(user, password, businessKey, url, inquiryUrl,
+ publishUrl);
+ } catch (MMUddiException err) {
+ err.printStackTrace();
+ }
+ }
+
+ /**
+ * Add a business to the UDDI Registry.
+ *
+ * @param UddiUserName
+ * The username used to logon to the UDDI registry
+ * @param UddiPassword
+ * The password used to logon to the UDDI registry
+ * @param businessName
+ * The name for the bussiness entity to add
+ * @param inquiryUrl
+ * The inquiry url of the UDDI registry
+ * @param publishUrl
+ * The publish url of the UDDI registry
+ * @since 5.6
+ */
+ public void addBusiness(String uddiUserName, String uddiPassword,
+ String businessName, String inquiryUrl, String publishUrl)
+ throws MMUddiException {
+
+ SaveBusiness saveBusiness = new SaveBusiness();
+ try {
+ saveBusiness.addBusiness(uddiUserName, uddiPassword, businessName,
+ publishUrl, inquiryUrl);
+ } catch (InvalidParameterException err) {
+ err.printStackTrace();
+ }
+ }
+
+}
More information about the federate-commits
mailing list