You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2017/10/09 16:17:38 UTC

juddi git commit: JUDDI-943 fixed

Repository: juddi
Updated Branches:
  refs/heads/master de1de4c4f -> 6ea7ff250


JUDDI-943 fixed


Project: http://git-wip-us.apache.org/repos/asf/juddi/repo
Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/6ea7ff25
Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/6ea7ff25
Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/6ea7ff25

Branch: refs/heads/master
Commit: 6ea7ff2503c0a536c6f35d6806b114688d7d4063
Parents: de1de4c
Author: Alex O'Ree <al...@apache.org>
Authored: Mon Oct 9 12:17:35 2017 -0400
Committer: Alex O'Ree <al...@apache.org>
Committed: Mon Oct 9 12:17:35 2017 -0400

----------------------------------------------------------------------
 .../juddi/v3/client/config/WebHelper.java       | 140 ++++++++++---------
 .../juddi/v3/client/config/WebHelperTest.java   |   2 -
 2 files changed, 73 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/juddi/blob/6ea7ff25/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java
----------------------------------------------------------------------
diff --git a/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java b/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java
index 67345ee..b920e72 100644
--- a/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java
+++ b/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java
@@ -22,73 +22,79 @@ import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+/**
+ * 
+ * @author kstam
+ */
 public class WebHelper {
-	
-	public static final Log logger = LogFactory.getLog(WebHelper.class);
-	public static final String UDDI_CLIENT_NAME           = "uddi.client.name";
-	public static final String UDDI_CLIENT_CONFIG_FILE    = "uddi.client.config.file";
-	public static final String JUDDI_CLIENT_NAME          = "juddi.client.name";
-	public static final String JUDDI_CLIENT_TRANSPORT     = "juddi.client.transport";
-	
 
-	/**
-	 * Checks the servlet context for the manager defined in the web context. Optionally, in your 
-	 * web.xml you can specify either the manager name if you want to use an existing manager 
-	 * called 'uddi-portlet-manager':
-	 * <pre>
-	 * &lt;context-param&gt;
-	 *   &lt;param-name&gt;uddi.client.manager.name&lt;/param-name&gt;
-	 *   &lt;param-value&gt;uddi-portlet-manager&lt;/param-value&gt;
-	 * &lt;/context-param&gt;
-	 * </pre>
-	 * or, if you don't want to use the default META-INF/uddi.xml file path, but 'META-INF/my-uddi.xml' instead,
-	 * then you can set:
-	 * <pre>
-	 * &lt;context-param&gt;
-	 *   &lt;param-name&gt;uddi.client.config.path&lt;/param-name&gt;
-	 *   &lt;param-value&gt;META-INF/my-uddi.xml&lt;/param-value&gt;
-	 * &lt;/context-param&gt;
-	 * </pre>
-	 * @param servletContext
-	 * @return a UDDI Client instance
-	 * @throws ConfigurationException
-	 */
-	public static UDDIClient getUDDIClient(ServletContext servletContext) throws ConfigurationException 
-	{
-		if (servletContext.getAttribute(JUDDI_CLIENT_NAME)!=null) {
-			String clientName = String.valueOf(servletContext.getAttribute(JUDDI_CLIENT_NAME));
-			return UDDIClientContainer.getUDDIClient(clientName);
-		} else {
-			String clientName = servletContext.getInitParameter(UDDI_CLIENT_NAME);
-			if (clientName!=null) {
-				try {
-					UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
-					logger.info("Client " + clientName + " was already started.");
-					servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName);
-					return client;
-				} catch (ConfigurationException ce) {
-					logger.debug("Client " + clientName + " is not yet started.");
-				}
-			}
-			String clientConfigFile = servletContext.getInitParameter(UDDI_CLIENT_CONFIG_FILE);
-			if (clientConfigFile==null) clientConfigFile = ClientConfig.DEFAULT_UDDI_CONFIG;
-			
-			logger.info("Reading the clientName from the clientConfig file " + clientConfigFile);
-			UDDIClient client = new UDDIClient(clientConfigFile);
-			if (client.getName()==null) {
-				logger.warn("Deprecated, client name set to 'default', however it should be provided in the uddi.xml");
-				clientName = "default";
-			}
-			if (client.getName()!=null) {
-				logger.info("Starting Client " + client.getName() + "...");
-                    clientName = client.getName();
-			} else {
-				throw new ConfigurationException("A client name needs to be specified in the client config file.");
-			}
-			
-			client.start();
-			servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName);
-			return client;
-		}
-	}
+        public static final Log logger = LogFactory.getLog(WebHelper.class);
+        public static final String UDDI_CLIENT_NAME = "uddi.client.name";
+        public static final String UDDI_CLIENT_CONFIG_FILE = "uddi.client.config.file";
+        public static final String JUDDI_CLIENT_NAME = "juddi.client.name";
+        public static final String JUDDI_CLIENT_TRANSPORT = "juddi.client.transport";
+
+        /**
+         * Checks the servlet context for the manager defined in the web
+         * context. Optionally, in your web.xml you can specify either the
+         * manager name if you want to use an existing manager called
+         * 'uddi-portlet-manager':
+         * <pre>
+         * &lt;context-param&gt;
+         *   &lt;param-name&gt;uddi.client.manager.name&lt;/param-name&gt;
+         *   &lt;param-value&gt;uddi-portlet-manager&lt;/param-value&gt;
+         * &lt;/context-param&gt;
+         * </pre> or, if you don't want to use the default META-INF/uddi.xml
+         * file path, but 'META-INF/my-uddi.xml' instead, then you can set:
+         * <pre>
+         * &lt;context-param&gt;
+         *   &lt;param-name&gt;uddi.client.config.path&lt;/param-name&gt;
+         *   &lt;param-value&gt;META-INF/my-uddi.xml&lt;/param-value&gt;
+         * &lt;/context-param&gt;
+         * </pre>
+         *
+         * @param servletContext
+         * @return a UDDI Client instance
+         * @throws ConfigurationException
+         */
+        public static UDDIClient getUDDIClient(ServletContext servletContext) throws ConfigurationException {
+                if (servletContext.getAttribute(JUDDI_CLIENT_NAME) != null) {
+                        String clientName = String.valueOf(servletContext.getAttribute(JUDDI_CLIENT_NAME));
+                        return UDDIClientContainer.getUDDIClient(clientName);
+                } else {
+                        String clientName = servletContext.getInitParameter(UDDI_CLIENT_NAME);
+                        if (clientName != null) {
+                                try {
+                                        UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
+                                        logger.info("Client " + clientName + " was already started.");
+                                        servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName);
+                                        return client;
+                                } catch (ConfigurationException ce) {
+                                        logger.debug("Client " + clientName + " is not yet started.");
+                                }
+                        }
+                        String clientConfigFile = servletContext.getInitParameter(UDDI_CLIENT_CONFIG_FILE);
+                        if (clientConfigFile == null) {
+                                clientConfigFile = ClientConfig.DEFAULT_UDDI_CONFIG;
+                        }
+                        
+
+                        logger.info("Reading the clientName from the clientConfig file " + clientConfigFile);
+                        UDDIClient client = new UDDIClient(clientConfigFile);
+                        if (client.getName() == null) {
+                                logger.warn("Deprecated, client name set to 'default', however it should be provided in the uddi.xml");
+                                clientName = "default";
+                        }
+                        if (client.getName() != null) {
+                                logger.info("Starting Client " + client.getName() + "...");
+                                clientName = client.getName();
+                        } else {
+                                throw new ConfigurationException("A client name needs to be specified in the client config file.");
+                        }
+
+                        client.start();
+                        servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName);
+                        return client;
+                }
+        }
 }

http://git-wip-us.apache.org/repos/asf/juddi/blob/6ea7ff25/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java
----------------------------------------------------------------------
diff --git a/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java b/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java
index 57fdc2d..283c194 100644
--- a/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java
+++ b/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java
@@ -17,7 +17,6 @@ package org.apache.juddi.v3.client.config;
 
 import java.util.UUID;
 import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.configuration.ConfigurationException;
 import static org.apache.juddi.v3.client.config.WebHelper.JUDDI_CLIENT_NAME;
 import static org.apache.juddi.v3.client.config.WebHelper.UDDI_CLIENT_CONFIG_FILE;
@@ -27,7 +26,6 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.*;
 import static org.easymock.EasyMock.*;
 import org.junit.Assert;
 


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