You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by lm...@apache.org on 2008/04/02 16:55:08 UTC

svn commit: r643926 - in /webservices/woden/trunk/java: src/org/apache/woden/internal/wsdl20/assertions/Description1001.java test/org/apache/woden/internal/wsdl20/assertions/AssertionTestSuite.java

Author: lmandel
Date: Wed Apr  2 07:55:06 2008
New Revision: 643926

URL: http://svn.apache.org/viewvc?rev=643926&view=rev
Log:
[WODEN-203] Merged fix into HEAD.

Modified:
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
    webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/AssertionTestSuite.java

Modified: webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java?rev=643926&r1=643925&r2=643926&view=diff
==============================================================================
--- webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java (original)
+++ webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java Wed Apr  2 07:55:06 2008
@@ -1,6 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
 package org.apache.woden.internal.wsdl20.assertions;
 
-import java.io.FileNotFoundException;
 import java.net.URI;
 import java.net.URL;
 
@@ -11,8 +26,22 @@
 import org.apache.woden.wsdl20.validation.WodenContext;
 import org.apache.woden.wsdl20.xml.DescriptionElement;
 
+/**
+ * This class represents assertion Description-1001 from the WSDL 2.0 specification.
+ * For details about this assertion see:
+ * http://www.w3.org/TR/2007/REC-wsdl20-20070626/#Description-1001
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ * @author Lawrence Mandel (lmandel@apache.org)
+ */
 public class Description1001 implements Assertion {
 
+	/**
+	 * A list of URI schemes for which this assertion will attempt to check if
+	 * the target namespace is dereferencable. 
+	 */
+	private static String searchableSchemes = "http,ftp,file";
+	
     public String getId() {
         return "Description-1001".intern();
     }
@@ -24,24 +53,26 @@
         try {
             URI resolvedUri = wodenCtx.getUriResolver().resolveURI(tns);
             URI uri = resolvedUri != null ? resolvedUri : tns;
-            URL url = uri.toURL();
-            Object o = url.getContent();
+            String scheme = uri.getScheme();
+            
+            // Only check if the scheme is a type that we can locate.
+            // TODO: See if the searchable schemes should be extensible.
+            Object o = null;
+            if(searchableSchemes.contains(scheme)) {
+            	URL url = uri.toURL();
+            	o = url.getContent();
+            }
             if(o == null) {
-                wodenCtx.getErrorReporter().reportError(
-                        new ErrorLocatorImpl(), getId(), new Object[] {tns}, ErrorReporter.SEVERITY_WARNING);
+                throw new Exception();
             }
-        } catch (FileNotFoundException e1) {
-            wodenCtx.getErrorReporter().reportError(
-                    new ErrorLocatorImpl(), getId(), new Object[] {tns}, ErrorReporter.SEVERITY_WARNING);
-            
         } catch (WSDLException e2) {
+        	// A WSDLException may be thrown due to a problem with the URI resolver so we should report this exception.
             throw e2;
         } catch (Exception e) {
-            // IOException
-            // MalformedURLException
-            throw new WSDLException(WSDLException.OTHER_ERROR,
-                                    "Fatal error.",
-                                    e);
+        	// Any other exception including IOExceptoin, MalformedURLException, UnknownHostException, and 
+        	// FileNotFoundException means that the namespace was not resolvable.
+        	wodenCtx.getErrorReporter().reportError(
+                    new ErrorLocatorImpl(), getId(), new Object[] {tns}, ErrorReporter.SEVERITY_WARNING);
         }
     }
 

Modified: webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/AssertionTestSuite.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/AssertionTestSuite.java?rev=643926&r1=643925&r2=643926&view=diff
==============================================================================
--- webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/AssertionTestSuite.java (original)
+++ webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/AssertionTestSuite.java Wed Apr  2 07:55:06 2008
@@ -30,6 +30,7 @@
 		TestSuite suite = new TestSuite(
 				"Test for org.apache.woden.internal.wsdl20.assertions");
 		//$JUnit-BEGIN$
+		suite.addTestSuite(TestDescription1001.class);
 		suite.addTestSuite(TestInterface1009.class);
 		suite.addTestSuite(TestInterface1010.class);
 		//$JUnit-END$



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org