Apache Nutch is an extensible and scalable web crawler
NUTCH-836 : Remove deprecated parse plugins
Julien Niochecc2ace2f540f
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xmlindex b2d4da7a9..565b722ce 100644--- a/conf/nutch-default.xml+++ b/conf/nutch-default.xml@@ -956,17 +956,14 @@<property><name>plugin.includes</name>- <value>protocol-http|urlfilter-regex|parse-(text|html|js|tika)|index-(basic|anchor)|query-(basic|site|url)|response-(json|xml)|summary-basic|scoring-opic|urlnormalizer-(pass|regex|basic)</value>+ <value>protocol-http|urlfilter-regex|parse-tika|index-(basic|anchor)|query-(basic|site|url)|response-(json|xml)|summary-basic|scoring-opic|urlnormalizer-(pass|regex|basic)</value><description>Regular expression naming plugin directory names toinclude. Any plugin not matching this expression is excluded.In any case you need at least include the nutch-extensionpoints plugin. Bydefault Nutch includes crawling just HTML and plain text via HTTP,and basic indexing and search plugins. In order to use HTTPS please enableprotocol-httpclient, but be aware of possible intermittent problems with the- underlying commons-httpclient library. Nutch now also includes integration with Tika- to leverage Tika's parsing capabilities for multiple content types. The existing Nutch- parser implementations will likely be phased out in the next release or so, as such, it is- a good idea to begin migrating away from anything not provided by parse-tika.+ underlying commons-httpclient library.</description></property>diff --git a/conf/parse-plugins.xml b/conf/parse-plugins.xmlindex 2cf6f0c92..fede1ee7b 100644--- a/conf/parse-plugins.xml+++ b/conf/parse-plugins.xml@@ -22,126 +22,10 @@<parse-plugins>-<!--- The following mimetype are now handled by the default parser (parse-tika).- You can uncomment the associations below to override parse-tika- and chose which plugin should be used for a given content type-- <mimeType name="application/msword">- <plugin id="parse-msword" />- </mimeType>-- <mimeType name="application/pdf">- <plugin id="parse-pdf" />- </mimeType>-- <mimeType name="application/postscript">- <plugin id="parse-pdf" />- </mimeType>-- <mimeType name="application/vnd.ms-excel">- <plugin id="parse-msexcel" />- </mimeType>-- <mimeType name="application/vnd.ms-powerpoint">- <plugin id="parse-mspowerpoint" />- </mimeType>-- <mimeType name="application/vnd.oasis.opendocument.text">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.oasis.opendocument.text-template">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.oasis.opendocument.text-master">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.oasis.opendocument.text-web">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.oasis.opendocument.presentation">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.oasis.opendocument.presentation-template">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.oasis.opendocument.spreadsheet">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.oasis.opendocument.spreadsheet-template">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.sun.xml.calc">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.sun.xml.calc.template">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.sun.xml.impress">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.sun.xml.impress.template">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.sun.xml.writer">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/vnd.sun.xml.writer.template">- <plugin id="parse-oo" />- </mimeType>-- <mimeType name="application/x-csh">- <plugin id="parse-text" />- </mimeType>-- <mimeType name="application/x-kword">- <plugin id="parse-msword" />- </mimeType>-- <mimeType name="application/x-kspread">- <plugin id="parse-msexcel" />- </mimeType>-- <mimeType name="text/html">- <plugin id="parse-html" />- </mimeType>-- <mimeType name="text/plain">- <plugin id="parse-text" />- </mimeType>-- <mimeType name="text/richtext">- <plugin id="parse-tika" />- </mimeType>-- <mimeType name="text/rtf">- <plugin id="parse-tika" />- </mimeType>-- <mimeType name="text/sgml">- <plugin id="parse-html" />- </mimeType>-- <mimeType name="text/tab-separated-values">- <plugin id="parse-msexcel" />- </mimeType>--->-- <mimeType name="application/xhtml+xml">- <plugin id="parse-html" />+ <!-- by default if the mimeType is set to *, or+ if it can't be determined, use parse-tika -->+ <mimeType name="*">+ <plugin id="parse-tika" /></mimeType><mimeType name="application/rss+xml">@@ -172,9 +56,9 @@</mimeType><mimeType name="text/xml">- <plugin id="parse-html" />+ <plugin id="parse-tika" /><plugin id="parse-rss" />- <plugin id="feed" />+ <plugin id="feed" /></mimeType><!-- Types for parse-ext plugin: required for unit tests to pass. -->@@ -190,30 +74,16 @@<!-- alias mappings for parse-xxx names to the actual extension implementationids described in each plugin's plugin.xml file --><aliases>- <alias name="parse-tika"- extension-id="org.apache.nutch.parse.tika.Parser" />+ <alias name="parse-tika"+ extension-id="org.apache.nutch.parse.tika.TikaParser" /><alias name="parse-ext" extension-id="ExtParser" />- <alias name="parse-html"- extension-id="org.apache.nutch.parse.html.HtmlParser" /><alias name="parse-js" extension-id="JSParser" />- <alias name="parse-msexcel"- extension-id="org.apache.nutch.parse.msexcel.MSExcelParser" />- <alias name="parse-mspowerpoint"- extension-id="org.apache.nutch.parse.mspowerpoint.MSPowerPointParser" />- <alias name="parse-msword"- extension-id="org.apache.nutch.parse.msword.MSWordParser" />- <alias name="parse-oo"- extension-id="org.apache.nutch.parse.oo.OpenDocument.Text" />- <alias name="parse-pdf"- extension-id="org.apache.nutch.parse.pdf.PdfParser" /><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"extension-id="org.apache.nutch.parse.swf.SWFParser" />- <alias name="parse-text"- extension-id="org.apache.nutch.parse.text.TextParser" /><alias name="parse-zip"extension-id="org.apache.nutch.parse.zip.ZipParser" /></aliases>diff --git a/default.properties b/default.propertiesindex b46cc336d..0c266c05a 100644--- a/default.properties+++ b/default.properties@@ -52,8 +52,7 @@ javac.version= 1.5#plugins.api=\org.apache.nutch.protocol.http.api*:\- org.apache.nutch.urlfilter.api*:\- org.apache.nutch.parse.ms*+ org.apache.nutch.urlfilter.api*## Protocol Plugins@@ -83,18 +82,10 @@ plugins.scoring=\#plugins.parse=\org.apache.nutch.parse.ext*:\- org.apache.nutch.parse.html*:\org.apache.nutch.parse.js:\- org.apache.nutch.parse.mp3*:\- org.apache.nutch.parse.msexcel*:\- org.apache.nutch.parse.mspowerpoint*:\- org.apache.nutch.parse.msword*:\- org.apache.nutch.parse.oo*:\- org.apache.nutch.parse.pdf*:\- org.apache.nutch.parse.rtf*:\org.apache.nutch.parse.rss*:\org.apache.nutch.parse.swf*:\- org.apache.nutch.parse.text:\+ org.apache.nutch.parse.tika:\org.apache.nutch.parse.zip#diff --git a/src/plugin/build.xml b/src/plugin/build.xmlindex 561d97e6e..986901d3e 100755--- a/src/plugin/build.xml+++ b/src/plugin/build.xml@@ -36,10 +36,8 @@<ant dir="field-boost" target="deploy"/><ant dir="languageidentifier" target="deploy"/><ant dir="lib-http" target="deploy"/>- <ant dir="lib-jakarta-poi" target="deploy"/><ant dir="lib-lucene-analyzers" target="deploy"/><ant dir="lib-nekohtml" target="deploy"/>- <ant dir="lib-parsems" target="deploy"/><ant dir="lib-regex-filter" target="deploy"/><ant dir="lib-xml" target="deploy"/><ant dir="microformats-reltag" target="deploy"/>@@ -50,16 +48,9 @@<ant dir="protocol-http" target="deploy"/><ant dir="protocol-httpclient" target="deploy"/><ant dir="parse-ext" target="deploy"/>- <ant dir="parse-html" target="deploy"/><ant dir="parse-js" target="deploy"/>- <ant dir="parse-msexcel" target="deploy"/>- <ant dir="parse-mspowerpoint" target="deploy"/>- <ant dir="parse-msword" target="deploy"/>- <ant dir="parse-oo" target="deploy"/>- <ant dir="parse-pdf" target="deploy"/><ant dir="parse-rss" target="deploy"/><ant dir="parse-swf" target="deploy"/>- <ant dir="parse-text" target="deploy"/><ant dir="parse-tika" target="deploy"/><ant dir="parse-zip" target="deploy"/><ant dir="query-basic" target="deploy"/>@@ -98,12 +89,6 @@<ant dir="ontology" target="test"/><ant dir="protocol-httpclient" target="test"/><!--ant dir="parse-ext" target="test"/-->- <ant dir="parse-html" target="test"/>- <ant dir="parse-msexcel" target="test"/>- <ant dir="parse-mspowerpoint" target="test"/>- <ant dir="parse-msword" target="test"/>- <ant dir="parse-oo" target="test"/>- <ant dir="parse-pdf" target="test"/><ant dir="parse-rss" target="test"/><ant dir="feed" target="test"/><ant dir="parse-swf" target="test"/>@@ -138,10 +123,8 @@<ant dir="languageidentifier" target="clean"/><ant dir="lib-commons-httpclient" target="clean"/><ant dir="lib-http" target="clean"/>- <ant dir="lib-jakarta-poi" target="clean"/><ant dir="lib-lucene-analyzers" target="clean"/><ant dir="lib-nekohtml" target="clean"/>- <ant dir="lib-parsems" target="clean"/><ant dir="lib-regex-filter" target="clean"/><ant dir="lib-xml" target="clean"/><ant dir="microformats-reltag" target="clean"/>@@ -152,18 +135,9 @@<ant dir="protocol-http" target="clean"/><ant dir="protocol-httpclient" target="clean"/><ant dir="parse-ext" target="clean"/>- <ant dir="parse-html" target="clean"/><ant dir="parse-js" target="clean"/>- <ant dir="parse-mp3" target="clean"/>- <ant dir="parse-msexcel" target="clean"/>- <ant dir="parse-mspowerpoint" target="clean"/>- <ant dir="parse-msword" target="clean"/>- <ant dir="parse-oo" target="clean"/>- <ant dir="parse-pdf" target="clean"/><ant dir="parse-rss" target="clean"/>- <ant dir="parse-rtf" target="clean"/><ant dir="parse-swf" target="clean"/>- <ant dir="parse-text" target="clean"/><ant dir="parse-tika" target="clean"/><ant dir="parse-zip" target="clean"/><ant dir="query-basic" target="clean"/>diff --git a/src/plugin/creativecommons/build.xml b/src/plugin/creativecommons/build.xmlindex 98606ec2a..c141a8cee 100755--- a/src/plugin/creativecommons/build.xml+++ b/src/plugin/creativecommons/build.xml@@ -22,7 +22,7 @@<!-- Deploy Unit test dependencies --><target name="deps-test"><ant target="deploy" inheritall="false" dir="../nutch-extensionpoints"/>- <ant target="deploy" inheritall="false" dir="../parse-html"/>+ <!-- <ant target="deploy" inheritall="false" dir="../parse-html"/> --></target>diff --git a/src/plugin/creativecommons/src/test/org/creativecommons/nutch/TestCCParseFilter.java b/src/plugin/creativecommons/src/test/org/creativecommons/nutch/TestCCParseFilter.javaindex 9519b6421..d77c48cd2 100755--- a/src/plugin/creativecommons/src/test/org/creativecommons/nutch/TestCCParseFilter.java+++ b/src/plugin/creativecommons/src/test/org/creativecommons/nutch/TestCCParseFilter.java@@ -38,10 +38,14 @@ public class TestCCParseFilter extends TestCase {public void testPages() throws Exception {pageTest(new File(testDir, "anchor.html"), "http://foo.com/","http://creativecommons.org/licenses/by-nc-sa/1.0", "a", null);+ // Tika returns <a> whereas parse-html returns <rel>+ // check laterpageTest(new File(testDir, "rel.html"), "http://foo.com/",- "http://creativecommons.org/licenses/by-nc/2.0", "rel", null);+ "http://creativecommons.org/licenses/by-nc/2.0", "a", null);+ // Tika returns <a> whereas parse-html returns <rdf>+ // check laterpageTest(new File(testDir, "rdf.html"), "http://foo.com/",- "http://creativecommons.org/licenses/by-nc/1.0", "rdf", "text");+ "http://creativecommons.org/licenses/by-nc/1.0", "a", null);}public void pageTest(File file, String url,@@ -62,8 +66,8 @@ public class TestCCParseFilter extends TestCase {Content content =new Content(url, url, bytes, contentType, new Metadata(), conf);- Parse parse = new ParseUtil(conf).parseByExtensionId("parse-html", content).get(content.getUrl());-+ Parse parse = new ParseUtil(conf).parse(content).get(content.getUrl());+Metadata metadata = parse.getData().getParseMeta();assertEquals(license, metadata.get("License-Url"));assertEquals(location, metadata.get("License-Location"));diff --git a/src/plugin/languageidentifier/build.xml b/src/plugin/languageidentifier/build.xmlindex f8dac538a..668075e9a 100644--- a/src/plugin/languageidentifier/build.xml+++ b/src/plugin/languageidentifier/build.xml@@ -33,7 +33,6 @@<!-- Deploy Unit test dependencies --><target name="deps-test"><ant target="deploy" inheritall="false" dir="../nutch-extensionpoints"/>- <ant target="deploy" inheritall="false" dir="../parse-html"/></target></project>diff --git a/src/plugin/lib-jakarta-poi/build.xml b/src/plugin/lib-jakarta-poi/build.xmldeleted file mode 100644index 307612d93..000000000--- a/src/plugin/lib-jakarta-poi/build.xml+++ /dev/null@@ -1,34 +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="lib-jakarta-poi" default="jar">-- <import file="../build-plugin.xml"/>-- <!--- ! Override the compile and jar targets,- ! since there is nothing to compile here.- ! -->- <target name="compile" depends="init"/>-- <target name="jar" depends="compile">- <copy todir="${build.dir}" verbose="true">- <fileset dir="${root}/lib" includes="**/*.jar"/>- </copy>- </target>--</project>diff --git a/src/plugin/lib-jakarta-poi/lib/poi-3.5-beta4-20081128.jar b/src/plugin/lib-jakarta-poi/lib/poi-3.5-beta4-20081128.jardeleted file mode 100644index 658e6153f..000000000Binary files a/src/plugin/lib-jakarta-poi/lib/poi-3.5-beta4-20081128.jar and /dev/null differdiff --git a/src/plugin/lib-jakarta-poi/lib/poi-scratchpad-3.5-beta4-20081128.jar b/src/plugin/lib-jakarta-poi/lib/poi-scratchpad-3.5-beta4-20081128.jardeleted file mode 100644index 707a4f234..000000000Binary files a/src/plugin/lib-jakarta-poi/lib/poi-scratchpad-3.5-beta4-20081128.jar and /dev/null differdiff --git a/src/plugin/lib-jakarta-poi/plugin.xml b/src/plugin/lib-jakarta-poi/plugin.xmldeleted file mode 100644index 3078594d9..000000000--- a/src/plugin/lib-jakarta-poi/plugin.xml+++ /dev/null@@ -1,40 +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.--->-<!--- ! Jakarta POI - Java API To Access Microsoft Format Files- ! (http://jakarta.apache.org/poi/)- !- ! Dowload : http://www.apache.org/dyn/closer.cgi/jakarta/poi/- ! License : http://www.apache.org/licenses/LICENSE-2.0.txt- !-->-<plugin- id="lib-jakarta-poi"- name="Jakarta POI - Java API To Access Microsoft Format Files"- version="2.5.1"- provider-name="jakarta.apache.org">-- <runtime>- <library name="poi-3.5-beta4-20081128.jar">- <export name="*"/>- </library>- <library name="poi-scratchpad-3.5-beta4-20081128.jar">- <export name="*"/>- </library>- </runtime>--</plugin>diff --git a/src/plugin/lib-parsems/build.xml b/src/plugin/lib-parsems/build.xmldeleted file mode 100644index aedec8e4b..000000000--- a/src/plugin/lib-parsems/build.xml+++ /dev/null@@ -1,40 +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="lib-parsems" default="jar-core">-- <import file="../build-plugin.xml"/>-- <!-- Build compilation dependencies -->- <target name="deps-jar">- <ant target="jar" inheritall="false" dir="../lib-jakarta-poi"/>- </target>-- <!-- Add compilation dependencies to classpath -->- <path id="plugin.deps">- <fileset dir="${nutch.root}/build">- <include name="**/lib-jakarta-poi/*.jar" />- </fileset>- </path>-- <!-- Deploy Unit test dependencies -->- <target name="deps-test">- <ant target="deploy" inheritall="false" dir="../lib-jakarta-poi"/>- <ant target="deploy" inheritall="false" dir="../nutch-extensionpoints"/>- </target>--</project>diff --git a/src/plugin/lib-parsems/plugin.xml b/src/plugin/lib-parsems/plugin.xmldeleted file mode 100644index d4fd7d540..000000000--- a/src/plugin/lib-parsems/plugin.xml+++ /dev/null@@ -1,37 +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.--->-<!--- ! A common framework for microsoft documents parsers implementations- !-->-<plugin- id="lib-parsems"- name="Parse MS Documents Framework"- version="1.0"- provider-name="org.apache.nutch">-- <runtime>- <library name="lib-parsems.jar">- <export name="*"/>- </library>- </runtime>-- <requires>- <import plugin="lib-jakarta-poi"/>- </requires>--</plugin>diff --git a/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/MSBaseParser.java b/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/MSBaseParser.javadeleted file mode 100644index b7dabec30..000000000--- a/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/MSBaseParser.java+++ /dev/null@@ -1,166 +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.ms;--// JDK imports-import java.io.ByteArrayInputStream;-import java.io.File;-import java.io.FileInputStream;-import java.util.Properties;--// Commons Logging imports-import org.apache.commons.logging.Log;-import org.apache.commons.logging.LogFactory;--// Hadoop imports-import org.apache.hadoop.conf.Configuration;--// Nutch imports-import org.apache.nutch.metadata.DublinCore;-import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.net.protocols.Response;-import org.apache.nutch.parse.Outlink;-import org.apache.nutch.parse.OutlinkExtractor;-import org.apache.nutch.parse.ParseData;-import org.apache.nutch.parse.ParseImpl;-import org.apache.nutch.parse.ParseResult;-import org.apache.nutch.parse.ParseStatus;-import org.apache.nutch.parse.Parser;-import org.apache.nutch.protocol.Content;-import org.apache.nutch.util.LogUtil;-import org.apache.nutch.util.NutchConfiguration;---/**- * A generic Microsoft document parser.- *- * @author Jérôme Charron- */-public abstract class MSBaseParser implements Parser {-- private Configuration conf;-- protected static final Log LOG = LogFactory.getLog(MSBaseParser.class);--- /**- * Parses a Content with a specific {@link MSExtractor Microsoft document- * extractor}.- */- protected ParseResult getParse(MSExtractor extractor, Content content) {-- String text = null;- String title = null;- Outlink[] outlinks = null;- Properties properties = null;-- try {- byte[] raw = content.getContent();- String contentLength = content.getMetadata().get(Metadata.CONTENT_LENGTH);- if ((contentLength != null) &&- (raw.length != Integer.parseInt(contentLength))) {- return new ParseStatus(ParseStatus.FAILED,- ParseStatus.FAILED_TRUNCATED,- "Content truncated at " + raw.length +" bytes. " +- "Parser can't handle incomplete file.")- .getEmptyParseResult(content.getUrl(), this.conf);- }- extractor.extract(new ByteArrayInputStream(raw));- text = extractor.getText();- properties = extractor.getProperties();- outlinks = OutlinkExtractor.getOutlinks(text, content.getUrl(), getConf());-- } catch (Exception e) {- return new ParseStatus(ParseStatus.FAILED,- "Can't be handled as Microsoft document. " + e)- .getEmptyParseResult(content.getUrl(), this.conf);- }-- // collect meta data- Metadata metadata = new Metadata();- if (properties != null) {- title = properties.getProperty(DublinCore.TITLE);- properties.remove(DublinCore.TITLE);- metadata.setAll(properties);- }-- if (text == null) { text = ""; }- if (title == null) { title = ""; }-- ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS, title,- outlinks, content.getMetadata(),- metadata);- return ParseResult.createParseResult(content.getUrl(),- new ParseImpl(text, parseData));- }--- /**- * Main for testing. Pass a ms document as argument- */- public static void main(String mime, MSBaseParser parser, String args[]) {- if (args.length < 1) {- System.err.println("Usage:");- System.err.println("\t" + parser.getClass().getName() + " <file>");- System.exit(1);- }-- String file = args[0];- byte[] raw = getRawBytes(new File(file));-- Metadata meta = new Metadata();- meta.set(Response.CONTENT_LENGTH, "" + raw.length);- Content content = new Content(file, file, raw, mime, meta,- NutchConfiguration.create());-- System.out.println(parser.getParse(content).get(file).getText());- }-- private final static byte[] getRawBytes(File f) {- try {- if (!f.exists())- return null;- FileInputStream fin = new FileInputStream(f);- byte[] buffer = new byte[(int) f.length()];- fin.read(buffer);- fin.close();- return buffer;- } catch (Exception err) {- err.printStackTrace(LogUtil.getErrorStream(LOG));- return null;- }-- }--- /* ---------------------------- *- * <implemenation:Configurable> *- * ---------------------------- */-- public void setConf(Configuration conf) {- this.conf = conf;- }-- public Configuration getConf() {- return this.conf;- }-- /* ----------------------------- *- * </implemenation:Configurable> *- * ----------------------------- */--}diff --git a/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/MSExtractor.java b/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/MSExtractor.javadeleted file mode 100644index a40de7a2d..000000000--- a/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/MSExtractor.java+++ /dev/null@@ -1,199 +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.ms;--// JDK imports-import java.io.InputStream;-import java.util.Date;-import java.util.Properties;--// Commons Logging imports-import org.apache.commons.logging.Log;-import org.apache.commons.logging.LogFactory;--// Nutch imports-import org.apache.nutch.metadata.DublinCore;-import org.apache.nutch.metadata.HttpHeaders;-import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.metadata.Office;-import org.apache.nutch.net.protocols.HttpDateFormat;-import org.apache.nutch.util.StringUtil;--// Jakarta POI imports-import org.apache.poi.hpsf.PropertySetFactory;-import org.apache.poi.hpsf.SummaryInformation;-import org.apache.poi.poifs.eventfilesystem.POIFSReader;-import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;-import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;---/**- * Defines a Microsoft document content extractor.- *- * @author Jérôme Charron- */-public abstract class MSExtractor {-- protected final static Log LOG = LogFactory.getLog(MSExtractor.class);-- private String text = null;- private POIFSReader reader = null;- private PropertiesBroker properties = null;--- /** Constructs a new Microsoft document extractor. */- protected MSExtractor() { }--- /**- * Extracts properties and text from an MS Document input stream- */- protected void extract(InputStream input) throws Exception {- // First, extract properties- this.reader = new POIFSReader();- this.properties = new PropertiesBroker();- this.reader.registerListener(- new PropertiesReaderListener(this.properties),- SummaryInformation.DEFAULT_STREAM_NAME);- input.reset();- if (input.available() > 0) {- reader.read(input);- }- // Then, extract text- input.reset();- this.text = extractText(input);- }-- /**- * Extracts the text content from a Microsoft document input stream.- */- protected abstract String extractText(InputStream input) throws Exception;--- /**- * Get the content text of the Microsoft document.- * @return the content text of the document- */- protected String getText() {- return this.text;- }--- /**- * Get the <code>Properties</code> of the Microsoft document.- * @return the properties of the document- */- protected Properties getProperties() {- return properties.getProperties();- }--- private final static class PropertiesBroker {-- private final static int TIMEOUT = 2 * 1000;- private Properties properties = null;-- public synchronized Properties getProperties() {-- final long start = new Date().getTime();- long now = start;-- while (this.properties == null && now - start < TIMEOUT) {- try {- wait(TIMEOUT / 10);- } catch (InterruptedException e) {- }- now = new Date().getTime();- }- notifyAll();- return this.properties;- }-- public synchronized void setProperties(Properties properties) {- this.properties = properties;- notifyAll();- }- }--- private class PropertiesReaderListener implements POIFSReaderListener {-- private PropertiesBroker propertiesBroker;- private Properties metadata = new Properties();-- PropertiesReaderListener(PropertiesBroker propertiesBroker) {- this.propertiesBroker = propertiesBroker;- }-- public void processPOIFSReaderEvent(POIFSReaderEvent event) {- if (!event.getName().startsWith(SummaryInformation.DEFAULT_STREAM_NAME)) {- return;- }-- try {- SummaryInformation si = (SummaryInformation)- PropertySetFactory.create(event.getStream());- setProperty(DublinCore.TITLE, si.getTitle());- setProperty(Office.APPLICATION_NAME, si.getApplicationName());- setProperty(Office.AUTHOR, si.getAuthor());- setProperty(Office.CHARACTER_COUNT, si.getCharCount());- setProperty(Office.COMMENTS, si.getComments());- setProperty(DublinCore.DATE, si.getCreateDateTime());-// setProperty(Office.EDIT_TIME, si.getEditTime());- setProperty(HttpHeaders.LAST_MODIFIED, si.getLastSaveDateTime());- setProperty(Office.KEYWORDS, si.getKeywords());- setProperty(Office.LAST_AUTHOR, si.getLastAuthor());- setProperty(Office.LAST_PRINTED, si.getLastPrinted());- setProperty(Office.LAST_SAVED, si.getLastSaveDateTime());- setProperty(Office.PAGE_COUNT, si.getPageCount());- setProperty(Office.REVISION_NUMBER, si.getRevNumber());- setProperty(DublinCore.RIGHTS, si.getSecurity());- setProperty(DublinCore.SUBJECT, si.getSubject());- setProperty(Office.TEMPLATE, si.getTemplate());- setProperty(Office.WORD_COUNT, si.getWordCount());- } catch (Exception ex) {- }- propertiesBroker.setProperties(metadata);- }-- private final void setProperty(String name, String value) {- if (!StringUtil.isEmpty(name) && !StringUtil.isEmpty(value)) {- metadata.setProperty(name, value);- }- }-- private final void setProperty(String name, int value) {- if (value != 0) {- setProperty(name, String.valueOf(value));- }- }-- private final void setProperty(String name, long value) {- if (value != 0) {- setProperty(name, String.valueOf(value));- }- }-- private final void setProperty(String name, Date date) {- if (date != null) {- setProperty(name, HttpDateFormat.toString(date));- }- }-- }--}diff --git a/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/package.html b/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/package.htmldeleted file mode 100644index 35df3b618..000000000--- a/src/plugin/lib-parsems/src/java/org/apache/nutch/parse/ms/package.html+++ /dev/null@@ -1,5 +0,0 @@-<html>-<body>-<p>Common API for Microsoft © documents parsing.</p>-</body>-</html>diff --git a/src/plugin/parse-html/build.xml b/src/plugin/parse-html/build.xmldeleted file mode 100755index a5b99b566..000000000--- a/src/plugin/parse-html/build.xml+++ /dev/null@@ -1,40 +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-html" default="jar-core">-- <import file="../build-plugin.xml"/>-- <!-- Build compilation dependencies -->- <target name="deps-jar">- <ant target="jar" inheritall="false" dir="../lib-nekohtml"/>- </target>-- <!-- Add compilation dependencies to classpath -->- <path id="plugin.deps">- <fileset dir="${nutch.root}/build">- <include name="**/lib-nekohtml/*.jar" />- </fileset>- </path>-- <!-- Deploy Unit test dependencies -->- <target name="deps-test">- <ant target="deploy" inheritall="false" dir="../lib-nekohtml"/>- <ant target="deploy" inheritall="false" dir="../nutch-extensionpoints"/>- </target>--</project>diff --git a/src/plugin/parse-html/lib/tagsoup-1.2.jar b/src/plugin/parse-html/lib/tagsoup-1.2.jardeleted file mode 100644index af27803ec..000000000Binary files a/src/plugin/parse-html/lib/tagsoup-1.2.jar and /dev/null differdiff --git a/src/plugin/parse-html/lib/tagsoup.LICENSE.txt b/src/plugin/parse-html/lib/tagsoup.LICENSE.txtdeleted file mode 100644index 261eeb9e9..000000000--- a/src/plugin/parse-html/lib/tagsoup.LICENSE.txt+++ /dev/null@@ -1,201 +0,0 @@- Apache License- Version 2.0, January 2004- http://www.apache.org/licenses/-- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION-- 1. Definitions.-- "License" shall mean the terms and conditions for use, reproduction,- and distribution as defined by Sections 1 through 9 of this document.-- "Licensor" shall mean the copyright owner or entity authorized by- the copyright owner that is granting the License.-- "Legal Entity" shall mean the union of the acting entity and all- other entities that control, are controlled by, or are under common- control with that entity. For the purposes of this definition,- "control" means (i) the power, direct or indirect, to cause the- direction or management of such entity, whether by contract or- otherwise, or (ii) ownership of fifty percent (50%) or more of the- outstanding shares, or (iii) beneficial ownership of such entity.-- "You" (or "Your") shall mean an individual or Legal Entity- exercising permissions granted by this License.-- "Source" form shall mean the preferred form for making modifications,- including but not limited to software source code, documentation- source, and configuration files.-- "Object" form shall mean any form resulting from mechanical- transformation or translation of a Source form, including but- not limited to compiled object code, generated documentation,- and conversions to other media types.-- "Work" shall mean the work of authorship, whether in Source or- Object form, made available under the License, as indicated by a- copyright notice that is included in or attached to the work- (an example is provided in the Appendix below).-- "Derivative Works" shall mean any work, whether in Source or Object- form, that is based on (or derived from) the Work and for which the- editorial revisions, annotations, elaborations, or other modifications- represent, as a whole, an original work of authorship. For the purposes- of this License, Derivative Works shall not include works that remain- separable from, or merely link (or bind by name) to the interfaces of,- the Work and Derivative Works thereof.-- "Contribution" shall mean any work of authorship, including- the original version of the Work and any modifications or additions- to that Work or Derivative Works thereof, that is intentionally- submitted to Licensor for inclusion in the Work by the copyright owner- or by an individual or Legal Entity authorized to submit on behalf of- the copyright owner. For the purposes of this definition, "submitted"- means any form of electronic, verbal, or written communication sent- to the Licensor or its representatives, including but not limited to- communication on electronic mailing lists, source code control systems,- and issue tracking systems that are managed by, or on behalf of, the- Licensor for the purpose of discussing and improving the Work, but- excluding communication that is conspicuously marked or otherwise- designated in writing by the copyright owner as "Not a Contribution."-- "Contributor" shall mean Licensor and any individual or Legal Entity- on behalf of whom a Contribution has been received by Licensor and- subsequently incorporated within the Work.-- 2. Grant of Copyright License. Subject to the terms and conditions of- this License, each Contributor hereby grants to You a perpetual,- worldwide, non-exclusive, no-charge, royalty-free, irrevocable- copyright license to reproduce, prepare Derivative Works of,- publicly display, publicly perform, sublicense, and distribute the- Work and such Derivative Works in Source or Object form.-- 3. Grant of Patent License. Subject to the terms and conditions of- this License, each Contributor hereby grants to You a perpetual,- worldwide, non-exclusive, no-charge, royalty-free, irrevocable- (except as stated in this section) patent license to make, have made,- use, offer to sell, sell, import, and otherwise transfer the Work,- where such license applies only to those patent claims licensable- by such Contributor that are necessarily infringed by their- Contribution(s) alone or by combination of their Contribution(s)- with the Work to which such Contribution(s) was submitted. If You- institute patent litigation against any entity (including a- cross-claim or counterclaim in a lawsuit) alleging that the Work- or a Contribution incorporated within the Work constitutes direct- or contributory patent infringement, then any patent licenses- granted to You under this License for that Work shall terminate- as of the date such litigation is filed.-- 4. Redistribution. You may reproduce and distribute copies of the- Work or Derivative Works thereof in any medium, with or without- modifications, and in Source or Object form, provided that You- meet the following conditions:-- (a) You must give any other recipients of the Work or- Derivative Works a copy of this License; and-- (b) You must cause any modified files to carry prominent notices- stating that You changed the files; and-- (c) You must retain, in the Source form of any Derivative Works- that You distribute, all copyright, patent, trademark, and- attribution notices from the Source form of the Work,- excluding those notices that do not pertain to any part of- the Derivative Works; and-- (d) If the Work includes a "NOTICE" text file as part of its- distribution, then any Derivative Works that You distribute must- include a readable copy of the attribution notices contained- within such NOTICE file, excluding those notices that do not- pertain to any part of the Derivative Works, in at least one- of the following places: within a NOTICE text file distributed- as part of the Derivative Works; within the Source form or- documentation, if provided along with the Derivative Works; or,- within a display generated by the Derivative Works, if and- wherever such third-party notices normally appear. The contents- of the NOTICE file are for informational purposes only and- do not modify the License. You may add Your own attribution- notices within Derivative Works that You distribute, alongside- or as an addendum to the NOTICE text from the Work, provided- that such additional attribution notices cannot be construed- as modifying the License.-- You may add Your own copyright statement to Your modifications and- may provide additional or different license terms and conditions- for use, reproduction, or distribution of Your modifications, or- for any such Derivative Works as a whole, provided Your use,- reproduction, and distribution of the Work otherwise complies with- the conditions stated in this License.-- 5. Submission of Contributions. Unless You explicitly state otherwise,- any Contribution intentionally submitted for inclusion in the Work- by You to the Licensor shall be under the terms and conditions of- this License, without any additional terms or conditions.- Notwithstanding the above, nothing herein shall supersede or modify- the terms of any separate license agreement you may have executed- with Licensor regarding such Contributions.-- 6. Trademarks. This License does not grant permission to use the trade- names, trademarks, service marks, or product names of the Licensor,- except as required for reasonable and customary use in describing the- origin of the Work and reproducing the content of the NOTICE file.-- 7. Disclaimer of Warranty. Unless required by applicable law or- agreed to in writing, Licensor provides the Work (and each- Contributor provides its Contributions) on an "AS IS" BASIS,- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or- implied, including, without limitation, any warranties or conditions- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A- PARTICULAR PURPOSE. You are solely responsible for determining the- appropriateness of using or redistributing the Work and assume any- risks associated with Your exercise of permissions under this License.-- 8. Limitation of Liability. In no event and under no legal theory,- whether in tort (including negligence), contract, or otherwise,- unless required by applicable law (such as deliberate and grossly- negligent acts) or agreed to in writing, shall any Contributor be- liable to You for damages, including any direct, indirect, special,- incidental, or consequential damages of any character arising as a- result of this License or out of the use or inability to use the- Work (including but not limited to damages for loss of goodwill,- work stoppage, computer failure or malfunction, or any and all- other commercial damages or losses), even if such Contributor- has been advised of the possibility of such damages.-- 9. Accepting Warranty or Additional Liability. While redistributing- the Work or Derivative Works thereof, You may choose to offer,- and charge a fee for, acceptance of support, warranty, indemnity,- or other liability obligations and/or rights consistent with this- License. However, in accepting such obligations, You may act only- on Your own behalf and on Your sole responsibility, not on behalf- of any other Contributor, and only if You agree to indemnify,- defend, and hold each Contributor harmless for any liability- incurred by, or claims asserted against, such Contributor by reason- of your accepting any such warranty or additional liability.-- END OF TERMS AND CONDITIONS-- APPENDIX: How to apply the Apache License to your work.-- To apply the Apache License to your work, attach the following- boilerplate notice, with the fields enclosed by brackets "[]"- replaced with your own identifying information. (Don't include- the brackets!) The text should be enclosed in the appropriate- comment syntax for the file format. We also recommend that a- file or class name and description of purpose be included on the- same "printed page" as the copyright notice for easier- identification within third-party archives.-- Copyright [yyyy] [name of copyright owner]-- Licensed 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.diff --git a/src/plugin/parse-html/plugin.xml b/src/plugin/parse-html/plugin.xmldeleted file mode 100755index d38377436..000000000--- a/src/plugin/parse-html/plugin.xml+++ /dev/null@@ -1,48 +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-html"- name="Html Parse Plug-in"- version="1.0.0"- provider-name="nutch.org">-- <runtime>- <library name="parse-html.jar">- <export name="*"/>- </library>- <library name="tagsoup-1.2.jar"/>- </runtime>-- <requires>- <import plugin="nutch-extensionpoints"/>- <import plugin="lib-nekohtml"/>- </requires>-- <extension id="org.apache.nutch.parse.html"- name="HtmlParse"- point="org.apache.nutch.parse.Parser">-- <implementation id="org.apache.nutch.parse.html.HtmlParser"- class="org.apache.nutch.parse.html.HtmlParser">- <parameter name="contentType" value="text/html"/>- <parameter name="pathSuffix" value=""/>- </implementation>-- </extension>--</plugin>diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMBuilder.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMBuilder.javadeleted file mode 100644index 4485ea535..000000000--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMBuilder.java+++ /dev/null@@ -1,740 +0,0 @@-/*- * XXX [email protected]: This class is copied verbatim from Xalan-J 2.6.0- * XXX distribution, org.apache.xml.utils.DOMBuilder, in order to- * avoid dependency on Xalan.- */--/*- * 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.- */-/*- * $Id$- */-package org.apache.nutch.parse.html;--import java.util.Stack;--import org.w3c.dom.Comment;-import org.w3c.dom.Document;-import org.w3c.dom.DocumentFragment;-import org.w3c.dom.Element;-import org.w3c.dom.Node;-import org.w3c.dom.Text;-import org.w3c.dom.CDATASection;--import org.xml.sax.Attributes;-import org.xml.sax.ContentHandler;-import org.xml.sax.Locator;-import org.xml.sax.ext.LexicalHandler;-/**- * This class takes SAX events (in addition to some extra events- * that SAX doesn't handle yet) and adds the result to a document- * or document fragment.- */-public class DOMBuilder- implements ContentHandler, LexicalHandler-{-- /** Root document */- public Document m_doc;-- /** Current node */- protected Node m_currentNode = null;-- /** First node of document fragment or null if not a DocumentFragment */- public DocumentFragment m_docFrag = null;-- /** Vector of element nodes */- protected Stack m_elemStack = new Stack();-- /**- * DOMBuilder instance constructor... it will add the DOM nodes- * to the document fragment.- *- * @param doc Root document- * @param node Current node- */- public DOMBuilder(Document doc, Node node)- {- m_doc = doc;- m_currentNode = node;- }-- /**- * DOMBuilder instance constructor... it will add the DOM nodes- * to the document fragment.- *- * @param doc Root document- * @param docFrag Document fragment- */- public DOMBuilder(Document doc, DocumentFragment docFrag)- {- m_doc = doc;- m_docFrag = docFrag;- }-- /**- * DOMBuilder instance constructor... it will add the DOM nodes- * to the document.- *- * @param doc Root document- */- public DOMBuilder(Document doc)- {- m_doc = doc;- }-- /**- * Get the root node of the DOM being created. This- * is either a Document or a DocumentFragment.- *- * @return The root document or document fragment if not null- */- public Node getRootNode()- {- return (null != m_docFrag) ? (Node) m_docFrag : (Node) m_doc;- }-- /**- * Get the node currently being processed.- *- * @return the current node being processed- */- public Node getCurrentNode()- {- return m_currentNode;- }-- /**- * Return null since there is no Writer for this class.- *- * @return null- */- public java.io.Writer getWriter()- {- return null;- }-- /**- * Append a node to the current container.- *- * @param newNode New node to append- */- protected void append(Node newNode) throws org.xml.sax.SAXException- {-- Node currentNode = m_currentNode;-- if (null != currentNode)- {- currentNode.appendChild(newNode);-- // System.out.println(newNode.getNodeName());- }- else if (null != m_docFrag)- {- m_docFrag.appendChild(newNode);- }- else- {- boolean ok = true;- short type = newNode.getNodeType();-- if (type == Node.TEXT_NODE)- {- String data = newNode.getNodeValue();-- if ((null != data) && (data.trim().length() > 0))- {- throw new org.xml.sax.SAXException("Warning: can't output text before document element! Ignoring...");- }-- ok = false;- }- else if (type == Node.ELEMENT_NODE)- {- if (m_doc.getDocumentElement() != null)- {- throw new org.xml.sax.SAXException("Can't have more than one root on a DOM!");- }- }-- if (ok)- m_doc.appendChild(newNode);- }- }-- /**- * Receive an object for locating the origin of SAX document events.- *- * <p>SAX parsers are strongly encouraged (though not absolutely- * required) to supply a locator: if it does so, it must supply- * the locator to the application by invoking this method before- * invoking any of the other methods in the ContentHandler- * interface.</p>- *- * <p>The locator allows the application to determine the end- * position of any document-related event, even if the parser is- * not reporting an error. Typically, the application will- * use this information for reporting its own errors (such as- * character content that does not match an application's- * business rules). The information returned by the locator- * is probably not sufficient for use with a search engine.</p>- *- * <p>Note that the locator will return correct information only- * during the invocation of the events in this interface. The- * application should not attempt to use it at any other time.</p>- *- * @param locator An object that can return the location of- * any SAX document event.- * @see org.xml.sax.Locator- */- public void setDocumentLocator(Locator locator)- {-- // No action for the moment.- }-- /**- * Receive notification of the beginning of a document.- *- * <p>The SAX parser will invoke this method only once, before any- * other methods in this interface or in DTDHandler (except for- * setDocumentLocator).</p>- */- public void startDocument() throws org.xml.sax.SAXException- {-- // No action for the moment.- }-- /**- * Receive notification of the end of a document.- *- * <p>The SAX parser will invoke this method only once, and it will- * be the last method invoked during the parse. The parser shall- * not invoke this method until it has either abandoned parsing- * (because of an unrecoverable error) or reached the end of- * input.</p>- */- public void endDocument() throws org.xml.sax.SAXException- {-- // No action for the moment.- }-- /**- * Receive notification of the beginning of an element.- *- * <p>The Parser will invoke this method at the beginning of every- * element in the XML document; there will be a corresponding- * endElement() event for every startElement() event (even when the- * element is empty). All of the element's content will be- * reported, in order, before the corresponding endElement()- * event.</p>- *- * <p>If the element name has a namespace prefix, the prefix will- * still be attached. Note that the attribute list provided will- * contain only attributes with explicit values (specified or- * defaulted): #IMPLIED attributes will be omitted.</p>- *- *- * @param ns The namespace of the node- * @param localName The local part of the qualified name- * @param name The element name.- * @param atts The attributes attached to the element, if any.- * @see #endElement- * @see org.xml.sax.Attributes- */- public void startElement(- String ns, String localName, String name, Attributes atts)- throws org.xml.sax.SAXException- {-- Element elem;-- // Note that the namespace-aware call must be used to correctly- // construct a Level 2 DOM, even for non-namespaced nodes.- if ((null == ns) || (ns.length() == 0))- elem = m_doc.createElementNS(null,name);- else- elem = m_doc.createElementNS(ns, name);-- append(elem);-- try- {- int nAtts = atts.getLength();-- if (0 != nAtts)- {- for (int i = 0; i < nAtts; i++)- {-- //System.out.println("type " + atts.getType(i) + " name " + atts.getLocalName(i) );- // First handle a possible ID attribute- if (atts.getType(i).equalsIgnoreCase("ID"))- setIDAttribute(atts.getValue(i), elem);-- String attrNS = atts.getURI(i);-- if("".equals(attrNS))- attrNS = null; // DOM represents no-namespace as null-- // System.out.println("attrNS: "+attrNS+", localName: "+atts.getQName(i)- // +", qname: "+atts.getQName(i)+", value: "+atts.getValue(i));- // Crimson won't let us set an xmlns: attribute on the DOM.- String attrQName = atts.getQName(i);-- // In SAX, xmlns: attributes have an empty namespace, while in DOM they should have the xmlns namespace- if (attrQName.startsWith("xmlns:"))- attrNS = "http://www.w3.org/2000/xmlns/";-- // ALWAYS use the DOM Level 2 call!- elem.setAttributeNS(attrNS,attrQName, atts.getValue(i));- }- }-- // append(elem);-- m_elemStack.push(elem);-- m_currentNode = elem;-- // append(elem);- }- catch(java.lang.Exception de)- {- // de.printStackTrace();- throw new org.xml.sax.SAXException(de);- }-- }-- /**---- * Receive notification of the end of an element.- *- * <p>The SAX parser will invoke this method at the end of every- * element in the XML document; there will be a corresponding- * startElement() event for every endElement() event (even when the- * element is empty).</p>- *- * <p>If the element name has a namespace prefix, the prefix will- * still be attached to the name.</p>- *- *- * @param ns the namespace of the element- * @param localName The local part of the qualified name of the element- * @param name The element name- */- public void endElement(String ns, String localName, String name)- throws org.xml.sax.SAXException- {- m_elemStack.pop();- m_currentNode = m_elemStack.isEmpty() ? null : (Node)m_elemStack.peek();- }-- /**- * Set an ID string to node association in the ID table.- *- * @param id The ID string.- * @param elem The associated ID.- */- public void setIDAttribute(String id, Element elem)- {-- // Do nothing. This method is meant to be overiden.- }-- /**- * Receive notification of character data.- *- * <p>The Parser will call this method to report each chunk of- * character data. SAX parsers may return all contiguous character- * data in a single chunk, or they may split it into several- * chunks; however, all of the characters in any single event- * must come from the same external entity, so that the Locator- * provides useful information.</p>- *- * <p>The application must not attempt to read from the array- * outside of the specified range.</p>- *- * <p>Note that some parsers will report whitespace using the- * ignorableWhitespace() method rather than this one (validating- * parsers must do so).</p>- *- * @param ch The characters from the XML document.- * @param start The start position in the array.- * @param length The number of characters to read from the array.- * @see #ignorableWhitespace- * @see org.xml.sax.Locator- */- public void characters(char ch[], int start, int length) throws org.xml.sax.SAXException- {- if(isOutsideDocElem()- && XMLCharacterRecognizer.isWhiteSpace(ch, start, length))- return; // avoid DOM006 Hierarchy request error-- if (m_inCData)- {- cdata(ch, start, length);-- return;- }-- String s = new String(ch, start, length);- Node childNode;- childNode = m_currentNode != null ? m_currentNode.getLastChild(): null;- if( childNode != null && childNode.getNodeType() == Node.TEXT_NODE ){- ((Text)childNode).appendData(s);- }- else{- Text text = m_doc.createTextNode(s);- append(text);- }- }-- /**- * If available, when the disable-output-escaping attribute is used,- * output raw text without escaping. A PI will be inserted in front- * of the node with the name "lotusxsl-next-is-raw" and a value of- * "formatter-to-dom".- *- * @param ch Array containing the characters- * @param start Index to start of characters in the array- * @param length Number of characters in the array- */- public void charactersRaw(char ch[], int start, int length)- throws org.xml.sax.SAXException- {- if(isOutsideDocElem()- && XMLCharacterRecognizer.isWhiteSpace(ch, start, length))- return; // avoid DOM006 Hierarchy request error--- String s = new String(ch, start, length);-- append(m_doc.createProcessingInstruction("xslt-next-is-raw",- "formatter-to-dom"));- append(m_doc.createTextNode(s));- }-- /**- * Report the beginning of an entity.- *- * The start and end of the document entity are not reported.- * The start and end of the external DTD subset are reported- * using the pseudo-name "[dtd]". All other events must be- * properly nested within start/end entity events.- *- * @param name The name of the entity. If it is a parameter- * entity, the name will begin with '%'.- * @see #endEntity- * @see org.xml.sax.ext.DeclHandler#internalEntityDecl- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl- */- public void startEntity(String name) throws org.xml.sax.SAXException- {-- // Almost certainly the wrong behavior...- // entityReference(name);- }-- /**- * Report the end of an entity.- *- * @param name The name of the entity that is ending.- * @see #startEntity- */- public void endEntity(String name) throws org.xml.sax.SAXException{}-- /**- * Receive notivication of a entityReference.- *- * @param name name of the entity reference- */- public void entityReference(String name) throws org.xml.sax.SAXException- {- append(m_doc.createEntityReference(name));- }-- /**- * Receive notification of ignorable whitespace in element content.- *- * <p>Validating Parsers must use this method to report each chunk- * of ignorable whitespace (see the W3C XML 1.0 recommendation,- * section 2.10): non-validating parsers may also use this method- * if they are capable of parsing and using content models.</p>- *- * <p>SAX parsers may return all contiguous whitespace in a single- * chunk, or they may split it into several chunks; however, all of- * the characters in any single event must come from the same- * external entity, so that the Locator provides useful- * information.</p>- *- * <p>The application must not attempt to read from the array- * outside of the specified range.</p>- *- * @param ch The characters from the XML document.- * @param start The start position in the array.- * @param length The number of characters to read from the array.- * @see #characters- */- public void ignorableWhitespace(char ch[], int start, int length)- throws org.xml.sax.SAXException- {- if(isOutsideDocElem())- return; // avoid DOM006 Hierarchy request error-- String s = new String(ch, start, length);-- append(m_doc.createTextNode(s));- }-- /**- * Tell if the current node is outside the document element.- *- * @return true if the current node is outside the document element.- */- private boolean isOutsideDocElem()- {- return (null == m_docFrag) && m_elemStack.size() == 0 && (null == m_currentNode || m_currentNode.getNodeType() == Node.DOCUMENT_NODE);- }-- /**- * Receive notification of a processing instruction.- *- * <p>The Parser will invoke this method once for each processing- * instruction found: note that processing instructions may occur- * before or after the main document element.</p>- *- * <p>A SAX parser should never report an XML declaration (XML 1.0,- * section 2.8) or a text declaration (XML 1.0, section 4.3.1)- * using this method.</p>- *- * @param target The processing instruction target.- * @param data The processing instruction data, or null if- * none was supplied.- */- public void processingInstruction(String target, String data)- throws org.xml.sax.SAXException- {- append(m_doc.createProcessingInstruction(target, data));- }-- /**- * Report an XML comment anywhere in the document.- *- * This callback will be used for comments inside or outside the- * document element, including comments in the external DTD- * subset (if read).- *- * @param ch An array holding the characters in the comment.- * @param start The starting position in the array.- * @param length The number of characters to use from the array.- */- public void comment(char ch[], int start, int length) throws org.xml.sax.SAXException- {- // tagsoup sometimes submits invalid values here- if (ch == null || start < 0 || length >= (ch.length - start) || length < 0) return;- append(m_doc.createComment(new String(ch, start, length)));- }-- /** Flag indicating that we are processing a CData section */- protected boolean m_inCData = false;-- /**- * Report the start of a CDATA section.- *- * @see #endCDATA- */- public void startCDATA() throws org.xml.sax.SAXException- {- m_inCData = true;- append(m_doc.createCDATASection(""));- }-- /**- * Report the end of a CDATA section.- *- * @see #startCDATA- */- public void endCDATA() throws org.xml.sax.SAXException- {- m_inCData = false;- }-- /**- * Receive notification of cdata.- *- * <p>The Parser will call this method to report each chunk of- * character data. SAX parsers may return all contiguous character- * data in a single chunk, or they may split it into several- * chunks; however, all of the characters in any single event- * must come from the same external entity, so that the Locator- * provides useful information.</p>- *- * <p>The application must not attempt to read from the array- * outside of the specified range.</p>- *- * <p>Note that some parsers will report whitespace using the- * ignorableWhitespace() method rather than this one (validating- * parsers must do so).</p>- *- * @param ch The characters from the XML document.- * @param start The start position in the array.- * @param length The number of characters to read from the array.- * @see #ignorableWhitespace- * @see org.xml.sax.Locator- */- public void cdata(char ch[], int start, int length) throws org.xml.sax.SAXException- {- if(isOutsideDocElem()- && XMLCharacterRecognizer.isWhiteSpace(ch, start, length))- return; // avoid DOM006 Hierarchy request error-- String s = new String(ch, start, length);-- // XXX [email protected]: modified from the original, to accomodate TagSoup.- Node n = m_currentNode.getLastChild();- if (n instanceof CDATASection)- ((CDATASection)n).appendData(s);- else if (n instanceof Comment)- ((Comment)n).appendData(s);- }-- /**- * Report the start of DTD declarations, if any.- *- * Any declarations are assumed to be in the internal subset- * unless otherwise indicated.- *- * @param name The document type name.- * @param publicId The declared public identifier for the- * external DTD subset, or null if none was declared.- * @param systemId The declared system identifier for the- * external DTD subset, or null if none was declared.- * @see #endDTD- * @see #startEntity- */- public void startDTD(String name, String publicId, String systemId)- throws org.xml.sax.SAXException- {-- // Do nothing for now.- }-- /**- * Report the end of DTD declarations.- *- * @see #startDTD- */- public void endDTD() throws org.xml.sax.SAXException- {-- // Do nothing for now.- }-- /**- * Begin the scope of a prefix-URI Namespace mapping.- *- * <p>The information from this event is not necessary for- * normal Namespace processing: the SAX XML reader will- * automatically replace prefixes for element and attribute- * names when the http://xml.org/sax/features/namespaces- * feature is true (the default).</p>- *- * <p>There are cases, however, when applications need to- * use prefixes in character data or in attribute values,- * where they cannot safely be expanded automatically; the- * start/endPrefixMapping event supplies the information- * to the application to expand prefixes in those contexts- * itself, if necessary.</p>- *- * <p>Note that start/endPrefixMapping events are not- * guaranteed to be properly nested relative to each-other:- * all startPrefixMapping events will occur before the- * corresponding startElement event, and all endPrefixMapping- * events will occur after the corresponding endElement event,- * but their order is not guaranteed.</p>- *- * @param prefix The Namespace prefix being declared.- * @param uri The Namespace URI the prefix is mapped to.- * @see #endPrefixMapping- * @see #startElement- */- public void startPrefixMapping(String prefix, String uri)- throws org.xml.sax.SAXException- {-- /*- // Not sure if this is needed or wanted- // Also, it fails in the stree.- if((null != m_currentNode)- && (m_currentNode.getNodeType() == Node.ELEMENT_NODE))- {- String qname;- if(((null != prefix) && (prefix.length() == 0))- || (null == prefix))- qname = "xmlns";- else- qname = "xmlns:"+prefix;-- Element elem = (Element)m_currentNode;- String val = elem.getAttribute(qname); // Obsolete, should be DOM2...?- if(val == null)- {- elem.setAttributeNS("http://www.w3.org/XML/1998/namespace",- qname, uri);- }- }- */- }-- /**- * End the scope of a prefix-URI mapping.- *- * <p>See startPrefixMapping for details. This event will- * always occur after the corresponding endElement event,- * but the order of endPrefixMapping events is not otherwise- * guaranteed.</p>- *- * @param prefix The prefix that was being mapping.- * @see #startPrefixMapping- * @see #endElement- */- public void endPrefixMapping(String prefix) throws org.xml.sax.SAXException{}-- /**- * Receive notification of a skipped entity.- *- * <p>The Parser will invoke this method once for each entity- * skipped. Non-validating processors may skip entities if they- * have not seen the declarations (because, for example, the- * entity was declared in an external DTD subset). All processors- * may skip external entities, depending on the values of the- * http://xml.org/sax/features/external-general-entities and the- * http://xml.org/sax/features/external-parameter-entities- * properties.</p>- *- * @param name The name of the skipped entity. If it is a- * parameter entity, the name will begin with '%'.- */- public void skippedEntity(String name) throws org.xml.sax.SAXException{}-}diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.javadeleted file mode 100644index 55870dafa..000000000--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java+++ /dev/null@@ -1,419 +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.html;--import java.net.URL;-import java.net.MalformedURLException;-import java.util.Collection;-import java.util.ArrayList;-import java.util.HashMap;-import java.util.Stack;--import org.apache.nutch.parse.Outlink;-import org.apache.nutch.util.NodeWalker;-import org.apache.hadoop.conf.Configuration;--import org.w3c.dom.*;--/**- * A collection of methods for extracting content from DOM trees.- *- * This class holds a few utility methods for pulling content out of- * DOM nodes, such as getOutlinks, getText, etc.- *- */-public class DOMContentUtils {-- public static class LinkParams {- public String elName;- public String attrName;- public int childLen;-- public LinkParams(String elName, String attrName, int childLen) {- this.elName = elName;- this.attrName = attrName;- this.childLen = childLen;- }-- public String toString() {- return "LP[el=" + elName + ",attr=" + attrName + ",len=" + childLen + "]";- }- }-- private HashMap linkParams = new HashMap();- private Configuration conf;-- public DOMContentUtils(Configuration conf) {- setConf(conf);- }-- public void setConf(Configuration conf) {- // forceTags is used to override configurable tag ignoring, later on- Collection<String> forceTags = new ArrayList<String>(1);-- this.conf = conf;- linkParams.clear();- linkParams.put("a", new LinkParams("a", "href", 1));- linkParams.put("area", new LinkParams("area", "href", 0));- if (conf.getBoolean("parser.html.form.use_action", true)) {- linkParams.put("form", new LinkParams("form", "action", 1));- if (conf.get("parser.html.form.use_action") != null)- forceTags.add("form");- }- linkParams.put("frame", new LinkParams("frame", "src", 0));- linkParams.put("iframe", new LinkParams("iframe", "src", 0));- linkParams.put("script", new LinkParams("script", "src", 0));- linkParams.put("link", new LinkParams("link", "href", 0));- linkParams.put("img", new LinkParams("img", "src", 0));-- // remove unwanted link tags from the linkParams map- String[] ignoreTags = conf.getStrings("parser.html.outlinks.ignore_tags");- for ( int i = 0 ; ignoreTags != null && i < ignoreTags.length ; i++ ) {- if ( ! forceTags.contains(ignoreTags[i]) )- linkParams.remove(ignoreTags[i]);- }- }-- /**- * This method takes a {@link StringBuffer} and a DOM {@link Node},- * and will append all the content text found beneath the DOM node to- * the <code>StringBuffer</code>.- *- * <p>- *- * If <code>abortOnNestedAnchors</code> is true, DOM traversal will- * be aborted and the <code>StringBuffer</code> will not contain- * any text encountered after a nested anchor is found.- *- * <p>- *- * @return true if nested anchors were found- */- public boolean getText(StringBuffer sb, Node node,- boolean abortOnNestedAnchors) {- if (getTextHelper(sb, node, abortOnNestedAnchors, 0)) {- return true;- }- return false;- }--- /**- * This is a convinience method, equivalent to {@link- * #getText(StringBuffer,Node,boolean) getText(sb, node, false)}.- *- */- public void getText(StringBuffer sb, Node node) {- getText(sb, node, false);- }-- // returns true if abortOnNestedAnchors is true and we find nested- // anchors- private boolean getTextHelper(StringBuffer sb, Node node,- boolean abortOnNestedAnchors,- int anchorDepth) {- boolean abort = false;- NodeWalker walker = new NodeWalker(node);-- while (walker.hasNext()) {-- Node currentNode = walker.nextNode();- String nodeName = currentNode.getNodeName();- short nodeType = currentNode.getNodeType();-- if ("script".equalsIgnoreCase(nodeName)) {- walker.skipChildren();- }- if ("style".equalsIgnoreCase(nodeName)) {- walker.skipChildren();- }- if (abortOnNestedAnchors && "a".equalsIgnoreCase(nodeName)) {- anchorDepth++;- if (anchorDepth > 1) {- abort = true;- break;- }- }- if (nodeType == Node.COMMENT_NODE) {- walker.skipChildren();- }- if (nodeType == Node.TEXT_NODE) {- // cleanup and trim the value- String text = currentNode.getNodeValue();- text = text.replaceAll("\\s+", " ");- text = text.trim();- if (text.length() > 0) {- if (sb.length() > 0) sb.append(' ');- sb.append(text);- }- }- }-- return abort;- }-- /**- * This method takes a {@link StringBuffer} and a DOM {@link Node},- * and will append the content text found beneath the first- * <code>title</code> node to the <code>StringBuffer</code>.- *- * @return true if a title node was found, false otherwise- */- public boolean getTitle(StringBuffer sb, Node node) {-- NodeWalker walker = new NodeWalker(node);-- while (walker.hasNext()) {-- Node currentNode = walker.nextNode();- String nodeName = currentNode.getNodeName();- short nodeType = currentNode.getNodeType();-- if ("body".equalsIgnoreCase(nodeName)) { // stop after HEAD- return false;- }-- if (nodeType == Node.ELEMENT_NODE) {- if ("title".equalsIgnoreCase(nodeName)) {- getText(sb, currentNode);- return true;- }- }- }-- return false;- }-- /** If Node contains a BASE tag then it's HREF is returned. */- public URL getBase(Node node) {-- NodeWalker walker = new NodeWalker(node);-- while (walker.hasNext()) {-- Node currentNode = walker.nextNode();- String nodeName = currentNode.getNodeName();- short nodeType = currentNode.getNodeType();-- // is this node a BASE tag?- if (nodeType == Node.ELEMENT_NODE) {-- if ("body".equalsIgnoreCase(nodeName)) { // stop after HEAD- return null;- }-- if ("base".equalsIgnoreCase(nodeName)) {- NamedNodeMap attrs = currentNode.getAttributes();- for (int i= 0; i < attrs.getLength(); i++ ) {- Node attr = attrs.item(i);- if ("href".equalsIgnoreCase(attr.getNodeName())) {- try {- return new URL(attr.getNodeValue());- } catch (MalformedURLException e) {}- }- }- }- }- }-- // no.- return null;- }--- private boolean hasOnlyWhiteSpace(Node node) {- String val= node.getNodeValue();- for (int i= 0; i < val.length(); i++) {- if (!Character.isWhitespace(val.charAt(i)))- return false;- }- return true;- }-- // this only covers a few cases of empty links that are symptomatic- // of nekohtml's DOM-fixup process...- private boolean shouldThrowAwayLink(Node node, NodeList children,- int childLen, LinkParams params) {- if (childLen == 0) {- // this has no inner structure- if (params.childLen == 0) return false;- else return true;- } else if ((childLen == 1)- && (children.item(0).getNodeType() == Node.ELEMENT_NODE)- && (params.elName.equalsIgnoreCase(children.item(0).getNodeName()))) {- // single nested link- return true;-- } else if (childLen == 2) {-- Node c0= children.item(0);- Node c1= children.item(1);-- if ((c0.getNodeType() == Node.ELEMENT_NODE)- && (params.elName.equalsIgnoreCase(c0.getNodeName()))- && (c1.getNodeType() == Node.TEXT_NODE)- && hasOnlyWhiteSpace(c1) ) {- // single link followed by whitespace node- return true;- }-- if ((c1.getNodeType() == Node.ELEMENT_NODE)- && (params.elName.equalsIgnoreCase(c1.getNodeName()))- && (c0.getNodeType() == Node.TEXT_NODE)- && hasOnlyWhiteSpace(c0) ) {- // whitespace node followed by single link- return true;- }-- } else if (childLen == 3) {- Node c0= children.item(0);- Node c1= children.item(1);- Node c2= children.item(2);-- if ((c1.getNodeType() == Node.ELEMENT_NODE)- && (params.elName.equalsIgnoreCase(c1.getNodeName()))- && (c0.getNodeType() == Node.TEXT_NODE)- && (c2.getNodeType() == Node.TEXT_NODE)- && hasOnlyWhiteSpace(c0)- && hasOnlyWhiteSpace(c2) ) {- // single link surrounded by whitespace nodes- return true;- }- }-- return false;- }-- /**- * Handles cases where the url param information is encoded into the base- * url as opposed to the target.- * <p>- * If the taget contains params (i.e. ';xxxx') information then the target- * params information is assumed to be correct and any base params information- * is ignored. If the base contains params information but the tareget does- * not, then the params information is moved to the target allowing it to be- * correctly determined by the java.net.URL class.- *- * @param base The base URL.- * @param target The target path from the base URL.- *- * @return URL A URL with the params information correctly encoded.- *- * @throws MalformedURLException If the url is not a well formed URL.- */- private URL fixEmbeddedParams(URL base, String target)- throws MalformedURLException{-- // the target contains params information or the base doesn't then no- // conversion necessary, return regular URL- if (target.indexOf(';') >= 0 || base.toString().indexOf(';') == -1) {- return new URL(base, target);- }-- // get the base url and it params information- String baseURL = base.toString();- int startParams = baseURL.indexOf(';');- String params = baseURL.substring(startParams);-- // if the target has a query string then put the params information after- // any path but before the query string, otherwise just append to the path- int startQS = target.indexOf('?');- if (startQS >= 0) {- target = target.substring(0, startQS) + params +- target.substring(startQS);- }- else {- target += params;- }-- return new URL(base, target);- }-- /**- * This method finds all anchors below the supplied DOM- * <code>node</code>, and creates appropriate {@link Outlink}- * records for each (relative to the supplied <code>base</code>- * URL), and adds them to the <code>outlinks</code> {@link- * ArrayList}.- *- * <p>- *- * Links without inner structure (tags, text, etc) are discarded, as- * are links which contain only single nested links and empty text- * nodes (this is a common DOM-fixup artifact, at least with- * nekohtml).- */- public void getOutlinks(URL base, ArrayList outlinks,- Node node) {-- NodeWalker walker = new NodeWalker(node);- while (walker.hasNext()) {-- Node currentNode = walker.nextNode();- String nodeName = currentNode.getNodeName();- short nodeType = currentNode.getNodeType();- NodeList children = currentNode.getChildNodes();- int childLen = (children != null) ? children.getLength() : 0;-- if (nodeType == Node.ELEMENT_NODE) {-- nodeName = nodeName.toLowerCase();- LinkParams params = (LinkParams)linkParams.get(nodeName);- if (params != null) {- if (!shouldThrowAwayLink(currentNode, children, childLen, params)) {-- StringBuffer linkText = new StringBuffer();- getText(linkText, currentNode, true);-- NamedNodeMap attrs = currentNode.getAttributes();- String target = null;- boolean noFollow = false;- boolean post = false;- for (int i= 0; i < attrs.getLength(); i++ ) {- Node attr = attrs.item(i);- String attrName = attr.getNodeName();- if (params.attrName.equalsIgnoreCase(attrName)) {- target = attr.getNodeValue();- } else if ("rel".equalsIgnoreCase(attrName) &&- "nofollow".equalsIgnoreCase(attr.getNodeValue())) {- noFollow = true;- } else if ("method".equalsIgnoreCase(attrName) &&- "post".equalsIgnoreCase(attr.getNodeValue())) {- post = true;- }- }- if (target != null && !noFollow && !post)- try {-- URL url = (base.toString().indexOf(';') > 0) ?- fixEmbeddedParams(base, target) : new URL(base, target);- outlinks.add(new Outlink(url.toString(),- linkText.toString().trim()));- } catch (MalformedURLException e) {- // don't care- }- }- // this should not have any children, skip them- if (params.childLen == 0) continue;- }- }- }- }--}-diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HTMLMetaProcessor.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HTMLMetaProcessor.javadeleted file mode 100644index c57038d66..000000000--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HTMLMetaProcessor.java+++ /dev/null@@ -1,213 +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.html;--import java.net.URL;--import org.apache.nutch.parse.HTMLMetaTags;-import org.w3c.dom.*;--/**- * Class for parsing META Directives from DOM trees. This class- * handles specifically Robots META directives (all, none, nofollow,- * noindex), finding BASE HREF tags, and HTTP-EQUIV no-cache- * instructions. All meta directives are stored in a HTMLMetaTags instance.- */-public class HTMLMetaProcessor {-- /**- * Utility class with indicators for the robots directives "noindex"- * and "nofollow", and HTTP-EQUIV/no-cache- */-- /**- * Sets the indicators in <code>robotsMeta</code> to appropriate- * values, based on any META tags found under the given- * <code>node</code>.- */- public static final void getMetaTags (- HTMLMetaTags metaTags, Node node, URL currURL) {-- metaTags.reset();- getMetaTagsHelper(metaTags, node, currURL);- }-- private static final void getMetaTagsHelper(- HTMLMetaTags metaTags, Node node, URL currURL) {-- if (node.getNodeType() == Node.ELEMENT_NODE) {-- if ("body".equalsIgnoreCase(node.getNodeName())) {- // META tags should not be under body- return;- }-- if ("meta".equalsIgnoreCase(node.getNodeName())) {- NamedNodeMap attrs = node.getAttributes();- Node nameNode = null;- Node equivNode = null;- Node contentNode = null;- // Retrieves name, http-equiv and content attribues- for (int i=0; i<attrs.getLength(); i++) {- Node attr = attrs.item(i);- String attrName = attr.getNodeName().toLowerCase();- if (attrName.equals("name")) {- nameNode = attr;- } else if (attrName.equals("http-equiv")) {- equivNode = attr;- } else if (attrName.equals("content")) {- contentNode = attr;- }- }-- if (nameNode != null) {- if (contentNode != null) {- String name = nameNode.getNodeValue().toLowerCase();- metaTags.getGeneralTags().setProperty(name, contentNode.getNodeValue());- if ("robots".equals(name)) {-- if (contentNode != null) {- String directives =- contentNode.getNodeValue().toLowerCase();- int index = directives.indexOf("none");-- if (index >= 0) {- metaTags.setNoIndex();- metaTags.setNoFollow();- }-- index = directives.indexOf("all");- if (index >= 0) {- // do nothing...- }-- index = directives.indexOf("noindex");- if (index >= 0) {- metaTags.setNoIndex();- }-- index = directives.indexOf("nofollow");- if (index >= 0) {- metaTags.setNoFollow();- }-- index = directives.indexOf("noarchive");- if (index >= 0) {- metaTags.setNoCache();- }- }-- } // end if (name == robots)- }- }-- if (equivNode != null) {- if (contentNode != null) {- String name = equivNode.getNodeValue().toLowerCase();- String content = contentNode.getNodeValue();- metaTags.getHttpEquivTags().setProperty(name, content);- if ("pragma".equals(name)) {- content = content.toLowerCase();- int index = content.indexOf("no-cache");- if (index >= 0)- metaTags.setNoCache();- } else if ("refresh".equals(name)) {- int idx = content.indexOf(';');- String time = null;- if (idx == -1) { // just the refresh time- time = content;- } else time = content.substring(0, idx);- try {- metaTags.setRefreshTime(Integer.parseInt(time));- // skip this if we couldn't parse the time- metaTags.setRefresh(true);- } catch (Exception e) {- ;- }- URL refreshUrl = null;- if (metaTags.getRefresh() && idx != -1) { // set the URL- idx = content.toLowerCase().indexOf("url=");- if (idx == -1) { // assume a mis-formatted entry with just the url- idx = content.indexOf(';') + 1;- } else idx += 4;- if (idx != -1) {- String url = content.substring(idx);- try {- refreshUrl = new URL(url);- } catch (Exception e) {- // XXX according to the spec, this has to be an absolute- // XXX url. However, many websites use relative URLs and- // XXX expect browsers to handle that.- // XXX Unfortunately, in some cases this may create a- // XXX infinitely recursive paths (a crawler trap)...- // if (!url.startsWith("/")) url = "/" + url;- try {- refreshUrl = new URL(currURL, url);- } catch (Exception e1) {- refreshUrl = null;- }- }- }- }- if (metaTags.getRefresh()) {- if (refreshUrl == null) {- // apparently only refresh time was present. set the URL- // to the same URL.- refreshUrl = currURL;- }- metaTags.setRefreshHref(refreshUrl);- }- }- }- }-- } else if ("base".equalsIgnoreCase(node.getNodeName())) {- NamedNodeMap attrs = node.getAttributes();- Node hrefNode = attrs.getNamedItem("href");-- if (hrefNode != null) {- String urlString = hrefNode.getNodeValue();-- URL url = null;- try {- if (currURL == null)- url = new URL(urlString);- else- url = new URL(currURL, urlString);- } catch (Exception e) {- ;- }-- if (url != null)- metaTags.setBaseHref(url);- }-- }-- }-- NodeList children = node.getChildNodes();- if (children != null) {- int len = children.getLength();- for (int i = 0; i < len; i++) {- getMetaTagsHelper(metaTags, children.item(i), currURL);- }- }- }--}diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HtmlParser.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HtmlParser.javadeleted file mode 100644index eb841a57e..000000000--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HtmlParser.java+++ /dev/null@@ -1,297 +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.html;--import java.util.ArrayList;-import java.util.Map;-import java.net.URL;-import java.net.MalformedURLException;-import java.nio.charset.Charset;-import java.io.*;-import java.util.regex.*;--import org.cyberneko.html.parsers.*;-import org.xml.sax.InputSource;-import org.xml.sax.SAXException;-import org.w3c.dom.*;-import org.apache.html.dom.*;--import org.apache.commons.logging.Log;-import org.apache.commons.logging.LogFactory;--import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.metadata.Nutch;-import org.apache.nutch.protocol.Content;-import org.apache.hadoop.conf.*;-import org.apache.nutch.parse.*;-import org.apache.nutch.util.*;--public class HtmlParser implements Parser {- public static final Log LOG = LogFactory.getLog("org.apache.nutch.parse.html");-- // I used 1000 bytes at first, but found that some documents have- // meta tag well past the first 1000 bytes.- // (e.g. http://cn.promo.yahoo.com/customcare/music.html)- private static final int CHUNK_SIZE = 2000;- private static Pattern metaPattern =- Pattern.compile("<meta\\s+([^>]*http-equiv=\"?content-type\"?[^>]*)>",- Pattern.CASE_INSENSITIVE);- private static Pattern charsetPattern =- Pattern.compile("charset=\\s*([a-z][_\\-0-9a-z]*)",- Pattern.CASE_INSENSITIVE);-- private String parserImpl;-- /**- * Given a <code>byte[]</code> representing an html file of an- * <em>unknown</em> encoding, read out 'charset' parameter in the meta tag- * from the first <code>CHUNK_SIZE</code> bytes.- * If there's no meta tag for Content-Type or no charset is specified,- * <code>null</code> is returned. <br />- * FIXME: non-byte oriented character encodings (UTF-16, UTF-32)- * can't be handled with this.- * We need to do something similar to what's done by mozilla- * (http://lxr.mozilla.org/seamonkey/source/parser/htmlparser/src/nsParser.cpp#1993).- * See also http://www.w3.org/TR/REC-xml/#sec-guessing- * <br />- *- * @param content <code>byte[]</code> representation of an html file- */-- private static String sniffCharacterEncoding(byte[] content) {- int length = content.length < CHUNK_SIZE ?- content.length : CHUNK_SIZE;-- // We don't care about non-ASCII parts so that it's sufficient- // to just inflate each byte to a 16-bit value by padding.- // For instance, the sequence {0x41, 0x82, 0xb7} will be turned into- // {U+0041, U+0082, U+00B7}.- String str = "";- try {- str = new String(content, 0, length,- Charset.forName("ASCII").toString());- } catch (UnsupportedEncodingException e) {- // code should never come here, but just in case...- return null;- }-- Matcher metaMatcher = metaPattern.matcher(str);- String encoding = null;- if (metaMatcher.find()) {- Matcher charsetMatcher = charsetPattern.matcher(metaMatcher.group(1));- if (charsetMatcher.find())- encoding = new String(charsetMatcher.group(1));- }-- return encoding;- }-- private String defaultCharEncoding;-- private Configuration conf;-- private DOMContentUtils utils;-- private HtmlParseFilters htmlParseFilters;-- private String cachingPolicy;-- public ParseResult getParse(Content content) {- HTMLMetaTags metaTags = new HTMLMetaTags();-- URL base;- try {- base = new URL(content.getBaseUrl());- } catch (MalformedURLException e) {- return new ParseStatus(e).getEmptyParseResult(content.getUrl(), getConf());- }-- String text = "";- String title = "";- Outlink[] outlinks = new Outlink[0];- Metadata metadata = new Metadata();-- // parse the content- DocumentFragment root;- try {- byte[] contentInOctets = content.getContent();- InputSource input = new InputSource(new ByteArrayInputStream(contentInOctets));-- EncodingDetector detector = new EncodingDetector(conf);- detector.autoDetectClues(content, true);- detector.addClue(sniffCharacterEncoding(contentInOctets), "sniffed");- String encoding = detector.guessEncoding(content, defaultCharEncoding);-- metadata.set(Metadata.ORIGINAL_CHAR_ENCODING, encoding);- metadata.set(Metadata.CHAR_ENCODING_FOR_CONVERSION, encoding);-- input.setEncoding(encoding);- if (LOG.isTraceEnabled()) { LOG.trace("Parsing..."); }- root = parse(input);- } catch (IOException e) {- return new ParseStatus(e).getEmptyParseResult(content.getUrl(), getConf());- } catch (DOMException e) {- return new ParseStatus(e).getEmptyParseResult(content.getUrl(), getConf());- } catch (SAXException e) {- return new ParseStatus(e).getEmptyParseResult(content.getUrl(), getConf());- } catch (Exception e) {- e.printStackTrace(LogUtil.getWarnStream(LOG));- return new ParseStatus(e).getEmptyParseResult(content.getUrl(), getConf());- }-- // get meta directives- HTMLMetaProcessor.getMetaTags(metaTags, root, base);- if (LOG.isTraceEnabled()) {- LOG.trace("Meta tags for " + base + ": " + metaTags.toString());- }- // check meta directives- if (!metaTags.getNoIndex()) { // okay to index- StringBuffer sb = new StringBuffer();- if (LOG.isTraceEnabled()) { LOG.trace("Getting text..."); }- utils.getText(sb, root); // extract text- text = sb.toString();- sb.setLength(0);- if (LOG.isTraceEnabled()) { LOG.trace("Getting title..."); }- utils.getTitle(sb, root); // extract title- title = sb.toString().trim();- }-- if (!metaTags.getNoFollow()) { // okay to follow links- ArrayList<Outlink> l = new ArrayList<Outlink>(); // extract outlinks- URL baseTag = utils.getBase(root);- if (LOG.isTraceEnabled()) { LOG.trace("Getting links..."); }- utils.getOutlinks(baseTag!=null?baseTag:base, l, root);- outlinks = l.toArray(new Outlink[l.size()]);- if (LOG.isTraceEnabled()) {- LOG.trace("found "+outlinks.length+" outlinks in "+content.getUrl());- }- }-- ParseStatus status = new ParseStatus(ParseStatus.SUCCESS);- if (metaTags.getRefresh()) {- status.setMinorCode(ParseStatus.SUCCESS_REDIRECT);- status.setArgs(new String[] {metaTags.getRefreshHref().toString(),- Integer.toString(metaTags.getRefreshTime())});- }- ParseData parseData = new ParseData(status, title, outlinks,- content.getMetadata(), metadata);- ParseResult parseResult = ParseResult.createParseResult(content.getUrl(),- new ParseImpl(text, parseData));-- // run filters on parse- ParseResult filteredParse = this.htmlParseFilters.filter(content, parseResult,- metaTags, root);- if (metaTags.getNoCache()) { // not okay to cache- for (Map.Entry<org.apache.hadoop.io.Text, Parse> entry : filteredParse)- entry.getValue().getData().getParseMeta().set(Nutch.CACHING_FORBIDDEN_KEY,- cachingPolicy);- }- return filteredParse;- }-- private DocumentFragment parse(InputSource input) throws Exception {- if (parserImpl.equalsIgnoreCase("tagsoup"))- return parseTagSoup(input);- else return parseNeko(input);- }-- private DocumentFragment parseTagSoup(InputSource input) throws Exception {- HTMLDocumentImpl doc = new HTMLDocumentImpl();- DocumentFragment frag = doc.createDocumentFragment();- DOMBuilder builder = new DOMBuilder(doc, frag);- org.ccil.cowan.tagsoup.Parser reader = new org.ccil.cowan.tagsoup.Parser();- reader.setContentHandler(builder);- reader.setFeature(org.ccil.cowan.tagsoup.Parser.ignoreBogonsFeature, true);- reader.setFeature(org.ccil.cowan.tagsoup.Parser.bogonsEmptyFeature, false);- reader.setProperty("http://xml.org/sax/properties/lexical-handler", builder);- reader.parse(input);- return frag;- }-- private DocumentFragment parseNeko(InputSource input) throws Exception {- DOMFragmentParser parser = new DOMFragmentParser();- try {- parser.setFeature("http://cyberneko.org/html/features/augmentations",- true);- parser.setProperty("http://cyberneko.org/html/properties/default-encoding",- defaultCharEncoding);- parser.setFeature("http://cyberneko.org/html/features/scanner/ignore-specified-charset",- true);- parser.setFeature("http://cyberneko.org/html/features/balance-tags/ignore-outside-content",- false);- parser.setFeature("http://cyberneko.org/html/features/balance-tags/document-fragment",- true);- parser.setFeature("http://cyberneko.org/html/features/report-errors",- LOG.isTraceEnabled());- } catch (SAXException e) {}- // convert Document to DocumentFragment- HTMLDocumentImpl doc = new HTMLDocumentImpl();- doc.setErrorChecking(false);- DocumentFragment res = doc.createDocumentFragment();- DocumentFragment frag = doc.createDocumentFragment();- parser.parse(input, frag);- res.appendChild(frag);-- try {- while(true) {- frag = doc.createDocumentFragment();- parser.parse(input, frag);- if (!frag.hasChildNodes()) break;- if (LOG.isInfoEnabled()) {- LOG.info(" - new frag, " + frag.getChildNodes().getLength() + " nodes.");- }- res.appendChild(frag);- }- } catch (Exception x) { x.printStackTrace(LogUtil.getWarnStream(LOG));};- return res;- }-- public static void main(String[] args) throws Exception {- //LOG.setLevel(Level.FINE);- String name = args[0];- String url = "file:"+name;- File file = new File(name);- byte[] bytes = new byte[(int)file.length()];- DataInputStream in = new DataInputStream(new FileInputStream(file));- in.readFully(bytes);- Configuration conf = NutchConfiguration.create();- HtmlParser parser = new HtmlParser();- parser.setConf(conf);- Parse parse = parser.getParse(- new Content(url, url, bytes, "text/html", new Metadata(), conf)).get(url);- System.out.println("data: "+parse.getData());-- System.out.println("text: "+parse.getText());-- }-- public void setConf(Configuration conf) {- this.conf = conf;- this.htmlParseFilters = new HtmlParseFilters(getConf());- this.parserImpl = getConf().get("parser.html.impl", "neko");- this.defaultCharEncoding = getConf().get(- "parser.character.encoding.default", "windows-1252");- this.utils = new DOMContentUtils(conf);- this.cachingPolicy = getConf().get("parser.caching.forbidden.policy",- Nutch.CACHING_FORBIDDEN_CONTENT);- }-- public Configuration getConf() {- return this.conf;- }-}diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/XMLCharacterRecognizer.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/XMLCharacterRecognizer.javadeleted file mode 100644index dfc694d94..000000000--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/XMLCharacterRecognizer.java+++ /dev/null@@ -1,113 +0,0 @@-/*- * XXX [email protected]: This class is copied verbatim from Xalan-J 2.6.0- * XXX distribution, org.apache.xml.utils.XMLCharacterRecognizer,- * XXX in order to avoid dependency on Xalan.- */--/*- * 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.- */-/*- * $Id$- */-package org.apache.nutch.parse.html;--/**- * Class used to verify whether the specified <var>ch</var>- * conforms to the XML 1.0 definition of whitespace.- */-public class XMLCharacterRecognizer-{-- /**- * Returns whether the specified <var>ch</var> conforms to the XML 1.0 definition- * of whitespace. Refer to <A href="http://www.w3.org/TR/1998/REC-xml-19980210#NT-S">- * the definition of <CODE>S</CODE></A> for details.- * @param ch Character to check as XML whitespace.- * @return =true if <var>ch</var> is XML whitespace; otherwise =false.- */- public static boolean isWhiteSpace(char ch)- {- return (ch == 0x20) || (ch == 0x09) || (ch == 0xD) || (ch == 0xA);- }-- /**- * Tell if the string is whitespace.- *- * @param ch Character array to check as XML whitespace.- * @param start Start index of characters in the array- * @param length Number of characters in the array- * @return True if the characters in the array are- * XML whitespace; otherwise, false.- */- public static boolean isWhiteSpace(char ch[], int start, int length)- {-- int end = start + length;-- for (int s = start; s < end; s++)- {- if (!isWhiteSpace(ch[s]))- return false;- }-- return true;- }-- /**- * Tell if the string is whitespace.- *- * @param buf StringBuffer to check as XML whitespace.- * @return True if characters in buffer are XML whitespace, false otherwise- */- public static boolean isWhiteSpace(StringBuffer buf)- {-- int n = buf.length();-- for (int i = 0; i < n; i++)- {- if (!isWhiteSpace(buf.charAt(i)))- return false;- }-- return true;- }-- /**- * Tell if the string is whitespace.- *- * @param s String to check as XML whitespace.- * @return True if characters in buffer are XML whitespace, false otherwise- */- public static boolean isWhiteSpace(String s)- {-- if(null != s)- {- int n = s.length();-- for (int i = 0; i < n; i++)- {- if (!isWhiteSpace(s.charAt(i)))- return false;- }- }-- return true;- }--}diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/package.html b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/package.htmldeleted file mode 100644index c65038932..000000000--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/package.html+++ /dev/null@@ -1,5 +0,0 @@-<html>-<body>-<p>An HTML document parsing plugin.</p><p>This package relies on <a href="http://www.apache.org/~andyc/neko/doc/html/index.html">NekoHTML</a>.</p>-</body>-</html>diff --git a/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.java b/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.javadeleted file mode 100644index 4ecc5f069..000000000--- a/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.java+++ /dev/null@@ -1,408 +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.html;--import junit.framework.TestCase;--import org.apache.nutch.parse.Outlink;-import org.apache.hadoop.conf.Configuration;-import org.apache.nutch.util.NutchConfiguration;--import java.io.ByteArrayInputStream;-import java.net.MalformedURLException;-import java.net.URL;-import java.util.ArrayList;-import java.util.StringTokenizer;--import org.cyberneko.html.parsers.*;-import org.xml.sax.*;-import org.w3c.dom.*;-import org.apache.html.dom.*;--/**- * Unit tests for DOMContentUtils.- */-public class TestDOMContentUtils extends TestCase {-- private static final String[] testPages= {- new String("<html><head><title> title </title><script> script </script>"- + "</head><body> body <a href=\"http://www.nutch.org\">"- + " anchor </a><!--comment-->"- + "</body></html>"),- new String("<html><head><title> title </title><script> script </script>"- + "</head><body> body <a href=\"/\">"- + " home </a><!--comment-->"- + "<style> style </style>"- + " <a href=\"bot.html\">"- + " bots </a>"- + "</body></html>"),- new String("<html><head><title> </title>"- + "</head><body> "- + "<a href=\"/\"> separate this "- + "<a href=\"ok\"> from this"- + "</a></a>"- + "</body></html>"),- // this one relies on certain neko fixup behavior, possibly- // distributing the anchors into the LI's-but not the other- // anchors (outside of them, instead)! So you get a tree that- // looks like:- // ... <li> <a href=/> home </a> </li>- // <li> <a href=/> <a href="1"> 1 </a> </a> </li>- // <li> <a href=/> <a href="1"> <a href="2"> 2 </a> </a> </a> </li>- new String("<html><head><title> my title </title>"- + "</head><body> body "- + "<ul>"- + "<li> <a href=\"/\"> home"- + "<li> <a href=\"1\"> 1"- + "<li> <a href=\"2\"> 2"- + "</ul>"- + "</body></html>"),- // test frameset link extraction. The invalid frame in the middle will be- // fixed to a third standalone frame.- new String("<html><head><title> my title </title>"- + "</head><frameset rows=\"20,*\"> "- + "<frame src=\"top.html\">"- + "</frame>"- + "<frameset cols=\"20,*\">"- + "<frame src=\"left.html\">"- + "<frame src=\"invalid.html\"/>"- + "</frame>"- + "<frame src=\"right.html\">"- + "</frame>"- + "</frameset>"- + "</frameset>"- + "</body></html>"),- // test <area> and <iframe> link extraction + url normalization- new String("<html><head><title> my title </title>"- + "</head><body>"- + "<img src=\"logo.gif\" usemap=\"#green\" border=\"0\">"- + "<map name=\"green\">"- + "<area shape=\"polygon\" coords=\"19,44,45,11,87\" href=\"../index.html\">"- + "<area shape=\"rect\" coords=\"128,132,241,179\" href=\"#bottom\">"- + "<area shape=\"circle\" coords=\"68,211,35\" href=\"../bot.html\">"- + "</map>"- + "<a name=\"bottom\"/><h1> the bottom </h1> "- + "<iframe src=\"../docs/index.html\"/>"- + "</body></html>"),- // test whitespace processing for plain text extraction- new String("<html><head>\n <title> my\t\n title\r\n </title>\n"- + " </head>\n"- + " <body>\n"- + " <h1> Whitespace\ttest </h1> \n"- + "\t<a href=\"../index.html\">\n \twhitespace test\r\n\t</a> \t\n"- + " <p> This is<span> a whitespace<span></span> test</span>. Newlines\n"- + "should appear as space too.</p><p>Tabs\tare spaces too.\n</p>"- + " This\t<b>is a</b> break -><br>and the line after<i> break</i>.<br>\n"- + "<table>"- + " <tr><td>one</td><td>two</td><td>three</td></tr>\n"- + " <tr><td>space here </td><td> space there</td><td>no space</td></tr>"- + "\t<tr><td>one\r\ntwo</td><td>two\tthree</td><td>three\r\tfour</td></tr>\n"- + "</table>put some text here<Br>and there."- + "<h2>End\tthis\rmadness\n!</h2>\r\n"- + " . . . ."- + "</body> </html>"),-- // test that <a rel=nofollow> links are not returned- new String("<html><head></head><body>"- + "<a href=\"http://www.nutch.org\" rel=\"nofollow\"> ignore </a>"- + "<a rel=\"nofollow\" href=\"http://www.nutch.org\"> ignore </a>"- + "</body></html>"),- // test that POST form actions are skipped- new String("<html><head></head><body>"- + "<form method='POST' action='/search.jsp'><input type=text>"- + "<input type=submit><p>test1</p></form>"- + "<form method='GET' action='/dummy.jsp'><input type=text>"- + "<input type=submit><p>test2</p></form></body></html>"),- // test that all form actions are skipped- new String("<html><head></head><body>"- + "<form method='POST' action='/search.jsp'><input type=text>"- + "<input type=submit><p>test1</p></form>"- + "<form method='GET' action='/dummy.jsp'><input type=text>"- + "<input type=submit><p>test2</p></form></body></html>"),- new String("<html><head><title> title </title>"- + "</head><body>"- + "<a href=\";x\">anchor1</a>"- + "<a href=\"g;x\">anchor2</a>"- + "<a href=\"g;x?y#s\">anchor3</a>"- + "</body></html>"),- new String("<html><head><title> title </title>"- + "</head><body>"- + "<a href=\"g\">anchor1</a>"- + "<a href=\"g?y#s\">anchor2</a>"- + "<a href=\"?y=1\">anchor3</a>"- + "<a href=\"?y=1#s\">anchor4</a>"- + "<a href=\"?y=1;somethingelse\">anchor5</a>"- + "</body></html>"),- };-- private static int SKIP = 9;-- private static String[] testBaseHrefs= {- "http://www.nutch.org",- "http://www.nutch.org/docs/foo.html",- "http://www.nutch.org/docs/",- "http://www.nutch.org/docs/",- "http://www.nutch.org/frames/",- "http://www.nutch.org/maps/",- "http://www.nutch.org/whitespace/",- "http://www.nutch.org//",- "http://www.nutch.org/",- "http://www.nutch.org/",- "http://www.nutch.org/",- "http://www.nutch.org/;something"- };-- private static final DocumentFragment testDOMs[]=- new DocumentFragment[testPages.length];-- private static URL[] testBaseHrefURLs=- new URL[testPages.length];--- private static final String[] answerText= {- "title body anchor",- "title body home bots",- "separate this from this",- "my title body home 1 2",- "my title",- "my title the bottom",- "my title Whitespace test whitespace test "- + "This is a whitespace test . Newlines should appear as space too. "- + "Tabs are spaces too. This is a break -> and the line after break . "- + "one two three space here space there no space "- + "one two two three three four put some text here and there. "- + "End this madness ! . . . .",- "ignore ignore",- "test1 test2",- "test1 test2",- "title anchor1 anchor2 anchor3",- "title anchor1 anchor2 anchor3 anchor4 anchor5"- };-- private static final String[] answerTitle= {- "title",- "title",- "",- "my title",- "my title",- "my title",- "my title",- "",- "",- "",- "title",- "title"- };-- // note: should be in page-order- private static Outlink[][] answerOutlinks;-- private static Configuration conf;- private static DOMContentUtils utils = null;-- public TestDOMContentUtils(String name) {- super(name);- }-- private static void setup() {- conf = NutchConfiguration.create();- conf.setBoolean("parser.html.form.use_action", true);- utils = new DOMContentUtils(conf);- DOMFragmentParser parser= new DOMFragmentParser();- for (int i= 0; i < testPages.length; i++) {- DocumentFragment node=- new HTMLDocumentImpl().createDocumentFragment();- try {- parser.parse(- new InputSource(- new ByteArrayInputStream(testPages[i].getBytes()) ),- node);- testBaseHrefURLs[i]= new URL(testBaseHrefs[i]);- } catch (Exception e) {- assertTrue("caught exception: " + e, false);- }- testDOMs[i]= node;- }- try {- answerOutlinks = new Outlink[][]{- {- new Outlink("http://www.nutch.org", "anchor"),- },- {- new Outlink("http://www.nutch.org/", "home"),- new Outlink("http://www.nutch.org/docs/bot.html", "bots"),- },- {- new Outlink("http://www.nutch.org/", "separate this"),- new Outlink("http://www.nutch.org/docs/ok", "from this"),- },- {- new Outlink("http://www.nutch.org/", "home"),- new Outlink("http://www.nutch.org/docs/1", "1"),- new Outlink("http://www.nutch.org/docs/2", "2"),- },- {- new Outlink("http://www.nutch.org/frames/top.html", ""),- new Outlink("http://www.nutch.org/frames/left.html", ""),- new Outlink("http://www.nutch.org/frames/invalid.html", ""),- new Outlink("http://www.nutch.org/frames/right.html", ""),- },- {- new Outlink("http://www.nutch.org/maps/logo.gif", ""),- new Outlink("http://www.nutch.org/index.html", ""),- new Outlink("http://www.nutch.org/maps/#bottom", ""),- new Outlink("http://www.nutch.org/bot.html", ""),- new Outlink("http://www.nutch.org/docs/index.html", ""),- },- {- new Outlink("http://www.nutch.org/index.html", "whitespace test"),- },- {- },- {- new Outlink("http://www.nutch.org/dummy.jsp", "test2"),- },- {- },- {- new Outlink("http://www.nutch.org/;x", "anchor1"),- new Outlink("http://www.nutch.org/g;x", "anchor2"),- new Outlink("http://www.nutch.org/g;x?y#s", "anchor3")- },- {- new Outlink("http://www.nutch.org/g;something", "anchor1"),- new Outlink("http://www.nutch.org/g;something?y#s", "anchor2"),- new Outlink("http://www.nutch.org/;something?y=1", "anchor3"),- new Outlink("http://www.nutch.org/;something?y=1#s", "anchor4"),- new Outlink("http://www.nutch.org/?y=1;somethingelse", "anchor5")- }- };-- } catch (MalformedURLException e) {-- }- }-- private static boolean equalsIgnoreWhitespace(String s1, String s2) {- StringTokenizer st1= new StringTokenizer(s1);- StringTokenizer st2= new StringTokenizer(s2);-- while (st1.hasMoreTokens()) {- if (!st2.hasMoreTokens())- return false;- if ( ! st1.nextToken().equals(st2.nextToken()) )- return false;- }- if (st2.hasMoreTokens())- return false;- return true;- }-- public void testGetText() {- if (testDOMs[0] == null)- setup();- for (int i= 0; i < testPages.length; i++) {- StringBuffer sb= new StringBuffer();- utils.getText(sb, testDOMs[i]);- String text= sb.toString();- assertTrue("expecting text: " + answerText[i]- + System.getProperty("line.separator")- + System.getProperty("line.separator")- + "got text: "+ text,- equalsIgnoreWhitespace(answerText[i], text));- }- }-- public void testGetTitle() {- if (testDOMs[0] == null)- setup();- for (int i= 0; i < testPages.length; i++) {- StringBuffer sb= new StringBuffer();- utils.getTitle(sb, testDOMs[i]);- String text= sb.toString();- assertTrue("expecting text: " + answerText[i]- + System.getProperty("line.separator")- + System.getProperty("line.separator")- + "got text: "+ text,- equalsIgnoreWhitespace(answerTitle[i], text));- }- }-- public void testGetOutlinks() {- if (testDOMs[0] == null)- setup();- for (int i= 0; i < testPages.length; i++) {- ArrayList outlinks= new ArrayList();- if (i == SKIP) {- conf.setBoolean("parser.html.form.use_action", false);- utils.setConf(conf);- } else {- conf.setBoolean("parser.html.form.use_action", true);- utils.setConf(conf);- }- utils.getOutlinks(testBaseHrefURLs[i], outlinks, testDOMs[i]);- Outlink[] outlinkArr= new Outlink[outlinks.size()];- outlinkArr= (Outlink[]) outlinks.toArray(outlinkArr);- compareOutlinks(answerOutlinks[i], outlinkArr);- }- }-- private static final void appendOutlinks(StringBuffer sb, Outlink[] o) {- for (int i= 0; i < o.length; i++) {- sb.append(o[i].toString());- sb.append(System.getProperty("line.separator"));- }- }-- private static final String outlinksString(Outlink[] o) {- StringBuffer sb= new StringBuffer();- appendOutlinks(sb, o);- return sb.toString();- }-- private static final void compareOutlinks(Outlink[] o1, Outlink[] o2) {- if (o1.length != o2.length) {- assertTrue("got wrong number of outlinks (expecting " + o1.length- + ", got " + o2.length + ")"- + System.getProperty("line.separator")- + "answer: " + System.getProperty("line.separator")- + outlinksString(o1)- + System.getProperty("line.separator")- + "got: " + System.getProperty("line.separator")- + outlinksString(o2)- + System.getProperty("line.separator"),- false- );- }-- for (int i= 0; i < o1.length; i++) {- if (!o1[i].equals(o2[i])) {- assertTrue("got wrong outlinks at position " + i- + System.getProperty("line.separator")- + "answer: " + System.getProperty("line.separator")- + o1[i].toString()- + System.getProperty("line.separator")- + "got: " + System.getProperty("line.separator")- + o2[i].toString(),- false- );-- }- }- }-}diff --git a/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestRobotsMetaProcessor.java b/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestRobotsMetaProcessor.javadeleted file mode 100644index e98584496..000000000--- a/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestRobotsMetaProcessor.java+++ /dev/null@@ -1,182 +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.html;--import junit.framework.TestCase;--import org.apache.nutch.parse.HTMLMetaTags;--import java.io.ByteArrayInputStream;-import java.net.URL;--import org.cyberneko.html.parsers.*;-import org.xml.sax.*;-import org.w3c.dom.*;-import org.apache.html.dom.*;--/** Unit tests for HTMLMetaProcessor. */-public class TestRobotsMetaProcessor extends TestCase {- public TestRobotsMetaProcessor(String name) {- super(name);- }-- /*-- some sample tags:-- <meta name="robots" content="index,follow">- <meta name="robots" content="noindex,follow">- <meta name="robots" content="index,nofollow">- <meta name="robots" content="noindex,nofollow">-- <META HTTP-EQUIV="Pragma" CONTENT="no-cache">-- */--- public static String[] tests=- {- "<html><head><title>test page</title>"- + "<META NAME=\"ROBOTS\" CONTENT=\"NONE\"> "- + "<META HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\"> "- + "</head><body>"- + " some text"- + "</body></html>",-- "<html><head><title>test page</title>"- + "<meta name=\"robots\" content=\"all\"> "- + "<meta http-equiv=\"pragma\" content=\"no-cache\"> "- + "</head><body>"- + " some text"- + "</body></html>",-- "<html><head><title>test page</title>"- + "<MeTa NaMe=\"RoBoTs\" CoNtEnT=\"nOnE\"> "- + "<MeTa HtTp-EqUiV=\"pRaGmA\" cOnTeNt=\"No-CaChE\"> "- + "</head><body>"- + " some text"- + "</body></html>",-- "<html><head><title>test page</title>"- + "<meta name=\"robots\" content=\"none\"> "- + "</head><body>"- + " some text"- + "</body></html>",-- "<html><head><title>test page</title>"- + "<meta name=\"robots\" content=\"noindex,nofollow\"> "- + "</head><body>"- + " some text"- + "</body></html>",-- "<html><head><title>test page</title>"- + "<meta name=\"robots\" content=\"noindex,follow\"> "- + "</head><body>"- + " some text"- + "</body></html>",-- "<html><head><title>test page</title>"- + "<meta name=\"robots\" content=\"index,nofollow\"> "- + "</head><body>"- + " some text"- + "</body></html>",-- "<html><head><title>test page</title>"- + "<meta name=\"robots\" content=\"index,follow\"> "- + "<base href=\"http://www.nutch.org/\">"- + "</head><body>"- + " some text"- + "</body></html>",-- "<html><head><title>test page</title>"- + "<meta name=\"robots\"> "- + "<base href=\"http://www.nutch.org/base/\">"- + "</head><body>"- + " some text"- + "</body></html>",-- };-- public static final boolean[][] answers= {- {true, true, true}, // NONE- {false, false, true}, // all- {true, true, true}, // nOnE- {true, true, false}, // none- {true, true, false}, // noindex,nofollow- {true, false, false}, // noindex,follow- {false, true, false}, // index,nofollow- {false, false, false}, // index,follow- {false, false, false}, // missing!- };-- private URL[][] currURLsAndAnswers;-- public void testRobotsMetaProcessor() {- DOMFragmentParser parser= new DOMFragmentParser();;-- try {- currURLsAndAnswers= new URL[][] {- {new URL("http://www.nutch.org"), null},- {new URL("http://www.nutch.org"), null},- {new URL("http://www.nutch.org"), null},- {new URL("http://www.nutch.org"), null},- {new URL("http://www.nutch.org"), null},- {new URL("http://www.nutch.org"), null},- {new URL("http://www.nutch.org"), null},- {new URL("http://www.nutch.org/foo/"),- new URL("http://www.nutch.org/")},- {new URL("http://www.nutch.org"),- new URL("http://www.nutch.org/base/")}- };- } catch (Exception e) {- assertTrue("couldn't make test URLs!", false);- }-- for (int i= 0; i < tests.length; i++) {- byte[] bytes= tests[i].getBytes();-- DocumentFragment node = new HTMLDocumentImpl().createDocumentFragment();-- try {- parser.parse(new InputSource(new ByteArrayInputStream(bytes)), node);- } catch (Exception e) {- e.printStackTrace();- }-- HTMLMetaTags robotsMeta= new HTMLMetaTags();- HTMLMetaProcessor.getMetaTags(robotsMeta, node,- currURLsAndAnswers[i][0]);-- assertTrue("got index wrong on test " + i,- robotsMeta.getNoIndex() == answers[i][0]);- assertTrue("got follow wrong on test " + i,- robotsMeta.getNoFollow() == answers[i][1]);- assertTrue("got cache wrong on test " + i,- robotsMeta.getNoCache() == answers[i][2]);- assertTrue("got base href wrong on test " + i + " (got "- + robotsMeta.getBaseHref() + ")",- ( (robotsMeta.getBaseHref() == null)- && (currURLsAndAnswers[i][1] == null) )- || ( (robotsMeta.getBaseHref() != null)- && robotsMeta.getBaseHref().equals(- currURLsAndAnswers[i][1]) ) );-- }- }--}diff --git a/src/plugin/parse-msexcel/build.xml b/src/plugin/parse-msexcel/build.xmldeleted file mode 100644index ef382773c..000000000--- a/src/plugin/parse-msexcel/build.xml+++ /dev/null@@ -1,53 +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-msexcel" default="jar-core">-- <import file="../build-plugin.xml" />-- <!-- Build compilation dependencies -->- <target name="deps-jar">- <ant target="jar" inheritall="false" dir="../lib-jakarta-poi"/>- <ant target="jar" inheritall="false" dir="../lib-parsems"/>- </target>-- <!-- Add compilation dependencies to classpath -->- <path id="plugin.deps">- <fileset dir="${nutch.root}/build">- <include name="**/lib-jakarta-poi/*.jar" />- <include name="**/lib-parsems/*.jar" />- </fileset>- </path>-- <!-- Deploy Unit test dependencies -->- <target name="deps-test">- <ant target="deploy" inheritall="false" dir="../lib-jakarta-poi"/>- <ant target="deploy" inheritall="false" dir="../lib-parsems"/>- <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 todir="${build.test}/data">- <fileset dir="sample">- <include name="*.xls" />- </fileset>- </copy>--</project>diff --git a/src/plugin/parse-msexcel/plugin.xml b/src/plugin/parse-msexcel/plugin.xmldeleted file mode 100644index a3d6059af..000000000--- a/src/plugin/parse-msexcel/plugin.xml+++ /dev/null@@ -1,47 +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-msexcel"- name="MSExcel Parse Plug-in"- version="1.0.0"- provider-name="nutch.org">-- <runtime>- <library name="parse-msexcel.jar">- <export name="*"/>- </library>- </runtime>-- <requires>- <import plugin="nutch-extensionpoints"/>- <import plugin="lib-jakarta-poi"/>- <import plugin="lib-parsems"/>- </requires>-- <extension id="org.apache.nutch.parse.msexcel"- name="MSExcelParser"- point="org.apache.nutch.parse.Parser">-- <implementation id="org.apache.nutch.parse.msexcel.MSExcelParser"- class="org.apache.nutch.parse.msexcel.MSExcelParser">- <parameter name="contentType" value="application/vnd.ms-excel"/>- <parameter name="pathSuffix" value="xls"/>- </implementation>- </extension>--</plugin>diff --git a/src/plugin/parse-msexcel/sample/test.xls b/src/plugin/parse-msexcel/sample/test.xlsdeleted file mode 100644index da4e6bf31..000000000Binary files a/src/plugin/parse-msexcel/sample/test.xls and /dev/null differdiff --git a/src/plugin/parse-msexcel/sample/test.xls.content b/src/plugin/parse-msexcel/sample/test.xls.contentdeleted file mode 100644index 5bf675c36..000000000--- a/src/plugin/parse-msexcel/sample/test.xls.content+++ /dev/null@@ -1,3 +0,0 @@-BitStream test.xls 321654.0 Apache incubator 1234.0 Doug Cutting 89078 CS 599 Search Engines Spring 2005.0 SBC 1234.0 764893.0 Java NUTCH!!--BitStream test.xls 321654.0 Apache incubator 1234.0 Doug Cutting 89078.0 CS 599 Search Engines Spring 2005.0 SBC 1234.0 764893.0 Java NUTCH!!\ No newline at end of filediff --git a/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/ExcelExtractor.java b/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/ExcelExtractor.javadeleted file mode 100644index c571b3d0b..000000000--- a/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/ExcelExtractor.java+++ /dev/null@@ -1,92 +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.msexcel;--// JDK imports-import java.io.InputStream;--// Jakarta POI imports-import org.apache.poi.hssf.usermodel.HSSFCell;-import org.apache.poi.hssf.usermodel.HSSFRow;-import org.apache.poi.hssf.usermodel.HSSFSheet;-import org.apache.poi.hssf.usermodel.HSSFWorkbook;--// Nutch imports-import org.apache.nutch.parse.ms.MSExtractor;---/**- * Excel Text and Properties extractor.- *- * @author Rohit Kulkarni & Ashish Vaidya- * @author Jérôme Charron- */-class ExcelExtractor extends MSExtractor {--- protected String extractText(InputStream input) throws Exception {-- StringBuilder resultText = new StringBuilder();- HSSFWorkbook wb = new HSSFWorkbook(input);- if (wb == null) {- return resultText.toString();- }-- HSSFSheet sheet;- HSSFRow row;- HSSFCell cell;- int sNum = 0;- int rNum = 0;- int cNum = 0;-- sNum = wb.getNumberOfSheets();-- for (int i=0; i<sNum; i++) {- if ((sheet = wb.getSheetAt(i)) == null) {- continue;- }- rNum = sheet.getLastRowNum();- for (int j=0; j<=rNum; j++) {- if ((row = sheet.getRow(j)) == null){- continue;- }- cNum = row.getLastCellNum();-- for (int k=0; k<cNum; k++) {- if ((cell = row.getCell((short) k)) != null) {- /*if(HSSFDateUtil.isCellDateFormatted(cell) == true) {- resultText.append(cell.getDateCellValue().toString())- } else- */- if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {- resultText.append(cell.getStringCellValue()).append(" ");- } else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {- double d = cell.getNumericCellValue();- resultText.append(d).append(" ");- }- /* else if(cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA){- resultText.append(cell.getCellFormula());- }- */- }- }- }- }- return resultText.toString();- }--}diff --git a/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/MSExcelParser.java b/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/MSExcelParser.javadeleted file mode 100644index 7f6b9de40..000000000--- a/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/MSExcelParser.java+++ /dev/null@@ -1,51 +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.msexcel;--// Nutch imports-import org.apache.nutch.parse.ParseResult;-import org.apache.nutch.parse.ms.MSBaseParser;-import org.apache.nutch.protocol.Content;---/**- * An Excel document parser.- *- * @author Rohit Kulkarni & Ashish Vaidya- * @author Jérôme Charron- */-public class MSExcelParser extends MSBaseParser {-- /**- * Associated Mime type for Excel files- * (<code>application/vnd.ms-excel</code>).- */- public static final String MIME_TYPE = "application/vnd.ms-excel";--- public ParseResult getParse(Content content) {- return getParse(new ExcelExtractor(), content);- }-- /**- * Main for testing. Pass an excel document as argument- */- public static void main(String args[]) {- main(MIME_TYPE, new MSExcelParser(), args);- }--}diff --git a/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/package.html b/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/package.htmldeleted file mode 100644index 8c6dcc166..000000000--- a/src/plugin/parse-msexcel/src/java/org/apache/nutch/parse/msexcel/package.html+++ /dev/null@@ -1,6 +0,0 @@-<html>-<body>-<p>A Microsoft © Excel document parsing plugin.</p>-<p>This package relies on Jakarta <a href="http://jakarta.apache.org/poi/index.html">POI</a>.</p>-</body>-</html>diff --git a/src/plugin/parse-msexcel/src/test/org/apache/nutch/parse/msexcel/TestMSExcelParser.java b/src/plugin/parse-msexcel/src/test/org/apache/nutch/parse/msexcel/TestMSExcelParser.javadeleted file mode 100644index 82ac3ce75..000000000--- a/src/plugin/parse-msexcel/src/test/org/apache/nutch/parse/msexcel/TestMSExcelParser.java+++ /dev/null@@ -1,88 +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.-*/-/*- * TestMSExcelParser.java- * Based on the Unit Tests for MSWordParser by John Xing- */-package org.apache.nutch.parse.msexcel;--// Nutch imports-import org.apache.nutch.crawl.CrawlDatum;-import org.apache.nutch.parse.ParseUtil;-import org.apache.nutch.protocol.ProtocolFactory;-import org.apache.nutch.protocol.Protocol;-import org.apache.nutch.protocol.Content;-import org.apache.nutch.protocol.ProtocolException;-import org.apache.nutch.parse.Parse;-import org.apache.nutch.parse.ParseException;-import org.apache.nutch.util.NutchConfiguration;--// JUnit imports-import junit.framework.TestCase;--// Hadoop imports-import org.apache.hadoop.conf.Configuration;-import org.apache.hadoop.io.Text;---/**- * Based on Unit tests for MSWordParser by John Xing- *- * @author Rohit Kulkarni & Ashish Vaidya- */-public class TestMSExcelParser extends TestCase {-- private String fileSeparator = System.getProperty("file.separator");- // This system property is defined in ./src/plugin/build-plugin.xml- private String sampleDir = System.getProperty("test.data",".");-- // Make sure sample files are copied to "test.data"-- private String[] sampleFiles = {"test.xls"};-- private String expectedText = "BitStream test.xls 321654.0 Apache " +- "incubator 1234.0 Doug Cutting 89078.0 " +- "CS 599 Search Engines Spring 2005.0 SBC " +- "1234.0 764893.0 Java NUTCH!! ";-- public TestMSExcelParser(String name) {- super(name);- }-- public void testIt() throws ProtocolException, ParseException {-- String urlString;- Protocol protocol;- Content content;- Parse parse;-- Configuration conf = NutchConfiguration.create();- ParseUtil parser = new ParseUtil(conf);- ProtocolFactory factory = new ProtocolFactory(conf);- for (int i = 0; i < sampleFiles.length; i++) {- urlString = "file:" + sampleDir + fileSeparator + sampleFiles[i];-- protocol = factory.getProtocol(urlString);- content = protocol.getProtocolOutput(new Text(urlString),- new CrawlDatum()).getContent();- parse = parser.parseByExtensionId("parse-msexcel", content).get(content.getUrl());-- assertTrue(parse.getText().equals(expectedText));- }- }--}diff --git a/src/plugin/parse-mspowerpoint/README.txt b/src/plugin/parse-mspowerpoint/README.txtdeleted file mode 100644index 2ece7f6ab..000000000--- a/src/plugin/parse-mspowerpoint/README.txt+++ /dev/null@@ -1,8 +0,0 @@-Pugin to support parsing of MS PowerPoint files.--Contributed by Stephan Strittmatter <[email protected]>.--Note:-======-For parsing MS PowerPoint files it is required to get the complete filestream.-Please check the property <protocol>.content.limit at nutch-default.xml.\ No newline at end of filediff --git a/src/plugin/parse-mspowerpoint/build.xml b/src/plugin/parse-mspowerpoint/build.xmldeleted file mode 100644index 60e0bce91..000000000--- a/src/plugin/parse-mspowerpoint/build.xml+++ /dev/null@@ -1,80 +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-mspowerpoint" default="jar-core">-- <import file="../build-plugin.xml" />-- <!-- Build compilation dependencies -->- <target name="deps-jar">- <ant target="jar" inheritall="false" dir="../lib-jakarta-poi"/>- <ant target="jar" inheritall="false" dir="../lib-parsems"/>- </target>-- <!-- Add compilation dependencies to classpath -->- <path id="plugin.deps">- <fileset dir="${nutch.root}/build">- <include name="**/lib-jakarta-poi/*.jar" />- <include name="**/lib-parsems/*.jar" />- </fileset>- </path>-- <!-- Deploy Unit test dependencies -->- <target name="deps-test">- <ant target="deploy" inheritall="false" dir="../lib-jakarta-poi"/>- <ant target="deploy" inheritall="false" dir="../lib-parsems"/>- <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 todir="${build.test}/data">- <fileset dir="sample">- <include name="*.ppt" />- <include name="*.content" />- <include name="*.meta" />- </fileset>- </copy>-- <!-- ================================================================== -->- <!-- Run unit tests -->- <!-- ================================================================== -->- <target name="test" depends="compile-test, deploy" if="test.available">- <echo message="Testing plugin: ${name}"/>-- <junit printsummary="yes" haltonfailure="no" fork="yes"- errorProperty="tests.failed" failureProperty="tests.failed">- <sysproperty key="test.data" value="${build.test}/data"/>- <sysproperty key="test.input" value="${root}/data"/>- <classpath refid="test.classpath"/>- <formatter type="plain" />- <batchtest todir="${build.test}" unless="testcase">- <fileset dir="${src.test}"- includes="**/AllTests.java" excludes="**/${test.exclude}.java" />- </batchtest>- <batchtest todir="${build.test}" if="testcase">- <fileset dir="${src.test}" includes="**/${testcase}.java"/>- </batchtest>- </junit>-- <fail if="tests.failed">Tests failed!</fail>-- </target>--</project>diff --git a/src/plugin/parse-mspowerpoint/plugin.xml b/src/plugin/parse-mspowerpoint/plugin.xmldeleted file mode 100644index e7b6e2677..000000000--- a/src/plugin/parse-mspowerpoint/plugin.xml+++ /dev/null@@ -1,46 +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-mspowerpoint"- name="MSPowerPoint Parse Plug-in"- version="1.0.0"- provider-name="nutch.org">-- <runtime>- <library name="parse-mspowerpoint.jar">- <export name="*"/>- </library>- </runtime>-- <requires>- <import plugin="lib-jakarta-poi"/>- <import plugin="nutch-extensionpoints"/>- <import plugin="lib-parsems"/>- </requires>-- <extension id="net.nutch.parse.mspowerpoint"- name="MSPowerPointParse"- point="org.apache.nutch.parse.Parser">- <implementation id="org.apache.nutch.parse.mspowerpoint.MSPowerPointParser"- class="org.apache.nutch.parse.mspowerpoint.MSPowerPointParser">- <parameter name="contentType" value="application/vnd.ms-powerpoint"/>- <parameter name="pathSuffix" value=""/>- </implementation>- </extension>--</plugin>diff --git a/src/plugin/parse-mspowerpoint/sample/README.txt b/src/plugin/parse-mspowerpoint/sample/README.txtdeleted file mode 100644index b6bfb23b8..000000000--- a/src/plugin/parse-mspowerpoint/sample/README.txt+++ /dev/null@@ -1,6 +0,0 @@-Directory to store PowerPoint samples.-If ther is a file "test.ppt" the testcase searches for a reference file "test.ppt.content"-to compare the extracted content.-Additionaly a file "test.ppt.meta" could be stored here to compair the meta information.---- Stephan Strittmatterdiff --git a/src/plugin/parse-mspowerpoint/sample/test.ppt b/src/plugin/parse-mspowerpoint/sample/test.pptdeleted file mode 100644index 8b5696889..000000000Binary files a/src/plugin/parse-mspowerpoint/sample/test.ppt and /dev/null differdiff --git a/src/plugin/parse-mspowerpoint/sample/test.ppt.content b/src/plugin/parse-mspowerpoint/sample/test.ppt.contentdeleted file mode 100644index 8a3f19598..000000000--- a/src/plugin/parse-mspowerpoint/sample/test.ppt.content+++ /dev/null@@ -1,19 +0,0 @@--Nutch Parser Test-My initial test file for the PowerPoint parser of nutch-Second page-Test-Of-PowerPoint-Extraction-Some Unicode-I do not know the content and I can not read it, just gathered from other ppt-files:-Презентация PowerPoint--Stephan Strittmatter │ル│ル│ル│ル Some Notes-│ル│ルTextmasterformate durch Klicken bearbeiten-Zweite Ebene-Dritte Ebene-Vierte Ebene-Fnfte Ebene-│ル│ル Notes of second pagediff --git a/src/plugin/parse-mspowerpoint/sample/test.ppt.meta b/src/plugin/parse-mspowerpoint/sample/test.ppt.metadeleted file mode 100644index 79cf15775..000000000--- a/src/plugin/parse-mspowerpoint/sample/test.ppt.meta+++ /dev/null@@ -1,2 +0,0 @@-Title: Test-Outlinks: 0diff --git a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/ContentReaderListener.java b/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/ContentReaderListener.javadeleted file mode 100644index 1c209941c..000000000--- a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/ContentReaderListener.java+++ /dev/null@@ -1,431 +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.mspowerpoint;--import java.util.Enumeration;-import java.util.Hashtable;-import java.util.List;-import java.util.Vector;--import org.apache.commons.logging.Log;-import org.apache.commons.logging.LogFactory;--import org.apache.poi.hdf.extractor.Utils;-import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;-import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;-import org.apache.poi.poifs.filesystem.DocumentInputStream;-import org.apache.poi.util.LittleEndian;-import org.apache.poi.util.StringUtil;--/**- * Listener to read the content of PowerPoint file and transfere it to the- * passed <code>StringBuffer</code>.- *- * @author Stephan Strittmatter - http://www.sybit.de- *- * @version 1.0- *- */-class ContentReaderListener implements POIFSReaderListener {-- private static final Log LOG = LogFactory.getLog(ContentReaderListener.class);-- /** Buffer holding the content of the file */- protected final transient StringBuffer buf;-- /**- * Constructs Listener to get content of PowerPoint file.- *- * @param content- * StringBuffer refereing the content of the PowerPoint file.- */- public ContentReaderListener(final StringBuffer content) {- this.buf = content;- }-- /**- * Reads the internal PowerPoint document stream.- *- * @see org.apache.poi.poifs.eventfilesystem.POIFSReaderListener#processPOIFSReaderEvent(org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent)- */- public void processPOIFSReaderEvent(final POIFSReaderEvent event) {-- if (event == null || event.getName() == null- || !event.getName().startsWith(PPTConstants.POWERPOINT_DOCUMENT)) {- if (LOG.isWarnEnabled()) {- LOG.warn("Stream not processed. It is not a PowerPoint document: : "- + event.getName());- }- return;- }-- try {- final DocumentInputStream dis = event.getStream();- final byte pptdata[] = new byte[dis.available()];- dis.read(pptdata, 0, dis.available());- int offset = 0;- long offsetPD = 0;-- /*- * Traverse Bytearray to get CurrentUserEditAtom Call to extract the Text- * in all PlaceHolders to hold PPTClientTextBox objects for mapping into- * Slide Objects- */- Hashtable/* <Long, TextBox> */containerTextBox = new Hashtable/*- * <Long,- * TextBox>- */();- // Traverse ByteArray to identiy edit paths of ClientTextBoxes- long n = pptdata.length - 20;- for (long i = 0; i < n; i++) {-- final long type = LittleEndian.getUShort(pptdata, (int) i + 2);- // final long size = LittleEndian.getUInt(pptdata, (int) i + 4);-- if (PPTConstants.PPT_ATOM_USEREDIT == type) {- /*- * Checking the Record Header (UserEditAtom)- */- // final long lastSlideID = LittleEndian.getInt(pptdata, (int) i + 8);- // final long version = LittleEndian.getUInt(pptdata, (int) i + 12);- offset = (int) LittleEndian.getUInt(pptdata, (int) i + 16);- offsetPD = LittleEndian.getUInt(pptdata, (int) i + 20);-- /*- * Call to extract ClientTextBox text in each UserEditAtom- */- containerTextBox = extractTextBoxes(containerTextBox, offset,- pptdata, offsetPD);- } else if (PPTConstants.PPT_ATOM_DRAWINGGROUP == type) {- // if (LOG.isTraceEnabled()) {- // LOG.trace("PPT_DRAWINGGROUP_ATOM ignored: " + type);- // }- } else if (PPTConstants.PPT_ATOM_TEXTBYTE == type) {- // if (LOG.isTraceEnabled()) {- // LOG.trace("PPT_TEXTBYTE_ATOM ignored: " + type);- // }- } else if (PPTConstants.PPT_ATOM_TEXTCHAR == type) {- // if (LOG.isTraceEnabled()) {- // LOG.trace("PPT_TEXTCHAR_ATOM ignored: " + type);- // }- } else {- // no action- // if (LOG.isTraceEnabled()) {- // LOG.trace("type not handled: " + type);- // }- }- }-- final List/* <PPTSlide> */slides = extractSlides(offset, pptdata,- offsetPD);-- if (slides.size() == 0) {- if (LOG.isInfoEnabled()) { LOG.info("No slides extracted!"); }-- } else {- Slide slide = (Slide) slides.get(slides.size() - 1);-- for (Enumeration enumeration = containerTextBox.elements(); enumeration- .hasMoreElements();) {- final TextBox textBox = (TextBox) enumeration.nextElement();- slide.addContent(textBox.getContent());- }-- /*- * Merging TextBox data with Slide Data Printing the text from Slides- * vector object.- */- List scontent;- for (int i = 0; i < slides.size(); i++) {- slide = (Slide) slides.get(i);- scontent = slide.getContent();- String contentText;-- for (int j = 0; j < scontent.size(); j++) {- contentText = scontent.get(j).toString();- this.buf.append(contentText);-- // to avoid concatinated words we add a blank additional- if (contentText.length() > 0- && !(contentText.endsWith("\r") || contentText.endsWith("\n"))) {- this.buf.append(" ");- }- }- }- }- } catch (Throwable ex) {- // because of not killing complete crawling all Throwables are catched.- if (LOG.isErrorEnabled()) { LOG.error("processPOIFSReaderEvent", ex); }- }- }-- /**- * Extracts the client text boxes of a slide.- *- * @param containerTextBox- * @param offset- * @param pptdata- * @param offsetPD- * @return Hashtable- * @see TextBox- */- protected Hashtable/* <Long, TextBox> */extractTextBoxes(- final Hashtable/* <Long, TextBox> */containerTextBox, final int offset,- final byte[] pptdata, final long offsetPD) {-- // To hold temporary data- FilteredStringWriter outStream = new FilteredStringWriter();-- TextBox textBox;-- // Traversing the bytearray up to Presist directory position- for (int i = offset; i < offsetPD - 20; i++) {- try {- // Record info- // final long rinfo = LittleEndian.getUShort(pptdata, (int) i);- // Record Type- final long recordType = LittleEndian.getUShort(pptdata, i + 2);- // Record Size- final long recordSize = LittleEndian.getUInt(pptdata, i + 4);-- if (recordType == PPTConstants.PPT_ATOM_DRAWINGGROUP) {- /*- * Record type is of Drawing Group- */-- // Total number of objects- // final long objectCount = LittleEndian.getUInt(pptdata, (int) i +- // 8);- // currentID = Group ID+number of objects- long currentID = LittleEndian.getInt(pptdata, i + 12);- currentID = ((int) (currentID / 1024)) * 1024;-- if (currentID == PPTConstants.PPT_MASTERSLIDE) {- // Ignore Master Slide objects- if (LOG.isTraceEnabled()) { LOG.trace("Ignore master slide."); }- i++;- continue;- }-- // Check for the ClientTextBox GroupID existence- if (containerTextBox.containsKey(new Long(currentID))) {- // If exists get Client Textbox Group- textBox = (TextBox) containerTextBox.get(new Long(currentID));- textBox.setContent("");-- } else {- textBox = new TextBox(currentID);- containerTextBox.put(new Long(currentID), textBox);- }-- /*- * Iterating the bytearray for TextCharAtoms and TextBytesAtom- */- if ((offsetPD - 20) != recordSize) {- // TODO something wrong? Probably an OLE-Object, which we ignore.- if (LOG.isDebugEnabled()) {- LOG.debug("offsetPD - 20=" + (offsetPD - 20) + " recordsize="- + recordSize);- }- } else {- for (int startPos = i + 8; startPos < offsetPD - 20- && startPos < recordSize; startPos++) { // && startPos <- // recordSize??- try {-- // Record info- // final long nrinfo = LittleEndian.getUShort(pptdata, (int) j);-- // Record Type- final long ntype = LittleEndian- .getUShort(pptdata, startPos + 2);-- // Record size- // Note that the size doesn't include the 8 byte atom header- final long nsize = LittleEndian.getUInt(pptdata, startPos + 4);-- if (ntype == PPTConstants.PPT_ATOM_DRAWINGGROUP) {- /*- * Break the loop if next GroupID found- */- i = startPos - 1;- break;- } else if (ntype == PPTConstants.PPT_ATOM_TEXTBYTE) {- // TextByteAtom record- outStream = new FilteredStringWriter();- long ii = 0;- for (ii = startPos + 6; ii <= startPos + 6 + nsize; ii++) {- // For loop to changed to a function- // if ((ii + 2) >= pptdata.length)- // break; // FIXME- outStream.write((char) (pptdata[(int) ii + 2]));- }-- // Setting the identified text for Current- // groupID- textBox.setContent(textBox.getContent()- + outStream.toString());-- } else if (ntype == PPTConstants.PPT_ATOM_TEXTCHAR) {- // TextCharAtom record-- final String strTempContent = new String(pptdata,- startPos + 6, (int) (nsize) + 2);- final byte bytes[] = strTempContent.getBytes();- if (true) {- outStream = new FilteredStringWriter();- for (int ii = 0; ii < bytes.length - 1; ii += 2) {- // For loop to changed to a function- outStream.write((char) (pptdata[ii + 2]));- }- textBox.setContent(textBox.getContent()- + outStream.toString());- } else {- // this version is used within POI- String text = StringUtil.getFromCompressedUnicode(bytes, 0,- bytes.length);- textBox.setContent(textBox.getContent() + text);- }-- } else {- // ignored- // if (LOG.isTraceEnabled()) {- // LOG.trace("Ignored atom type: " + type);- // }- }- } catch (Throwable e) {- if (LOG.isErrorEnabled()) { LOG.error("extractTextBoxes", e); }- break;- }- }- }- } else {- // Record type is ignored- // if (LOG.isTraceEnabled()) {- // LOG.trace("Ignored record type: " + type);- // }- }- } catch (Throwable ee) {- if (LOG.isErrorEnabled()) { LOG.error("extractClientTextBoxes", ee); }- break;- }- }- return containerTextBox;- }-- /**- * Returns the Powerpoint <code>Slide</code> s of document as vector.- *- * @param offset- * @param pptdata- * @param offsetPD- * @return Vector of the powerpoint slides. Contains- * <code>{@link Slide Slide}</code>- * @see Slide- */- protected List /* <Slide> */extractSlides(final long offset,- final byte[] pptdata, final long offsetPD) {-- int sNum = 0;-- // List of all slides found- final List/* <Slide> */slides = new Vector/* <Slide> */();-- // current slide data- Slide currentSlide = null;-- // To store data found in TextCharAtoms and TextBytesAtoms- FilteredStringWriter outStream;-- for (long i = offset; i < pptdata.length - 20; i++) {-- final long recordInfo = LittleEndian.getUShort(pptdata, (int) i);- final long atomType = LittleEndian.getUShort(pptdata, (int) i + 2);- final long atomSize = LittleEndian.getUInt(pptdata, (int) i + 4);-- if (atomType == PPTConstants.PPT_ATOM_TEXTBYTE) {- /*- * TextByteAtom record- */- outStream = new FilteredStringWriter();-- for (long ii = i + 6; (ii <= i + 6 + atomSize)- && (ii + 2 < pptdata.length); ii++) {- try {- // if(ii+2 >= pptdata.length) break; //FIXME- byte value = pptdata[(int) ii + 2];- outStream.write(value);- } catch (ArrayIndexOutOfBoundsException ex) {- if (LOG.isTraceEnabled()) { LOG.trace("size=" + pptdata.length); }- if (LOG.isErrorEnabled()) { LOG.error("extractSlides", ex); }- }- }-- // Setting the identified text for Current Slide- if (currentSlide != null) {- currentSlide.addContent(outStream.toString());- }-- } else if (atomType == PPTConstants.PPT_ATOM_TEXTCHAR) {- /*- * TextCharAtom record- */- outStream = new FilteredStringWriter();- final String strTempContent = new String(pptdata, (int) i + 6,- (int) (atomSize) + 2);- final byte bytes[] = strTempContent.getBytes();-- for (int ii = 0; ii < bytes.length - 1; ii += 2) {- outStream.write(Utils.getUnicodeCharacter(bytes, ii));- }-- // Setting the identified text for Current Slide- if (currentSlide != null) {- currentSlide.addContent(outStream.toString());- }-- } else if (atomType == PPTConstants.PPT_ATOM_SLIDEPERSISTANT) {- /*- * SlidePresistAtom Record- */- if (sNum != 0) {- outStream = new FilteredStringWriter();-- final long slideID = LittleEndian.getUInt(pptdata, (int) i + 20);-- currentSlide = new Slide(slideID);- // currentSlide.addContent(outStream.toString());- slides.add(currentSlide);- }- sNum++;- } else if (atomType == PPTConstants.PPT_ATOM_DRAWINGGROUP) {- /*- * Diagram records are ignored- */- if (LOG.isTraceEnabled()) { LOG.trace("Drawing Groups are ignored."); }- break;- } else {- // ignored- // if (LOG.isTraceEnabled()) {- // LOG.trace("Unhandled atomType: " + atomType);- // }- }- }-- return slides;- }-}diff --git a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/FilteredStringWriter.java b/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/FilteredStringWriter.javadeleted file mode 100644index 03b196b10..000000000--- a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/FilteredStringWriter.java+++ /dev/null@@ -1,70 +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.mspowerpoint;--import java.io.StringWriter;--/**- * Writes to optimize ASCII output. Not needed chars are filtered (ignored).- *- * @author Stephan Strittmatter - http://www.sybit.de- * @version 1.0- */-public class FilteredStringWriter extends StringWriter {-- /**- * @see StringWriter#StringWriter()- */- public FilteredStringWriter() {- super();- }-- /**- * @param initialSize- * @see StringWriter#StringWriter(int)- */- public FilteredStringWriter(final int initialSize) {- super(initialSize);- }-- /**- * Chars which are not useful for Nutch indexing are filtered (ignored) on- * writing to the writer.- *- * @see java.io.Writer#write(int)- */- public void write(final int ch) {- if (ch == '\r') {- // PowerPoint seems to store files with \r as the line break- // -> unify to platform specific format- super.write(System.getProperty("line.separator"));- } else if (ch == 0) {- super.write(System.getProperty("line.separator"));- } else if (ch == '\b') {- // ignore it- } else if (Character.isISOControl((char) ch)) {- // replace by blank- // super.write(' ');- } else if (Character.isWhitespace((char) ch)) {- // unify to blank- super.write(' ');- } else {- super.write(ch);- }- }-}diff --git a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/MSPowerPointParser.java b/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/MSPowerPointParser.javadeleted file mode 100644index 4140fa317..000000000--- a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/MSPowerPointParser.java+++ /dev/null@@ -1,55 +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.mspowerpoint;--// Nutch imports-import org.apache.nutch.parse.ParseResult;-import org.apache.nutch.parse.ms.MSBaseParser;-import org.apache.nutch.protocol.Content;---/**- * Nutch-Parser for parsing MS PowerPoint slides ( mime type:- * application/vnd.ms-powerpoint).- * <p>- * It is based on org.apache.poi.*.- *- * @author Stephan Strittmatter - http://www.sybit.de- * @author Jérôme Charron- * @see <a href="http://jakarta.apache.org/poi">Jakarta POI</a>- */-public class MSPowerPointParser extends MSBaseParser {-- /**- * Associated Mime type for PowerPoint files- * (<code>application/vnd.ms-powerpoint</code>).- */- public static final String MIME_TYPE = "application/vnd.ms-powerpoint";--- public ParseResult getParse(final Content content) {- return getParse(new PPTExtractor(), content);- }-- /**- * Main for testing. Pass a powerpoint document as argument- */- public static void main(String args[]) {- main(MIME_TYPE, new MSPowerPointParser(), args);- }--}diff --git a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/PPTConstants.java b/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/PPTConstants.javadeleted file mode 100644index f5a69b015..000000000--- a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/PPTConstants.java+++ /dev/null@@ -1,63 +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.mspowerpoint;--/**- * Package protected class for the required internal MS PowerPoint constants.- *- * @author Stephan Strittmatter - http://www.sybit.de- *- * @version 1.0- */-class PPTConstants {-- /** ID of master slide */- public static final long PPT_MASTERSLIDE = 1024L;-- /** ATOM ID of slide */- public static long PPT_ATOM_SLIDE = 1007l;-- /** ATOM ID of notes */- public static final long PPT_ATOM_NOTES = 1009L;-- /** ATOM ID of persistend slide */- public static final long PPT_ATOM_SLIDEPERSISTANT = 1011L;-- /** ATOM ID of text char area. Holds text in byte swapped unicode form. */- public static final long PPT_ATOM_TEXTCHAR = 4000L;-- /** ATOM ID of text byte area. Holds text in ascii form */- public static final long PPT_ATOM_TEXTBYTE = 4008L;-- /** ATOM ID of user edit area */- public static final long PPT_ATOM_USEREDIT = 4085L;-- /** ATOM ID of drawing group area */- public static final long PPT_ATOM_DRAWINGGROUP = 61448L;-- /** Name for PowerPoint Documents within the file */- public static final String POWERPOINT_DOCUMENT = "PowerPoint Document";---- /**- * Protected constructor to prevent instantiation.- */- protected PPTConstants() {- // nothing- }-}\ No newline at end of filediff --git a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/PPTExtractor.java b/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/PPTExtractor.javadeleted file mode 100644index 6b2f91c0f..000000000--- a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/PPTExtractor.java+++ /dev/null@@ -1,57 +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.mspowerpoint;--// JDK imports-import java.io.IOException;-import java.io.InputStream;--// Nutch imports-import org.apache.nutch.parse.ms.MSExtractor;--// Jakarta POI imports-import org.apache.poi.poifs.eventfilesystem.POIFSReader;---/**- * Converts the Powerpoint document content to plain text.- *- * @author Stephan Strittmatter - http://www.sybit.de- * @author Jérôme Charron- */-class PPTExtractor extends MSExtractor {-- private StringBuffer text = null;- private POIFSReader reader = null;--- protected String extractText(InputStream input) throws Exception {- this.reader = new POIFSReader();- this.text = new StringBuffer();- reader.registerListener(- new ContentReaderListener(this.text),- PPTConstants.POWERPOINT_DOCUMENT);- input.reset();- if (input.available() > 0) {- this.reader.read(input);- } else if (LOG.isWarnEnabled()) {- LOG.warn("Input <=0 :" + input.available());- }- return (this.text != null) ? text.toString() : null;- }--}diff --git a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/Slide.java b/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/Slide.javadeleted file mode 100644index b5202341f..000000000--- a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/Slide.java+++ /dev/null@@ -1,74 +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.mspowerpoint;--import java.util.List;-import java.util.Vector;--/**- * Package protected class for a MS Powerpoint slide.- *- * @author Stephan Strittmatter - http://www.sybit.de- *- * @version 1.0- */-class Slide {--- /** Holds the Slide Number */- protected transient final long slideNumber;-- /** Holds the contents of the Slide */- protected transient final List/* <String> */contents;-- /**- * Initialise the Object for holding the contents of Power Point Slide- *- * @param number- */- public Slide(long number) {- this.slideNumber = number;- this.contents = new Vector/* <String> */();- }-- /**- * Add the Content of Slide to this Object- *- * @param content- */- public void addContent(String content) {- this.contents.add(content);- }-- /**- * returns the contents of slide as a vector object- *- * @return Vector- */- public List getContent() {- return this.contents;- }-- /**- * returns the slide value- *- * @return long- */- public long getSlideNumber() {- return this.slideNumber;- }-}\ No newline at end of filediff --git a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/TextBox.java b/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/TextBox.javadeleted file mode 100644index 27e84c8c8..000000000--- a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/TextBox.java+++ /dev/null@@ -1,89 +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.mspowerpoint;--/**- * Package protected class for the MS Powerpoint TextBox content- *- * @author Stephan Strittmatter - http://www.sybit.de- *- * @version 1.0- */-class TextBox {-- /**- * Current id of a text box- */- protected transient final long currentID;-- /**- * Content of text box- */- protected String content;-- /**- * Instantiates the text box object- *- * @param textBoxId- * id of text box- */- public TextBox(final long textBoxId) {- this.currentID = textBoxId;- this.content = "";- }-- /**- * Instantiates the text box object- *- * @param textBoxId- * id of text box- * @param content- * content of text box- */- public TextBox(final long textBoxId, final String content) {- this.currentID = textBoxId;- this.content = content;- }-- /**- * Sets the content of the text box- *- * @param content- * content of text Box- */- public void setContent(final String content) {- this.content = content;- }-- /**- * Returns the content of the text box- *- * @return content of text box- */- public String getContent() {- return this.content;- }-- /**- * Returns the current text box id- *- * @return long- */- public long getCurrentId() {- return this.currentID;- }-}\ No newline at end of filediff --git a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/package.html b/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/package.htmldeleted file mode 100644index a9339b51b..000000000--- a/src/plugin/parse-mspowerpoint/src/java/org/apache/nutch/parse/mspowerpoint/package.html+++ /dev/null@@ -1,37 +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.- */--->-<html>- <head>- <title>Microsoft PowerPoint document parsing plugin.</title>- </head>- <body>- <p>A Microsoft © PowerPoint document parsing plugin.</p>- <p>This package relies on Jakarta- <a href="http://jakarta.apache.org/poi/index.html">POI</a>.- </p>- <p> Implementation based on sources found at <a- href="http://groups.google.com/groups?selm=a4f8800541bc694d5af7dabb35e83b72%40localhost.talkaboutsoftware.com">Google- Groups </a>. It can also be found at <a- href="http://www.mail-archive.com/[email protected]/msg04809.html">http://www.mail-archive.com/[email protected]/msg04809.html</a>- written by Hari Shanker and Sudhakar Chavali. Thanks for the basic- work!</p>- <p>I changed these classes to support also Unicode content and- optimized them for Nuch.</p>- </body>-</html>\ No newline at end of filediff --git a/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/AllTests.java b/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/AllTests.javadeleted file mode 100644index d2253ab06..000000000--- a/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/AllTests.java+++ /dev/null@@ -1,88 +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.mspowerpoint;--import java.io.File;--import junit.framework.Test;-import junit.framework.TestCase;-import junit.framework.TestSuite;--/**- * @author Stephan Strittmatter - http://www.sybit.de- *- * @version 1.0- */-public class AllTests {-- /** This system property is defined in ./src/plugin/build-plugin.xml */- private final static String SAMPLE_DIR = System.getProperty("test.data",- "build/parse-mspowerpoint/test/data");-- /**- * Main to run the test- *- * @param args- * not required- */- public static void main(String[] args) {- junit.textui.TestRunner.run(AllTests.suite());- }-- /**- * @return Test for the PowerPoint plugin- */- public static Test suite() {- final TestSuite suite = new TestSuite(- "Test for org.apache.nutch.parse.mspowerpoint");-- System.out.println("Testing with ppt-files of dir: " + SAMPLE_DIR);-- final File sampleDir = new File(SAMPLE_DIR);-- //find all ppt-files in the test-directory- final FileExtensionFilter pptFilter = new FileExtensionFilter(".ppt");- final String[] pptFiles = sampleDir.list(pptFilter);-- if(pptFiles== null)- {- throw new IllegalArgumentException(SAMPLE_DIR + " does not contain any files: " + pptFilter);- }- TestSuite suiteAllFiles;--- // iterate over all ppt-files which are found and test against them- for (int i = 0; i < pptFiles.length; i++) {- //test the content...- suiteAllFiles = new TestSuite("Testing file [" + pptFiles[i] + "]");- TestCase test = new TestMSPowerPointParser(new File(pptFiles[i]));- test.setName("testContent");-- suiteAllFiles.addTest(test);-- //..then the properties- TestCase test2 = new TestMSPowerPointParser(new File(pptFiles[i]));- test2.setName("testMeta");- suiteAllFiles.addTest(test2);-- suite.addTest(suiteAllFiles);- }-- return suite;- }-}\ No newline at end of filediff --git a/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/FileExtensionFilter.java b/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/FileExtensionFilter.javadeleted file mode 100644index 5478e3b2d..000000000--- a/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/FileExtensionFilter.java+++ /dev/null@@ -1,56 +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.mspowerpoint;--import java.io.File;-import java.io.FilenameFilter;--/**- * Helper class to filter for specific files to test them.- *- * @author Stephan Strittmatter - http://www.sybit.de- *- * @version 1.0- */-/* package protected */class FileExtensionFilter implements FilenameFilter {- private String ext = "*";-- /**- * @param ext- */- public FileExtensionFilter(String ext) {- this.ext = ext;- }-- /* (non-Javadoc)- * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)- */- public boolean accept(File dir, String name) {- if (name.endsWith(this.ext))- return true;- return false;- }-- /* (non-Javadoc)- * @see java.lang.Object#toString()- */- public String toString() {- // TODO Auto-generated method stub- return this.ext;- }-}\ No newline at end of filediff --git a/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/TestMSPowerPointParser.java b/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/TestMSPowerPointParser.javadeleted file mode 100644index 31acbd27c..000000000--- a/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/TestMSPowerPointParser.java+++ /dev/null@@ -1,263 +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.mspowerpoint;--import java.io.BufferedReader;-import java.io.File;-import java.io.FileInputStream;-import java.io.FileOutputStream;-import java.io.IOException;-import java.io.InputStreamReader;-import java.io.OutputStreamWriter;--import junit.framework.TestCase;--import org.apache.commons.logging.Log;-import org.apache.commons.logging.LogFactory;--import org.apache.nutch.parse.Parse;-import org.apache.nutch.parse.ParseData;-import org.apache.nutch.parse.ParseUtil;-import org.apache.nutch.protocol.Content;-import org.apache.nutch.protocol.Protocol;-import org.apache.nutch.protocol.ProtocolFactory;-import org.apache.nutch.util.NutchConfiguration;--import org.apache.hadoop.io.Text;-import org.apache.nutch.crawl.CrawlDatum;--/**- * <p>- * Unit tests for MSPowerPointParser.- * </p>- * <p>- * Make sure sample files are copied to "test.data" as specified in- * ./src/plugin/parse-mspowerpoint/build.xml during plugin compilation. Check- * ./src/plugin/parse-mspowerpoint/sample/README.txt for what they are.- * </p>- *- * @author Stephan Strittmatter - http://www.sybit.de- *- * @version 1.0- */-public class TestMSPowerPointParser extends TestCase {- private static final Log LOG = LogFactory.getLog(TestMSPowerPointParser.class);-- private static final String CHARSET = "UTF-8";-- private final static String LINE_SEPARATOR = System.getProperty("line.separator");-- /** This system property is defined in ./src/plugin/build-plugin.xml */- private final static String SAMPLE_DIR = System.getProperty("test.data",- "build/parse-mspowerpoint/test/data");-- private final File sampleDir = new File(SAMPLE_DIR);-- /**- * Wether dumping the extracted data to file for visual checks.- */- private final static boolean DUMP_TO_FILE = false;-- private final File testFile;-- private String urlString;-- private Protocol protocol;-- private Content content;-- /**- *- * @param name- */- public TestMSPowerPointParser(String name) {- super(name);- this.testFile = new File(this.sampleDir, "test.ppt");- }-- /**- * @param file- */- public TestMSPowerPointParser(File file) {- super();- this.testFile = file;- }-- /**- * @see TestCase#setUp()- */- protected void setUp() throws Exception {- super.setUp();-- this.urlString = createUrl(this.testFile.getName());-- System.out.println("Testing file: " + this.urlString + "...");- this.protocol =new ProtocolFactory(NutchConfiguration.create()).getProtocol(this.urlString);- this.content = this.protocol.getProtocolOutput(new Text(this.urlString), new CrawlDatum()).getContent();- }-- /**- * @see TestCase#tearDown()- */- protected void tearDown() throws Exception {- super.tearDown();- }-- /**- * Testing all available ppt-docs stored in dir <code>SAMPLE_DIR</code> if- * parsable without exceptions.- *- * @see #SAMPLE_DIR- * @throws Exception- */- public void testContent() throws Exception {-- Parse parse = new ParseUtil(NutchConfiguration.create())- .parseByExtensionId("parse-mspowerpoint", this.content)- .get(this.content.getUrl());-- ParseData data = parse.getData();- String text = parse.getText();-- assertTrue("No content extracted length ==0", text.length() > 0);-- this.dumpToFile(this.testFile.getName(), data, text);-- final FileExtensionFilter contentFilter = new FileExtensionFilter(- this.testFile.getName() + ".content");- final File[] contentFiles = this.sampleDir.listFiles(contentFilter);-- if (contentFiles.length > 0) {- String testContent = this.fileToString(contentFiles[0]);-- for (int i = 0; i < text.length(); i++) {- char parsedChar = text.charAt(i);- char testChar = testContent.charAt(i);- assertEquals("Wrong char at position [" + i + "]", "" + testChar, ""- + parsedChar);- }- } else {- LOG.info("Comparison file for Content not available: "- + this.testFile.getName() + ".content");- }- }-- /**- * Testing all available ppt-docs stored in dir <code>SAMPLE_DIR</code> if- * parsable without exceptions.- *- * @see #SAMPLE_DIR- * @throws Exception- */- public void testMeta() throws Exception {-- Parse parse = new ParseUtil(NutchConfiguration.create())- .parseByExtensionId("parse-mspowerpoint", content)- .get(content.getUrl());-- ParseData data = parse.getData();-- final FileExtensionFilter titleFilter = new FileExtensionFilter(- this.testFile.getName() + ".meta");- final File[] titleFiles = this.sampleDir.listFiles(titleFilter);-- if (titleFiles.length > 0) {- assertEquals("Document Title", this.fileToString(titleFiles[0]),- "Title: " + data.getTitle() + LINE_SEPARATOR +- "Outlinks: " + data.getOutlinks().length + LINE_SEPARATOR);- } else {- assertTrue("Document Title length ==0", data.getTitle().length() > 0);- LOG.info("Comparison file for Title not available: "- + this.testFile.getName() + ".meta");- }- }-- /**- * create complete url- *- * @param fileName- * name of the file- * @return complete url.- */- private String createUrl(final String fileName) {- return "file:" + SAMPLE_DIR + "/" + fileName;- }-- /**- * Dump the parsed data to a UTF-8 formatted file for visual checks.- *- * @param data- * @param text- * @param fileName- * @throws IOException- */- private void dumpToFile(final String fileName, final ParseData data,- final String text) throws IOException {- if (TestMSPowerPointParser.DUMP_TO_FILE) {-- final File file = new File(fileName + ".txt");-- final FileOutputStream fos = new FileOutputStream(file);- final OutputStreamWriter osw = new OutputStreamWriter(fos, CHARSET);-- osw.write(data.toString());- osw.write(text);-- osw.close();- fos.close();- }- }-- /**- * Load the testfiles for comparison.- *- * @param file- * file to load- * @return UNF-8 encoded String content of file.- * @throws IOException- */- private String fileToString(final File file) throws IOException {- FileInputStream fis = null;- //InputStreamReader isr = null;- BufferedReader br = null;- final StringBuffer buf = new StringBuffer();-- try {- fis = new FileInputStream(file);- br = new BufferedReader(new InputStreamReader(fis, CHARSET));-- String line = br.readLine();- while (line != null) {- buf.append(line).append(LINE_SEPARATOR);- line = br.readLine();- }- } finally {- if (br != null) {- br.close();- }- if (fis != null) {- fis.close();- }- }-- String val = buf.toString();-- return val;- }--}diff --git a/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/package.html b/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/package.htmldeleted file mode 100644index a8e81bc18..000000000--- a/src/plugin/parse-mspowerpoint/src/test/org/apache/nutch/parse/mspowerpoint/package.html+++ /dev/null@@ -1,45 +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.- */--->-<html>- <head>- <title>Testing Package of Microsoft PowerPoint document parsing plugin.</title>- </head>- <body>- <h1>JUnit Testpackage for Microsoft © PowerPoint document parsing- plugin.</h1>- <p>The example ppt-files are located in the subdirectory- <code>src/plugins/parse-mspowerpoint/samples</code>. They are- copied by the ant-task to the directory- <code>src/plugins/parse-mspowerpoint/data</code> for testing.- Additionaly to the ppt-files, there could also be stored files with- the same name with postfix ".content" or ".title". If they exists,- the test classes are checking the extracted content against these- files.</p>- <h3>Example</h3>- <p>- <ul>- <li>PowerPoint file to test: <code>test.ppt</code></li>- <li>Reference file with content:- <code>test.ppt.content</code></li>- <li> Reference file with title and properties:- <code>test.ppt.title</code></li>- </ul>- </p>- </body>-</html>\ No newline at end of filediff --git a/src/plugin/parse-msword/build.xml b/src/plugin/parse-msword/build.xmldeleted file mode 100644index 5a0f40ca6..000000000--- a/src/plugin/parse-msword/build.xml+++ /dev/null@@ -1,51 +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-msword" default="jar-core">-- <import file="../build-plugin.xml"/>-- <!-- Build compilation dependencies -->- <target name="deps-jar">- <ant target="jar" inheritall="false" dir="../lib-jakarta-poi"/>- <ant target="jar" inheritall="false" dir="../lib-parsems"/>- </target>-- <!-- Add compilation dependencies to classpath -->- <path id="plugin.deps">- <fileset dir="${nutch.root}/build">- <include name="**/lib-jakarta-poi/*.jar" />- <include name="**/lib-parsems/*.jar" />- </fileset>- </path>-- <!-- Deploy Unit test dependencies -->- <target name="deps-test">- <ant target="deploy" inheritall="false" dir="../lib-jakarta-poi"/>- <ant target="deploy" inheritall="false" dir="../lib-parsems"/>- <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 todir="${build.test}/data">- <fileset dir="sample" includes="*.doc" />- </copy>--</project>diff --git a/src/plugin/parse-msword/plugin.xml b/src/plugin/parse-msword/plugin.xmldeleted file mode 100644index fd7de6f32..000000000--- a/src/plugin/parse-msword/plugin.xml+++ /dev/null@@ -1,47 +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-msword"- name="MSWord Parse Plug-in"- version="1.0.0"- provider-name="nutch.org">-- <runtime>- <library name="parse-msword.jar">- <export name="*"/>- </library>- </runtime>-- <requires>- <import plugin="nutch-extensionpoints"/>- <import plugin="lib-jakarta-poi"/>- <import plugin="lib-parsems"/>- </requires>-- <extension id="org.apache.nutch.parse.msword"- name="MSWordParse"- point="org.apache.nutch.parse.Parser">-- <implementation id="org.apache.nutch.parse.msword.MSWordParser"- class="org.apache.nutch.parse.msword.MSWordParser">- <parameter name="contentType" value="application/msword"/>- <parameter name="pathSuffix" value=""/>- </implementation>- </extension>--</plugin>diff --git a/src/plugin/parse-msword/sample/README.txt b/src/plugin/parse-msword/sample/README.txtdeleted file mode 100644index 6321d0d7a..000000000--- a/src/plugin/parse-msword/sample/README.txt+++ /dev/null@@ -1,9 +0,0 @@-20040710, John Xing--./word95.doc: Microsoft Word 95 file created with OpenOffice.org 1.1-./word97.doc: Microsoft Word 97/2000/XP file created with OpenOffice.org 1.1--Used for junit test by ./src/test/org/apache/nutch/parse/msword/TestMSWordParser.java--They all contain text:-This is a sample doc file prepared for nutch.diff --git a/src/plugin/parse-msword/sample/word95.doc b/src/plugin/parse-msword/sample/word95.docdeleted file mode 100644index b4a4096cb..000000000Binary files a/src/plugin/parse-msword/sample/word95.doc and /dev/null differdiff --git a/src/plugin/parse-msword/sample/word97.doc b/src/plugin/parse-msword/sample/word97.docdeleted file mode 100644index 4d012da9c..000000000Binary files a/src/plugin/parse-msword/sample/word97.doc and /dev/null differdiff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/FastSavedException.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/FastSavedException.javadeleted file mode 100644index 79f124d75..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/FastSavedException.java+++ /dev/null@@ -1,24 +0,0 @@-/* Copyright 2004 Ryan Ackley- *- * Licensed 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.msword;---public class FastSavedException extends Exception {-- public FastSavedException(String msg) {- super(msg);- }--}diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/MSWordParser.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/MSWordParser.javadeleted file mode 100644index d7af06179..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/MSWordParser.java+++ /dev/null@@ -1,54 +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.msword;--// Nutch imports-import org.apache.nutch.protocol.Content;-import org.apache.nutch.parse.ParseResult;-import org.apache.nutch.parse.ms.MSBaseParser;---/**- * Parser for mime type application/msword.- * It is based on org.apache.poi.*. We have to see how well it performs.- *- * @author John Xing- * @author Andy Hedges- * @author Jérôme Charron- */--public class MSWordParser extends MSBaseParser {-- /**- * Associated Mime type for Word files- * (<code>application/msword</code>).- */- public static final String MIME_TYPE = "application/msword";--- public ParseResult getParse(Content content) {- return getParse(new WordExtractor(), content);- }-- /**- * Main for testing. Pass an word document as argument- */- public static void main(String args[]) {- main(MIME_TYPE, new MSWordParser(), args);- }--}diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/PasswordProtectedException.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/PasswordProtectedException.javadeleted file mode 100644index 424d36fb7..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/PasswordProtectedException.java+++ /dev/null@@ -1,24 +0,0 @@-/* Copyright 2004 Ryan Ackley- *- * Licensed 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.msword;---public class PasswordProtectedException extends Exception {-- public PasswordProtectedException(String msg) {- super(msg);- }--}diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/Test.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/Test.javadeleted file mode 100644index 7b4438e2f..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/Test.java+++ /dev/null@@ -1,54 +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.msword;--import java.io.*;-/**- * Title:- * Description:- * Copyright: Copyright (c) 2003- * Company:- * @author- * @version 1.0- */--class Test-{-- public Test()- {- }- public static void main(String[] args)- {- try- {- WordExtractor extractor = new WordExtractor();- String s = extractor.extractText(new FileInputStream(args[0]));- System.out.println(s);- //OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream("C:\\test.txt"), "UTF-16LE");- OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream("./test.txt"));- out.write(s);- out.flush();- out.close();- }- catch (Exception e)- {- e.printStackTrace();- }- }-}diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/Word6Extractor.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/Word6Extractor.javadeleted file mode 100644index a0eabe5f3..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/Word6Extractor.java+++ /dev/null@@ -1,230 +0,0 @@-/* Copyright 2004 Ryan Ackley- *- * Licensed 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.msword;--import org.apache.nutch.parse.msword.chp.*;--import org.apache.poi.util.LittleEndian;-import org.apache.poi.hwpf.model.*;--import java.util.*;--/**- * This class is used to extract text from Word 6 documents only. It should- * only be called from the org.textmining.text.extraction.WordExtractor because- * it will automatically determine the version.- *- * @author Ryan Ackley- */-class Word6Extractor-{-- public Word6Extractor()- {- }-- /**- * Extracts the text- *- * @param mainStream The POIFS document stream entitled "WordDocument".- *- * @return The text from the document- * @throws Exception If there are any unexpected exceptions.- */- public String extractText(byte[] mainStream) throws Exception- {- int fcMin = LittleEndian.getInt(mainStream, 0x18);- int fcMax = LittleEndian.getInt(mainStream, 0x1C);-- int chpTableOffset = LittleEndian.getInt(mainStream, 0xb8);- int chpTableSize = LittleEndian.getInt(mainStream, 0xbc);-- // get a list of character properties-- Word6CHPBinTable chpTable = new Word6CHPBinTable(mainStream, chpTableOffset,- chpTableSize, fcMin, new TextPieceTable());- List textRuns = chpTable.getTextRuns();-- // iterate through the- WordTextBuffer finalTextBuf = new WordTextBuffer();- Iterator runsIt = textRuns.iterator();- while(runsIt.hasNext())- {- CHPX chpx = (CHPX)runsIt.next();- int runStart = chpx.getStart() + fcMin;- int runEnd = chpx.getEnd() + fcMin;-- if (!isDeleted(chpx.getGrpprl()))- {- String s = new String(mainStream, runStart, Math.min(runEnd, fcMax) - runStart, "Cp1252");- finalTextBuf.append(s);- if (runEnd >= fcMax)- {- break;- }- }- }-- return finalTextBuf.toString();- }-- /**- * Used to determine if a run of text has been deleted.- * @param grpprl The list of sprms for this run of text.- * @return- */- private boolean isDeleted(byte[] grpprl)- {- int offset = 0;- boolean deleted = false;- while (offset < grpprl.length)- {- switch (LittleEndian.getUnsignedByte(grpprl, offset++))- {- case 65:- deleted = grpprl[offset++] != 0;- break;- case 66:- offset++;- break;- case 67:- offset++;- break;- case 68:- offset += grpprl[offset];- break;- case 69:- offset += 2;- break;- case 70:- offset += 4;- break;- case 71:- offset++;- break;- case 72:- offset += 2;- break;- case 73:- offset += 3;- break;- case 74:- offset += grpprl[offset];- break;- case 75:- offset++;- break;- case 80:- offset += 2;- break;- case 81:- offset += grpprl[offset];- break;- case 82:- offset += grpprl[offset];- break;- case 83:- break;- case 85:- offset++;- break;- case 86:- offset++;- break;- case 87:- offset++;- break;- case 88:- offset++;- break;- case 89:- offset++;- break;- case 90:- offset++;- break;- case 91:- offset++;- break;- case 92:- offset++;- break;- case 93:- offset += 2;- break;- case 94:- offset++;- break;- case 95:- offset += 3;- break;- case 96:- offset += 2;- break;- case 97:- offset += 2;- break;- case 98:- offset++;- break;- case 99:- offset++;- break;- case 100:- offset++;- break;- case 101:- offset++;- break;- case 102:- offset++;- break;- case 103:- offset += grpprl[offset];- break;- case 104:- offset++;- break;- case 105:- offset += grpprl[offset];- break;- case 106:- offset += grpprl[offset];- break;- case 107:- offset += 2;- break;- case 108:- offset += grpprl[offset];- break;- case 109:- offset += 2;- break;- case 110:- offset += 2;- break;- case 117:- offset++;- break;- case 118:- offset++;- break;-- }- }- return deleted;- }-}diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordExtractor.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordExtractor.javadeleted file mode 100644index 7a4be2583..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordExtractor.java+++ /dev/null@@ -1,231 +0,0 @@-/* Copyright 2004 Ryan Ackley- *- * Licensed 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.msword;--// JDK imports-import java.io.InputStream;-import java.util.ArrayList;-import java.util.Iterator;-import java.util.List;--// Jakarta POI imports-import org.apache.poi.hwpf.model.CHPBinTable;-import org.apache.poi.hwpf.model.CHPX;-import org.apache.poi.hwpf.model.ComplexFileTable;-import org.apache.poi.hwpf.model.TextPiece;-import org.apache.poi.hwpf.model.TextPieceTable;-import org.apache.poi.hwpf.sprm.SprmIterator;-import org.apache.poi.hwpf.sprm.SprmOperation;-import org.apache.poi.poifs.filesystem.DocumentEntry;-import org.apache.poi.poifs.filesystem.DocumentInputStream;-import org.apache.poi.poifs.filesystem.POIFSFileSystem;-import org.apache.poi.util.LittleEndian;--// Nutch imports-import org.apache.nutch.parse.ms.MSExtractor;---/**- * This class extracts the text from a Word 6.0/95/97/2000/XP word doc- *- * @author Ryan Ackley- * @author Andy Hedges- * @author Jérôme Charron- *- */-class WordExtractor extends MSExtractor {--- /**- * Gets the text from a Word document.- *- * @param in The InputStream representing the Word file.- */- protected String extractText(InputStream in) throws Exception {-- ArrayList text = new ArrayList();- POIFSFileSystem fsys = new POIFSFileSystem(in);-- // load our POIFS document streams.- DocumentEntry headerProps =- (DocumentEntry)fsys.getRoot().getEntry("WordDocument");- DocumentInputStream din = fsys.createDocumentInputStream("WordDocument");- byte[] header = new byte[headerProps.getSize()];--- din.read(header);- din.close();-- int info = LittleEndian.getShort(header, 0xa);- if ((info & 0x4) != 0)- {- throw new FastSavedException("Fast-saved files are unsupported at this time");- }- if ((info & 0x100) != 0)- {- throw new PasswordProtectedException("This document is password protected");- }-- // determine the version of Word this document came from.- int nFib = LittleEndian.getShort(header, 0x2);- switch (nFib)- {- case 101:- case 102:- case 103:- case 104:- // this is a Word 6.0 doc send it to the extractor for that version.- Word6Extractor oldExtractor = new Word6Extractor();- return oldExtractor.extractText(header);- }-- //Get the information we need from the header- boolean useTable1 = (info & 0x200) != 0;-- //get the location of the piece table- int complexOffset = LittleEndian.getInt(header, 0x1a2);-- // determine which table stream we must use.- String tableName = null;- if (useTable1)- {- tableName = "1Table";- }- else- {- tableName = "0Table";- }-- DocumentEntry table = (DocumentEntry)fsys.getRoot().getEntry(tableName);- byte[] tableStream = new byte[table.getSize()];-- din = fsys.createDocumentInputStream(tableName);-- din.read(tableStream);- din.close();-- int chpOffset = LittleEndian.getInt(header, 0xfa);- int chpSize = LittleEndian.getInt(header, 0xfe);- int fcMin = LittleEndian.getInt(header, 0x18);-- // load our text pieces and our character runs- ComplexFileTable cft = new ComplexFileTable(header, tableStream, complexOffset, fcMin);- TextPieceTable tpt = cft.getTextPieceTable();- CHPBinTable cbt = new CHPBinTable(header, tableStream, chpOffset, chpSize, fcMin, tpt);-- List textPieces = tpt.getTextPieces();-- // make the POIFS objects available for garbage collection- din = null;- fsys = null;- table = null;- headerProps = null;-- List textRuns = cbt.getTextRuns();- Iterator runIt = textRuns.iterator();- Iterator textIt = textPieces.iterator();-- TextPiece currentPiece = (TextPiece)textIt.next();- int currentTextStart = currentPiece.getStart();- int currentTextEnd = currentPiece.getEnd();-- WordTextBuffer finalTextBuf = new WordTextBuffer();-- // iterate through all text runs extract the text only if they haven't been- // deleted- while (runIt.hasNext())- {- CHPX chpx = (CHPX)runIt.next();- boolean deleted = isDeleted(chpx.getGrpprl());- if (deleted)- {- continue;- }-- int runStart = chpx.getStart();- int runEnd = chpx.getEnd();-- while (runStart >= currentTextEnd)- {- currentPiece = (TextPiece) textIt.next ();- currentTextStart = currentPiece.getStart ();- currentTextEnd = currentPiece.getEnd ();- }-- if (runEnd < currentTextEnd)- {- String str = currentPiece.substring(runStart - currentTextStart, runEnd - currentTextStart);- finalTextBuf.append(str);- }- else if (runEnd > currentTextEnd)- {- while (runEnd > currentTextEnd)- {- String str = currentPiece.substring(runStart - currentTextStart,- currentTextEnd - currentTextStart);- finalTextBuf.append(str);- if (textIt.hasNext())- {- currentPiece = (TextPiece) textIt.next ();- currentTextStart = currentPiece.getStart ();- runStart = currentTextStart;- currentTextEnd = currentPiece.getEnd ();- }- else- {- return finalTextBuf.toString();- }- }- String str = currentPiece.substring(0, runEnd - currentTextStart);- finalTextBuf.append(str);- }- else- {- String str = currentPiece.substring(runStart - currentTextStart, runEnd - currentTextStart);- if (textIt.hasNext())- {- currentPiece = (TextPiece) textIt.next();- currentTextStart = currentPiece.getStart();- currentTextEnd = currentPiece.getEnd();- }- finalTextBuf.append(str);- }- }- return finalTextBuf.toString();- }-- /**- * Used to determine if a run of text has been deleted.- *- * @param grpprl The list of sprms for a particular run of text.- * @return true if this run of text has been deleted.- */- private boolean isDeleted(byte[] grpprl)- {- SprmIterator iterator = new SprmIterator(grpprl,0);- while (iterator.hasNext())- {- SprmOperation op = iterator.next();- // 0 is the operation that signals a FDelRMark operation- if (op.getOperation() == 0 && op.getOperand() != 0)- {- return true;- }- }- return false;- }--}-diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordTextBuffer.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordTextBuffer.javadeleted file mode 100644index ad93f5922..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordTextBuffer.java+++ /dev/null@@ -1,66 +0,0 @@-/* Copyright 2004 Ryan Ackley- *- * Licensed 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.msword;---/**- * This class acts as a StringBuffer for text from a word document. It allows- * processing of character before they- * @author Ryan Ackley- * @version 1.0- */-public class WordTextBuffer-{- StringBuffer _buf;- boolean _hold;-- public WordTextBuffer()- {- _buf = new StringBuffer();- _hold = false;- }-- public void append(String text)- {- char[] letters = text.toCharArray();- for (int x = 0; x < letters.length; x++)- {- switch(letters[x])- {- case '\r':- _buf.append("\r\n");- break;- case 0x13:- _hold = true;- break;- case 0x14:- _hold = false;- break;- default:- if (!_hold)- {- _buf.append(letters[x]);- }- break;- }- }- }-- public String toString()- {- return _buf.toString();- }--}diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordTextPiece.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordTextPiece.javadeleted file mode 100644index 3612fa961..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/WordTextPiece.java+++ /dev/null@@ -1,54 +0,0 @@-/* Copyright 2004 Ryan Ackley- *- * Licensed 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.msword;--/**- * This class stores info about the data structure describing a chunk of text- * in a Word document. Specifically, whether or not a Range of text uses- * unicode or Cp1252 encoding.- *- * @author Ryan Ackley- */--class WordTextPiece-{- private int _fcStart;- private boolean _usesUnicode;- private int _length;-- public WordTextPiece(int start, int length, boolean unicode)- {- _usesUnicode = unicode;- _length = length;- _fcStart = start;- }- public boolean usesUnicode()- {- return _usesUnicode;- }-- public int getStart()- {- return _fcStart;- }- public int getLength()- {- return _length;- }----}diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/chp/Word6CHPBinTable.java b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/chp/Word6CHPBinTable.javadeleted file mode 100644index 5f98ffeec..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/chp/Word6CHPBinTable.java+++ /dev/null@@ -1,77 +0,0 @@-/* Copyright 2004 Ryan Ackley- *- * Licensed 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.msword.chp;--import java.util.List;-import java.util.ArrayList;-import java.io.OutputStream;-import java.io.IOException;--import org.apache.poi.poifs.common.POIFSConstants;-import org.apache.poi.util.LittleEndian;-import org.apache.poi.hwpf.model.io.*;-import org.apache.poi.hwpf.model.*;--/**- * This class holds all of the character formatting properties from a Word- * 6.0/95 document.- *- * @author Ryan Ackley- */-public class Word6CHPBinTable-{- /** List of character properties.*/- ArrayList _textRuns = new ArrayList();-- /**- * Constructor used to read a binTable in from a Word document.- *- * @param documentStream The POIFS "WordDocument" stream from a Word document- * @param offset The offset of the Chp bin table in the main stream.- * @param size The size of the Chp bin table in the main stream.- * @param fcMin The start of text in the main stream.- */- public Word6CHPBinTable(byte[] documentStream, int offset,- int size, int fcMin, TextPieceTable tpt)- {- PlexOfCps binTable = new PlexOfCps(documentStream, offset, size, 2);-- int length = binTable.length();- for (int x = 0; x < length; x++)- {- GenericPropertyNode node = binTable.getProperty(x);-- int pageNum = LittleEndian.getShort((byte[])node.getBytes());- int pageOffset = POIFSConstants.BIG_BLOCK_SIZE * pageNum;-- CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,- pageOffset, fcMin, tpt);-- int fkpSize = cfkp.size();-- for (int y = 0; y < fkpSize; y++)- {- _textRuns.add(cfkp.getCHPX(y));- }- }- }-- public List getTextRuns()- {- return _textRuns;- }--}diff --git a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/package.html b/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/package.htmldeleted file mode 100644index b155c104a..000000000--- a/src/plugin/parse-msword/src/java/org/apache/nutch/parse/msword/package.html+++ /dev/null@@ -1,6 +0,0 @@-<html>-<body>-<p>A Microsoft © Word document parsing plugin.</p>-<p>This package relies on <a href="http://jakarta.apache.org/poi/index.html">POI</a>.</p>-</body>-</html>diff --git a/src/plugin/parse-msword/src/test/org/apache/nutch/parse/msword/TestMSWordParser.java b/src/plugin/parse-msword/src/test/org/apache/nutch/parse/msword/TestMSWordParser.javadeleted file mode 100644index de557583c..000000000--- a/src/plugin/parse-msword/src/test/org/apache/nutch/parse/msword/TestMSWordParser.java+++ /dev/null@@ -1,90 +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.msword;--import org.apache.nutch.protocol.ProtocolFactory;-import org.apache.nutch.protocol.Protocol;-import org.apache.nutch.protocol.Content;-import org.apache.nutch.protocol.ProtocolException;--import org.apache.nutch.parse.Parse;-import org.apache.nutch.parse.ParseImpl;-import org.apache.nutch.parse.ParseUtil;-import org.apache.nutch.parse.ParseException;-import org.apache.hadoop.conf.Configuration;-import org.apache.nutch.util.NutchConfiguration;--import org.apache.hadoop.io.Text;-import org.apache.nutch.crawl.CrawlDatum;--import java.io.File;-import java.io.FilenameFilter;--import junit.framework.TestCase;--/**- * Unit tests for MSWordParser.- *- * @author John Xing- */-public class TestMSWordParser extends TestCase {-- private String fileSeparator = System.getProperty("file.separator");- // This system property is defined in ./src/plugin/build-plugin.xml- private String sampleDir = System.getProperty("test.data",".");- // Make sure sample files are copied to "test.data" as specified in- // ./src/plugin/parse-msword/build.xml during plugin compilation.- // Check ./src/plugin/parse-msword/sample/README.txt for what they are.- private String[] sampleFiles = {"word95.doc","word97.doc"};-- private String expectedText = "This is a sample doc file prepared for nutch.";-- private Configuration conf;-- public TestMSWordParser(String name) {- super(name);- }-- protected void setUp() {- conf = NutchConfiguration.create();- conf.set("file.content.limit", "-1");- }-- protected void tearDown() {}-- public String getTextContent(String fileName) throws ProtocolException, ParseException {- String urlString = "file:" + sampleDir + fileSeparator + fileName;- Protocol protocol = new ProtocolFactory(conf).getProtocol(urlString);- Content content = protocol.getProtocolOutput(new Text(urlString), new CrawlDatum()).getContent();- Parse parse = new ParseUtil(conf).parseByExtensionId("parse-msword", content).get(content.getUrl());- return parse.getText();- }-- public void testIt() throws ProtocolException, ParseException {- for (int i=0; i<sampleFiles.length; i++) {- assertTrue(getTextContent(sampleFiles[i]).startsWith(expectedText));- }- }-- public void testOpeningDocs() throws ProtocolException, ParseException {- String[] filenames = new File(sampleDir).list();- for (int i = 0; i < filenames.length; i++) {- assertTrue("cann't read content of " + filenames[i], getTextContent(filenames[i]).length() > 0);- }- }-}diff --git a/src/plugin/parse-oo/build.xml b/src/plugin/parse-oo/build.xmldeleted file mode 100644index 7d21dae90..000000000--- a/src/plugin/parse-oo/build.xml+++ /dev/null@@ -1,47 +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-oo" 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"/>- </target>-- <!-- for junit test -->- <copy todir="${build.test}/data">- <fileset dir="sample">- <include name="ootest.*"/>- </fileset>- </copy>--</project>diff --git a/src/plugin/parse-oo/plugin.xml b/src/plugin/parse-oo/plugin.xmldeleted file mode 100644index aae669cf2..000000000--- a/src/plugin/parse-oo/plugin.xml+++ /dev/null@@ -1,134 +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-oo"- name="OpenOffice/OpenDocument Parse Plug-in"- version="1.0.0"- provider-name="nutch.org">--- <runtime>- <library name="parse-oo.jar">- <export name="*"/>- </library>- </runtime>-- <requires>- <import plugin="nutch-extensionpoints"/>- <import plugin="lib-xml"/>- </requires>-- <extension id="org.apache.nutch.parse.oo"- name="OOParse"- point="org.apache.nutch.parse.Parser">-- <!-- Text / Writer -->- <implementation id="org.apache.nutch.parse.oo.OpenDocument.Text"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.oasis.opendocument.text"/>- <parameter name="pathSuffix" value="odt"/>- </implementation>-- <implementation id="org.apache.nutch.parse.oo.StarOffice.Writer"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.sun.xml.writer"/>- <parameter name="pathSuffix" value="sxw"/>- </implementation>-- <!-- Text / Writer Template -->- <implementation id="org.apache.nutch.parse.oo.OpenDocument.TextTemplate"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.oasis.opendocument.text-template"/>- <parameter name="pathSuffix" value="ott"/>- </implementation>-- <implementation id="org.apache.nutch.parse.oo.StarOffice.WriterTemplate"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.sun.xml.writer.template"/>- <parameter name="pathSuffix" value="stw"/>- </implementation>-- <!-- Text-Web -->- <implementation id="org.apache.nutch.parse.oo.OpenDocument.TextWeb"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.oasis.opendocument.text-web"/>- <parameter name="pathSuffix" value="odh"/>- </implementation>-- <!-- Text-Master -->- <implementation id="org.apache.nutch.parse.oo.OpenDocument.TextMaster"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.oasis.opendocument.text-master"/>- <parameter name="pathSuffix" value="odm"/>- </implementation>-- <!-- Spreadsheet / Calc -->- <implementation id="org.apache.nutch.parse.oo.OpenDocument.Spreadsheet"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.oasis.opendocument.spreadsheet"/>- <parameter name="pathSuffix" value="ods"/>- </implementation>-- <implementation id="org.apache.nutch.parse.oo.StarOffice.Calc"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.sun.xml.calc"/>- <parameter name="pathSuffix" value="sxc"/>- </implementation>-- <!-- Spreadsheet / Calc Template -->- <implementation id="org.apache.nutch.parse.oo.OpenDocument.SpreadsheetTemplate"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.oasis.opendocument.spreadsheet-template"/>- <parameter name="pathSuffix" value="ots"/>- </implementation>-- <implementation id="org.apache.nutch.parse.oo.StarOffice.CalcTemplate"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.sun.xml.calc.template"/>- <parameter name="pathSuffix" value="stc"/>- </implementation>-- <!-- Presentation / Impress -->- <implementation id="org.apache.nutch.parse.oo.OpenDocument.Presentation"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.oasis.opendocument.presentation"/>- <parameter name="pathSuffix" value="odp"/>- </implementation>-- <implementation id="org.apache.nutch.parse.oo.StarOffice.Impress"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.sun.xml.impress"/>- <parameter name="pathSuffix" value="sxi"/>- </implementation>-- <!-- Presentation / Impress Template -->- <implementation id="org.apache.nutch.parse.oo.OpenDocument.PresentationTemplate"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.oasis.opendocument.presentation-template"/>- <parameter name="pathSuffix" value="otp"/>- </implementation>-- <implementation id="org.apache.nutch.parse.oo.StarOffice.ImpressTemplate"- class="org.apache.nutch.parse.oo.OOParser">- <parameter name="contentType" value="application/vnd.sun.xml.impress.template"/>- <parameter name="pathSuffix" value="sti"/>- </implementation>-- </extension>--</plugin>diff --git a/src/plugin/parse-oo/sample/ootest.odt b/src/plugin/parse-oo/sample/ootest.odtdeleted file mode 100644index e36e3898a..000000000Binary files a/src/plugin/parse-oo/sample/ootest.odt and /dev/null differdiff --git a/src/plugin/parse-oo/sample/ootest.sxw b/src/plugin/parse-oo/sample/ootest.sxwdeleted file mode 100644index 260b1c24a..000000000Binary files a/src/plugin/parse-oo/sample/ootest.sxw and /dev/null differdiff --git a/src/plugin/parse-oo/sample/ootest.txt b/src/plugin/parse-oo/sample/ootest.txtdeleted file mode 100644index f2c99d2a7..000000000--- a/src/plugin/parse-oo/sample/ootest.txt+++ /dev/null@@ -1,25 +0,0 @@-Abcedfg ????? Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer a leo in lacus malesuada ornare. Mauris sagittis. Nam vestibulum. Nunc gravida vestibulum augue. Praesent sed lectus quis lectus adipiscing bibendum. Sed nulla. Duis posuere justo eget urna. Proin lorem orci, vestibulum ut, consequat molestie, eleifend a, nibh. Mauris sed lacus. Etiam blandit tincidunt neque. Cras ac sapien. Duis erat. http://www.openoffice.org Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer a leo in lacus malesuada ornare. Mauris sagittis. Nam vestibulum. Nunc gravida vestibulum augue. Praesent sed lectus quis lectus adipiscing bibendum. Sed nulla. Duis posuere justo eget urna. Proin lorem orci , vestibulum ut, consequat molestie, eleifend a, nibh. Mauris sed lacus. Etiam blandit tincidunt neque. Cras ac sapien. Duis erat. Vivamus fringilla velit sit amet leo imperdiet sagittis. Maecenas porttitor. Nulla eget nibh. Nulla accumsan. Donec nec mi. Etiam dui justo, volutpat a, volutpat id, ornare sed, erat. Vivamus urna eros, nonummy id, vestibulum ut, elementum in, diam. Etiam eros nibh, porta vel, dignissim non, interdum eu, lorem. Curabitur lorem. Nulla pellentesque congue nisl. Duis id mauris et mauris varius hendrerit. Nunc sem. Nam id sem ut tortor sollicitudin bibendum. Mauris placerat, pede ut vestibulum venenatis, eros metus semper lacus, a fermentum felis massa sit amet lectus. Cras tellus eros, molestie sit amet, egestas varius, porttitor eget, odio. Nunc vitae augue luctus eros fringilla convallis. Proin tincidunt neque ut dui. Morbi at nisl. Nunc neque. Cras a sem et ligula semper eleifend. ĄćęłńóśźżĄĆĘŁŃÓŚŹŻ ÄöåÄÖä \’”<>& &-Abcdefg-Abcdefg-abcdefg-Akuku-Akuku-Akuku-akuku-Akuku-Akuku-Akuku-akuku-Title-Col1-Col2-Col3-head-Cell1-Cell2-Cel3-total-TOTAL-TOTAL-TOTAL- http://www.openoffice.org\ No newline at end of filediff --git a/src/plugin/parse-oo/src/java/org/apache/nutch/parse/oo/OOParser.java b/src/plugin/parse-oo/src/java/org/apache/nutch/parse/oo/OOParser.javadeleted file mode 100644index 25e126bfb..000000000--- a/src/plugin/parse-oo/src/java/org/apache/nutch/parse/oo/OOParser.java+++ /dev/null@@ -1,220 +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.oo;--import java.io.*;-import java.net.MalformedURLException;-import java.util.ArrayList;-import java.util.List;-import java.util.zip.*;--import org.apache.commons.logging.Log;-import org.apache.commons.logging.LogFactory;--import org.apache.hadoop.conf.Configuration;-import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.parse.*;-import org.apache.nutch.protocol.Content;-import org.apache.nutch.util.LogUtil;-import org.apache.nutch.util.NutchConfiguration;-import org.jaxen.*;-import org.jaxen.jdom.JDOMXPath;-import org.jdom.*;-import org.jdom.input.*;--/**- * Parser for OpenOffice and OpenDocument formats. This should handle- * the following formats: Text, Spreadsheet, Presentation, and- * corresponding templates and "master" documents.- *- * @author Andrzej Bialecki- */-public class OOParser implements Parser {- public static final Log LOG = LogFactory.getLog(OOParser.class);-- private Configuration conf;-- public OOParser () {- }-- public void setConf(Configuration conf) {- this.conf = conf;- }-- public Configuration getConf() {- return conf;- }-- public ParseResult getParse(Content content) {- String text = null;- String title = null;- Metadata metadata = new Metadata();- ArrayList outlinks = new ArrayList();-- try {- byte[] raw = content.getContent();- String contentLength = content.getMetadata().get("Content-Length");- if (contentLength != null- && raw.length != Integer.parseInt(contentLength)) {- return new ParseStatus(ParseStatus.FAILED, ParseStatus.FAILED_TRUNCATED,- "Content truncated at "+raw.length- +" bytes. Parser can't handle incomplete files.").getEmptyParseResult(content.getUrl(), conf);- }- ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(raw));- ZipEntry ze = null;- while ((ze = zis.getNextEntry()) != null) {- if (ze.getName().equals("content.xml")) {- text = parseContent(ze, zis, outlinks);- } else if (ze.getName().equals("meta.xml")) {- parseMeta(ze, zis, metadata);- }- }- zis.close();- } catch (Exception e) { // run time exception- e.printStackTrace(LogUtil.getWarnStream(LOG));- return new ParseStatus(ParseStatus.FAILED,- "Can't be handled as OO document. " + e).getEmptyParseResult(content.getUrl(), conf);- }-- title = metadata.get(Metadata.TITLE);- if (text == null)- text = "";-- if (title == null)- title = "";-- Outlink[] links = (Outlink[])outlinks.toArray(new Outlink[outlinks.size()]);- ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS, title, links, metadata);- return ParseResult.createParseResult(content.getUrl(), new ParseImpl(text, parseData));- }-- // extract as much plain text as possible.- private String parseContent(ZipEntry ze, ZipInputStream zis, ArrayList outlinks) throws Exception {- StringBuffer res = new StringBuffer();- FilterInputStream fis = new FilterInputStream(zis) {- public void close() {};- };- SAXBuilder builder = new SAXBuilder();- Document doc = builder.build(fis);- Element root = doc.getRootElement();- // XXX this is expensive for very large documents. In those cases another- // XXX method (direct processing of SAX events, or XMLPull) should be used.- XPath path = new JDOMXPath("//text:span | //text:p | //text:tab | //text:tab-stop | //text:a");- path.addNamespace("text", root.getNamespace("text").getURI());- Namespace xlink = Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink");- List list = path.selectNodes(doc);- boolean lastp = true;- for (int i = 0; i < list.size(); i++) {- Element el = (Element)list.get(i);- String text = el.getText();- if (el.getName().equals("p")) {- // skip empty paragraphs- if (!text.equals("")) {- if (!lastp) res.append("\n");- res.append(text + "\n");- lastp = true;- }- } else if (el.getName().startsWith("tab")) {- res.append("\t");- lastp = false;- } else if (el.getName().equals("a")) {- List nl = el.getChildren();- String a = null;- for (int k = 0; k < nl.size(); k++) {- Element anchor = (Element)nl.get(k);- String nsName = anchor.getNamespacePrefix() + ":" + anchor.getName();- if (!nsName.equals("text:span")) continue;- a = anchor.getText();- break;- }- String u = el.getAttributeValue("href", xlink);- if (u == null) u = a; // often anchors are URLs- try {- Outlink o = new Outlink(u, a);- outlinks.add(o);- } catch (MalformedURLException mue) {- // skip- }- if (a != null && !a.equals("")) {- if (!lastp) res.append(' ');- res.append(a);- lastp = false;- }- } else {- if (!text.equals("")) {- if (!lastp) res.append(' ');- res.append(text);- }- lastp = false;- }- }- return res.toString();- }-- // extract metadata and convert them to Nutch format- private void parseMeta(ZipEntry ze, ZipInputStream zis, Metadata metadata) throws Exception {- FilterInputStream fis = new FilterInputStream(zis) {- public void close() {};- };- SAXBuilder builder = new SAXBuilder();- Document doc = builder.build(fis);- XPath path = new JDOMXPath("/office:document-meta/office:meta/*");- Element root = doc.getRootElement();- path.addNamespace("office", root.getNamespace("office").getURI());- List list = path.selectNodes(doc);- for (int i = 0; i < list.size(); i++) {- Element n = (Element)list.get(i);- String text = n.getText();- if (text.trim().equals("")) continue;- String name = n.getName();- if (name.equals("title"))- metadata.add(Metadata.TITLE, text);- else if (name.equals("language"))- metadata.add(Metadata.LANGUAGE, text);- else if (name.equals("creation-date"))- metadata.add(Metadata.DATE, text);- else if (name.equals("print-date"))- metadata.add(Metadata.LAST_PRINTED, text);- else if (name.equals("generator"))- metadata.add(Metadata.APPLICATION_NAME, text);- else if (name.equals("creator"))- metadata.add(Metadata.CREATOR, text);- }- }-- public static void main(String[] args) throws Exception {- OOParser oo = new OOParser();- Configuration conf = NutchConfiguration.create();- oo.setConf(conf);- FileInputStream fis = new FileInputStream(args[0]);- byte[] bytes = new byte[fis.available()];- fis.read(bytes);- fis.close();- Content c = new Content("local", "local", bytes, "application/vnd.oasis.opendocument.text", new Metadata(), conf);- Parse p = oo.getParse(c).get(c.getUrl());- System.out.println(p.getData());- System.out.println("Text: '" + p.getText() + "'");- /*- // create the test output file- OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("e:\\ootest.txt"), "UTF-8");- osw.write(p.getText());- osw.flush();- osw.close();- */- }-}diff --git a/src/plugin/parse-oo/src/test/org/apache/nutch/parse/oo/TestOOParser.java b/src/plugin/parse-oo/src/test/org/apache/nutch/parse/oo/TestOOParser.javadeleted file mode 100644index 6771ea55b..000000000--- a/src/plugin/parse-oo/src/test/org/apache/nutch/parse/oo/TestOOParser.java+++ /dev/null@@ -1,100 +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.oo;--import java.io.FileInputStream;-import java.io.InputStreamReader;--import org.apache.nutch.crawl.CrawlDatum;-import org.apache.hadoop.conf.Configuration;-import org.apache.hadoop.io.Text;-import org.apache.nutch.protocol.*;--import org.apache.nutch.parse.Parse;-import org.apache.nutch.parse.ParseException;-import org.apache.nutch.util.NutchConfiguration;--import junit.framework.TestCase;--/**- * Unit tests for OOParser.- *- * @author Andrzej Bialecki- */-public class TestOOParser extends TestCase {-- private String fileSeparator = System.getProperty("file.separator");- // This system property is defined in ./src/plugin/build-plugin.xml- private String sampleDir = System.getProperty("test.data",".");- // Make sure sample files are copied to "test.data" as specified in- // ./src/plugin/parse-oo/build.xml during plugin compilation.- private String[] sampleFiles = {"ootest.odt", "ootest.sxw"};-- private String sampleText = "ootest.txt";-- private String expectedText;-- public TestOOParser(String name) {- super(name);- try {- // read the test string- FileInputStream fis = new FileInputStream(sampleDir + fileSeparator + sampleText);- StringBuffer sb = new StringBuffer();- int len = 0;- InputStreamReader isr = new InputStreamReader(fis, "UTF-8");- char[] buf = new char[1024];- while ((len = isr.read(buf)) > 0) {- sb.append(buf, 0, len);- }- isr.close();- expectedText = sb.toString();- // normalize space- expectedText = expectedText.replaceAll("[ \t\r\n]+", " ");- } catch (Exception e) {- e.printStackTrace();- }- }-- protected void setUp() {}-- protected void tearDown() {}-- public void testIt() throws ProtocolException, ParseException {- String urlString;- Content content;- Parse parse;- Configuration conf = NutchConfiguration.create();- Protocol protocol;- ProtocolFactory factory = new ProtocolFactory(conf);- OOParser parser = new OOParser();- parser.setConf(conf);-- for (int i=0; i<sampleFiles.length; i++) {- urlString = "file:" + sampleDir + fileSeparator + sampleFiles[i];-- protocol = factory.getProtocol(urlString);- content = protocol.getProtocolOutput(new Text(urlString), new CrawlDatum()).getContent();-- parse = parser.getParse(content).get(content.getUrl());-- String text = parse.getText().replaceAll("[ \t\r\n]+", " ");- assertTrue(expectedText.equals(text));- }- }--}diff --git a/src/plugin/parse-pdf/build.xml b/src/plugin/parse-pdf/build.xmldeleted file mode 100644index 2c3b97c26..000000000--- a/src/plugin/parse-pdf/build.xml+++ /dev/null@@ -1,37 +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-pdf" default="jar-core">-- <import file="../build-plugin.xml"/>-- <!-- Deploy Unit test dependencies -->- <target name="deps-test">- <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 todir="${build.test}/data">- <fileset dir="sample">- <include name="*.pdf"/>- </fileset>- </copy>--</project>diff --git a/src/plugin/parse-pdf/lib/FontBox-0.2.0-dev.jar b/src/plugin/parse-pdf/lib/FontBox-0.2.0-dev.jardeleted file mode 100644index a0ba4cb0a..000000000Binary files a/src/plugin/parse-pdf/lib/FontBox-0.2.0-dev.jar and /dev/null differdiff --git a/src/plugin/parse-pdf/lib/FontBox-LICENSE.txt b/src/plugin/parse-pdf/lib/FontBox-LICENSE.txtdeleted file mode 100644index c8485baa0..000000000--- a/src/plugin/parse-pdf/lib/FontBox-LICENSE.txt+++ /dev/null@@ -1,25 +0,0 @@-Copyright (c) 2003-2005, www.fontbox.org-All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:--1. Redistributions of source code must retain the above copyright notice,- this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright notice,- this list of conditions and the following disclaimer in the documentation- and/or other materials provided with the distribution.-3. Neither the name of fontbox; nor the names of its- contributors may be used to endorse or promote products derived from this- software without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE-DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ No newline at end of filediff --git a/src/plugin/parse-pdf/lib/JempBox-0.2.0.jar b/src/plugin/parse-pdf/lib/JempBox-0.2.0.jardeleted file mode 100644index b7de2c8d9..000000000Binary files a/src/plugin/parse-pdf/lib/JempBox-0.2.0.jar and /dev/null differdiff --git a/src/plugin/parse-pdf/lib/JempBox-LICENSE.txt b/src/plugin/parse-pdf/lib/JempBox-LICENSE.txtdeleted file mode 100644index 15dfcf5e8..000000000--- a/src/plugin/parse-pdf/lib/JempBox-LICENSE.txt+++ /dev/null@@ -1,25 +0,0 @@-Copyright (c) 2006-2007, www.jempbox.org-All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:--1. Redistributions of source code must retain the above copyright notice,- this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright notice,- this list of conditions and the following disclaimer in the documentation- and/or other materials provided with the distribution.-3. Neither the name of pdfbox; nor the names of its- contributors may be used to endorse or promote products derived from this- software without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE-DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.diff --git a/src/plugin/parse-pdf/lib/NOTICE.txt b/src/plugin/parse-pdf/lib/NOTICE.txtdeleted file mode 100644index d7fc5a8d6..000000000--- a/src/plugin/parse-pdf/lib/NOTICE.txt+++ /dev/null@@ -1,6 +0,0 @@-This plugin uses an unreleased version of PDFBox, obtained from SourceForce-CVS repository (HEAD revision as of Feb 3 2009), because the last released-version contains a bug related to document decryption (see NUTCH-643).--The libraries should be updated to a regular PDFBox release whenever that-becomes available.diff --git a/src/plugin/parse-pdf/lib/PDFBox-0.7.4-dev.jar b/src/plugin/parse-pdf/lib/PDFBox-0.7.4-dev.jardeleted file mode 100644index 3a337f576..000000000Binary files a/src/plugin/parse-pdf/lib/PDFBox-0.7.4-dev.jar and /dev/null differdiff --git a/src/plugin/parse-pdf/lib/PDFBox-LICENSE.txt b/src/plugin/parse-pdf/lib/PDFBox-LICENSE.txtdeleted file mode 100644index 81dcdaa28..000000000--- a/src/plugin/parse-pdf/lib/PDFBox-LICENSE.txt+++ /dev/null@@ -1,25 +0,0 @@-Copyright (c) 2003-2005, www.pdfbox.org-All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:--1. Redistributions of source code must retain the above copyright notice,- this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright notice,- this list of conditions and the following disclaimer in the documentation- and/or other materials provided with the distribution.-3. Neither the name of pdfbox; nor the names of its- contributors may be used to endorse or promote products derived from this- software without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE-DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ No newline at end of filediff --git a/src/plugin/parse-pdf/lib/bcprov-LICENSE.txt b/src/plugin/parse-pdf/lib/bcprov-LICENSE.txtdeleted file mode 100644index cf1d6be93..000000000--- a/src/plugin/parse-pdf/lib/bcprov-LICENSE.txt+++ /dev/null@@ -1,7 +0,0 @@-Copyright (c) 2000 - 2008 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)--Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:--The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.--THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.diff --git a/src/plugin/parse-pdf/lib/bcprov-jdk14-132.jar b/src/plugin/parse-pdf/lib/bcprov-jdk14-132.jardeleted file mode 100644index 552721d0e..000000000Binary files a/src/plugin/parse-pdf/lib/bcprov-jdk14-132.jar and /dev/null differdiff --git a/src/plugin/parse-pdf/plugin.xml b/src/plugin/parse-pdf/plugin.xmldeleted file mode 100644index 7801b1ef4..000000000--- a/src/plugin/parse-pdf/plugin.xml+++ /dev/null@@ -1,56 +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-pdf"- name="Pdf Parse Plug-in"- version="1.0.0"- provider-name="nutch.org">--- <runtime>- <library name="parse-pdf.jar">- <export name="*"/>- </library>- <library name="PDFBox-0.7.4-dev.jar"/>- <library name="FontBox-0.2.0-dev.jar"/>- <library name="JempBox-0.2.0-dev.jar"/>- <library name="bcprov-jdk14-132.jar"/>- <!-- Uncomment the following two lines after you have downloaded the- libraries, see README.txt for more details.-->- <!--- <library name="jai_codec.jar"/>- <library name="jai_core.jar"/>- -->- </runtime>-- <requires>- <import plugin="nutch-extensionpoints"/>- </requires>-- <extension id="org.apache.nutch.parse.pdf"- name="PdfParse"- point="org.apache.nutch.parse.Parser">-- <implementation id="org.apache.nutch.parse.pdf.PdfParser"- class="org.apache.nutch.parse.pdf.PdfParser">- <parameter name="contentType" value="application/pdf"/>- <parameter name="pathSuffix" value=""/>- </implementation>- </extension>--</plugin>diff --git a/src/plugin/parse-pdf/sample/README.txt b/src/plugin/parse-pdf/sample/README.txtdeleted file mode 100644index 9f68af87a..000000000--- a/src/plugin/parse-pdf/sample/README.txt+++ /dev/null@@ -1,13 +0,0 @@-1. pdftest.pdf:-A small pdf file picked up from internet. It contains text:-E:\M55\!\1725.fm 2003-01-01 18:15 P Tagg, IPM, University of Liverpool-A VERY SMALL PDF FILE-A VERY SMALL PDF FILE-A VERY SMALL PDF FILE-A VERY SMALL PDF FILE-A VERY SMALL PDF FILE-A VERY SMALL PDF FILE--2. encrypt.pdf:-The same file as above, encrypted with owner's password 'owner'-and empty user's password.diff --git a/src/plugin/parse-pdf/sample/encrypted.pdf b/src/plugin/parse-pdf/sample/encrypted.pdfdeleted file mode 100644index 383cebbca..000000000Binary files a/src/plugin/parse-pdf/sample/encrypted.pdf and /dev/null differdiff --git a/src/plugin/parse-pdf/sample/pdftest.pdf b/src/plugin/parse-pdf/sample/pdftest.pdfdeleted file mode 100644index e7c6e6277..000000000--- a/src/plugin/parse-pdf/sample/pdftest.pdf+++ /dev/null@@ -1,157 +0,0 @@-%PDF-1.2-%����--9 0 obj-<<-/Length 10 0 R-/Filter /FlateDecode->>-stream-H�͐�J�0�� ��{��f�$M��n�-���[&je���ۤ�~�$���}�Ʌ�Ij���s����~�X�-],��$Y���)�'N�u�1!���V�?��?-�b1Rbb�҉�H�[��TD:#�&ح��X���i�$qnf�����]������a��{��أ���q|J�Ls]�Q�I��j�%��9��`���U�ite�z�$����OeB�Ēү�R��@zܗ���g���<���-endstream-endobj-10 0 obj-246-endobj-4 0 obj-<<-/Type /Page-/Parent 5 0 R-/Resources <<-/Font <<-/F0 6 0 R-/F1 7 0 R->>-/ProcSet 2 0 R->>-/Contents 9 0 R->>-endobj-6 0 obj-<<-/Type /Font-/Subtype /TrueType-/Name /F0-/BaseFont /Arial-/Encoding /WinAnsiEncoding->>-endobj-7 0 obj-<<-/Type /Font-/Subtype /TrueType-/Name /F1-/BaseFont /BookAntiqua,Bold-/FirstChar 31-/LastChar 255-/Widths [ 750 250 278 402 606 500 889 833 227 333 333 444 606 250 333 250-296 500 500 500 500 500 500 500 500 500 500 250 250 606 606 606-444 747 778 667 722 833 611 556 833 833 389 389 778 611 1000 833-833 611 833 722 611 667 778 778 1000 667 667 667 333 606 333 606-500 333 500 611 444 611 500 389 556 611 333 333 611 333 889 611-556 611 611 389 444 333 611 556 833 500 556 500 310 606 310 606-750 500 750 333 500 500 1000 500 500 333 1000 611 389 1000 750 750-750 750 278 278 500 500 606 500 1000 333 998 444 389 833 750 750-667 250 278 500 500 606 500 606 500 333 747 438 500 606 333 747-500 400 549 361 361 333 576 641 250 333 361 488 500 889 890 889-444 778 778 778 778 778 778 1000 722 611 611 611 611 389 389 389-389 833 833 833 833 833 833 833 606 833 778 778 778 778 667 611-611 500 500 500 500 500 500 778 444 500 500 500 500 333 333 333-333 556 611 556 556 556 556 556 549 556 611 611 611 611 556 611-556 ]-/Encoding /WinAnsiEncoding-/FontDescriptor 8 0 R->>-endobj-8 0 obj-<<-/Type /FontDescriptor-/FontName /BookAntiqua,Bold-/Flags 16418-/FontBBox [ -250 -260 1236 930 ]-/MissingWidth 750-/StemV 146-/StemH 146-/ItalicAngle 0-/CapHeight 930-/XHeight 651-/Ascent 930-/Descent 260-/Leading 210-/MaxWidth 1030-/AvgWidth 460->>-endobj-2 0 obj-[ /PDF /Text ]-endobj-5 0 obj-<<-/Kids [4 0 R ]-/Count 1-/Type /Pages-/MediaBox [ 0 0 612 792 ]->>-endobj-1 0 obj-<<-/Creator (1725.fm)-/CreationDate (1-Jan-3 18:15PM)-/Title (1725.PDF)-/Author (Unknown)-/Producer (Acrobat PDFWriter 3.02 for Windows)-/Keywords ()-/Subject ()->>-endobj-3 0 obj-<<-/Pages 5 0 R-/Type /Catalog-/DefaultGray 11 0 R-/DefaultRGB 12 0 R->>-endobj-11 0 obj-[/CalGray-<<-/WhitePoint [0.9505 1 1.0891 ]-/Gamma 0.2468->>-]-endobj-12 0 obj-[/CalRGB-<<-/WhitePoint [0.9505 1 1.0891 ]-/Gamma [0.2468 0.2468 0.2468 ]-/Matrix [0.4361 0.2225 0.0139 0.3851 0.7169 0.0971 0.1431 0.0606 0.7141 ]->>-]-endobj-xref-0 13-0000000000 65535 f-0000002172 00000 n-0000002046 00000 n-0000002363 00000 n-0000000375 00000 n-0000002080 00000 n-0000000518 00000 n-0000000633 00000 n-0000001760 00000 n-0000000021 00000 n-0000000352 00000 n-0000002460 00000 n-0000002548 00000 n-trailer-<<-/Size 13-/Root 3 0 R-/Info 1 0 R-/ID [<47149510433dd4882f05f8c124223734><47149510433dd4882f05f8c124223734>]->>-startxref-2726-%%EOFdiff --git a/src/plugin/parse-pdf/src/java/org/apache/nutch/parse/pdf/PdfParser.java b/src/plugin/parse-pdf/src/java/org/apache/nutch/parse/pdf/PdfParser.javadeleted file mode 100644index 695b87de4..000000000--- a/src/plugin/parse-pdf/src/java/org/apache/nutch/parse/pdf/PdfParser.java+++ /dev/null@@ -1,179 +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.pdf;--import org.pdfbox.pdfparser.PDFParser;-import org.pdfbox.pdmodel.PDDocument;-import org.pdfbox.pdmodel.PDDocumentInformation;-import org.pdfbox.pdmodel.encryption.BadSecurityHandlerException;-import org.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;-import org.pdfbox.util.PDFTextStripper;--import org.pdfbox.exceptions.CryptographyException;--// Commons Logging imports-import org.apache.commons.logging.Log;-import org.apache.commons.logging.LogFactory;--import org.apache.nutch.protocol.Content;-import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.net.protocols.Response;-import org.apache.hadoop.conf.Configuration;-import org.apache.nutch.parse.ParseResult;-import org.apache.nutch.parse.ParseStatus;-import org.apache.nutch.parse.Parser;-import org.apache.nutch.parse.ParseData;-import org.apache.nutch.parse.ParseImpl;-import org.apache.nutch.parse.Outlink;-import org.apache.nutch.parse.OutlinkExtractor;-import org.apache.nutch.util.LogUtil;--import java.text.SimpleDateFormat;-import java.util.Calendar;--import java.io.ByteArrayInputStream;-import java.io.IOException;--/*********************************************- * parser for mime type application/pdf.- * It is based on org.pdfbox.*. We have to see how well it does the job.- *- * @author John Xing- *- * Note on 20040614 by Xing:- * Some codes are stacked here for convenience (see inline comments).- * They may be moved to more appropriate places when new codebase- * stabilizes, especially after code for indexing is written.- *- *********************************************/--public class PdfParser implements Parser {- public static final Log LOG = LogFactory.getLog("org.apache.nutch.parse.pdf");- private Configuration conf;-- public ParseResult getParse(Content content) {-- // in memory representation of pdf file- PDDocument pdf = null;-- String text = null;- String title = null;- Metadata metadata = new Metadata();-- try {-- byte[] raw = content.getContent();-- String contentLength = content.getMetadata().get(Response.CONTENT_LENGTH);- if (contentLength != null- && raw.length != Integer.parseInt(contentLength)) {- return new ParseStatus(ParseStatus.FAILED, ParseStatus.FAILED_TRUNCATED,- "Content truncated at "+raw.length- +" bytes. Parser can't handle incomplete pdf file.").getEmptyParseResult(content.getUrl(), getConf());- }-- PDFParser parser = new PDFParser(new ByteArrayInputStream(raw));- parser.parse();-- pdf = parser.getPDDocument();-- if (pdf.isEncrypted()) {- //Just try using the default password and move on- pdf.openProtection(new StandardDecryptionMaterial(""));- }-- // collect text- PDFTextStripper stripper = new PDFTextStripper();- text = stripper.getText(pdf);-- // collect title- PDDocumentInformation info = pdf.getDocumentInformation();- title = info.getTitle();- // more useful info, currently not used. please keep them for future use.- metadata.add(Metadata.PAGE_COUNT, String.valueOf(pdf.getNumberOfPages()));- metadata.add(Metadata.AUTHOR, info.getAuthor());- metadata.add(Metadata.SUBJECT, info.getSubject());- metadata.add(Metadata.KEYWORDS, info.getKeywords());- metadata.add(Metadata.CREATOR, info.getCreator());- metadata.add(Metadata.PUBLISHER, info.getProducer());-- //TODO: Figure out why we get a java.io.IOException: Error converting date:1-Jan-3 18:15PM- //error here-- //metadata.put(DATE, dcDateFormatter.format(info.getCreationDate().getTime()));- //metadata.put(LAST_MODIFIED, dcDateFormatter.format(info.getModificationDate().getTime()));-- } catch (CryptographyException e) {- return new ParseStatus(ParseStatus.FAILED,- "Error decrypting document. " + e).getEmptyParseResult(content.getUrl(), getConf());- } catch (BadSecurityHandlerException e) {- return new ParseStatus(ParseStatus.FAILED,- "Error decrypting document. " + e).getEmptyParseResult(content.getUrl(), getConf());- } catch (Exception e) { // run time exception- if (LOG.isWarnEnabled()) {- LOG.warn("General exception in PDF parser: "+e.getMessage());- e.printStackTrace(LogUtil.getWarnStream(LOG));- }- return new ParseStatus(ParseStatus.FAILED,- "Can't be handled as pdf document. " + e).getEmptyParseResult(content.getUrl(), getConf());- } finally {- try {- if (pdf != null)- pdf.close();- } catch (IOException e) {- // nothing to do- }- }-- if (text == null)- text = "";-- if (title == null)- title = "";-- // collect outlink- Outlink[] outlinks = OutlinkExtractor.getOutlinks(text, getConf());-- ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS, title,- outlinks, content.getMetadata(),- metadata);- return ParseResult.createParseResult(content.getUrl(), new ParseImpl(text, parseData));- // any filter?- //return HtmlParseFilters.filter(content, parse, root);- }-- // format date- // currently not used. please keep it for future use.- private String formatDate(Calendar date) {- String retval = null;- if(date != null) {- SimpleDateFormat formatter = new SimpleDateFormat();- retval = formatter.format(date.getTime());- }- return retval;- }-- public void setConf(Configuration conf) {- this.conf = conf;- }-- public Configuration getConf() {- return this.conf;- }--}diff --git a/src/plugin/parse-pdf/src/java/org/apache/nutch/parse/pdf/package.html b/src/plugin/parse-pdf/src/java/org/apache/nutch/parse/pdf/package.htmldeleted file mode 100644index 0b2767e98..000000000--- a/src/plugin/parse-pdf/src/java/org/apache/nutch/parse/pdf/package.html+++ /dev/null@@ -1,5 +0,0 @@-<html>-<body>-<p>A pdf parsing plugin.</p><p>This package relies on <a href="http://www.pdfbox.org">PDFBox</a>.</p>-</body>-</html>diff --git a/src/plugin/parse-pdf/src/test/org/apache/nutch/parse/pdf/TestPdfParser.java b/src/plugin/parse-pdf/src/test/org/apache/nutch/parse/pdf/TestPdfParser.javadeleted file mode 100644index f5e4dbd5a..000000000--- a/src/plugin/parse-pdf/src/test/org/apache/nutch/parse/pdf/TestPdfParser.java+++ /dev/null@@ -1,83 +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.pdf;--import org.apache.nutch.protocol.ProtocolFactory;-import org.apache.nutch.protocol.Protocol;-import org.apache.nutch.protocol.Content;-import org.apache.nutch.protocol.ProtocolException;--import org.apache.nutch.parse.Parse;-import org.apache.nutch.parse.ParseUtil;-import org.apache.nutch.parse.ParseException;-import org.apache.hadoop.conf.Configuration;-import org.apache.nutch.util.NutchConfiguration;--import org.apache.hadoop.io.Text;-import org.apache.nutch.crawl.CrawlDatum;--import junit.framework.TestCase;--/**- * Unit tests for PdfParser.- *- * @author John Xing- */-public class TestPdfParser extends TestCase {-- private String fileSeparator = System.getProperty("file.separator");- // This system property is defined in ./src/plugin/build-plugin.xml- private String sampleDir = System.getProperty("test.data",".");- // Make sure sample files are copied to "test.data" as specified in- // ./src/plugin/parse-pdf/build.xml during plugin compilation.- // Check ./src/plugin/parse-pdf/sample/README.txt for what they are.- private String[] sampleFiles = {- "pdftest.pdf",- "encrypted.pdf"- };-- private String expectedText = "A VERY SMALL PDF FILE";-- public TestPdfParser(String name) {- super(name);- }-- protected void setUp() {}-- protected void tearDown() {}-- public void testIt() throws ProtocolException, ParseException {- String urlString;- Protocol protocol;- Content content;- Parse parse;-- for (int i = 0; i < sampleFiles.length; i++) {- urlString = "file:" + sampleDir + fileSeparator + sampleFiles[i];-- Configuration conf = NutchConfiguration.create();- protocol = new ProtocolFactory(conf).getProtocol(urlString);- content = protocol.getProtocolOutput(new Text(urlString), new CrawlDatum()).getContent();- parse = new ParseUtil(conf).parseByExtensionId("parse-pdf", content).get(content.getUrl());-- int index = parse.getText().indexOf(expectedText);- assertTrue(index > 0);- }- }--}diff --git a/src/plugin/parse-text/build.xml b/src/plugin/parse-text/build.xmldeleted file mode 100755index 6b1ae4b7c..000000000--- a/src/plugin/parse-text/build.xml+++ /dev/null@@ -1,22 +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-text" default="jar-core">-- <import file="../build-plugin.xml"/>--</project>diff --git a/src/plugin/parse-text/plugin.xml b/src/plugin/parse-text/plugin.xmldeleted file mode 100755index b0a2b408f..000000000--- a/src/plugin/parse-text/plugin.xml+++ /dev/null@@ -1,47 +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-text"- name="Text Parse Plug-in"- version="1.0.0"- provider-name="nutch.org">--- <runtime>- <library name="parse-text.jar">- <export name="*"/>- </library>- </runtime>-- <requires>- <import plugin="nutch-extensionpoints"/>- </requires>-- <extension id="org.apache.nutch.parse.text"- name="TextParse"- point="org.apache.nutch.parse.Parser">-- <implementation id="org.apache.nutch.parse.text.TextParser"- class="org.apache.nutch.parse.text.TextParser">- <parameter name="contentType" value="text/plain"/>- <parameter name="pathSuffix" value="txt"/>- </implementation>-- </extension>--</plugin>diff --git a/src/plugin/parse-text/src/java/org/apache/nutch/parse/text/TextParser.java b/src/plugin/parse-text/src/java/org/apache/nutch/parse/text/TextParser.javadeleted file mode 100644index ac2ab91e4..000000000--- a/src/plugin/parse-text/src/java/org/apache/nutch/parse/text/TextParser.java+++ /dev/null@@ -1,67 +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.text;--import org.apache.nutch.protocol.Content;-import org.apache.nutch.parse.*;-import org.apache.nutch.util.*;--import org.apache.hadoop.conf.Configuration;--public class TextParser implements Parser {-- private Configuration conf;-- /**- * Encoding to be used when character set isn't specified- * as HTTP header.- */- private String defaultEncoding;-- /**- * Parses plain text document. This code uses configured default encoding- * {@code parser.character.encoding.default} if character set isn't specified- * as HTTP header.- */- public ParseResult getParse(Content content) {- EncodingDetector detector = new EncodingDetector(conf);- detector.autoDetectClues(content, false);- String encoding = detector.guessEncoding(content, defaultEncoding);- String text;- try {- text = new String(content.getContent(), encoding);- } catch (java.io.UnsupportedEncodingException e) {- return new ParseStatus(e)- .getEmptyParseResult(content.getUrl(), getConf());- }-- ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS, "",- OutlinkExtractor.getOutlinks(text, getConf()), content.getMetadata());- return ParseResult.createParseResult(content.getUrl(), new ParseImpl(text, parseData));- }-- public void setConf(Configuration conf) {- this.conf = conf;- defaultEncoding = conf.get("parser.character.encoding.default",- "windows-1252");- }-- public Configuration getConf() {- return this.conf;- }-}diff --git a/src/plugin/parse-text/src/java/org/apache/nutch/parse/text/package.html b/src/plugin/parse-text/src/java/org/apache/nutch/parse/text/package.htmldeleted file mode 100644index da25d8a97..000000000--- a/src/plugin/parse-text/src/java/org/apache/nutch/parse/text/package.html+++ /dev/null@@ -1,5 +0,0 @@-<html>-<body>-<p>A plain text parsing plugin.</p><p></p>-</body>-</html>diff --git a/src/plugin/parse-tika/plugin.xml b/src/plugin/parse-tika/plugin.xmlindex 1659a2e43..64fff3c84 100644--- a/src/plugin/parse-tika/plugin.xml+++ b/src/plugin/parse-tika/plugin.xml@@ -58,7 +58,7 @@id="org.apache.nutch.parse.tika"name="TikaParser">- <implementation id="org.apache.nutch.parse.tika.Parser"+ <implementation id="org.apache.nutch.parse.tika.TikaParser"class="org.apache.nutch.parse.tika.TikaParser"><parameter name="contentType" value="*"/></implementation>diff --git a/src/plugin/parse-zip/build.xml b/src/plugin/parse-zip/build.xmlindex b53236560..991ce317b 100644--- a/src/plugin/parse-zip/build.xml+++ b/src/plugin/parse-zip/build.xml@@ -23,7 +23,7 @@<target name="deps-test"><ant target="deploy" inheritall="false" dir="../nutch-extensionpoints"/><ant target="deploy" inheritall="false" dir="../protocol-file"/>- <ant target="deploy" inheritall="false" dir="../parse-text"/>+ <!-- <ant target="deploy" inheritall="false" dir="../parse-text"/>--></target>diff --git a/src/test/crawl-tests.xml b/src/test/crawl-tests.xmlindex 87eeb2c42..deb4c3af0 100644--- a/src/test/crawl-tests.xml+++ b/src/test/crawl-tests.xml@@ -6,7 +6,7 @@<property><name>plugin.includes</name>- <value>parse-html|protocol-http|urlfilter-suffix|scoring-opic</value>+ <value>parse-tika|protocol-http|urlfilter-suffix|scoring-opic</value><description>Enable required plugins.</description></property>diff --git a/src/test/org/apache/nutch/parse/TestParserFactory.java b/src/test/org/apache/nutch/parse/TestParserFactory.javaindex 05877c464..08c96e537 100644--- a/src/test/org/apache/nutch/parse/TestParserFactory.java+++ b/src/test/org/apache/nutch/parse/TestParserFactory.java@@ -50,9 +50,9 @@ public class TestParserFactory extends TestCase {/** Unit test for <code>getExtensions(String)</code> method. */public void testGetExtensions() throws Exception {Extension ext = (Extension)parserFactory.getExtensions("text/html").get(0);- assertEquals("parse-html", ext.getDescriptor().getPluginId());+ assertEquals("parse-tika", ext.getDescriptor().getPluginId());ext = (Extension) parserFactory.getExtensions("text/html; charset=ISO-8859-1").get(0);- assertEquals("parse-html", ext.getDescriptor().getPluginId());+ assertEquals("parse-tika", ext.getDescriptor().getPluginId());ext = (Extension)parserFactory.getExtensions("foo/bar").get(0);assertEquals("parse-tika", ext.getDescriptor().getPluginId());}@@ -62,14 +62,14 @@ public class TestParserFactory extends TestCase {Parser [] parsers = parserFactory.getParsers("text/html", "http://foo.com");assertNotNull(parsers);assertEquals(1, parsers.length);- assertEquals("org.apache.nutch.parse.html.HtmlParser",+ assertEquals("org.apache.nutch.parse.tika.TikaParser",parsers[0].getClass().getName());parsers = parserFactory.getParsers("text/html; charset=ISO-8859-1","http://foo.com");assertNotNull(parsers);assertEquals(1, parsers.length);- assertEquals("org.apache.nutch.parse.html.HtmlParser",+ assertEquals("org.apache.nutch.parse.tika.TikaParser",parsers[0].getClass().getName());parsers = parserFactory.getParsers("application/x-javascript",@@ -82,7 +82,7 @@ public class TestParserFactory extends TestCase {parsers = parserFactory.getParsers("text/plain", "http://foo.com");assertNotNull(parsers);assertEquals(1, parsers.length);- assertEquals("org.apache.nutch.parse.text.TextParser",+ assertEquals("org.apache.nutch.parse.tika.TikaParser",parsers[0].getClass().getName());Parser parser1 = parserFactory.getParsers("text/plain", "http://foo.com")[0];diff --git a/src/test/org/apache/nutch/parse/parse-plugin-test.xml b/src/test/org/apache/nutch/parse/parse-plugin-test.xmlindex 232021ec4..b748905dc 100644--- a/src/test/org/apache/nutch/parse/parse-plugin-test.xml+++ b/src/test/org/apache/nutch/parse/parse-plugin-test.xml@@ -22,9 +22,9 @@<parse-plugins><!-- by default if the mimeType is set to *, or- can't be determined, use parse-text -->+ if it can't be determined, use parse-tika --><mimeType name="*">- <plugin id="parse-text" />+ <plugin id="parse-tika" /></mimeType><!-- test these 4 plugins -->@@ -34,12 +34,6 @@! it should not block the process and then the next one is used!--><plugin id="parse-plugin-that-not-exist"/>- <plugin id="parse-html"/>- </mimeType>-- <mimeType name="text/plain">- <!-- Test that an extension-id can be directly used here -->- <plugin id="org.apache.nutch.parse.text.TextParser"/></mimeType><mimeType name="application/x-javascript">@@ -47,19 +41,18 @@</mimeType><mimeType name="text/rss">- <plugin id="parse-rss"/>+ <!-- Test that an extension-id can be directly used here -->+ <plugin id="org.apache.nutch.parse.rss.RSSParser"/></mimeType><!-- alias mappings for parse-xxx names to the actual extension implementationids described in each plugin's plugin.xml file --><aliases>- <alias name="parse-html"- extension-id="org.apache.nutch.parse.html.HtmlParser" /><alias name="parse-js"extension-id="JSParser" /><alias name="parse-rss"extension-id="org.apache.nutch.parse.rss.RSSParser" />- <alias name="parse-text"- extension-id="org.apache.nutch.parse.text.TextParser" />+ <alias name="parse-tika"+ extension-id="org.apache.nutch.parse.tika.TikaParser" /></aliases></parse-plugins>