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 2013/11/10 14:57:30 UTC

svn commit: r1540474 - in /juddi/trunk/juddi-core/src: main/java/org/apache/juddi/model/ main/java/org/apache/juddi/validation/ main/resources/ test/java/org/apache/juddi/api/impl/

Author: alexoree
Date: Sun Nov 10 13:57:29 2013
New Revision: 1540474

URL: http://svn.apache.org/r1540474
Log:
JUDDI-705 fixed. validation added, model/Node.java updated to have explicit lengths for all fields

Modified:
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/model/Node.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java
    juddi/trunk/juddi-core/src/main/resources/messages.properties
    juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_100_ClientSubscriptionInfoTest.java

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/model/Node.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/model/Node.java?rev=1540474&r1=1540473&r2=1540474&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/model/Node.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/model/Node.java Sun Nov 10 13:57:29 2013
@@ -31,12 +31,10 @@ public class Node implements java.io.Ser
 	@Transient
 	private static final long serialVersionUID = -893203927029468343L;
 	@Id
-	@Column(name="name", nullable = false)
+	@Column(name="name", nullable = false, length=255)
 	private String name;
 	@Column(name="client_name", nullable = false, length=255)
 	private String clientName;
-	@Column(name="proxy_transport", nullable = false, length=255)
-	private String proxyTransport;
 	@Column(name="security_url", nullable = false, length=255)
 	private String securityUrl;
 	@Column(name="inquiry_url", nullable = false, length=255)
@@ -47,13 +45,16 @@ public class Node implements java.io.Ser
 	private String custodyTransferUrl;
 	@Column(name="subscription_url", nullable = false, length=255)
 	private String subscriptionUrl;
-	@Column(name="juddi_api_url", length=255)
+        @Column(name="proxy_transport", nullable = false, length=255)
+	private String proxyTransport;
+        
+	@Column(name="juddi_api_url", nullable = true, length=255)
 	private String juddiApiUrl;
-	@Column(name="factory_initial", length=255)
+	@Column(name="factory_initial", nullable = true, length=255)
 	private String factoryInitial;
-	@Column(name="factory_url_pkgs", length=255)
+	@Column(name="factory_url_pkgs", nullable = true, length=255)
 	private String factoryURLPkgs;
-	@Column(name="factory_naming_provider", length=255)
+	@Column(name="factory_naming_provider", nullable = true, length=255)
 	private String factoryNamingProvider;
 
 	public Node() {}

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java?rev=1540474&r1=1540473&r2=1540474&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateNode.java Sun Nov 10 13:57:29 2013
@@ -14,10 +14,11 @@
  * limitations under the License.
  *
  */
-
 package org.apache.juddi.validation;
 
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.persistence.EntityManager;
 
@@ -28,54 +29,93 @@ import org.apache.juddi.v3.error.FatalEr
 import org.apache.juddi.v3.error.ValueNotAllowedException;
 import org.uddi.v3_service.DispositionReportFaultMessage;
 
