Author: keith Date: Sun Jul 13 07:06:16 2008 New Revision: 19193 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19193
Log: Again getting rid of other Exceptions and throwing only MashupFault Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Entry.java trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Feed.java trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IEntry.java trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IFeed.java trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/MediaModule.java Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Entry.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Entry.java?rev=19193&r1=19192&r2=19193&view=diff ============================================================================== --- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Entry.java (original) +++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Entry.java Sun Jul 13 07:06:16 2008 @@ -15,41 +15,27 @@ */ package org.wso2.mashup.hostobjects.feed; +import com.sun.syndication.feed.module.mediarss.MediaEntryModuleImpl; +import com.sun.syndication.feed.module.mediarss.types.MediaContent; import com.sun.syndication.feed.synd.SyndContent; import com.sun.syndication.feed.synd.SyndContentImpl; import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndEntryImpl; -import com.sun.syndication.feed.synd.SyndLink; import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.feed.synd.SyndFeedImpl; -import com.sun.syndication.feed.module.mediarss.MediaEntryModuleImpl; -import com.sun.syndication.feed.module.mediarss.types.MediaContent; -import com.sun.syndication.io.SyndFeedOutput; +import com.sun.syndication.feed.synd.SyndLink; import com.sun.syndication.io.FeedException; -import org.apache.abdera.i18n.iri.IRISyntaxException; -import org.apache.axis2.AxisFault; -import org.apache.xerces.parsers.DOMParser; +import com.sun.syndication.io.SyndFeedOutput; import org.mozilla.javascript.Context; +import org.mozilla.javascript.Function; import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.ScriptableObject; -import org.mozilla.javascript.Function; import org.wso2.mashup.MashupFault; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXException; -import org.xml.sax.InputSource; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.ParserConfigurationException; + import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; -import java.io.IOException; -import java.io.StringReader; /** * <p/> @@ -162,11 +148,11 @@ } } - public void jsSet_link(Object link) throws IRISyntaxException { + public void jsSet_link(Object link) { entry.setLink(String.valueOf(link)); } - public String[] jsGet_link() throws IRISyntaxException { + public String[] jsGet_link() { String[] links; if (entry.getLinks().size() > 0) { List list = entry.getLinks(); @@ -186,7 +172,7 @@ return null; } - public void jsSet_published(Object published) throws AxisFault { + public void jsSet_published(Object published) throws MashupFault { Date date; if (published instanceof Date) { @@ -198,7 +184,7 @@ if (date != null) { entry.setPublishedDate(date); } else { - throw new AxisFault("Invalid parameter"); + throw new MashupFault("Invalid parameter"); } } @@ -228,7 +214,7 @@ return entry.getTitle(); } - public void jsSet_updated(Object updated) throws AxisFault { + public void jsSet_updated(Object updated) throws MashupFault { Date date; if (updated instanceof Date) { @@ -240,7 +226,7 @@ if (date != null) { entry.setUpdatedDate(date); } else { - throw new AxisFault("Invalid parameter"); + throw new MashupFault("Invalid parameter"); } } @@ -256,11 +242,11 @@ * @param thisObj Gives an instance of the js object from which this method was called * @param arguments The argument for this is a Module object * @param funObj - * @throws IOException + * @throws MashupFault */ public static void jsFunction_addMediaModule(Context cx, Scriptable thisObj, Object[] arguments, - Function funObj) throws IOException { + Function funObj) throws MashupFault { Entry entryObj = (Entry) thisObj; if (arguments[0] instanceof MediaModule) { MediaModule mediaModule = (MediaModule) arguments[0]; @@ -276,11 +262,11 @@ * @param thisObj Gives an instance of the js object from which this method was called * @param arguments None * @param funObj - * @throws IOException + * @throws MashupFault */ public static MediaModule[] jsFunction_getMediaModules(Context cx, Scriptable thisObj, Object[] arguments, - Function funObj) throws IOException { + Function funObj) { MediaModule[] retMediaModules = null; Entry entryObj = (Entry) thisObj; @@ -370,7 +356,7 @@ return cx.newObject(this, "XML", objects); } } catch (FeedException e) { - throw new MashupFault(e.getMessage()); + throw new MashupFault(e); } return null; Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Feed.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Feed.java?rev=19193&r1=19192&r2=19193&view=diff ============================================================================== --- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Feed.java (original) +++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/Feed.java Sun Jul 13 07:06:16 2008 @@ -22,8 +22,6 @@ import com.sun.syndication.feed.synd.SyndLink; import com.sun.syndication.io.FeedException; import com.sun.syndication.io.SyndFeedOutput; -import org.apache.abdera.i18n.iri.IRISyntaxException; -import org.apache.axis2.AxisFault; import org.mozilla.javascript.Context; import org.mozilla.javascript.Function; import org.mozilla.javascript.Scriptable; @@ -114,7 +112,7 @@ return feed.getDescription(); } - public void jsSet_updated(Object updated) throws AxisFault { + public void jsSet_updated(Object updated) throws MashupFault { Date date; if (updated instanceof Date) { @@ -126,7 +124,7 @@ if (date != null) { feed.setPublishedDate(date); } else { - throw new AxisFault("Invalid parameter"); + throw new MashupFault("Invalid parameter"); } } @@ -165,11 +163,11 @@ return null; } - public void jsSet_link(Object link) throws IRISyntaxException { + public void jsSet_link(Object link) { feed.setLink(String.valueOf(link)); } - public String[] jsGet_link() throws IRISyntaxException { + public String[] jsGet_link() { if (feed != null) { String[] links; if (feed.getLinks().size() > 0) { @@ -214,7 +212,7 @@ Object[] objects = { xmlRep }; return cx.newObject(this, "XML", objects); } catch (FeedException e) { - throw new MashupFault(e.getMessage()); + throw new MashupFault(e); } } return null; @@ -242,42 +240,35 @@ * @param arguments No arguments required * @param funObj * @return AtomEntryHostObject[] An Array of Entry Host Objects contained in this feed - * @throws java.io.IOException */ public static Entry[] jsFunction_getEntries(Context cx, Scriptable thisObj, Object[] arguments, - Function funObj) throws IOException { + Function funObj) { Feed feedObject = (Feed) thisObj; Entry[] 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(); - - SyndEntry currentEntry = null; - - //Converting the list of ROME Entries to Entry Host Objects - while (tempEntryIterator.hasNext()) { - currentEntry = (SyndEntry) tempEntryIterator.next(); - Entry newEntry = (Entry) cx.newObject(feedObject, "Entry", new Object[0]); - newEntry.setEntry(currentEntry); - - // Storing the feed type of the entry so that it is self aware - newEntry.setType(feedObject.getFeed().getFeedType()); - - convertedEntries.add(newEntry); - } - - retEntries = new Entry[convertedEntries.size()]; - convertedEntries.toArray(retEntries); + //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(); + + SyndEntry currentEntry = null; + + //Converting the list of ROME Entries to Entry Host Objects + while (tempEntryIterator.hasNext()) { + currentEntry = (SyndEntry) tempEntryIterator.next(); + Entry newEntry = (Entry) cx.newObject(feedObject, "Entry", new Object[0]); + newEntry.setEntry(currentEntry); - } catch (Exception e) { - e.printStackTrace(); + // Storing the feed type of the entry so that it is self aware + newEntry.setType(feedObject.getFeed().getFeedType()); + convertedEntries.add(newEntry); } + retEntries = new Entry[convertedEntries.size()]; + convertedEntries.toArray(retEntries); + return retEntries; } @@ -299,7 +290,7 @@ */ public static Scriptable jsFunction_insertEntry(Context cx, Scriptable thisObj, Object[] arguments, - Function funObj) throws IOException { + Function funObj) { Feed feedObject = (Feed) thisObj; Entry retScriptObject = null; @@ -343,10 +334,10 @@ * @param thisObj Gives an instance of the js object from which this method was called * @param arguments The expected argument is a String representing the file path * @param funObj - * @throws IOException + * @throws MashupFault */ public static Scriptable jsFunction_writeTo(Context cx, Scriptable thisObj, Object[] arguments, - Function funObj) throws IOException { + Function funObj) throws MashupFault { Feed feedObject = (Feed) thisObj; JavaScriptFileObject fileHostObject; @@ -364,11 +355,13 @@ output.output(feedObject.feed, fileWriter); fileWriter.flush(); } else { - throw new AxisFault("Invalid parameter"); + throw new MashupFault("Invalid parameter"); } } catch (FeedException e) { e.printStackTrace(); - throw new AxisFault(e.getMessage()); + throw new MashupFault(e); + } catch (IOException e) { + throw new MashupFault(e); } return feedObject; } Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java?rev=19193&r1=19192&r2=19193&view=diff ============================================================================== --- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java (original) +++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/FeedReader.java Sun Jul 13 07:06:16 2008 @@ -69,14 +69,14 @@ * @throws java.io.IOException */ public static Feed jsFunction_get(Context cx, Scriptable thisObj, Object[] arguments, - Function funObj) throws IOException { + Function funObj) throws MashupFault { Feed retFeed; FeedReader feedReaderObject = (FeedReader) thisObj; GetMethod method = new GetMethod(); if (arguments[0] instanceof String) { String feedUrl = (String) arguments[0]; - URL targetURL = new URL(feedUrl); try { + URL targetURL = new URL(feedUrl); int statusCode = MashupUtils.executeHTTPMethod(method, targetURL); if (statusCode != HttpStatus.SC_OK) { throw new MashupFault( Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IEntry.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IEntry.java?rev=19193&r1=19192&r2=19193&view=diff ============================================================================== --- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IEntry.java (original) +++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IEntry.java Sun Jul 13 07:06:16 2008 @@ -15,8 +15,6 @@ */ package org.wso2.mashup.hostobjects.feed; -import org.apache.abdera.i18n.iri.IRISyntaxException; -import org.apache.axis2.AxisFault; import org.mozilla.javascript.Scriptable; import org.wso2.mashup.MashupFault; @@ -47,11 +45,11 @@ String jsGet_contributor(); - void jsSet_link(Object link) throws IRISyntaxException; + void jsSet_link(Object link); - String[] jsGet_link() throws IRISyntaxException; + String[] jsGet_link(); - void jsSet_published(Object published) throws AxisFault; + void jsSet_published(Object published) throws MashupFault; Date jsGet_published(); @@ -63,7 +61,7 @@ String jsGet_title(); - void jsSet_updated(Object updated) throws AxisFault; + void jsSet_updated(Object updated) throws MashupFault; String jsGet_updated(); Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IFeed.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IFeed.java?rev=19193&r1=19192&r2=19193&view=diff ============================================================================== --- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IFeed.java (original) +++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/IFeed.java Sun Jul 13 07:06:16 2008 @@ -15,9 +15,8 @@ */ package org.wso2.mashup.hostobjects.feed; -import org.apache.abdera.i18n.iri.IRISyntaxException; -import org.apache.axis2.AxisFault; import org.mozilla.javascript.Scriptable; +import org.wso2.mashup.MashupFault; public interface IFeed { @@ -28,7 +27,7 @@ String jsGet_author(); - void jsSet_updated(Object updated) throws AxisFault; + void jsSet_updated(Object updated) throws MashupFault; String jsGet_updated(); @@ -40,9 +39,9 @@ String jsGet_contributor(); - void jsSet_link(Object link) throws IRISyntaxException; + void jsSet_link(Object link); - String[] jsGet_link() throws IRISyntaxException; + String[] jsGet_link(); void jsSet_title(Object title); @@ -53,6 +52,6 @@ * * @return E4X XML */ - public Scriptable jsGet_XML() throws AxisFault; + public Scriptable jsGet_XML() throws MashupFault; } Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/MediaModule.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/MediaModule.java?rev=19193&r1=19192&r2=19193&view=diff ============================================================================== --- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/MediaModule.java (original) +++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/feed/MediaModule.java Sun Jul 13 07:06:16 2008 @@ -27,8 +27,6 @@ import org.mozilla.javascript.ScriptableObject; import org.wso2.mashup.MashupFault; -import java.io.IOException; -import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; @@ -76,7 +74,7 @@ * @param args A string reprepsentation of the media object URI is mandatory */ public static Scriptable jsConstructor(Context cx, Object[] args, Function ctorObj, - boolean inNewExpr) throws IOException { + boolean inNewExpr) throws MashupFault { MediaModule newMediaModule = null; //The first argument is a string representing the URI of the media @@ -176,7 +174,7 @@ try { tempThumbs.add(new Thumbnail(new URI(uri))); } catch (URISyntaxException e) { - throw new MashupFault(e.getMessage()); + throw new MashupFault(e); } thumbnails = new Thumbnail[tempThumbs.size()]; _______________________________________________ Mashup-dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev
