Author: kstam
Date: Sat Feb  4 16:43:43 2012
New Revision: 1240536

URL: http://svn.apache.org/viewvc?rev=1240536&view=rev
Log:
SCOUT-106, SCOUT-107 turns out the spec requires the 
javax.xml.registry.queryManagerURL to be defined (you should throw an 
InvalidRequestException rather then defaulting it to something)

Modified:
    juddi/scout/trunk/pom.xml
    
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java
    
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java
    
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java
    
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
    
juddi/scout/trunk/src/test/java/org/apache/ws/scout/registry/ConnectionFactoryTest.java

Modified: juddi/scout/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/juddi/scout/trunk/pom.xml?rev=1240536&r1=1240535&r2=1240536&view=diff
==============================================================================
--- juddi/scout/trunk/pom.xml (original)
+++ juddi/scout/trunk/pom.xml Sat Feb  4 16:43:43 2012
@@ -8,7 +8,7 @@
        </parent>
        <groupId>org.apache.juddi.scout</groupId>
        <artifactId>scout</artifactId>
-       <version>1.2.6-SNAPSHOT</version>
+       <version>1.2.5-SNAPSHOT</version>
        <packaging>bundle</packaging>
 
        <properties>

Modified: 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java?rev=1240536&r1=1240535&r2=1240536&view=diff
==============================================================================
--- 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java
 (original)
+++ 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java
 Sat Feb  4 16:43:43 2012
@@ -23,6 +23,7 @@ import java.util.Properties;
 import javax.xml.registry.Connection;
 import javax.xml.registry.ConnectionFactory;
 import javax.xml.registry.FederatedConnection;
+import javax.xml.registry.InvalidRequestException;
 import javax.xml.registry.JAXRException;
 import javax.xml.registry.UnsupportedCapabilityException;
 
