cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r520313 - in /incubator/cxf/trunk/tools: common/src/main/java/org/apache/cxf/tools/util/ common/src/test/java/org/apache/cxf/tools/util/ javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/ wsdlto/core/src/main/java/org/apache/cxf...
Date Tue, 20 Mar 2007 08:19:31 GMT
Author: mmao
Date: Tue Mar 20 01:19:30 2007
New Revision: 520313

URL: http://svn.apache.org/viewvc?view=rev&rev=520313
Log:
[CXF-426]  wsdl2java generates code/annotations with absolute paths even if relative paths
are specified on the command line.

Modified:
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
    incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java
    incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/InterfaceMapper.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java?view=diff&rev=520313&r1=520312&r2=520313
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
Tue Mar 20 01:19:30 2007
@@ -21,6 +21,8 @@
 
 import java.io.File;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -213,4 +215,28 @@
     private static boolean contiansReservedKeywords(String token) {
         return KEYWORDS.contains(token);
     }
+
+    public static String normalize(String uri) {
+        File file = new File(uri);
+        if (file.isAbsolute()) {
+            return getAbsoluteURI(uri);
+        }
+        return uri.replace("\\", "/");
+    }
+
+    public static String getAbsoluteURI(String arg) {
+        File tmpFile = null;
+        URI uri = null;
+        try {
+            uri = new URI(arg);
+            if (!uri.isAbsolute()) {
+                File tmpfile = new File("");
+                uri = tmpfile.toURI().resolve(uri);
+            }
+            tmpFile = new File(uri);
+        } catch (URISyntaxException e) {
+            tmpFile = new File(arg);
+        }
+        return tmpFile.toURI().toString();
+    }    
 }

Modified: incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java?view=diff&rev=520313&r1=520312&r2=520313
==============================================================================
--- incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
(original)
+++ incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
Tue Mar 20 01:19:30 2007
@@ -29,4 +29,29 @@
         packageName = URIParserUtil.getPackageName("urn://www.class.iona.com");
         assertEquals(packageName, "com.iona._class");
     }
+
+    public void testNormalize() throws Exception {
+        String uri = "wsdl/hello_world.wsdl";
+        assertEquals(uri, URIParserUtil.normalize(uri));
+
+        uri = "C:\\src\\wsdl/hello_world.wsdl";
+        assertEquals("file:/C:/src/wsdl/hello_world.wsdl", URIParserUtil.normalize(uri));
+
+        uri = "wsdl\\hello_world.wsdl";
+        assertEquals("wsdl/hello_world.wsdl", URIParserUtil.normalize(uri));        
+    }
+
+    public void testGetAbsoluteURI() throws Exception {
+        String uri = "wsdl/hello_world.wsdl";
+        String uri2 = URIParserUtil.getAbsoluteURI(uri);
+        assertNotNull(uri2);
+        assertTrue(uri2.startsWith("file"));
+        assertTrue(uri2.contains(uri));
+
+        uri = getClass().getResource("/schemas/wsdl/xml-binding.xsd").toString();
+        uri2 = URIParserUtil.getAbsoluteURI(uri);
+        assertNotNull(uri2);
+        assertTrue(uri2.startsWith("file"));
+        assertTrue(uri2.contains(uri));        
+    }
 }

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java?view=diff&rev=520313&r1=520312&r2=520313
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java
Tue Mar 20 01:19:30 2007
@@ -373,7 +373,7 @@
     }
 
     private String getLocation(String wsdlFile) throws URISyntaxException {
-        return new File(JavaToWSDLProcessorTest.class.getResource(wsdlFile).toURI()).getAbsolutePath();
+        return JavaToWSDLProcessorTest.class.getResource(wsdlFile).toString();
     }
 
 }

Modified: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?view=diff&rev=520313&r1=520312&r2=520313
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Tue Mar 20 01:19:30 2007
@@ -22,8 +22,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -31,7 +29,6 @@
 import java.util.Properties;
 import java.util.Set;
 import java.util.logging.Logger;
-
 import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
 
@@ -53,6 +50,7 @@
 import org.apache.cxf.tools.common.toolspec.parser.CommandDocument;
 import org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor;
 import org.apache.cxf.tools.util.ClassCollector;
+import org.apache.cxf.tools.util.URIParserUtil;
 import org.apache.cxf.tools.validator.internal.AbstractValidator;
 import org.apache.cxf.tools.validator.internal.ServiceValidator;
 import org.apache.cxf.tools.wsdlto.core.AbstractWSDLBuilder;
