You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by am...@apache.org on 2009/07/03 16:32:53 UTC

svn commit: r790927 - /webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java

Author: amilas
Date: Fri Jul  3 14:32:53 2009
New Revision: 790927

URL: http://svn.apache.org/viewvc?rev=790927&view=rev
Log:
there are some instances where schema available at the url given by the target namespace without giving schema locations.
this change allows to retrive schema from such locations.

Modified:
    webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java

Modified: webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java?rev=790927&r1=790926&r2=790927&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java (original)
+++ webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java Fri Jul  3 14:32:53 2009
@@ -86,6 +86,7 @@
             }
 
             final Map schemaToInputSourceMap = new HashMap();
+            final Map<String, StringBuffer> publicIDToStringMap = new HashMap<String, StringBuffer>();
 
             //create the type mapper
             JavaTypeMapper mapper = new JavaTypeMapper();
@@ -140,6 +141,28 @@
                             returnInputSource.setSystemId(systemId);
                         }
                     }
+
+                    if (returnInputSource == null) {
+                        if (publicId != null) {
+
+                            if (!publicIDToStringMap.containsKey(publicId)) {
+                                URL url = new URL(publicId);
+                                BufferedReader bufferedReader =
+                                        new BufferedReader(new InputStreamReader(url.openStream()));
+                                StringBuffer stringBuffer = new StringBuffer();
+                                String str = null;
+                                while ((str = bufferedReader.readLine()) != null) {
+                                    stringBuffer.append(str);
+                                }
+                                publicIDToStringMap.put(publicId, stringBuffer);
+                            }
+
+                            String schemaString = publicIDToStringMap.get(publicId).toString();
+                            returnInputSource = new InputSource(new StringReader(schemaString));
+                            returnInputSource.setPublicId(publicId);
+                            returnInputSource.setSystemId(publicId);
+                        }
+                    }
                     return returnInputSource;
                 }
             };