-
 /**
  * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
  */
 public class ValidateNode extends ValidateUDDIApi {
 
-	public ValidateNode(UddiEntityPublisher publisher) {
-		super(publisher);
-	}
-
-	
-	
-	/*-------------------------------------------------------------------
-	 ClientSubscriptionInf functions are specific to jUDDI.
-	 --------------------------------------------------------------------*/
-
-
-	public void validateSaveNode(EntityManager em, org.apache.juddi.api_v3.SaveNode body) throws DispositionReportFaultMessage {
-
-		if (body == null)
-			throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
-		
-		// No null or empty list
-		List<Node> nodes = body.getNode();
-		if (nodes == null)
-			throw new ValueNotAllowedException(new ErrorMessage("errors.saveNodes.NoInput"));
-		
-		for (Node clerk : body.getNode()) {
-			validateNode(clerk);
-		}
-
-	}
-	
-	public void validateNode(org.apache.juddi.api_v3.Node node) throws DispositionReportFaultMessage {
-
-		// No null input
-		if (node == null)
-			throw new ValueNotAllowedException(new ErrorMessage("errors.node.NullInput"));
-		
-		String name = node.getName();
-		if (name == null || name.length() == 0)
-			throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoName"));
-	
-		//TODO could check we have all the urls
-	
-	}
-	
-	
-	
-	
+    public ValidateNode(UddiEntityPublisher publisher) {
+        super(publisher);
+    }
+
+    /*-------------------------------------------------------------------
+     validateSaveNode functions are specific to jUDDI.
+     --------------------------------------------------------------------*/
+    public void validateSaveNode(EntityManager em, org.apache.juddi.api_v3.SaveNode body) throws DispositionReportFaultMessage {
+
+        if (body == null) {
+            throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
+        }
+
+        // No null or empty list
+        List<Node> nodes = body.getNode();
+        if (nodes == null) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.saveNodes.NoInput"));
+        }
+
+        for (Node clerk : body.getNode()) {
+            validateNode(clerk);
+        }
+
+    }
+
+    public void validateNode(org.apache.juddi.api_v3.Node node) throws DispositionReportFaultMessage {
+
+        // No null input
+        if (node == null) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NullInput"));
+        }
+
+        String name = node.getName();
+        if (name == null || name.length() == 0 || node.getClientName().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoName"));
+        }
+        if (node.getDescription() == null || node.getDescription().length() == 0 || node.getDescription().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoDescription"));
+        }
+        if (node.getClientName() == null || node.getClientName().length() == 0 || node.getClientName().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoClientName"));
+        }
+        if (node.getCustodyTransferUrl() == null || node.getCustodyTransferUrl().length() == 0 || node.getClientName().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoNCT"));
+        }
+        if (node.getInquiryUrl() == null || node.getInquiryUrl().length() == 0 || node.getInquiryUrl().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoIN"));
+        }
+        if (node.getPublishUrl() == null || node.getPublishUrl().length() == 0 || node.getPublishUrl().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoPUB"));
+        }
+        if (node.getSubscriptionListenerUrl() == null || node.getSubscriptionListenerUrl().length() == 0 || node.getSubscriptionListenerUrl().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSUBL"));
+        }
+        if (node.getSubscriptionUrl() == null || node.getSubscriptionUrl().length() == 0 || node.getSubscriptionUrl().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSUB"));
+        }
+        if (node.getProxyTransport() == null || node.getProxyTransport().length() == 0 || node.getProxyTransport().length() > 255) {
+            throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoProxy"));
+        } else {
+            try {
+                //validate that the class exists and that it is of type
+                //org.apache.juddi.v3.client.transport.Transport
+                Class<?> forName = Class.forName(node.getProxyTransport());
+                Object j = forName.newInstance();
+                if (!(j instanceof org.apache.juddi.v3.client.transport.Transport)) {
+                    throw new ValueNotAllowedException(new ErrorMessage("errors.node.illegalProxyTransport"));
+                }
+            } catch (Exception ex) {
+                throw new ValueNotAllowedException(new ErrorMessage("errors.node.illegalProxyTransport"));
+            }
+        }
+        if (node.getFactoryInitial() == null || node.getFactoryInitial().length() == 0 || node.getFactoryInitial().length() > 255) {
+            //    throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoName"));
+        }
+        if (node.getFactoryNamingProvider() == null || node.getFactoryNamingProvider().length() == 0 || node.getFactoryNamingProvider().length() > 255) {
+            //    throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoName"));
+        }
+        if (node.getFactoryURLPkgs() == null || node.getFactoryURLPkgs().length() == 0 || node.getFactoryURLPkgs().length() > 255) {
+            //    throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoName"));
+        }
+
+
+    }
 }

Modified: juddi/trunk/juddi-core/src/main/resources/messages.properties
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/resources/messages.properties?rev=1540474&r1=1540473&r2=1540474&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/resources/messages.properties (original)
+++ juddi/trunk/juddi-core/src/main/resources/messages.properties Sun Nov 10 13:57:29 2013
@@ -223,7 +223,16 @@ errors.clerk.NullNodeInput=The Node stru
 errors.clerk.NoName=A valid clerk name was not specified
 errors.clerk.NoPublisherName=A valid publisher name was not specified
 errors.node.NullInput=The Node structure cannot be blank
