Changeset 21

Show
Ignore:
Timestamp:
01/22/07 10:38:09 (6 years ago)
Author:
robert
Message:

* made setProxy a bit more tolerant
* slightly changed log messages

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • jala/branches/release-1.0/code/XmlRpcRequest.js

    r4 r21  
    7373      if (proxyString && proxyString.trim()) { 
    7474         var idx = proxyString.indexOf(":"); 
    75          var host = proxyString.substring(0, idx); 
    76          var port = proxyString.substring(idx+1); 
    77          if (java.lang.Class.forName("java.net.Proxy") != null) { 
    78             // construct a proxy instance 
    79             var socket = new java.net.InetSocketAddress(host, port); 
    80             proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, socket); 
    81          } else { 
    82             // the pre jdk1.5 way: set the system properties 
    83             var sys = java.lang.System.getProperties(); 
    84             if (host) { 
    85                app.log("[Helma XmlRpc Client] WARNING: setting system http proxy to " 
    86                        + host + ":" + port); 
    87                sys.put("http.proxySet", "true"); 
    88                sys.put("http.proxyHost", host); 
    89                sys.put("http.proxyPort", port); 
     75         if (idx > 0) { 
     76            var host = proxyString.substring(0, idx); 
     77            var port = proxyString.substring(idx+1); 
     78            if (host != null && port != null) { 
     79               if (java.lang.Class.forName("java.net.Proxy") != null) { 
     80                  // construct a proxy instance 
     81                  var socket = new java.net.InetSocketAddress(host, port); 
     82                  proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, socket); 
     83               } else { 
     84                  // the pre jdk1.5 way: set the system properties 
     85                  var sys = java.lang.System.getProperties(); 
     86                  if (host) { 
     87                     app.log("[Jala XmlRpc Client] WARNING: setting system http proxy to " 
     88                             + host + ":" + port); 
     89                     sys.put("http.proxySet", "true"); 
     90                     sys.put("http.proxyHost", host); 
     91                     sys.put("http.proxyPort", port); 
     92                  } 
     93               } 
    9094            } 
    9195         } 
     
    247251/** @ignore */ 
    248252jala.XmlRpcRequest.prototype.toString = function() { 
    249    return "[Helma XmlRpc Client]"; 
     253   return "[Jala XmlRpc Request]"; 
    250254}; 
    251255 
     
    275279   var params = new java.util.Vector(); 
    276280   for (var i=0;i<arguments.length;i++) { 
    277       params.add(XmlRpcRequest.convertArgument(arguments[i])); 
     281      params.add(jala.XmlRpcRequest.convertArgument(arguments[i])); 
    278282   } 
    279283 
     
    289293   conn.setAllowUserInteraction(false); 
    290294   conn.setRequestMethod("POST"); 
    291    conn.setRequestProperty("User-Agent", "Helma XmlRpc Client"); 
     295   conn.setRequestProperty("User-Agent", "Jala XmlRpc Client"); 
    292296   conn.setRequestProperty("Content-Type", "text/xml"); 
    293297   conn.setRequestProperty("Content-Length", requestBytes.length); 
     
    332336            result.error = parsedResult; 
    333337         } else { 
    334             result.result = XmlRpcRequest.convertResult(parsedResult); 
     338            result.result = jala.XmlRpcRequest.convertResult(parsedResult); 
    335339         } 
    336340      } 
    337341   } catch (e) { 
    338       result.error = "[Helma XmlRpc Client] Error executing " + this.getMethodName() 
    339                      + " with arguments " + XmlRpcRequest.argumentsToString(arguments) 
     342      result.error = "[Jala XmlRpc Request] Error executing " + this.getMethodName() 
     343                     + " with arguments " + jala.XmlRpcRequest.argumentsToString(arguments) 
    340344                     + ", the error is: " + e.toString(); 
    341345   } 
    342346   if (app.__app__.debug() == true) { 
    343       app.logger.debug("XmlRpcRequest (" + ((new Date()) - start) + " ms): executed '" 
     347      app.logger.debug("[Jala XmlRpc Request] (" + ((new Date()) - start) + " ms): executed '" 
    344348                       + this.getMethodName() + "' with arguments: " 
    345                        + XmlRpcRequest.argumentsToString(arguments)); 
     349                       + jala.XmlRpcRequest.argumentsToString(arguments)); 
    346350   } 
    347351   return result; 
     
    361365      result = new java.util.Vector(obj.length); 
    362366      for (var i=0;i<obj.length;i++) { 
    363          result.add(i, XmlRpcRequest.convertArgument(obj[i])); 
     367         result.add(i, jala.XmlRpcRequest.convertArgument(obj[i])); 
    364368      } 
    365369   } else if (obj instanceof Date) { 
     
    381385      result = new java.util.Hashtable(); 
    382386      for (var key in obj) { 
    383          result.put(key, XmlRpcRequest.convertArgument(obj[key])); 
     387         result.put(key, jala.XmlRpcRequest.convertArgument(obj[key])); 
    384388      } 
    385389   } else { 
     
    402406      var e = obj.elements(); 
    403407      while (e.hasMoreElements()) { 
    404          result.push(XmlRpcRequest.convertResult(e.nextElement())); 
     408         result.push(jala.XmlRpcRequest.convertResult(e.nextElement())); 
    405409      } 
    406410   } else if (obj instanceof java.util.Hashtable) { 
     
    411415      while (e.hasMoreElements()) { 
    412416         key = e.nextElement(); 
    413          result[key] = XmlRpcRequest.convertResult(obj.get(key)); 
     417         result[key] = jala.XmlRpcRequest.convertResult(obj.get(key)); 
    414418      } 
    415419   } else if (obj instanceof java.lang.String) {