Author: keith
Date: Sun Jul 13 06:57:43 2008
New Revision: 19192
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19192

Log:
Making sure host objects throw MashupFault instead of other errors


Modified:
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/APPClientHostObject.java
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomEntryHostObject.java
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomFeedHostObject.java
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/GoogleLogin.java

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/APPClientHostObject.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/APPClientHostObject.java?rev=19192&r1=19191&r2=19192&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/APPClientHostObject.java
 (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/APPClientHostObject.java
 Sun Jul 13 06:57:43 2008
@@ -28,7 +28,6 @@
 import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.protocol.client.RequestOptions;
 import org.apache.abdera.protocol.client.util.BaseRequestEntity;
-import org.apache.axis2.AxisFault;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Function;
@@ -36,11 +35,13 @@
 import org.mozilla.javascript.Scriptable;
 import org.mozilla.javascript.ScriptableObject;
 import org.wso2.javascript.xmlimpl.XML;
+import org.wso2.mashup.MashupFault;
 
 import javax.activation.MimeTypeParseException;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.MalformedURLException;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -98,9 +99,9 @@
      * </p>
      *
      * @param object
-     * @throws IOException
+     * @throws MashupFault
      */
-    public void jsSet_credentials(Object object) throws IOException {
+    public void jsSet_credentials(Object object) throws MashupFault {
         if (object instanceof NativeObject) {
             nativeCredentials = (NativeObject) object;
 
@@ -108,36 +109,35 @@
             if (username instanceof String) {
                 usernameString = (String) username;
             } else {
-                throw new AxisFault("Username field needs to be a String.");
+                throw new MashupFault("Username field needs to be a String.");
             }
             Object password = ScriptableObject.getProperty(nativeCredentials, 
"password");
             if (password instanceof String) {
                 passwordString = (String) password;
             } else {
-                throw new AxisFault("Password field needs to be a String.");
+                throw new MashupFault("Password field needs to be a String.");
             }
             Object service = ScriptableObject.getProperty(nativeCredentials, 
"service");
             if (service instanceof String) {
                 serviceString = (String) service;
             } else {
-                throw new AxisFault("Service field needs to be a String.");
+                throw new MashupFault("Service field needs to be a String.");
             }
             Object authType = ScriptableObject.getProperty(nativeCredentials, 
"authtype");
             if (authType instanceof String) {
                 authenticationType = (String) authType;
             } else {
-                throw new AxisFault("Authnetication Type field needs to be a 
String.");
+                throw new MashupFault("Authnetication Type field needs to be a 
String.");
             }
         } else {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
     }
 
     /**
      * @return the credentials object or null
-     * @throws IOException
      */
-    public Scriptable jsGet_credentials() throws IOException {
+    public Scriptable jsGet_credentials() {
         return nativeCredentials;
     }
 
@@ -163,13 +163,13 @@
      * </pre>
      *
      * @return AtomEntry
-     * @throws IOException
+     * @throws MashupFault
      */
     public static Scriptable jsFunction_get(Context cx, Scriptable thisObj, 
Object[] arguments,
-                                            Function funObj) throws 
IOException {
+                                            Function funObj) throws 
MashupFault {
         APPClientHostObject hostObject = (APPClientHostObject) thisObj;
         if (arguments.length == 0) {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
 
         if (arguments[0] instanceof String) {
@@ -195,9 +195,7 @@
                             .getDocument().getRoot());
                     return entryHostObject;
                 } catch (IRISyntaxException e) {
-                    throw AxisFault.makeFault(e);
-                } catch (MimeTypeParseException e) {
-                    throw AxisFault.makeFault(e);
+                    throw new MashupFault(e);
                 }
             }
         }
@@ -218,24 +216,29 @@
      * </pre>
      *
      * @return AtomFeed
-     * @throws IOException
+     * @throws MashupFault
      */
     synchronized public static Scriptable jsFunction_getFeed(Context cx, 
Scriptable thisObj,
                                                              Object[] 
arguments,
-                                                             Function funObj) 
throws IOException {
+                                                             Function funObj) 
throws MashupFault {
         APPClientHostObject hostObject = (APPClientHostObject) thisObj;
         if (arguments.length == 0) {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
 
         if (arguments[0] instanceof String) {
 
-            URL url = new URL((String) arguments[0]);
+
             Feed feed = null;
             try {
+                URL url = new URL((String) arguments[0]);
                 feed = (Feed) 
Abdera.getNewParser().parse(url.openStream()).getRoot();
             } catch (IRISyntaxException e) {
-                e.printStackTrace();
+                throw new MashupFault(e);
+            } catch (MalformedURLException e) {
+                throw new MashupFault(e);
+            } catch (IOException e) {
+                throw new MashupFault(e);
             }
 
             Scriptable feedHostObject = cx.newObject(hostObject, "AtomFeed", 
new Object[0]);
@@ -256,9 +259,9 @@
                             .getDocument().getRoot());
                     return feedHostObject;
                 } catch (IRISyntaxException e) {
-                    throw AxisFault.makeFault(e);
+                    throw new MashupFault(e);
                 } catch (MimeTypeParseException e) {
-                    throw AxisFault.makeFault(e);
+                    throw new MashupFault(e);
                 }
             }
         }
@@ -271,17 +274,17 @@
      */
     public static Scriptable jsFunction_getForEdit(Context cx, Scriptable 
thisObj,
                                                    Object[] arguments, 
Function funObj)
-            throws IOException {
+            throws MashupFault {
         APPClientHostObject hostObject = (APPClientHostObject) thisObj;
         if (arguments.length == 0) {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
 
         if (arguments[0] instanceof AtomEntryHostObject) {
             AtomEntryHostObject atomEntryHostObject = (AtomEntryHostObject) 
arguments[0];
             Entry entry = atomEntryHostObject.getEntry();
             if (entry != null) {
-                IRI editUri = null;
+                IRI editUri;
                 try {
                     editUri = getEditURI(entry);
                     ClientResponse clientResponse = 
hostObject.client.get(editUri.toString());
@@ -291,9 +294,7 @@
                             .getDocument().getRoot());
                     return entryHostObject;
                 } catch (IRISyntaxException e) {
-                    throw AxisFault.makeFault(e);
-                } catch (MimeTypeParseException e) {
-                    throw AxisFault.makeFault(e);
+                    throw new MashupFault(e);
                 }
             }
             return null;
@@ -301,7 +302,7 @@
         return null;
     }
 
-    private static IRI getEditURI(Entry entry) throws MimeTypeParseException, 
IRISyntaxException {
+    private static IRI getEditURI(Entry entry) throws MashupFault {
         IRI editUri = null;
         List editLinks = entry.getLinks("edit");
         for (Iterator iter = editLinks.iterator(); iter.hasNext();) {
@@ -310,9 +311,13 @@
             // assume that it's always going to point to an Atom document
             // representation.
             if (link.getMimeType() != null) {
-                if (link.getMimeType().match("application/atom+xml")) {
-                    editUri = link.getResolvedHref();
-                    break;
+                try {
+                    if (link.getMimeType().match("application/atom+xml")) {
+                        editUri = link.getResolvedHref();
+                        break;
+                    }
+                } catch (MimeTypeParseException e) {
+                    throw new MashupFault(e);
                 }
             } else { // assume that an edit link with no type
                 // attribute is the right one to use
@@ -378,11 +383,11 @@
      * @throws IOException
      */
     public static Scriptable jsFunction_post(Context cx, Scriptable thisObj, 
Object[] arguments,
-                                             Function funObj) throws 
IOException {
+                                             Function funObj) throws 
MashupFault {
         APPClientHostObject hostObject = (APPClientHostObject) thisObj;
         Entry entry;
         if (arguments.length != 2) {
-            throw new AxisFault("Invalid Number of Parameters");
+            throw new MashupFault("Invalid Number of Parameters");
         }
         if (arguments[1] instanceof AtomEntryHostObject) {
             AtomEntryHostObject atomEntryHostObject = (AtomEntryHostObject) 
arguments[1];
@@ -396,10 +401,10 @@
                 Scriptable entryHostObject = post(cx, arguments, hostObject, 
entry);
                 return entryHostObject;
             } catch (IRISyntaxException e) {
-                throw new AxisFault(e.toString());
+                throw new MashupFault(e);
             }
         } else {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
     }
 
@@ -411,10 +416,10 @@
      * @param hostObject - This object
      * @param entry      - Entry to be posted
      * @return the posted entry returned by the server
-     * @throws AxisFault
+     * @throws MashupFault
      */
     private static Scriptable post(Context cx, Object[] arguments, 
APPClientHostObject hostObject,
-                                   Entry entry) throws AxisFault {
+                                   Entry entry) throws MashupFault {
 
         performAuthentication(hostObject, (String) arguments[0]);
         Response response = hostObject.client.post((String) arguments[0],
@@ -423,7 +428,7 @@
 
         // Check the response.
         if (response.getStatus() != 201) {
-            throw new AxisFault("Posting Failed." + response.getStatusText());
+            throw new MashupFault("Posting Failed." + 
response.getStatusText());
         }
 
         Scriptable entryHostObject = cx.newObject(hostObject, "AtomEntry", new 
Object[0]);
@@ -462,7 +467,7 @@
      */
     public static void jsFunction_put(Context cx, Scriptable thisObj, Object[] 
arguments,
                                       Function funObj)
-            throws IOException, Exception, IRISyntaxException {
+            throws MashupFault {
         APPClientHostObject hostObject = (APPClientHostObject) thisObj;
         Entry entry;
         String url;
@@ -478,10 +483,10 @@
                     }
                     url = (String) arguments[0];
                 } catch (IRISyntaxException e) {
-                    throw new AxisFault(e.toString());
+                    throw new MashupFault(e);
                 }
             } else {
-                throw new AxisFault("Invalid Parameter");
+                throw new MashupFault("Invalid Parameter");
             }
         } else if (arguments.length == 1) {
             if (arguments[0] instanceof AtomEntryHostObject) {
@@ -489,18 +494,18 @@
                 entry = atomEntryHostObject.getEntry();
                 url = getEditURI(entry).toString();
             } else {
-                throw new AxisFault("URI Parameter is Missing.");
+                throw new MashupFault("URI Parameter is Missing.");
             }
 
         } else {
-            throw new AxisFault("Invalid Number of Parameters");
+            throw new MashupFault("Invalid Number of Parameters");
         }
 
         performAuthentication(hostObject, url);
         ClientResponse response = hostObject.client.put(url, entry, 
hostObject.options);
 
         if (response.getStatus() != 200)
-            throw new AxisFault("Put Failed." + response.getStatusText());
+            throw new MashupFault("Put Failed." + response.getStatusText());
 
     }
 
@@ -519,7 +524,7 @@
      */
     public static void jsFunction_deleteEntry(Context cx, Scriptable thisObj, 
Object[] arguments,
                                               Function funObj)
-            throws IOException, Exception, IRISyntaxException {
+            throws MashupFault {
         APPClientHostObject hostObject = (APPClientHostObject) thisObj;
         Entry entry;
         String url;
@@ -531,10 +536,10 @@
             } else if (arguments[0] instanceof String) {
                 url = (String) arguments[0];
             } else {
-                throw new AxisFault("Invalid Parameter");
+                throw new MashupFault("Invalid Parameter");
             }
         } else {
-            throw new AxisFault("Invalid Number of Parameters");
+            throw new MashupFault("Invalid Number of Parameters");
         }
 
 
@@ -542,9 +547,9 @@
         if (url != null) {
             ClientResponse response = hostObject.client.delete(url, 
hostObject.options);
             if (response.getStatus() != 200)
-                throw new AxisFault("Delete Failed." + 
response.getStatusText());
+                throw new MashupFault("Delete Failed." + 
response.getStatusText());
         } else {
-            throw new AxisFault("Entry Cannot be deleted.");
+            throw new MashupFault("Entry Cannot be deleted.");
         }
     }
 
@@ -553,9 +558,9 @@
      * AtomEntry object.
      *
      * @throws IRISyntaxException
-     * @throws AxisFault
+     * @throws MashupFault
      */
-    private Entry createEntry(NativeObject nativeEntry) throws 
IRISyntaxException, AxisFault {
+    private Entry createEntry(NativeObject nativeEntry) throws MashupFault {
         Entry entry;
         Factory factory = abdera.getFactory();
         entry = factory.newEntry();
@@ -597,7 +602,7 @@
         } else if (content instanceof String) {
             entry.setContent((String) content);
         } else {
-            throw new AxisFault("Unsupported Content");
+            throw new MashupFault("Unsupported Content");
         }
 
         // process contributor
@@ -677,7 +682,7 @@
         } else if (title instanceof String) {
             entry.setTitle((String) (title));
         } else {
-            throw new AxisFault("An Entry MUST have a title.");
+            throw new MashupFault("An Entry MUST have a title.");
         }
 
         // process updated
@@ -698,7 +703,8 @@
      *
      * @param hostObject
      */
-    private static void performAuthentication(APPClientHostObject hostObject, 
String uri) {
+    private static void performAuthentication(APPClientHostObject hostObject, 
String uri)
+            throws MashupFault {
 
         try {
             if (hostObject.authenticationType.compareToIgnoreCase("google") == 
0) {
@@ -716,10 +722,7 @@
                         hostObject.usernameString, hostObject.passwordString));
             }
         } catch (URISyntaxException e) {
-            e.printStackTrace();
+            throw new MashupFault(e);
         }
-
-
     }
-
 }

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomEntryHostObject.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomEntryHostObject.java?rev=19192&r1=19191&r2=19192&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomEntryHostObject.java
 (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomEntryHostObject.java
 Sun Jul 13 06:57:43 2008
@@ -17,16 +17,15 @@
 
 import org.apache.abdera.Abdera;
 import org.apache.abdera.factory.Factory;
-import org.apache.abdera.i18n.iri.IRISyntaxException;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Link;
 import org.apache.abdera.parser.stax.util.FOMHelper;
-import org.apache.axis2.AxisFault;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Scriptable;
 import org.mozilla.javascript.ScriptableObject;
 import org.wso2.javascript.xmlimpl.XML;
 import org.wso2.mashup.hostobjects.feed.IEntry;
+import org.wso2.mashup.MashupFault;
 
 import java.util.Date;
 import java.util.List;
@@ -186,7 +185,7 @@
     }
 
     //process id
-    public void jsSet_id(Object id) throws IRISyntaxException {
+    public void jsSet_id(Object id) {
         if (id instanceof String) {
             entry.setId((String) (id));
         } else {
@@ -194,18 +193,18 @@
         }
     }
 
-    public String jsGet_id() throws IRISyntaxException {
+    public String jsGet_id() {
         if (entry != null)
             return entry.getId().toASCIIString();
         return null;
     }
 
     // process link                   
-    public void jsSet_link(Object link) throws IRISyntaxException {
+    public void jsSet_link(Object link) {
         entry.addLink(String.valueOf(link));
     }
 
-    public String[] jsGet_link() throws IRISyntaxException {
+    public String[] jsGet_link() {
         if (entry != null) {
             List list = entry.getLinks();
             int size = list.size();
@@ -220,7 +219,7 @@
     }
 
     //process published
-    public void jsSet_published(Object published) throws AxisFault {
+    public void jsSet_published(Object published) throws MashupFault {
         Date date = null;
 
         if (published instanceof Date) {
@@ -232,7 +231,7 @@
         if (date != null) {
             entry.setPublished(date);
         } else {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
     }
 
@@ -288,7 +287,7 @@
     }
 
     //process updated
-    public void jsSet_updated(Object updated) throws AxisFault {
+    public void jsSet_updated(Object updated) throws MashupFault {
         Date date = null;
 
         if (updated instanceof Date) {
@@ -300,7 +299,7 @@
         if (date != null) {
             entry.setUpdated(date);
         } else {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
     }
 

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomFeedHostObject.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomFeedHostObject.java?rev=19192&r1=19191&r2=19192&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomFeedHostObject.java
  (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/AtomFeedHostObject.java
  Sun Jul 13 06:57:43 2008
@@ -30,6 +30,7 @@
 import org.wso2.javascript.xmlimpl.XML;
 import org.wso2.mashup.hostobjects.feed.IFeed;
 import org.wso2.mashup.hostobjects.file.JavaScriptFileObject;
+import org.wso2.mashup.MashupFault;
 
 import java.io.FileWriter;
 import java.io.IOException;
@@ -138,7 +139,7 @@
         return "AtomFeed";
     }
 
-    public void jsSet_id(Object id) throws IRISyntaxException {
+    public void jsSet_id(Object id) {
         if (id instanceof String) {
             feed.setId((String) (id));
         } else {
@@ -146,7 +147,7 @@
         }
     }
 
-    public String jsGet_id() throws IRISyntaxException {
+    public String jsGet_id() {
         if (feed != null)
             return feed.getId().toASCIIString();
         return null;
@@ -160,8 +161,8 @@
         return feed.getAuthor().getName();
     }
 
-    public void jsSet_updated(Object updated) throws AxisFault {
-        Date date = null;
+    public void jsSet_updated(Object updated) throws MashupFault {
+        Date date;
 
         if (updated instanceof Date) {
             date = (Date) updated;
@@ -172,7 +173,7 @@
         if (date != null) {
             feed.setUpdated(date);
         } else {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
 
     }
@@ -203,11 +204,11 @@
         return null;
     }
 
-    public void jsSet_link(Object link) throws IRISyntaxException {
+    public void jsSet_link(Object link) {
         feed.addLink(String.valueOf(link));
     }
 
-    public String[] jsGet_link() throws IRISyntaxException {
+    public String[] jsGet_link() {
         if (feed != null) {
             List list = feed.getLinks();
             int size = list.size();
@@ -277,7 +278,7 @@
      * @throws IOException
      */
     public static Scriptable jsFunction_addEntry(Context cx, Scriptable 
thisObj, Object[] arguments,
-                                                 Function funObj) throws 
IOException {
+                                                 Function funObj) {
 
         AtomFeedHostObject feedObject = (AtomFeedHostObject) thisObj;
         AtomEntryHostObject retScriptObject = null;
@@ -308,7 +309,7 @@
      */
     public static Scriptable jsFunction_insertEntry(Context cx, Scriptable 
thisObj,
                                                     Object[] arguments,
-                                                    Function funObj) throws 
IOException {
+                                                    Function funObj) {
 
         AtomFeedHostObject feedObject = (AtomFeedHostObject) thisObj;
         AtomEntryHostObject retScriptObject = null;
@@ -338,7 +339,7 @@
      * @throws IOException
      */
     public static Scriptable jsFunction_getEntry(Context cx, Scriptable 
thisObj, Object[] arguments,
-                                                 Function funObj) throws 
IOException {
+                                                 Function funObj) throws 
MashupFault {
 
         AtomFeedHostObject feedObject = (AtomFeedHostObject) thisObj;
         AtomEntryHostObject retScriptObject = null;
@@ -352,14 +353,14 @@
                             .newObject(feedObject, "AtomEntry", new Object[0]);
                     retScriptObject.setEntry(entry);
                 } else {
-                    throw new AxisFault("Invalid Atom Entry Id");
+                    throw new MashupFault("Invalid Atom Entry Id");
                 }
 
             } catch (IRISyntaxException e) {
                 e.printStackTrace();
             }
         } else {
-            throw new AxisFault("Invalid parameter");
+            throw new MashupFault("Invalid parameter");
         }
 
         return retScriptObject;
@@ -378,36 +379,30 @@
      */
     public static AtomEntryHostObject[] jsFunction_getEntries(Context cx, 
Scriptable thisObj,
                                                               Object[] 
arguments,
-                                                              Function funObj) 
throws IOException {
+                                                              Function funObj) 
{
         AtomFeedHostObject feedObject = (AtomFeedHostObject) thisObj;
         AtomEntryHostObject[] retEntries = null;
 
-        try {
-            //Retrieving the entries from our feed
-            List tempEntries = feedObject.feed.getEntries();
-            Iterator tempEntryIterator = tempEntries.iterator();
-
-            //Creating a list to store converted Entries
-            ArrayList convertedEntries = new ArrayList();
-
-            Entry currentEntry = null;
-
-            //Converting the list of Abdera Entries to AtomEntryHostObjects
-            while (tempEntryIterator.hasNext()) {
-                currentEntry = (Entry) tempEntryIterator.next();
-                AtomEntryHostObject newAtomEntry =
-                        (AtomEntryHostObject) cx.newObject(feedObject, 
"AtomEntry", new Object[0]);
-                newAtomEntry.setEntry(currentEntry);
-                convertedEntries.add(newAtomEntry);
-            }
-
-            retEntries = new AtomEntryHostObject[convertedEntries.size()];
-            convertedEntries.toArray(retEntries);
-
-        } catch (Exception e) {
-            e.printStackTrace();
+        //Retrieving the entries from our feed
+        List tempEntries = feedObject.feed.getEntries();
+        Iterator tempEntryIterator = tempEntries.iterator();
+
+        //Creating a list to store converted Entries
+        ArrayList convertedEntries = new ArrayList();
+
+        Entry currentEntry;
+
+        //Converting the list of Abdera Entries to AtomEntryHostObjects
+        while (tempEntryIterator.hasNext()) {
+            currentEntry = (Entry) tempEntryIterator.next();
+            AtomEntryHostObject newAtomEntry =
+                    (AtomEntryHostObject) cx.newObject(feedObject, 
"AtomEntry", new Object[0]);
+            newAtomEntry.setEntry(currentEntry);
+            convertedEntries.add(newAtomEntry);
         }
 
+        retEntries = new AtomEntryHostObject[convertedEntries.size()];
+        convertedEntries.toArray(retEntries);
         return retEntries;
     }
 
@@ -422,24 +417,29 @@
      * @throws IOException
      */
     public static Scriptable jsFunction_writeTo(Context cx, Scriptable 
thisObj, Object[] arguments,
-                                                Function funObj) throws 
IOException {
+                                                Function funObj) throws 
MashupFault {
 
         AtomFeedHostObject feedObject = (AtomFeedHostObject) thisObj;
         JavaScriptFileObject fileHostObject;
-        if (arguments[0] instanceof String) {
-            fileHostObject = (JavaScriptFileObject) cx.newObject(feedObject, 
"File", arguments);
-            FileWriter fileWriter = new FileWriter(fileHostObject.getFile());
-            feedObject.feed.writeTo(fileWriter);
-            fileWriter.flush();
-        } else if (arguments[0] instanceof JavaScriptFileObject) {
-            fileHostObject = (JavaScriptFileObject) arguments[0];
-            FileWriter fileWriter = new FileWriter(fileHostObject.getFile());
-            feedObject.feed.writeTo(fileWriter);
-            fileWriter.flush();
-        } else {
-            throw new AxisFault("Invalid parameter");
+        try {
+            if (arguments[0] instanceof String) {
+                fileHostObject = (JavaScriptFileObject) 
cx.newObject(feedObject, "File", arguments);
+                FileWriter fileWriter = new 
FileWriter(fileHostObject.getFile());
+                feedObject.feed.writeTo(fileWriter);
+                fileWriter.flush();
+            } else if (arguments[0] instanceof JavaScriptFileObject) {
+                fileHostObject = (JavaScriptFileObject) arguments[0];
+                FileWriter fileWriter = new 
FileWriter(fileHostObject.getFile());
+                feedObject.feed.writeTo(fileWriter);
+                fileWriter.flush();
+            } else {
+                throw new MashupFault("Invalid parameter");
+            }
+            return feedObject;
+        } catch (IOException
+                e) {
+            throw new MashupFault(e);
         }
-        return feedObject;
     }
 
 

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/GoogleLogin.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/GoogleLogin.java?rev=19192&r1=19191&r2=19192&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/GoogleLogin.java
 (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/atom/GoogleLogin.java
 Sun Jul 13 06:57:43 2008
@@ -20,6 +20,7 @@
 import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.protocol.client.RequestOptions;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.wso2.mashup.MashupFault;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -51,15 +52,18 @@
         return null;
     }
 
-    private static String read(InputStream in) throws IOException {
+    private static String read(InputStream in) throws MashupFault {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         int n = -1;
-        while ((n = in.read()) != -1) {
-            out.write(n);
+        try {
+            while ((n = in.read()) != -1) {
+                out.write(n);
+            }
+            out.flush();
+        } catch (IOException e) {
+            throw new MashupFault(e);
         }
-        out.flush();
-        String auth = new String(out.toByteArray());
-        return auth;
+        return new String(out.toByteArray());
     }
 
     private static String getRequest(String id, String pwd, String service)

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to