@@ -63,6 +64,9 @@ public class ConnectionFactoryImpl exten
 
     public Connection createConnection() throws JAXRException
     {
+        //The JAXR spec requires the queryManagerURL to be defined
+        String queryManagerURL = properties.getProperty(QUERYMANAGER_PROPERTY);
+        if (queryManagerURL==null) throw new InvalidRequestException("Missing 
required property " + QUERYMANAGER_PROPERTY);
         return new ConnectionImpl(properties);
     }
 

Modified: 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java
URL: 
http://svn.apache.org/viewvc/juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java?rev=1240536&r1=1240535&r2=1240536&view=diff
==============================================================================
--- 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java
 (original)
+++ 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java
 Sat Feb  4 16:43:43 2012
@@ -21,6 +21,7 @@ import java.util.Properties;
 import java.util.Set;
 
 import javax.xml.registry.Connection;
+import javax.xml.registry.InvalidRequestException;
 import javax.xml.registry.JAXRException;
 import javax.xml.registry.RegistryService;
 
@@ -53,7 +54,7 @@ public class ConnectionImpl implements C
     private String uddiVersion;
     UDDIClerkManager manager = null;
 
-    public ConnectionImpl(Properties properties)
+    public ConnectionImpl(Properties properties) throws InvalidRequestException
     {
         postalScheme = 
properties.getProperty(ConnectionFactoryImpl.POSTALADDRESSSCHEME_PROPERTY);
         String val = 
properties.getProperty(ConnectionFactoryImpl.MAXROWS_PROPERTY);

Modified: 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java
URL: 
http://svn.apache.org/viewvc/juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java?rev=1240536&r1=1240535&r2=1240536&view=diff
==============================================================================
--- 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java 
(original)
+++ 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java 
Sat Feb  4 16:43:43 2012
@@ -34,6 +34,7 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.registry.InvalidRequestException;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.logging.Log;
@@ -105,8 +106,6 @@ import org.xml.sax.SAXException;
 
 public class RegistryImpl implements IRegistry {
 
-       public static final String DEFAULT_INQUIRY_ENDPOINT        = 
"http://localhost:8080/juddi/inquiry";;
-       public static final String DEFAULT_PUBLISH_ENDPOINT        = 
"http://localhost:8080/juddi/publish";;
        public static final String DEFAULT_ADMIN_ENDPOINT          = 
"http://localhost:8080/juddi/admin";;
        public static final String DEFAULT_TRANSPORT_CLASS         = 
"org.apache.ws.scout.transport.SaajTransport";
        public static final String DEFAULT_SECURITY_PROVIDER       = 
"com.sun.net.ssl.internal.ssl.Provider";
@@ -135,26 +134,32 @@ public class RegistryImpl implements IRe
 
        /**
         * Creates a new instance of RegistryImpl.
+        * @throws InvalidRequestException 
         */
-       public RegistryImpl(Properties props) {
+       public RegistryImpl(Properties props) throws InvalidRequestException {
                super();
 
                this.init(props);
        }
 
        /**
+        * @throws InvalidRequestException 
         * 
         */
-       private void init(Properties props) {
+       private void init(Properties props) throws InvalidRequestException {
                // We need to have a non-null Properties
                // instance so initialization takes place.
                if (props == null) props = new Properties();
 
                // Override defaults with specific specific values
                try {
-                       setInquiryURI(new 
URI(props.getProperty(ConnectionFactoryImpl.QUERYMANAGER_PROPERTY,DEFAULT_INQUIRY_ENDPOINT)));
-                       setPublishURI(new 
URI(props.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY, 
DEFAULT_PUBLISH_ENDPOINT)));
-                       setSecurityURI(new 
URI(props.getProperty(ConnectionFactoryImpl.SECURITYMANAGER_PROPERTY, 
getPublishURI().toString())));
+                       setInquiryURI(new 
URI(props.getProperty(ConnectionFactoryImpl.QUERYMANAGER_PROPERTY)));
+                       if 
(props.containsKey(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY)) {
+                           setPublishURI(new 
URI(props.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY)));
+                       }
+                       String securityURL = 
props.getProperty(ConnectionFactoryImpl.SECURITYMANAGER_PROPERTY, 
+                               
props.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY));
+                       if (securityURL!=null) setSecurityURI(new 
URI(securityURL));
                        setAdminURI(new 
URI(props.getProperty(ConnectionFactoryImpl.ADMIN_ENDPOINT_PROPERTY, 
DEFAULT_ADMIN_ENDPOINT)));
                        
setSecurityProvider(props.getProperty(ConnectionFactoryImpl.SECURITY_PROVIDER_PROPERTY,
 DEFAULT_SECURITY_PROVIDER));
                        
setProtocolHandler(props.getProperty(ConnectionFactoryImpl.PROTOCOL_HANDLER_PROPERTY,
 DEFAULT_PROTOCOL_HANDLER));
@@ -165,9 +170,8 @@ public class RegistryImpl implements IRe
                        JAXBContext context = 
JAXBContextUtil.getContext(JAXBContextUtil.UDDI_V2_VERSION);
             unmarshaller = context.createUnmarshaller(); 
             marshaller = context.createMarshaller();
-            
                } catch (URISyntaxException muex) {
-                       throw new RuntimeException(muex);
+                       throw new 
InvalidRequestException(muex.getMessage(),muex);
                } catch(JAXBException e) {
            throw new RuntimeException(e);
         }

Modified: 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
URL: 
http://svn.apache.org/viewvc/juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java?rev=1240536&r1=1240535&r2=1240536&view=diff
==============================================================================
--- 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
 (original)
+++ 
juddi/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
 Sat Feb  4 16:43:43 2012
@@ -35,6 +35,7 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.registry.InvalidRequestException;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.logging.Log;
@@ -144,17 +145,19 @@ public class RegistryV3Impl implements I
 
        /**
         * Creates a new instance of RegistryImpl.
+        * @throws InvalidRequestException 
         */
-       public RegistryV3Impl(Properties props, String nodeName, String 
managerName) {
+       public RegistryV3Impl(Properties props, String nodeName, String 
managerName) throws InvalidRequestException {
                super();
 
                this.init(props, nodeName, managerName);
        }
 
        /**
+        * @throws InvalidRequestException 
         * 
         */
-       private void init(Properties props, String nodeName, String 
managerName) {
+       private void init(Properties props, String nodeName, String 
managerName) throws InvalidRequestException {
            this.nodeName = nodeName;
            this.managerName = managerName;
         // We need to have a non-null Properties
@@ -182,7 +185,7 @@ public class RegistryV3Impl implements I
             marshaller = context.createMarshaller();
             
         } catch (URISyntaxException muex) {
-            throw new RuntimeException(muex);
+            throw new InvalidRequestException(muex.getMessage(), muex);
         } catch(JAXBException e) {
            throw new RuntimeException(e);
         }

Modified: 
juddi/scout/trunk/src/test/java/org/apache/ws/scout/registry/ConnectionFactoryTest.java
URL: 
http://svn.apache.org/viewvc/juddi/scout/trunk/src/test/java/org/apache/ws/scout/registry/ConnectionFactoryTest.java?rev=1240536&r1=1240535&r2=1240536&view=diff
==============================================================================
--- 
juddi/scout/trunk/src/test/java/org/apache/ws/scout/registry/ConnectionFactoryTest.java
 (original)
+++ 
juddi/scout/trunk/src/test/java/org/apache/ws/scout/registry/ConnectionFactoryTest.java
 Sat Feb  4 16:43:43 2012
@@ -141,18 +141,24 @@ public class ConnectionFactoryTest exten
     public void testCreateConnectionWithNullLifeCycleURL() throws 
JAXRException {
         Properties properties = new Properties();
         properties.setProperty(ConnectionFactoryImpl.QUERYMANAGER_PROPERTY, 
"http://localhost";);
-        factory.setProperties(properties);
-        Connection c = factory.createConnection();
+        Connection c = null;
         try {
+            factory.setProperties(properties);
+            c = factory.createConnection();
             assertEquals(ConnectionImpl.class, c.getClass());
+        } catch (Exception e) {
+            fail("it's ok to have a null lifeCycleURL");
         } finally {
-            c.close();
+            if (c!=null) c.close();
         }
     }
 
     public void testCreateConnectionWithNullQueryURL() {
         try {
             factory.createConnection();
+            fail("should have thrown an InvalidRequestException");
+        } catch (InvalidRequestException ire) {
+            //expected
         } catch (Exception e) {
             fail("threw Exception");
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to