You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by tc...@apache.org on 2010/12/16 20:38:05 UTC

svn commit: r1050116 - in /juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper: UDDIInquiryService.java UDDIPublicationService.java UDDISecurityService.java

Author: tcunning
Date: Thu Dec 16 19:38:05 2010
New Revision: 1050116

URL: http://svn.apache.org/viewvc?rev=1050116&view=rev
Log:
JUDDI-434
Fix NPE issue for operation not being found and throw an 
IllegalArgumentException.   Fixed this in Inquiry/Publication/Security.

Modified:
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIInquiryService.java
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIPublicationService.java
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDISecurityService.java

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIInquiryService.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIInquiryService.java?rev=1050116&r1=1050115&r2=1050116&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIInquiryService.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIInquiryService.java Thu Dec 16 19:38:05 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2001-2010 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.
@@ -27,10 +27,9 @@ import javax.xml.transform.dom.DOMSource
 import javax.xml.transform.stream.StreamResult;
 
 import org.apache.juddi.v3.client.ClassUtil;
-import org.apache.juddi.v3.client.transport.Transport;
-
 import org.apache.juddi.v3.client.config.UDDIClerkManager;
 import org.apache.juddi.v3.client.config.UDDIClientContainer;
+import org.apache.juddi.v3.client.transport.Transport;
 import org.uddi.api_v3.FindBinding;
 import org.uddi.api_v3.FindBusiness;
 import org.uddi.api_v3.FindRelatedBusinesses;
@@ -69,40 +68,43 @@ public class UDDIInquiryService {
 		operations.put("get_operationalInfo", new Handler("getOperationalInfo", GetOperationalInfo.class));
 	}
 
-	
+
 
 	//Verify that the appropriate endpoint was targeted for
 	// this service request.  The validateRequest method will
 	// throw an UnsupportedOperationException if anything's amiss.
 	public void validateRequest(String operation)
-			throws UnsupportedOperationException
+	    throws UnsupportedOperationException
 	{
 	    if ((operation == null) || (operation.trim().length() == 0))
 	    	throw new UnsupportedOperationException("operation " + operation + " not supported");
 	}
