Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-888 : Remove parse-rss

Julien Nioched243097bd82f
diff --git a/CHANGES.txt b/CHANGES.txt
index 9c64ab63b..36bfa75da 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Release 2.0 - Current Development
+* NUTCH-888 Remove parse-rss and add tests for rss to parse-tika (jnioche)
+
* NUTCH-991 SolrDedup must issue a commit (markus)
* NUTCH 986 SolrDedup fails due to date incorrect format (markus)
diff --git a/conf/parse-plugins.xml b/conf/parse-plugins.xml
index d5495e9f7..5b20be6e1 100644
--- a/conf/parse-plugins.xml
+++ b/conf/parse-plugins.xml
@@ -37,7 +37,7 @@
</mimeType>
<mimeType name="application/rss+xml">
- <plugin id="parse-rss" />
+ <plugin id="parse-tika" />
<plugin id="feed" />
</mimeType>
@@ -65,7 +65,6 @@
<mimeType name="text/xml">
<plugin id="parse-tika" />
- <plugin id="parse-rss" />
<plugin id="feed" />
</mimeType>
@@ -88,8 +87,6 @@
extension-id="org.apache.nutch.parse.tika.TikaParser" />
<alias name="parse-ext" extension-id="ExtParser" />
<alias name="parse-js" extension-id="JSParser" />
- <alias name="parse-rss"
- extension-id="org.apache.nutch.parse.rss.RSSParser" />
<alias name="feed"
extension-id="org.apache.nutch.parse.feed.FeedParser" />
<alias name="parse-swf"
diff --git a/src/plugin/build.xml b/src/plugin/build.xml
index 3fcc37cdd..b3f756c0f 100755
--- a/src/plugin/build.xml
+++ b/src/plugin/build.xml
@@ -44,7 +44,6 @@
<ant dir="protocol-sftp" target="deploy"/>
<ant dir="parse-js" target="deploy"/>
<ant dir="parse-html" target="deploy"/>
- <ant dir="parse-rss" target="deploy"/>
<ant dir="parse-tika" target="deploy"/>
<ant dir="scoring-link" target="deploy"/>
<ant dir="scoring-opic" target="deploy"/>
@@ -72,11 +71,9 @@
<!-- ====================================================== -->
<target name="test">
<ant dir="creativecommons" target="test"/>
- <ant dir="parse-rss" target="test"/>
<ant dir="parse-tika" target="test"/>
<ant dir="protocol-file" target="test"/>
<ant dir="parse-html" target="test"/>
- <ant dir="parse-rss" target="test"/>
<ant dir="index-more" target="test"/>
<ant dir="languageidentifier" target="test"/>
<ant dir="protocol-httpclient" target="test"/>
@@ -117,7 +114,6 @@
<ant dir="parse-ext" target="clean"/>
<ant dir="parse-js" target="clean"/>
<ant dir="parse-html" target="clean"/>
- <ant dir="parse-rss" target="clean"/>
<ant dir="parse-swf" target="clean"/>
<ant dir="parse-tika" target="clean"/>
<ant dir="parse-zip" target="clean"/>
diff --git a/src/plugin/parse-rss/build.xml b/src/plugin/parse-rss/build.xml
deleted file mode 100644
index 71c40d3e7..000000000
--- a/src/plugin/parse-rss/build.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project name="parse-rss" default="jar-core">
-
- <import file="../build-plugin.xml"/>
-
- <!-- Build compilation dependencies -->
- <target name="deps-jar">
- <ant target="jar" inheritall="false" dir="../lib-xml"/>
- </target>
-
- <!-- Add compilation dependencies to classpath -->
- <path id="plugin.deps">
- <fileset dir="${nutch.root}/build">
- <include name="**/lib-xml/*.jar" />
- </fileset>
- </path>
-
- <!-- Deploy Unit test dependencies -->
- <target name="deps-test">
- <ant target="deploy" inheritall="false" dir="../lib-xml"/>
- <ant target="deploy" inheritall="false" dir="../nutch-extensionpoints"/>
- <ant target="deploy" inheritall="false" dir="../protocol-file"/>
- </target>
-
-
- <!-- for junit test -->
- <mkdir dir="${build.test}/data"/>
- <copy file="sample/rsstest.rss" todir="${build.test}/data"/>
-
-</project>
diff --git a/src/plugin/parse-rss/ivy.xml b/src/plugin/parse-rss/ivy.xml
deleted file mode 100644
index 37a6be13a..000000000
--- a/src/plugin/parse-rss/ivy.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" ?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<ivy-module version="1.0">
- <info organisation="org.apache.nutch" module="${ant.project.name}">
- <license name="Apache 2.0"/>
- <ivyauthor name="Apache Nutch Team" url="http://nutch.apache.org"/>
- <description>
- Apache Nutch
- </description>
- </info>
-
- <configurations>
- <include file="${nutch.root}/ivy/ivy-configurations.xml"/>
- </configurations>
-
- <publications>
- <!--get the artifact from our module name-->
- <artifact conf="master"/>
- </publications>
-
- <dependencies>
- <dependency org="xmlrpc" name="xmlrpc" rev="1.2" conf="*->master"/>
- </dependencies>
-
-</ivy-module>
diff --git a/src/plugin/parse-rss/lib/commons-feedparser-0.6-fork.jar b/src/plugin/parse-rss/lib/commons-feedparser-0.6-fork.jar
deleted file mode 100644
index a8eebe555..000000000
Binary files a/src/plugin/parse-rss/lib/commons-feedparser-0.6-fork.jar and /dev/null differ
diff --git a/src/plugin/parse-rss/plugin.xml b/src/plugin/parse-rss/plugin.xml
deleted file mode 100644
index 79fa19dc0..000000000
--- a/src/plugin/parse-rss/plugin.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<plugin
- id="parse-rss"
- name="RSS Parse Plug-in"
- version="1.0.0"
- provider-name="edu.usc.cs.cs599">
-
-
- <runtime>
- <library name="parse-rss.jar">
- <export name="*"/>
- </library>
- <library name="commons-feedparser-0.6-fork.jar"/>
- <library name="xml-rpc-1.2.jar"/>
- </runtime>
-
- <requires>
- <import plugin="nutch-extensionpoints"/>
- <import plugin="lib-xml"/>
- </requires>
-
- <extension id="org.apache.nutch.parse.rss"
- name="RssParse"
- point="org.apache.nutch.parse.Parser">
-
- <implementation id="org.apache.nutch.parse.rss.RSSParser"
- class="org.apache.nutch.parse.rss.RSSParser">
- <parameter name="contentType" value="application/rss+xml"/>
- <parameter name="pathSuffix" value="rss"/>
- </implementation>
- </extension>
-
-</plugin>
diff --git a/src/plugin/parse-rss/sample/rsstest.rss b/src/plugin/parse-rss/sample/rsstest.rss
deleted file mode 100644
index 07d7ec025..000000000
--- a/src/plugin/parse-rss/sample/rsstest.rss
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<rss version="0.91">
- <channel>
- <title>TestChannel</title>
- <link>http://test.channel.com/</link>
- <description>Sample RSS File for Junit test</description>
- <language>en-us</language>
-
- <item>
- <title>Home Page of Chris Mattmann</title>
- <link>http://www-scf.usc.edu/~mattmann/</link>
- <description>Chris Mattmann's home page</description>
- </item>
-
- <item>
- <title>Awesome Open Source Search Engine</title>
- <link>http://www.nutch.org/</link>
- <description>Yup, that's what it is</description>
- </item>
- </channel>
-</rss>
diff --git a/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/FeedParserListenerImpl.java b/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/FeedParserListenerImpl.java
deleted file mode 100644
index 67d1c6b4b..000000000
--- a/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/FeedParserListenerImpl.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nutch.parse.rss;
-
-import org.apache.commons.feedparser.DefaultFeedParserListener;
-import org.apache.commons.feedparser.FeedParserState;
-import org.apache.commons.feedparser.FeedParserException;
-
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.nutch.parse.rss.structs.RSSChannel;
-import org.apache.nutch.parse.rss.structs.RSSItem;
-
-/**
- *
- * @author mattmann
- * @version 1.0
- *
- * <p>
- * Feed parser listener class which builds up an RSS Channel model that can be
- * iterated through to retrieve the parsed information.
- * </p>
- */
-public class FeedParserListenerImpl extends DefaultFeedParserListener {
-
- private List fRssChannels = null;
-
- private RSSChannel fCurrentChannel = null;
-
- /**
- * <p>
- * Default Constructor
- * </p>
- */
- public FeedParserListenerImpl() {
- fRssChannels = new Vector();
- }
-
- /**
- * <p>
- * Gets a {@link List}of {@link RSSChannel}s that the listener parsed from
- * the RSS document.
- * </p>
- *
- * @return A {@link List}of {@link RSSChannel}s.
- */
- public List getChannels() {
- if (fRssChannels.size() > 0) {
- return fRssChannels;
- } else {
- //there was only one channel found
- //add it here, then return it
- fRssChannels.add(fCurrentChannel);
- return fRssChannels;
- }
- }
-
- /**
- * <p>
- * Callback method when the parser encounters an RSS Channel.
- * </p>
- *
- * @param state
- * The current state of the FeedParser.
- * @param title
- * The title of the RSS Channel.
- * @param link
- * A hyperlink to the RSS Channel.
- * @param description
- * The description of the RSS Channel.
- */
- public void onChannel(FeedParserState state, String title, String link,
- String description) throws FeedParserException {
-
- //capture the old channel if it's not null
- if (fCurrentChannel != null) {
- fRssChannels.add(fCurrentChannel);
- }
-
- //System.out.println("Found a new channel: " + title);
-
- fCurrentChannel = new RSSChannel(title, link, description);
-
- }
-
- /**
- * <p>
- * Callback method when the parser encounters an RSS Item.
- * </p>
- *
- * @param state
- * The current state of the FeedParser.
- * @param title
- * The title of the RSS Item.
- * @param link
- * A hyperlink to the RSS Item.
- * @param description
- * The description of the RSS Item.
- * @param permalink
- * A permanent link to the RSS Item.
- */
- public void onItem(FeedParserState state, String title, String link,
- String description, String permalink) throws FeedParserException {
-
- //System.out.println("Found a new published article: " + permalink);
- if (fCurrentChannel != null) { //should never be null
- fCurrentChannel.getItems().add(
- new RSSItem(title, link, description, permalink));
- }
-
- }
-
-}
diff --git a/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/RSSParser.java b/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/RSSParser.java
deleted file mode 100644
index 84897d923..000000000
--- a/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/RSSParser.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.nutch.parse.rss;
-
-// JDK imports
-import java.io.ByteArrayInputStream;
-import java.net.MalformedURLException;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.commons.feedparser.FeedParser;
-import org.apache.commons.feedparser.FeedParserFactory;
-import org.apache.commons.feedparser.FeedParserListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.nutch.parse.Outlink;
-import org.apache.nutch.parse.Parse;
-import org.apache.nutch.parse.ParseStatusUtils;
-import org.apache.nutch.parse.Parser;
-import org.apache.nutch.parse.rss.structs.RSSChannel;
-import org.apache.nutch.parse.rss.structs.RSSItem;
-import org.apache.nutch.protocol.Content;
-import org.apache.nutch.protocol.Protocol;
-import org.apache.nutch.protocol.ProtocolFactory;
-import org.apache.nutch.storage.WebPage;
-import org.apache.nutch.util.LogUtil;
-import org.apache.nutch.util.NutchConfiguration;
-
-/**
- *
- * @author mattmann
- * @version 1.0
- *
- * <p>
- * RSS Parser class for nutch
- * </p>
- */
-public class RSSParser implements Parser {
- public static final Logger LOG = LoggerFactory.getLogger("org.apache.nutch.parse.rss");
- private Configuration conf;
-
- private static Collection<WebPage.Field> FIELDS = new HashSet<WebPage.Field>();
-
- static {
- FIELDS.add(WebPage.Field.BASE_URL);
- }
-
- /**
- * <p>
- * Implementation method, parses the RSS content, and then returns a
- * {@link Parse}.
- * </p>
- *
- * @param content
- * The content to parse (hopefully an RSS content stream)
- * @return A {@link Parse}.
- */
- public Parse getParse(String url, WebPage page) {
-
- List theRSSChannels = null;
-
- try {
- byte[] raw = page.getContent().array();
-
- // create a new FeedParser...
- FeedParser parser = FeedParserFactory.newFeedParser();
-
- // create a listener for handling our callbacks
- FeedParserListener listener = new FeedParserListenerImpl();
-
- // start parsing our feed and have the onItem methods called
- parser.parse(listener, new ByteArrayInputStream(raw), /* resource */
- null);
-
- theRSSChannels = ((FeedParserListenerImpl) listener).getChannels();
-
- } catch (Exception e) { // run time exception
- if (LOG.isWarnEnabled()) {
- e.printStackTrace(LogUtil.getWarnStream(LOG));
- LOG.warn("nutch:parse-rss:RSSParser Exception: " + e.getMessage());
- }
- return ParseStatusUtils.getEmptyParse(e, getConf());
- }
-
- StringBuffer contentTitle = new StringBuffer(), indexText = new StringBuffer();
- List<Outlink> theOutlinks = new Vector<Outlink>();
-
- // for us, the contentTitle will be a concatenation of the titles of the
- // RSS Channels that we've parsed
- // and the index text will be a concatenation of the RSS Channel
- // descriptions, and descriptions of the RSS Items in the channel
-
- // also get the outlinks
-
- if (theRSSChannels != null) {
- for (int i = 0; i < theRSSChannels.size(); i++) {
- RSSChannel r = (RSSChannel) theRSSChannels.get(i);
- contentTitle.append(r.getTitle());
- contentTitle.append(" ");
-
- // concat the description to the index text
- indexText.append(r.getDescription());
- indexText.append(" ");
-
- if (r.getLink() != null) {
- try {
- // get the outlink
- if (r.getDescription() != null) {
- theOutlinks.add(new Outlink(r.getLink(), r.getDescription()));
- } else {
- theOutlinks.add(new Outlink(r.getLink(), ""));
- }
- } catch (MalformedURLException e) {
- if (LOG.isWarnEnabled()) {
- LOG.warn("MalformedURL: " + r.getLink());
- LOG.warn("Attempting to continue processing outlinks");
- e.printStackTrace(LogUtil.getWarnStream(LOG));
- }
- continue;
- }
- }
-
- // now get the descriptions of all the underlying RSS Items and
- // then index them too
- for (int j = 0; j < r.getItems().size(); j++) {
- RSSItem theRSSItem = (RSSItem) r.getItems().get(j);
- indexText.append(theRSSItem.getDescription());
- indexText.append(" ");
-
- String whichLink = null;
-
- if (theRSSItem.getPermalink() != null) whichLink = theRSSItem.getPermalink();
- else whichLink = theRSSItem.getLink();
-
- if (whichLink != null) {
- try {
- if (theRSSItem.getDescription() != null) {
- theOutlinks.add(new Outlink(whichLink, theRSSItem.getDescription()));
- } else {
- theOutlinks.add(new Outlink(whichLink, ""));
- }
- } catch (MalformedURLException e) {
- if (LOG.isWarnEnabled()) {
- LOG.warn("MalformedURL: " + whichLink);
- LOG.warn("Attempting to continue processing outlinks");
- e.printStackTrace(LogUtil.getWarnStream(LOG));
- }
- continue;
- }
- }
-
- }
-
- }
-
- if (LOG.isTraceEnabled()) {
- LOG.trace("nutch:parse-rss:getParse:indexText=" + indexText);
- LOG.trace("nutch:parse-rss:getParse:contentTitle=" + contentTitle);
- }
-
- } else if (LOG.isTraceEnabled()) {
- LOG.trace("nutch:parse-rss:Error:getParse: No RSS Channels recorded!");
- }
-
- // format the outlinks
- Outlink[] outlinks = theOutlinks.toArray(new Outlink[theOutlinks.size()]);
-
- if (LOG.isTraceEnabled()) {
- LOG.trace("nutch:parse-rss:getParse:found " + outlinks.length + " outlinks");
- }
- // if (LOG.isInfoEnabled()) {
- // LOG.info("Outlinks: "+outlinks);
- // }
-
- return new Parse(indexText.toString(), contentTitle.toString(), outlinks,
- ParseStatusUtils.STATUS_SUCCESS);
- }
-
- public void setConf(Configuration conf) {
- this.conf = conf;
- }
-
- public Configuration getConf() {
- return this.conf;
- }
-
- @Override
- public Collection<WebPage.Field> getFields() {
- return FIELDS;
- }
-
- public static void main(String[] args) throws Exception {
- // LOG.setLevel(Level.FINE);
- String url = args[0];
- Configuration conf = NutchConfiguration.create();
- RSSParser parser = new RSSParser();
- parser.setConf(conf);
- Protocol protocol = new ProtocolFactory(conf).getProtocol(url);
- WebPage page = new WebPage();
- Content c = protocol.getProtocolOutput(url, page).getContent();
- page.setContent(ByteBuffer.wrap(c.getContent()));
- Parse parse = parser.getParse(url, page);
- System.out.println("title: " + parse.getTitle());
- System.out.println("text: " + parse.getText());
- }
-
-}
diff --git a/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/structs/RSSChannel.java b/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/structs/RSSChannel.java
deleted file mode 100644
index b49619793..000000000
--- a/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/structs/RSSChannel.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nutch.parse.rss.structs;
-
-import java.util.List;
-import java.util.Vector;
-
-/**
- *
- * <p>
- * Data class for holding RSS Channels to send to Nutch's indexer
- * </p>
- *
- * @author mattmann
- * @version 1.0
- */
-public class RSSChannel {
-
- //description of the channel
- private String fDescription = null;
-
- // link to the channel's page
- private String fLink = null;
-
- // title of the Channel
- private String fTitle = null;
-
- // set of items in the Channel
- private List fItems = null;
-
- /**
- *
- * <p>
- * Default Constructor
- * </p>
- *
- * @param desc
- * The description of the channel.
- * @param link
- * A link to the channel's url.
- * @param title
- * The title of the channel.
- * @param items
- * A list of {@link RSSItem}s for this RSS Channel.
- */
- public RSSChannel(String desc, String link, String title, List items) {
- fDescription = desc;
- fLink = link;
- fTitle = title;
- fItems = items;
-
- }
-
- /**
- *
- * <p>
- * Constructor if you don't have the list of RSS Items ready yet.
- * </p>
- *
- * @param desc
- * The description of the channel.
- * @param link
- * A link to the channel's url.
- * @param title
- * The title of the channel.
- */
- public RSSChannel(String desc, String link, String title) {
- fDescription = desc;
- fLink = link;
- fTitle = title;
- fItems = new Vector();
-
- }
-
- /**
- *
- * <p>
- * Get the list of items for this channel.
- * </p>
- *
- * @return A list of {@link RSSItem}s.
- */
- public List getItems() {
- return fItems;
- }
-
- /**
- *
- * <p>
- * Returns the channel title
- * </p>
- *
- * @return The title of the channel.
- */
-
- public String getTitle() {
- return fTitle;
- }
-
- /**
- *
- * <p>
- * Returns a link to the RSS Channel.
- * </p>
- *
- * @return A {@link String}link to the RSS Channel.
- */
- public String getLink() {
- return fLink;
- }
-
- /**
- *
- * <p>
- * Returns a {@link String}description of the RSS Channel.
- * </p>
- *
- * @return The description of the RSS Channel.
- */
- public String getDescription() {
- return fDescription;
- }
-
- /**
- *
- * <p>
- * Sets the list of RSS items for this channel.
- * </p>
- *
- * @param items
- * A List of {@link RSSItem}s for this RSSChannel.
- */
- public void setItems(List items) {
- fItems = items;
- }
-
- /**
- *
- * <p>
- * Sets the Title for this RSS Channel.
- * </p>
- *
- * @param title
- * The title of this RSSChannel.
- */
- public void setTitle(String title) {
- fTitle = title;
- }
-
- /**
- *
- * <p>
- * Sets the link to this RSSChannel
- * </p>
- *
- * @param link
- * A {@link String}representation of a link to this RSS Channel.
- */
- public void setLink(String link) {
- fLink = link;
- }
-
- /**
- *
- * <p>
- * Sets the description of this RSSChannel
- * </p>
- *
- * @param description
- * A String description of this RSS Channel.
- */
- public void setDescription(String description) {
- fDescription = description;
- }
-}
diff --git a/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/structs/RSSItem.java b/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/structs/RSSItem.java
deleted file mode 100644
index 608b4367f..000000000
--- a/src/plugin/parse-rss/src/java/org/apache/nutch/parse/rss/structs/RSSItem.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.nutch.parse.rss.structs;
-
-/**
- *
- * <p>
- * Data class for holding RSS Items to send to Nutch's indexer
- * </p>
- *
- * @author mattmann
- * @version 1.0
- */
-public class RSSItem {
-
- //The title of this RSS Item
- private String fTitle = null;
-
- //The link that this RSS Item points to
- private String fLink = null;
-
- //The description of this RSS Item
- private String fDescription = null;
-
- //A permanent link that this RSS Item points to
- private String fPermalink = null;
-
- public RSSItem(String title, String link, String description,
- String permalink) {
- fTitle = title;
- fLink = link;
- fDescription = description;
- fPermalink = permalink;
- }
-
- /**
- *
- * <P>
- * Get the title for this RSS Item
- * </p>
- *
- * @return The title of this RSS Item
- */
- public String getTitle() {
- return fTitle;
- }
-
- /**
- *
- * <p>
- * Gets the link that this RSS Item points to.
- * </p>
- *
- * @return The link that this RSS Items points to.
- */
- public String getLink() {
- return fLink;
- }
-
- /**
- *
- * <p>
- * Gets the Description of this RSS Item
- * </p>
- *
- * @return The description of this RSS Item.
- */
- public String getDescription() {
- return fDescription;
- }
-
- /**
- *
- * <p>
- * If this RSS Item points to a permanent link, then this method returns it.
- * </p>
- *
- * @return The permanent link that this RSS Items points to.
- */
- public String getPermalink() {
- return fPermalink;
- }
-
- /**
- *
- * <p>
- * Sets the title for this RSS Item.
- * </p>
- *
- * @param title
- * The title of this RSS Item
- */
- public void setTitle(String title) {
- fTitle = title;
- }
-
- /**
- *
- * <p>
- * Sets the link that this RSS Item points to.
- * </p>
- *
- * @param link
- * The link that this RSS Item points to.
- */
- public void setLink(String link) {
- fTitle = link;
- }
-
- /**
- *
- * <p>
- * Sets the description of this RSS Item.
- * </p>
- *
- * @param description
- * The description of this RSS Item.
- */
- public void setDescription(String description) {
- fDescription = description;
- }
-
- /**
- *
- * <p>
- * Sets the permanent link that this RSS Item points to.
- * </p>
- *
- * @param permalink
- * The permanent link that this RSS Item points to
- */
- public void setPermalink(String permalink) {
- fPermalink = permalink;
- }
-
-}
diff --git a/src/plugin/parse-tika/build.xml b/src/plugin/parse-tika/build.xml
index ad71bf4b5..51a9a48c3 100644
--- a/src/plugin/parse-tika/build.xml
+++ b/src/plugin/parse-tika/build.xml
@@ -29,6 +29,7 @@
<mkdir dir="${build.test}/data"/>
<copy todir="${build.test}/data">
<fileset dir="sample">
+ <include name="*.rss"/>
<include name="*.rtf"/>
<include name="*.pdf"/>
<include name="ootest.*"/>
diff --git a/src/plugin/parse-tika/sample/rsstest.rss b/src/plugin/parse-tika/sample/rsstest.rss
new file mode 100644
index 000000000..6c4ae488d
--- /dev/null
+++ b/src/plugin/parse-tika/sample/rsstest.rss
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<rss version="0.91">
+ <channel>
+ <title>TestChannel</title>
+ <link>http://test.channel.com/</link>
+ <description>Sample RSS File for Junit test</description>
+ <language>en-us</language>
+
+ <item>
+ <title>Home Page of Chris Mattmann</title>
+ <link>http://www-scf.usc.edu/~mattmann/</link>
+ <description>Chris Mattmann's home page</description>
+ </item>
+
+ <item>
+ <title>Awesome Open Source Search Engine</title>
+ <link>http://www.nutch.org/</link>
+ <description>Yup, that's what it is</description>
+ </item>
+ </channel>
+</rss>
diff --git a/src/plugin/parse-rss/src/test/org/apache/nutch/parse/rss/TestRSSParser.java b/src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRSSParser.java
similarity index 78%
rename from src/plugin/parse-rss/src/test/org/apache/nutch/parse/rss/TestRSSParser.java
rename to src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRSSParser.java
index bcce44108..2df7aeafa 100644
--- a/src/plugin/parse-rss/src/test/org/apache/nutch/parse/rss/TestRSSParser.java
+++ b/src/plugin/parse-tika/src/test/org/apache/nutch/parse/tika/TestRSSParser.java
@@ -15,8 +15,12 @@
* limitations under the License.
*/
-package org.apache.nutch.parse.rss;
+package org.apache.nutch.parse.tika;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.nio.ByteBuffer;
import org.apache.nutch.protocol.ProtocolFactory;
@@ -54,7 +58,7 @@ public class TestRSSParser extends TestCase {
// Make sure sample files are copied to "test.data" as specified in
// ./src/plugin/parse-rss/build.xml during plugin compilation.
- private String[] sampleFiles = {"rsstest.rss"};
+ private String[] sampleFiles = { "rsstest.rss" };
/**
* <p>
@@ -79,7 +83,7 @@ public class TestRSSParser extends TestCase {
* file</li>
* </ul>
*/
- public void testIt() throws ProtocolException, ParseException {
+ public void testIt()throws ProtocolException, ParseException, IOException {
String urlString;
Protocol protocol;
Parse parse;
@@ -89,43 +93,45 @@ public class TestRSSParser extends TestCase {
for (int i = 0; i < sampleFiles.length; i++) {
urlString = "file:" + sampleDir + fileSeparator + sampleFiles[i];
- protocol = new ProtocolFactory(conf).getProtocol(urlString);
+ File file = new File(sampleDir + fileSeparator + sampleFiles[i]);
+ byte[] bytes = new byte[(int) file.length()];
+ DataInputStream in = new DataInputStream(new FileInputStream(file));
+ in.readFully(bytes);
+ in.close();
+
WebPage page = new WebPage();
- Content c = protocol.getProtocolOutput(urlString, page).getContent();
- page.setContent(ByteBuffer.wrap(c.getContent()));
- MimeType mtype = mimeutil.getMimeType(urlString);
+ page.setBaseUrl(new Utf8(urlString));
+ page.setContent(ByteBuffer.wrap(bytes));
+ MimeType mtype = mimeutil.getMimeType(file);
page.setContentType(new Utf8(mtype.getName()));
parse = new ParseUtil(conf).parse(urlString, page);
- // check that there are 3 outlinks:
- // http://test.channel.com
+ // check that there are 2 outlinks:
+
// http://www-scf.usc.edu/~mattmann/
// http://www.nutch.org
Outlink[] theOutlinks = parse.getOutlinks();
- assertTrue("There aren't 3 outlinks read!", theOutlinks.length == 3);
+ assertTrue("There aren't 2 outlinks read!", theOutlinks.length == 2);
// now check to make sure that those are the two outlinks
- boolean hasLink1 = false, hasLink2 = false, hasLink3 = false;
+ boolean hasLink1 = false, hasLink2 = false;
for (int j = 0; j < theOutlinks.length; j++) {
// System.out.println("reading "+theOutlinks[j].getToUrl());
- if (theOutlinks[j].getToUrl().equals("http://www-scf.usc.edu/~mattmann/")) {
+ if (theOutlinks[j].getToUrl().equals(
+ "http://www-scf.usc.edu/~mattmann/")) {
hasLink1 = true;
}
if (theOutlinks[j].getToUrl().equals("http://www.nutch.org/")) {
hasLink2 = true;
}
-
- if (theOutlinks[j].getToUrl().equals("http://test.channel.com/")) {
- hasLink3 = true;
- }
}
- if (!hasLink1 || !hasLink2 || !hasLink3) {
+ if (!hasLink1 || !hasLink2) {
fail("Outlinks read from sample rss file are not correct!");
}
}