2003/12/29 03:51:28
[org.ibex.core.git] / src / org / xwt / XMLRPC.java
index 0bdca37..94a380e 100644 (file)
@@ -77,7 +77,7 @@ class XMLRPC extends JS {
 
         public void startElement(XML.Element c) {
             content.reset();
-            //#switch(c.localName)
+            //#switch(c.getLocalName())
             case "fault": fault = true;
             case "struct": objects.setElementAt(new JS(), objects.size() - 1);
             case "array": objects.setElementAt(null, objects.size() - 1);
@@ -86,7 +86,7 @@ class XMLRPC extends JS {
         }
         
         public void endElement(XML.Element c) {
-            //#switch(c.localName)
+            //#switch(c.getLocalName())
             case "int": objects.setElementAt(new Integer(new String(content.getBuf(), 0, content.size())), objects.size() - 1);
             case "i4": objects.setElementAt(new Integer(new String(content.getBuf(), 0, content.size())), objects.size() - 1);
             case "boolean": objects.setElementAt(content.getBuf()[0] == '1' ? Boolean.TRUE : Boolean.FALSE, objects.size() - 1);
@@ -119,8 +119,8 @@ class XMLRPC extends JS {
                     objects.setElementAt(nd, objects.size() - 1);
                     
                 } catch (Exception e) {
-                    if (Log.on) Log.log(this, "error parsing date : " + s);
-                    if (Log.on) Log.log(this, e);
+                    if (Log.on) Log.info(this, "error parsing date : " + s);
+                    if (Log.on) Log.info(this, e);
                 }
             case "member":
                 Object memberValue = objects.elementAt(objects.size() - 1);
@@ -150,8 +150,8 @@ class XMLRPC extends JS {
         public void characters(char[] ch, int start, int length) {
             try { content.write(ch, start, length); }
             catch (Exception e) { 
-                if (Log.on) Log.log(this, "Exception in XMLRPC.content() -- this should never happen");
-                if (Log.on) Log.log(this, e);
+                if (Log.on) Log.info(this, "Exception in XMLRPC.content() -- this should never happen");
+                if (Log.on) Log.info(this, e);
             }
         }
         
@@ -220,8 +220,8 @@ class XMLRPC extends JS {
                 }
                 sb.append("\n              </base64></value>\n");
             } catch (IOException e) {
-                if (Log.on) Log.log(this, "caught IOException while attempting to send a ByteStream via XML-RPC");
-                if (Log.on) Log.log(this, e);
+                if (Log.on) Log.info(this, "caught IOException while attempting to send a ByteStream via XML-RPC");
+                if (Log.on) Log.info(this, e);
                 throw new JSExn("caught IOException while attempting to send a ByteStream via XML-RPC");
             }
 
@@ -313,32 +313,27 @@ class XMLRPC extends JS {
 
     final void call(final JS.UnpauseCallback callback, final JSArray args) {
         try {
-            if (Log.verbose) Log.log(this, "call to " + url + " : " + method);
+            if (Log.verbose) Log.info(this, "call to " + url + " : " + method);
             String request = buildRequest(args);
-            if (Log.verbose) Log.log(this, "send:\n" + request);
+            if (Log.verbose) Log.info(this, "send:\n" + request);
             InputStream is = http.POST("text/xml", request);
             BufferedReader br = new BufferedReader(new InputStreamReader(is));
-            if (Log.verbose) br = Log.loggedReader(br);
             if (tracker == null) tracker = new Hash();
             if (objects == null) objects = new Vec();
             try {
                 new Helper().parse(br);
                 final Object result = fault ? new JSExn(objects.elementAt(0)) : objects.size() == 0 ? null : objects.elementAt(0);
-                Scheduler.add(new Scheduler.Task() { public void perform() {
-                    try {
-                        callback.unpause(result);
-                    } catch (Exception e) {
-                        // FIXME
-                        Log.log(this, e);
-                    }
-                }});
+                Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(result); }});
             } finally {
                 tracker.clear();
                 objects.setSize(0);
             }
-        } catch (Exception e) {
-            // FIXME
-            Log.log(this, e);
+        } catch (final JSExn e) {
+            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(e); }});
+        } catch (final IOException e) {
+            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(new JSExn(e)); }});
+        } catch (final XML.Exn e) {
+            Scheduler.add(new Scheduler.Task() { public void perform() throws Exception { callback.unpause(new JSExn(e)); }});
         }
     }
 }