@@ -118,7 +116,7 @@
                 builder.setContext(context);
                 
                 //TODO: Modify builder api, let customized definition make sense.
-                builder.build(wsdlURL);
+                builder.build(URIParserUtil.getAbsoluteURI(wsdlURL));
                 builder.customize();
                 Definition definition = builder.getWSDLModel();
                 
@@ -288,10 +286,7 @@
         }
 
         String wsdl = (String)env.get(ToolConstants.CFG_WSDLURL);
-        
-        URI wsdlURI = getURI(wsdl);
-        env.put(ToolConstants.CFG_WSDLURL, wsdlURI.toString());
-        
+        env.put(ToolConstants.CFG_WSDLURL, URIParserUtil.normalize(wsdl));
         
         String[] bindingFiles;
         try {
@@ -305,9 +300,7 @@
         }
         
         for (int i = 0; i < bindingFiles.length; i++) {
-            
-            URI bindingURI = getURI(bindingFiles[i]);
-            bindingFiles[i] = bindingURI.toString();
+            bindingFiles[i] = URIParserUtil.getAbsoluteURI(bindingFiles[i]);
         }
         
         env.put(ToolConstants.CFG_BINDING,  bindingFiles);        
@@ -420,29 +413,6 @@
             return true;
         }
         return false;
-    }
-    
-    private URI getURI(String arg) {
-        File tmpFile = null;
-        URI uri = null;
-        try {
-            uri = new URI(arg);
-            if (!uri.isAbsolute()) {
-                File tmpfile = new File("");
-                uri = tmpfile.toURI().resolve(uri);
-            }
-            tmpFile = new File(uri);
-        } catch (URISyntaxException e) {
-            tmpFile = new File(arg);
-        }
-        if (!tmpFile.exists()) {
-            Message msg = new Message("FILE_NOT_EXIST", LOG, tmpFile.toURI());
-            throw new ToolException(msg);
-        } else if (tmpFile.isDirectory()) {
-            Message msg = new Message("NOT_A_FILE", LOG, tmpFile.toURI());
-            throw new ToolException(msg);
-        }
-        return tmpFile.toURI();
     }
     
     public void generateTypes() throws ToolException {

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java?view=diff&rev=520313&r1=520312&r2=520313
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
Tue Mar 20 01:19:30 2007
@@ -52,6 +52,7 @@
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.util.StAXUtil;
+import org.apache.cxf.tools.util.URIParserUtil;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ProcessorUtil;
 
 public final class CustomizationParser {
@@ -82,8 +83,8 @@
         this.env = pe;
         String[] bindingFiles;
         try {
-            this.wsdlURL = (String)env.get(ToolConstants.CFG_WSDLURL);
-            this.wsdlNode = this.getTargetNode(wsdlURL);
+            this.wsdlURL = URIParserUtil.getAbsoluteURI((String)env.get(ToolConstants.CFG_WSDLURL));
+            this.wsdlNode = this.getTargetNode(this.wsdlURL);
             bindingFiles = (String[])env.get(ToolConstants.CFG_BINDING);
             if (bindingFiles == null) {
                 return;

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/InterfaceMapper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/InterfaceMapper.java?view=diff&rev=520313&r1=520312&r2=520313
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/InterfaceMapper.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/InterfaceMapper.java
Tue Mar 20 01:19:30 2007
@@ -27,7 +27,6 @@
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ProcessorUtil;
 
 public final class InterfaceMapper {
-    //private static final Logger LOG = LogUtils.getL7dLogger(InterfaceMapper.class);
     private ToolContext context;
 
     public InterfaceMapper(ToolContext c) {

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?view=diff&rev=520313&r1=520312&r2=520313
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Tue Mar 20 01:19:30 2007
@@ -377,6 +377,6 @@
     }
 
     private String getLocation(String wsdlFile) throws URISyntaxException {
-        return this.getClass().getResource(wsdlFile).toURI().getPath();
+        return this.getClass().getResource(wsdlFile).toString();
     }
 }

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?view=diff&rev=520313&r1=520312&r2=520313
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Tue Mar 20 01:19:30 2007
@@ -811,6 +811,6 @@
 
 
     private String getLocation(String wsdlFile) throws URISyntaxException {
-        return this.getClass().getResource(wsdlFile).toURI().getPath();
+        return this.getClass().getResource(wsdlFile).toString();
     }
 }



Mime
View raw message