You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-dev@ws.apache.org by ow...@apache.org on 2003/04/16 12:08:48 UTC

cvs commit: xml-axis-wsif/java/src/org/apache/wsif/compiler/util Utils.java

owenb       2003/04/16 03:08:47

  Modified:    java/src/org/apache/wsif/wsdl
                        AuthenticatingProxyWSDLLocatorImpl.java
                        WSIFWSDLLocatorImpl.java
               java/src/org/apache/wsif/compiler/util Utils.java
  Log:
  Fixes to compile against latest wsdl4j (16th April 2003 build)
  
  Revision  Changes    Path
  1.15      +45 -22    xml-axis-wsif/java/src/org/apache/wsif/wsdl/AuthenticatingProxyWSDLLocatorImpl.java
  
  Index: AuthenticatingProxyWSDLLocatorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/AuthenticatingProxyWSDLLocatorImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AuthenticatingProxyWSDLLocatorImpl.java	26 Mar 2003 10:46:01 -0000	1.14
  +++ AuthenticatingProxyWSDLLocatorImpl.java	16 Apr 2003 10:08:46 -0000	1.15
  @@ -68,6 +68,7 @@
   
   import javax.wsdl.WSDLException;
   
  +import org.apache.wsif.logging.Trc;
   import org.xml.sax.InputSource;
   
   import com.ibm.wsdl.util.StringUtils;
  @@ -92,8 +93,9 @@
       };
       private static final char BASE64_PAD_CHAR = '=';
        
  -    Reader baseReader = null; 
  -    Reader importReader = null;
  +    Reader baseReader = null;
  +    InputStream baseInputStream = null;
  +    InputStream importInputStream = null;     
       String documentBase = "";
       String importBase = ""; 
       String wsdlLocation = "";
  @@ -145,23 +147,24 @@
        * @return The InputSource or null if the import cannot be resolved
        */
       public InputSource getBaseInputSource() {
  -        if (baseReader == null) {
  +    	Trc.entry(this);
  +    	if (baseReader != null) {
  +    		return new InputSource(baseReader);
  +    	}
  +        if (baseInputStream == null) {
               try {
               	URL url = StringUtils.getURL(null, wsdlLocation); 
               	// If file is on the local file system we don't need to
               	// use the proxy information.
                   if ("file".equals(url.getProtocol())) {
  -                	baseReader = StringUtils.getContentAsReader(url);
  +                	baseInputStream = StringUtils.getContentAsInputStream(url);
                   } else {
                       URLConnection con = url.openConnection();
                       createAuthString();
                       if (authString != null) {
                           con.setRequestProperty(PROXY_AUTH, authString);
                       }
  -                    InputStream in = con.getInputStream();
  -                    if (in != null) {
  -                        baseReader = new InputStreamReader(in);
  -                    }
  +                    baseInputStream = con.getInputStream();
                   }
                   if (url != null) {
                       documentBase = url.toString();
  @@ -170,8 +173,11 @@
                   documentBase = wsdlLocation;
               }
           }
  -        if (baseReader == null) return null;
  -        return new InputSource(baseReader);
  +        Trc.exit();
  +        if (baseInputStream == null) {
  +        	return null;
  +        }
  +        return new InputSource(baseInputStream);
       }
   
       /**
  @@ -182,21 +188,22 @@
        * @return The InputSource or null if the import cannot be resolved
        */
       public InputSource getImportInputSource(String base, String relativeLocation) {
  +    	Trc.entry(this, base, relativeLocation);
  +    	// Reset importInputStream if finding import within import
  +    	importInputStream = null;
  +    	
           try {
   			URL contextURL = (base != null) ? StringUtils.getURL(null, base) : null; 
               URL url = StringUtils.getURL(contextURL, relativeLocation);
               if ("file".equals(url.getProtocol())) {
  -                importReader = StringUtils.getContentAsReader(url);
  +                importInputStream = StringUtils.getContentAsInputStream(url);
               } else {
                   URLConnection con = url.openConnection();
                   createAuthString();
                   if (authString != null) {
                       con.setRequestProperty(PROXY_AUTH, authString);
                   }
  -                InputStream in = con.getInputStream();
  -                if (in != null) {
  -                    importReader = new InputStreamReader(in);
  -                }
  +                importInputStream = con.getInputStream();
               }
               importBase = (url == null) ? relativeLocation : url.toString();
           } catch (Exception e2) {        	
  @@ -204,8 +211,11 @@
           	// necessary to avoid a NullPointerException in WSDLReaderImpl
           	importBase = "unknownImportURI";
           }
  -        if (importReader == null) return null;
  -        return new InputSource(importReader);
  +        Trc.exit();
  +        if (importInputStream == null) {
  +        	return null;
  +        }
  +        return new InputSource(importInputStream);
       }
   
   	/**
  @@ -213,7 +223,13 @@
   	 */
       public Reader getBaseReader() {
       	InputSource is = getBaseInputSource();
  -    	return importReader;    	
  +    	if (is == null) return null;
  +    	if (is.getCharacterStream() != null) {
  +    		return is.getCharacterStream();
  +    	} else if (is.getByteStream() != null) {
  +    		return new InputStreamReader(is.getByteStream());
  +    	}    	
  +    	return null;
       }
   
   	/**
  @@ -221,7 +237,13 @@
   	 */
       public Reader getImportReader(String base, String relativeLocation) {    	    	
       	InputSource is = getImportInputSource(base, relativeLocation);
  -    	return importReader; 
  +    	if (is == null) return null;
  +    	if (is.getCharacterStream() != null) {
  +    		return is.getCharacterStream();
  +    	} else if (is.getByteStream() != null) {
  +    		return new InputStreamReader(is.getByteStream());
  +    	}    	
  +    	return null;
       }
   
       /**
  @@ -309,11 +331,12 @@
       }
   
       /**
  -     * Close any Reader objects that have been created
  -     * @throws IOException If a call to close() on one of the Reader objects fails
  +     * Close any Reader or stream objects that have been created
  +     * @throws IOException If a call to close() on one of the Reader or stream objects fails
        */
       public void close() throws IOException {
      		if (baseReader != null) baseReader.close();
  -  		if (importReader != null) importReader.close();
  +  		if (importInputStream != null) importInputStream.close();
  +  		if (baseInputStream != null) baseInputStream.close();
       }   
   }
  
  
  
  1.18      +4 -8      xml-axis-wsif/java/src/org/apache/wsif/wsdl/WSIFWSDLLocatorImpl.java
  
  Index: WSIFWSDLLocatorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/WSIFWSDLLocatorImpl.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- WSIFWSDLLocatorImpl.java	24 Mar 2003 13:07:02 -0000	1.17
  +++ WSIFWSDLLocatorImpl.java	16 Apr 2003 10:08:47 -0000	1.18
  @@ -124,7 +124,6 @@
       	if (baseReader != null) {
       		return new InputSource(baseReader);
       	}
  -    	Reader reader = null;
           if (baseInputStream == null) { 
               try { 
                   URL url = null; 
  @@ -150,7 +149,7 @@
                   } 
                   if (baseInputStream == null) { 
                       url = StringUtils.getURL(contextURL, wsdlLocation); 
  -                    reader = StringUtils.getContentAsReader(url);                    
  +                    baseInputStream = StringUtils.getContentAsInputStream(url);                    
                   } 
                   if (url != null) {
                       documentBase = url.toString(); 
  @@ -162,7 +161,6 @@
           } 
           Trc.exit();
           if (baseInputStream == null) {
  -        	if (reader != null) return new InputSource(reader);
           	return null;
           }
           return new InputSource(baseInputStream); 
  @@ -180,7 +178,6 @@
       	
       	// Reset importInputStream if finding import within import
       	importInputStream = null;
  -    	Reader reader = null;
       	boolean triedSU = false; 
           try { 
               // If a ClassLoader was used to load the base document, chances 
  @@ -197,7 +194,7 @@
                       // ClassLoader to find the import.
                       triedSU = true; 
                       url = StringUtils.getURL(null, relativeLocation); 
  -                    reader = StringUtils.getContentAsReader(url);                    
  +                    importInputStream = StringUtils.getContentAsInputStream(url);                    
                   } else { 
                       // Import location has been specified relative to the base document 
                       // and so we can to try to form the complete path to it. 						 
  @@ -234,7 +231,7 @@
               	triedSU = true; 
                   URL contextURL = (base != null) ? StringUtils.getURL(null, base) : null; 
                   url = StringUtils.getURL(contextURL, relativeLocation); 
  -                reader = StringUtils.getContentAsReader(url);                
  +                importInputStream = StringUtils.getContentAsInputStream(url);                
               } 
               importBase = (url == null) ? relativeLocation : url.toString(); 
           } catch (Exception e) {
  @@ -245,7 +242,7 @@
           		try {        		
                  	    URL contextURL = (base != null) ? StringUtils.getURL(null, base) : null; 
                       URL url = StringUtils.getURL(contextURL, relativeLocation); 
  -                    reader = StringUtils.getContentAsReader(url);
  +                    importInputStream = StringUtils.getContentAsInputStream(url);
                       importBase = (url == null) ? relativeLocation : url.toString();         		
           		} catch (Exception e2) {
           			Trc.exception(e2);
  @@ -261,7 +258,6 @@
           } 
           Trc.exit();
           if (importInputStream == null) {
  -        	if (reader != null) return new InputSource(reader); 
               return null;
           }
           return new InputSource(importInputStream); 
  
  
  
  1.6       +5 -1      xml-axis-wsif/java/src/org/apache/wsif/compiler/util/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/compiler/util/Utils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Utils.java	26 Feb 2003 15:55:21 -0000	1.5
  +++ Utils.java	16 Apr 2003 10:08:47 -0000	1.6
  @@ -61,6 +61,7 @@
   import java.io.IOException;
   import java.io.Reader;
   import java.io.StringWriter;
  +import java.util.Arrays;
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.List;
  @@ -177,7 +178,10 @@
   
       public static String getQuotedString(Reader source, int indent)
           throws WSIFException {
  -        String indentStr = StringUtils.getChars(indent, ' ');
  +        	
  +        char[] indentArray = new char[indent];
  +        Arrays.fill(indentArray, ' ');
  +        String indentStr = new String(indentArray);
   
           try {
               BufferedReader br = new BufferedReader(source);