Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes cae5b6fb8 -> 590ab0113


[CXF-6161] Make sure wsdl import uses valid file name
This closes #43


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3aecbd75
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3aecbd75
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3aecbd75

Branch: refs/heads/3.0.x-fixes
Commit: 3aecbd75418a527966e91ea260f58c26b3a320c9
Parents: cae5b6f
Author: Daniel Kulp <dk...@apache.org>
Authored: Fri Mar 24 11:05:04 2017 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri Mar 24 13:45:26 2017 -0400

----------------------------------------------------------------------
 core/src/main/java/org/apache/cxf/helpers/FileUtils.java     | 4 ++--
 .../org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java     | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3aecbd75/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java 
b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
index a8d3fa5..cd7a512 100644
--- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
@@ -45,8 +45,8 @@ public final class FileUtils {
     private FileUtils() {
         
     }
-    
-    public boolean isValidFileName(String name) {
+
+    public static boolean isValidFileName(String name) {
         for (int i = name.length(); i > 0; i--) {
             char c = name.charAt(i - 1);
             for (char c2 : ILLEGAL_CHARACTERS) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/3aecbd75/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
----------------------------------------------------------------------
diff --git 
a/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
 
b/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
index 3b57251..1a28859 100644
--- 
a/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
+++ 
b/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
@@ -789,7 +789,8 @@ public class WSDLToJavaContainer extends 
AbstractCXFToolContainer {
             }
            
             //get imported wsdls
-            List<Definition> defs = 
(List<Definition>)context.get(ToolConstants.IMPORTED_DEFINITION);            
+            int wsdlImportCount = 0;
+            List<Definition> defs = 
(List<Definition>)context.get(ToolConstants.IMPORTED_DEFINITION);
             Map<String, String> importWSDLMap = new HashMap<String, String>();
             for (Definition importDef : defs) {
                 File importedWsdlFile = null;
@@ -798,10 +799,11 @@ public class WSDLToJavaContainer extends 
AbstractCXFToolContainer {
                 } else {
                     importedWsdlFile = new 
File(importDef.getQName().getLocalPart() + ".wsdl");
                 }
+                if (!FileUtils.isValidFileName(importedWsdlFile.getName())) {
+                    importedWsdlFile = new File("import" + (++wsdlImportCount) 
+ ".wsdl");
+                }
                 importWSDLMap.put(importDef.getTargetNamespace(), 
importedWsdlFile.getName());
             }
-            
-            
             OutputStreamCreator outputStreamCreator = null;
             if (context.get(OutputStreamCreator.class) != null) {
                 outputStreamCreator = context.get(OutputStreamCreator.class);

Reply via email to