-errors.node.NoNameA valid node name was not specified
+errors.node.NoName=A valid node name was not specified
+errors.node.NoClientName=A valid client name was not specified
+errors.node.NoDescription=A description was not specified
+errors.node.NoCT=A custody transfer url was not specified
+errors.node.NoPUB=A publish url was not specified
+errors.node.NoIN=A inquiry url was not specified
+errors.node.NoSUBL=A subscription listener url was not specified
+errors.node.NoSUB=A subscription url was not specified
+errors.node.NoProxy=A transport proxy class must be specified. If you're not sure, use 'org.apache.juddi.v3.client.transport.JAXWSTransport'
+errors.node.illegalProxyTransport=The transport proxy class is invalid. If you're not sure, use 'org.apache.juddi.v3.client.transport.JAXWSTransport'
 
 #-- Authentication error messages
 errors.auth.AuthRequired=Authentication is required for this API call

Modified: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_100_ClientSubscriptionInfoTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_100_ClientSubscriptionInfoTest.java?rev=1540474&r1=1540473&r2=1540474&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_100_ClientSubscriptionInfoTest.java (original)
+++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_100_ClientSubscriptionInfoTest.java Sun Nov 10 13:57:29 2013
@@ -32,6 +32,7 @@ import org.apache.juddi.api_v3.SaveClerk
 import org.apache.juddi.api_v3.SaveClientSubscriptionInfo;
 import org.apache.juddi.api_v3.SaveNode;
 import org.apache.juddi.v3.error.InvalidKeyPassedException;
+import org.apache.juddi.v3.error.ValueNotAllowedException;
 import org.apache.juddi.v3.tck.TckPublisher;
 import org.apache.juddi.v3.tck.TckSecurity;
 import org.junit.AfterClass;
@@ -79,8 +80,9 @@ public class API_100_ClientSubscriptionI
 		node.setCustodyTransferUrl("http://localhost:8080/services/securityUrl");
 		node.setDescription("description");
 		node.setInquiryUrl("http://localhost:8080/services/securityUrl");
-		node.setPublishUrl("http://localhost:8080/services/securityUrl");
-		node.setProxyTransport("class");
+		node.setPublishUrl("http://localhost:8080/services/publishUrl");
+                node.setSubscriptionListenerUrl("http://localhost:8080/services/subUrladdClientSubscriptionInfo");
+		node.setProxyTransport("org.apache.juddi.v3.client.transport.JAXWSTransport");
 		node.setSubscriptionUrl("http://localhost:8080/services/securityUrl");
 		node.setName("default");
 		node.setClientName("defaultClient");
@@ -104,8 +106,9 @@ public class API_100_ClientSubscriptionI
 		node2.setDescription("description2");
 		node2.setInquiryUrl("http://localhost:8080/services/securityUrl2");
 		node2.setPublishUrl("http://localhost:8080/services/securityUrl2");
-		node2.setProxyTransport("class2");
+		node2.setProxyTransport("org.apache.juddi.v3.client.transport.JAXWSTransport");
 		node2.setSubscriptionUrl("http://localhost:8080/services/securityUrl2");
+                node2.setSubscriptionListenerUrl("http://localhost:8080/services/securityUrl2");
 		node2.setName("default2");
 		node2.setClientName("default2Client");
 		saveNode.getNode().add(node2);
@@ -163,5 +166,30 @@ public class API_100_ClientSubscriptionI
 			Assert.fail("No exception should be thrown");
 		}
 	}
+        
+        
+        
+        @Test(expected = ValueNotAllowedException.class)
+	public void addNodeInvalidProxy() throws Exception {
+		
+		Node node = new Node();
+		node.setSecurityUrl("http://localhost:8080/services/securityUrl");
+		node.setCustodyTransferUrl("http://localhost:8080/services/securityUrl");
+		node.setDescription("description");
+		node.setInquiryUrl("http://localhost:8080/services/securityUrl");
+		node.setPublishUrl("http://localhost:8080/services/publishUrl");
+                node.setSubscriptionListenerUrl("http://localhost:8080/services/subUrladdClientSubscriptionInfo");
+		node.setProxyTransport("orgasdasdasdasd.apache.juddi.v3.client.transport.JAXWSTransport");
+		node.setSubscriptionUrl("http://localhost:8080/services/securityUrl");
+		node.setName("default");
+		node.setClientName("defaultClient");
+		SaveNode saveNode = new SaveNode();
+		saveNode.setAuthInfo(authInfoJoe);
+		saveNode.getNode().add(node);
+		
+		NodeDetail nodeDetail = publisher.saveNode(saveNode);
+		
+		
+	}
 	
 }



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