owenb       2003/03/24 05:05:36

  Modified:    java/src/org/apache/wsif/wsdl
                        AuthenticatingProxyWSDLLocatorImpl.java
               java/src/org/apache/wsif/base WSIFServiceImpl.java
  Log:
  Allow AuthenticatingProxyWSDLLocatorImpl to read local files
  
  Revision  Changes    Path
  1.12      +33 -36    
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AuthenticatingProxyWSDLLocatorImpl.java   20 Mar 2003 16:47:14 -0000      1.11
  +++ AuthenticatingProxyWSDLLocatorImpl.java   24 Mar 2003 13:05:36 -0000      1.12
  @@ -70,6 +70,8 @@
   
   import org.xml.sax.InputSource;
   
  +import com.ibm.wsdl.util.StringUtils;
  +
   /**
    * Implementation of javax.wsdl.xml.WSDLLocator. This class can be used to
    * locate a wsdl document behind an authenticating proxy. Only http and ftp
  @@ -108,14 +110,6 @@
       public AuthenticatingProxyWSDLLocatorImpl(String wsdlLoc, String un, String 
passwd)
           throws WSDLException {
   
  -        if (wsdlLoc == null
  -            || (wsdlLoc.indexOf("http://";) == -1
  -                && wsdlLoc.indexOf("ftp://";) == -1)) {
  -            throw new WSDLException(
  -                WSDLException.OTHER_ERROR,
  -                "Base wsdl location type not supported. The 
AuthenticatingProxyWSDLLocatorImpl class "
  -                     + "only supports http and ftp urls for base wsdl locations");
  -        }
           this.wsdlLocation = wsdlLoc;
           passwdAuth = new PasswordAuthentication(un, passwd.toCharArray());
       }
  @@ -128,14 +122,6 @@
       public AuthenticatingProxyWSDLLocatorImpl(String wsdlLoc, 
PasswordAuthentication pa)
           throws WSDLException {
   
  -        if (wsdlLoc == null
  -            || (wsdlLoc.indexOf("http://";) == -1
  -                && wsdlLoc.indexOf("ftp://";) == -1)) {
  -            throw new WSDLException(
  -                WSDLException.OTHER_ERROR,
  -                "Base wsdl location type not supported. The 
AuthenticatingProxyWSDLLocatorImpl class "
  -                     + "only supports http and ftp urls for base wsdl locations");
  -        }
           this.wsdlLocation = wsdlLoc;
           passwdAuth = pa;
       }
  @@ -148,18 +134,25 @@
       public InputSource getBaseInputSource() {
           if (baseReader == null) {
               try {
  -                             URL url = new URL(wsdlLocation);
  -                URLConnection con = url.openConnection();
  -                createAuthString();
  -                if (authString != null) {
  -                    con.setRequestProperty(PROXY_AUTH, authString);
  -                }
  -                InputStream in = con.getInputStream();
  -                if (in != null) {
  -                    baseReader = new InputStreamReader(in);
  +             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);
  +                } 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);
  +                    }
                   }
  -                if (url != null)
  +                if (url != null) {
                       documentBase = url.toString();
  +                }
               } catch (Exception e) {
                   documentBase = wsdlLocation;
               }
  @@ -177,16 +170,20 @@
        */
       public InputSource getImportInputSource(String base, String relativeLocation) {
           try {
  -                     URL contextURL = (base != null) ? new URL(base) : null;        
    
  -            URL url = new URL(contextURL, relativeLocation);
  -            URLConnection con = url.openConnection();
  -            createAuthString();
  -            if (authString != null) {
  -                con.setRequestProperty(PROXY_AUTH, authString);
  -            }
  -            InputStream in = con.getInputStream();
  -            if (in != null) {
  -                importReader = new InputStreamReader(in);
  +                     URL contextURL = (base != null) ? StringUtils.getURL(null, 
base) : null; 
  +            URL url = StringUtils.getURL(contextURL, relativeLocation);
  +            if ("file".equals(url.getProtocol())) {
  +                importReader = StringUtils.getContentAsReader(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);
  +                }
               }
               importBase = (url == null) ? relativeLocation : url.toString();
           } catch (Exception e2) {             
  
  
  
  1.36      +3 -6      xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java
  
  Index: WSIFServiceImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- WSIFServiceImpl.java      19 Mar 2003 09:55:17 -0000      1.35
  +++ WSIFServiceImpl.java      24 Mar 2003 13:05:36 -0000      1.36
  @@ -175,9 +175,7 @@
           try {
               // Check if we need to read the wsdl through an authenticating proxy
               PasswordAuthentication pa = getProxyAuthentication();
  -            if (pa != null
  -                && (wsdlLoc.startsWith("http://";)
  -                    || wsdlLoc.startsWith("ftp://";))) {
  +            if (pa != null) {
                   def = WSIFUtils.readWSDLThroughAuthProxy(wsdlLoc, pa);
   
                   // We'll need to use a non default WSDLLocator to help find imported
  @@ -244,9 +242,7 @@
           try {
               // Check if we need to read the wsdl through an authenticating proxy
               PasswordAuthentication pa = getProxyAuthentication();
  -            if (pa != null
  -                && (wsdlLoc.startsWith("http://";)
  -                    || wsdlLoc.startsWith("ftp://";))) {
  +            if (pa != null) {
                   def = WSIFUtils.readWSDLThroughAuthProxy(wsdlLoc, pa);
   
                   // We'll need to use a non default WSDLLocator to help find imported
  @@ -1251,6 +1247,7 @@
               }
               SchemaType[] types = new SchemaType[schemaTypes.size()];
               schemaTypes.toArray(types);
  +                       
               Map mappings = mapper.getMappings(types);
               if (mappings != null) {
                   Iterator it = mappings.keySet().iterator();
  
  
  

Reply via email to