Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

fix for uncaught exception in RSSReader

orbiterbed38a5f8c64
diff --git a/htroot/FeedReader_p.java b/htroot/FeedReader_p.java
index 319fdeba2..b59217bc9 100644
--- a/htroot/FeedReader_p.java
+++ b/htroot/FeedReader_p.java
@@ -21,6 +21,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import java.io.IOException;
import java.net.MalformedURLException;
import de.anomic.http.httpRequestHeader;
@@ -52,28 +53,32 @@ public class FeedReader_p {
// int maxitems=Integer.parseInt(post.get("max", "0"));
// int offset=Integer.parseInt(post.get("offset", "0")); //offset to the first displayed item
- final RSSFeed feed = new RSSReader(url.toString()).getFeed();
-
- prop.putHTML("page_title", feed.getChannel().getTitle());
- if (feed.getChannel().getAuthor() == null) {
- prop.put("page_hasAuthor", "0");
- } else {
- prop.put("page_hasAuthor", "1");
- prop.putHTML("page_hasAuthor_author", feed.getChannel().getAuthor());
- }
- prop.putHTML("page_description", feed.getChannel().getDescription());
-
- int i = 0;
- for (final RSSMessage item: feed) {
- prop.putHTML("page_items_" + i + "_author", item.getAuthor());
- prop.putHTML("page_items_" + i + "_title", item.getTitle());
- prop.putHTML("page_items_" + i + "_link", item.getLink());
- prop.putHTML("page_items_" + i + "_description", item.getDescription());
- prop.putHTML("page_items_" + i + "_date", item.getPubDate());
- i++;
+ try {
+ final RSSFeed feed = new RSSReader(url.toString()).getFeed();
+
+ prop.putHTML("page_title", feed.getChannel().getTitle());
+ if (feed.getChannel().getAuthor() == null) {
+ prop.put("page_hasAuthor", "0");
+ } else {
+ prop.put("page_hasAuthor", "1");
+ prop.putHTML("page_hasAuthor_author", feed.getChannel().getAuthor());
+ }
+ prop.putHTML("page_description", feed.getChannel().getDescription());
+
+ int i = 0;
+ for (final RSSMessage item: feed) {
+ prop.putHTML("page_items_" + i + "_author", item.getAuthor());
+ prop.putHTML("page_items_" + i + "_title", item.getTitle());
+ prop.putHTML("page_items_" + i + "_link", item.getLink());
+ prop.putHTML("page_items_" + i + "_description", item.getDescription());
+ prop.putHTML("page_items_" + i + "_date", item.getPubDate());
+ i++;
+ }
+ prop.put("page_items", feed.size());
+ prop.put("page", "1");
+ } catch (IOException e) {
+ e.printStackTrace();
}
- prop.put("page_items", feed.size());
- prop.put("page", "1");
}
// return rewrite properties
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index 333835a63..097a1031e 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -1236,25 +1236,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// check for interruption
checkInterruption();
+ // enqueue to indexing queue
this.indexingDocumentProcessor.enQueue(new indexingQueueEntry(queueEntry, null, null));
- /*
-
- // THE FOLLOWING CAN BE CONCURRENT ->
-
- // parse and index the resource
- indexingQueueEntry document = parseDocument(new indexingQueueEntry(queueEntry, null, null));
-
- // do condensing
- indexingQueueEntry condensement = condenseDocument(document);
-
- // do a web structure analysis
- indexingQueueEntry analysis = webStructureAnalysis(condensement);
-
- // <- CONCURRENT UNTIL HERE, THEN SERIALIZE AGAIN
-
- // store the result
- storeDocumentIndex(analysis);
- */
return true;
} catch (final InterruptedException e) {
log.logInfo("DEQUEUE: Shutdown detected.");
diff --git a/source/de/anomic/xml/RSSReader.java b/source/de/anomic/xml/RSSReader.java
index 1e9241003..97b57e21a 100644
--- a/source/de/anomic/xml/RSSReader.java
+++ b/source/de/anomic/xml/RSSReader.java
@@ -30,6 +30,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@@ -57,25 +58,29 @@ public class RSSReader extends DefaultHandler {
parsingItem = false;
}
- public RSSReader(final String path) {
+ public RSSReader(final String path) throws IOException {
this();
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
try {
- final SAXParserFactory factory = SAXParserFactory.newInstance();
final SAXParser saxParser = factory.newSAXParser();
saxParser.parse(path, this);
- } catch (final Exception e) {
- e.printStackTrace();
+ } catch (SAXException e) {
+ throw new IOException (e.getMessage());
+ } catch (ParserConfigurationException e) {
+ throw new IOException (e.getMessage());
}
}
- public RSSReader(final InputStream stream) {
+ public RSSReader(final InputStream stream) throws IOException {
this();
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
try {
- final SAXParserFactory factory = SAXParserFactory.newInstance();
final SAXParser saxParser = factory.newSAXParser();
saxParser.parse(stream, this);
- } catch (final Exception e) {
- e.printStackTrace();
+ } catch (SAXException e) {
+ throw new IOException (e.getMessage());
+ } catch (ParserConfigurationException e) {
+ throw new IOException (e.getMessage());
}
}