-	
+
 	public Node inquire(Element uddiReq) throws Exception {
-		UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(null);
-		String clazz = manager.getClientConfig().getUDDINode(DEFAULT_NODE_NAME).getProxyTransport();
-        Class<?> transportClass = ClassUtil.forName(clazz,this.getClass());
-        Transport transport = (Transport) transportClass.getConstructor(String.class).newInstance(DEFAULT_NODE_NAME);
-		UDDIInquiryPortType inquiry = transport.getUDDIInquiryService();
-        
+	    UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(null);
+	    String clazz = manager.getClientConfig().getUDDINode(DEFAULT_NODE_NAME).getProxyTransport();
+            Class<?> transportClass = ClassUtil.forName(clazz,this.getClass());
+            Transport transport = (Transport) transportClass.getConstructor(String.class).newInstance(DEFAULT_NODE_NAME);
+            UDDIInquiryPortType inquiry = transport.getUDDIInquiryService();
+
 	    //new RequestHandler on it's own thread
 	    RequestHandler requestHandler = new RequestHandler();
 	    requestHandler.setPortType(inquiry);
-	      
+
 	    String operation = requestHandler.getOperation(uddiReq);
-		Handler opHandler = operations.get(operation);
+	    Handler opHandler = operations.get(operation);
+	    if (opHandler == null) {
+	        throw new IllegalArgumentException("Operation not found: " + operation);
+	    }
 	    requestHandler.setMethodName(opHandler.getMethodName());
-		requestHandler.setOperationClass(opHandler.getParameter());
+	    requestHandler.setOperationClass(opHandler.getParameter());
 
 	    @SuppressWarnings("unused")
-		String version   = requestHandler.getVersion(uddiReq,operation);
+	    String version   = requestHandler.getVersion(uddiReq,operation);
 	    validateRequest(operation);
 	    return requestHandler.invoke(uddiReq);
-	}	
-	
+	}
+
 	public String inquire(UDDIInquiryPortType inquiry, String request) throws Exception {
 	    java.io.InputStream sbis = new ByteArrayInputStream(request.getBytes());
 	    javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();
@@ -110,20 +112,24 @@ public class UDDIInquiryService {
 	    dbf.setValidating(false);
 	    DocumentBuilder db = dbf.newDocumentBuilder();
 	    Document doc = db.parse(sbis);
-		Element reqElem = doc.getDocumentElement();
-			
-		RequestHandler requestHandler = new RequestHandler();
-		requestHandler.setPortType(inquiry);
-		
-		String operation = reqElem.getTagName().toString();
-		Handler opHandler = operations.get(operation);
+	    Element reqElem = doc.getDocumentElement();
+
+	    RequestHandler requestHandler = new RequestHandler();
+	    requestHandler.setPortType(inquiry);
+
+	    String operation = reqElem.getTagName().toString();
+	    Handler opHandler = operations.get(operation);
+            if (opHandler == null) {
+                throw new IllegalArgumentException("Operation not found: " + operation);
+            }
+
 	    requestHandler.setMethodName(opHandler.getMethodName());
-		requestHandler.setOperationClass(opHandler.getParameter());
+	    requestHandler.setOperationClass(opHandler.getParameter());
 
 	    Node n = requestHandler.invoke(reqElem);
-	    
+
 	    StringWriter sw = new StringWriter();
-        Transformer t = TransformerFactory.newInstance().newTransformer();
+            Transformer t = TransformerFactory.newInstance().newTransformer();
 	    t.transform(new DOMSource(n), new StreamResult(sw));
 	    return sw.toString();
 	}

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIPublicationService.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIPublicationService.java?rev=1050116&r1=1050115&r2=1050116&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIPublicationService.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDIPublicationService.java Thu Dec 16 19:38:05 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2001-2010 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.
@@ -50,7 +50,7 @@ public class UDDIPublicationService {
 
 	private HashMap<String, Handler> operations = null;
 
-	
+
 	  public UDDIPublicationService() {
 		super();
 		operations = new HashMap<String, Handler>();
@@ -82,24 +82,28 @@ public class UDDIPublicationService {
 
 	public Node publish(Element uddiReq) throws Exception
 	{
-		UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(null);
-		String clazz = manager.getClientConfig().getUDDINode(DEFAULT_NODE_NAME).getProxyTransport();
-        Class<?> transportClass = ClassUtil.forName(clazz, this.getClass());
-        Transport transport = (Transport) transportClass.getConstructor(String.class).newInstance(DEFAULT_NODE_NAME);
-		UDDIPublicationPortType publish = transport.getUDDIPublishService();
+	    UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(null);
+	    String clazz = manager.getClientConfig().getUDDINode(DEFAULT_NODE_NAME).getProxyTransport();
+            Class<?> transportClass = ClassUtil.forName(clazz, this.getClass());
+            Transport transport = (Transport) transportClass.getConstructor(String.class).newInstance(DEFAULT_NODE_NAME);
+            UDDIPublicationPortType publish = transport.getUDDIPublishService();
 
 	    //new RequestHandler on it's own thread
 	    RequestHandler requestHandler = new RequestHandler();
 	    requestHandler.setPortType(publish);
 	    String operation = requestHandler.getOperation(uddiReq);
-		Handler opHandler = operations.get(operation);
+	    Handler opHandler = operations.get(operation);
+	    if (opHandler == null) {
+	        throw new IllegalArgumentException("Operation not found : " + operation);
+	    }
+
 	    requestHandler.setMethodName(opHandler.getMethodName());
-		requestHandler.setOperationClass(opHandler.getParameter());
-		  
-		@SuppressWarnings("unused")
+	    requestHandler.setOperationClass(opHandler.getParameter());
+
+	    @SuppressWarnings("unused")
 	    String version   = requestHandler.getVersion(uddiReq, operation);
 	    validateRequest(operation);
-	    
+
 	    Node temp = requestHandler.invoke(uddiReq);
 	    if (requestHandler.getException()!=null) {
 	    	throw new Exception(requestHandler.getException());

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDISecurityService.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDISecurityService.java?rev=1050116&r1=1050115&r2=1050116&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDISecurityService.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/wrapper/UDDISecurityService.java Thu Dec 16 19:38:05 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2001-2010 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.
@@ -22,20 +22,19 @@ import org.apache.juddi.v3.client.ClassU
 import org.apache.juddi.v3.client.config.UDDIClerkManager;
 import org.apache.juddi.v3.client.config.UDDIClientContainer;
 import org.apache.juddi.v3.client.transport.Transport;
+import org.uddi.api_v3.DiscardAuthToken;
+import org.uddi.api_v3.GetAuthToken;
 import org.uddi.v3_service.UDDISecurityPortType;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-import org.uddi.api_v3.GetAuthToken;
-import org.uddi.api_v3.DiscardAuthToken;
-
 /**
  * @author Tom Cunningham (tcunning@apache.org)
  * @author Kurt Stam (kurt.stam@redhat.com)
  */
 public class UDDISecurityService {
 	private final static String DEFAULT_NODE_NAME = "default";
-	
+
 	// collection of valid operations
 	private HashMap<String, Handler> operations = null;
 
@@ -45,7 +44,7 @@ public class UDDISecurityService {
 		operations.put("get_authToken", new Handler("getAuthToken", GetAuthToken.class));
 		operations.put("discard_authToken", new Handler("discardAuthToken", DiscardAuthToken.class));
 	}
-	
+
 	//Verify that the appropriate endpoint was targeted for
 	// this service request.  The validateRequest method will
 	// throw an UnsupportedOperationException if anything's amiss.
@@ -58,23 +57,27 @@ public class UDDISecurityService {
 
 	public Node secure(Element uddiReq) throws Exception
 	{
-		UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(null);
-		String clazz = manager.getClientConfig().getUDDINode(DEFAULT_NODE_NAME).getProxyTransport();
-        Class<?> transportClass = ClassUtil.forName(clazz, this.getClass());
-        Transport transport = (Transport) transportClass.getConstructor(String.class).newInstance(DEFAULT_NODE_NAME);
+	    UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(null);
+	    String clazz = manager.getClientConfig().getUDDINode(DEFAULT_NODE_NAME).getProxyTransport();
+            Class<?> transportClass = ClassUtil.forName(clazz, this.getClass());
+            Transport transport = (Transport) transportClass.getConstructor(String.class).newInstance(DEFAULT_NODE_NAME);
 	    UDDISecurityPortType security = transport.getUDDISecurityService();
-		
-		//new RequestHandler on it's own thread
-		RequestHandler requestHandler = new RequestHandler();
-		requestHandler.setPortType(security);
-		
-		String operation = requestHandler.getOperation(uddiReq);
-		Handler opHandler = operations.get(operation);
+
+	    //new RequestHandler on it's own thread
+	    RequestHandler requestHandler = new RequestHandler();
+	    requestHandler.setPortType(security);
+
+	    String operation = requestHandler.getOperation(uddiReq);
+	    Handler opHandler = operations.get(operation);
+	    if (opHandler == null) {
+	        throw new IllegalArgumentException("Operation not found: " + operation);
+	    }
+
 	    requestHandler.setMethodName(opHandler.getMethodName());
-		requestHandler.setOperationClass(opHandler.getParameter());
+	    requestHandler.setOperationClass(opHandler.getParameter());
 
-		@SuppressWarnings("unused")
-		String version   = requestHandler.getVersion(uddiReq, operation);
+	    @SuppressWarnings("unused")
+	    String version   = requestHandler.getVersion(uddiReq, operation);
 	    validateRequest(operation);
 	    return requestHandler.invoke(uddiReq);
 	}



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