Skip to content

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

refactoring of wiki parser. This was done to prepare the wiki parser as parser for wikipedia dumps, which will be used for performance test (to omit crawling)

orbiterc08f9b36a4aa
diff --git a/.classpath b/.classpath
index db78c572d..0ac94d62e 100644
--- a/.classpath
+++ b/.classpath
@@ -13,7 +13,6 @@
<classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="lib/tar.jar"/>
- <classpathentry exported="true" kind="lib" path="libx/bzip2.jar"/>
<classpathentry exported="true" kind="lib" path="libx/commons-discovery.jar"/>
<classpathentry exported="true" kind="lib" path="libx/jakarta-oro-2.0.7.jar"/>
<classpathentry exported="true" kind="lib" path="libx/jaxrpc.jar"/>
@@ -25,7 +24,6 @@
<classpathentry exported="true" kind="lib" path="libx/odf_utils_05_11_29.jar"/>
<classpathentry exported="true" kind="lib" path="libx/tm-extractors-1.0.jar"/>
<classpathentry exported="true" kind="lib" path="libx/wsdl4j.jar"/>
- <classpathentry kind="lib" path="D:/meinedaten/workspace/yacy/lib/xerces.jar"/>
<classpathentry exported="true" kind="lib" path="libx/poi-3.0-alpha2-20060616.jar"/>
<classpathentry exported="true" kind="lib" path="libx/poi-scratchpad-3.0-alpha2-20060616.jar"/>
<classpathentry exported="true" kind="lib" path="libx/inetlib.jar"/>
@@ -45,5 +43,7 @@
<classpathentry exported="true" kind="lib" path="lib/servlet-api.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-jxpath-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/sbbi-upnplib-1.0.4.jar"/>
+ <classpathentry kind="lib" path="lib/xerces.jar"/>
+ <classpathentry kind="lib" path="lib/bzip2.jar"/>
<classpathentry kind="output" path="gen"/>
</classpath>
diff --git a/build.xml b/build.xml
index 39f255a7f..8e799bacd 100644
--- a/build.xml
+++ b/build.xml
@@ -192,6 +192,7 @@
<pathelement location="${lib}/commons-io-1.4.jar" />
<pathelement location="${lib}/servlet-api.jar" />
<pathelement location="${lib}/xerces.jar" />
+ <pathelement location="${lib}/bzip2.jar" />
<!-- upnp (+ commons-logging) -->
<pathelement location="${lib}/sbbi-upnplib-1.0.4.jar" />
<pathelement location="${lib}/commons-jxpath-1.1.jar" />
diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.java
index db6f84094..25628156b 100644
--- a/htroot/ViewProfile.java
+++ b/htroot/ViewProfile.java
@@ -67,7 +67,6 @@ public class ViewProfile {
// get the profile
HashMap profile = null;
- String address = null;
if (hash.equals("localhash")) {
// read the profile from local peer
final Properties p = new Properties();
@@ -84,7 +83,6 @@ public class ViewProfile {
prop.put("localremotepeer", "0");
prop.putHTML("success_peername", sb.webIndex.peers().mySeed().getName());
prop.put("success_peerhash", sb.webIndex.peers().mySeed().hash);
- address = sb.webIndex.peers().mySeed().getPublicAddress();
} else {
// read the profile from remote peer
yacySeed seed = sb.webIndex.peers().getConnected(hash);
@@ -111,7 +109,6 @@ public class ViewProfile {
}
prop.putHTML("success_peername", seed.getName());
prop.put("success_peerhash", seed.hash);
- address = seed.getPublicAddress();
}
prop.put("localremotepeer", "1");
}
@@ -159,9 +156,7 @@ public class ViewProfile {
if(key.equals("comment")){
prop.putWiki(
"success_" + key + "_value",
- ((String) entry.getValue()).replaceAll("\r", "").replaceAll("\\\\n", "\n"),
- address
- );
+ ((String) entry.getValue()).replaceAll("\r", "").replaceAll("\\\\n", "\n"));
prop.put("success_" + key + "_b64value",Base64Order.standardCoder.encodeString((String) entry.getValue()));
}else{
prop.putHTML("success_" + key + "_value", value); //put replaces HTML Chars by entities.
diff --git a/htroot/Wiki.java b/htroot/Wiki.java
index 3004a7c02..f8393c9e8 100644
--- a/htroot/Wiki.java
+++ b/htroot/Wiki.java
@@ -35,7 +35,7 @@ import java.util.HashMap;
import java.util.Iterator;
import de.anomic.data.diff;
-import de.anomic.data.wikiBoard;
+import de.anomic.data.wiki.wikiBoard;
import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
diff --git a/libx/bzip2.jar b/libx/bzip2.jar
deleted file mode 100644
index 94eeb9789..000000000
Binary files a/libx/bzip2.jar and /dev/null differ
diff --git a/source/de/anomic/data/blogBoard.java b/source/de/anomic/data/blogBoard.java
index faee7f7e6..0cf31ce95 100644
--- a/source/de/anomic/data/blogBoard.java
+++ b/source/de/anomic/data/blogBoard.java
@@ -47,6 +47,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
+import de.anomic.data.wiki.wikiBoard;
import de.anomic.kelondro.blob.BLOBTree;
import de.anomic.kelondro.blob.MapView;
import de.anomic.kelondro.order.Base64Order;
diff --git a/source/de/anomic/data/blogBoardComments.java b/source/de/anomic/data/blogBoardComments.java
index 9897b27ec..9c2951723 100644
--- a/source/de/anomic/data/blogBoardComments.java
+++ b/source/de/anomic/data/blogBoardComments.java
@@ -46,6 +46,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
+import de.anomic.data.wiki.wikiBoard;
import de.anomic.kelondro.blob.BLOBTree;
import de.anomic.kelondro.blob.MapView;
import de.anomic.kelondro.order.Base64Order;
diff --git a/source/de/anomic/data/wiki/abstractWikiParser.java b/source/de/anomic/data/wiki/abstractWikiParser.java
index 6ef8be432..48c100ecb 100644
--- a/source/de/anomic/data/wiki/abstractWikiParser.java
+++ b/source/de/anomic/data/wiki/abstractWikiParser.java
@@ -7,29 +7,21 @@ import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
-import de.anomic.plasma.plasmaSwitchboard;
-
public abstract class abstractWikiParser implements wikiParser {
- private final plasmaSwitchboard sb;
+ String address;
- public abstractWikiParser(final plasmaSwitchboard sb) {
- this.sb = sb;
+ public abstractWikiParser(String address) {
+ this.address = address;
}
- protected abstract String transform(BufferedReader reader, int length, String publicAddress, plasmaSwitchboard sb) throws IOException;
+ protected abstract String transform(BufferedReader reader, int length) throws IOException;
public String transform(final String content) {
- return transform(content, this.sb);
- }
-
- public String transform(final String content, final plasmaSwitchboard sb) {
try {
return transform(
new BufferedReader(new StringReader(content)),
- content.length(),
- sb.webIndex.peers().mySeed().getPublicAddress(),
- sb);
+ content.length());
} catch (final IOException e) {
return "internal error: " + e.getMessage();
}
@@ -39,43 +31,33 @@ public abstract class abstractWikiParser implements wikiParser {
try {
return transform(
new BufferedReader(new StringReader(content)),
- content.length(),
- publicAddress,
- null);
+ content.length());
} catch (final IOException e) {
return "internal error: " + e.getMessage();
}
}
public String transform(final byte[] content) throws UnsupportedEncodingException {
- return transform(content, "UTF-8", this.sb);
+ return transform(content, "UTF-8");
}
- public String transform(final byte[] content, final String encoding) throws UnsupportedEncodingException {
- return transform(content, encoding, this.sb);
- }
-
public String transform(final byte[] content, final String encoding, final String publicAddress) throws UnsupportedEncodingException {
final ByteArrayInputStream bais = new ByteArrayInputStream(content);
try {
return transform(
new BufferedReader(new InputStreamReader(bais, encoding)),
- content.length,
- publicAddress,
- null);
+ content.length);
} catch (final IOException e) {
return "internal error: " + e.getMessage();
}
}
- public String transform(final byte[] content, final String encoding, final plasmaSwitchboard switchboard) throws UnsupportedEncodingException {
+ public String transform(final byte[] content, final String encoding) throws UnsupportedEncodingException {
final ByteArrayInputStream bais = new ByteArrayInputStream(content);
try {
return transform(
new BufferedReader(new InputStreamReader(bais, encoding)),
- content.length,
- sb.webIndex.peers().mySeed().getPublicAddress(),
- switchboard);
+ content.length);
} catch (final IOException e) {
return "internal error: " + e.getMessage();
}
diff --git a/source/de/anomic/data/wikiBoard.java b/source/de/anomic/data/wiki/wikiBoard.java
similarity index 96%
rename from source/de/anomic/data/wikiBoard.java
rename to source/de/anomic/data/wiki/wikiBoard.java
index 927f1584e..85cd23dc2 100644
--- a/source/de/anomic/data/wikiBoard.java
+++ b/source/de/anomic/data/wiki/wikiBoard.java
@@ -19,7 +19,7 @@
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.data;
+package de.anomic.data.wiki;
import java.io.File;
import java.io.IOException;
diff --git a/source/de/anomic/data/wikiCode.java b/source/de/anomic/data/wiki/wikiCode.java
similarity index 91%
rename from source/de/anomic/data/wikiCode.java
rename to source/de/anomic/data/wiki/wikiCode.java
index d79a4076c..d8a06d612 100644
--- a/source/de/anomic/data/wikiCode.java
+++ b/source/de/anomic/data/wiki/wikiCode.java
@@ -25,7 +25,7 @@
// Contains contributions from Alexander Schier [AS]
// Franz Brausze [FB] and Marc Nause [MN]
-package de.anomic.data;
+package de.anomic.data.wiki;
import java.io.BufferedReader;
import java.io.IOException;
@@ -33,10 +33,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import de.anomic.data.wiki.abstractWikiParser;
-import de.anomic.data.wiki.wikiParser;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
-import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
/** This class provides methods to handle texts that have been posted in the yacyWiki or other
@@ -80,19 +77,17 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
private final ArrayList<String> dirElements = new ArrayList<String>(); //list of headlines used to create diectory of page
/** Constructor of the class wikiCode */
- public wikiCode(final plasmaSwitchboard switchboard){
- super(switchboard);
+ public wikiCode(String address){
+ super(address);
}
protected String transform(
final BufferedReader reader,
- final int length,
- final String publicAddress,
- final plasmaSwitchboard switchboard) throws IOException {
+ final int length) throws IOException {
final StringBuilder out = new StringBuilder(length);
String line;
while ((line = reader.readLine()) != null)
- out.append(transformLine(line, publicAddress, switchboard)).append(serverCore.CRLF_STRING);
+ out.append(transformLine(line)).append(serverCore.CRLF_STRING);
return out.insert(0, directory()).toString();
}
@@ -101,7 +96,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
* @return a string with wiki code of parts of table replaced by HTML code for table
*/
//[FB], changes by [MN]
- private String processTable(String result, final plasmaSwitchboard switchboard){
+ private String processTable(String result){
//some variables that make it easier to change codes for the table
String line = "";
final String tableStart = "&#123;&#124;"; // {|
@@ -164,10 +159,10 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
propEnd = lenCellDivider;
}
table=false; cellprocessing=true;
- line+=">"+processTable(result.substring(propEnd,cellEnd).trim(), switchboard)+"</td>";
+ line+=">"+processTable(result.substring(propEnd,cellEnd).trim())+"</td>";
table=true; cellprocessing=false;
if (cellEnd<result.length()) {
- line+="\n"+processTable(result.substring(cellEnd), switchboard);
+ line+="\n"+processTable(result.substring(cellEnd));
}
result=line;
}
@@ -376,7 +371,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
/** This method processes links and images.
*/
//contributed by [AS] except where stated otherwise
- private String linksAndImages(String result, final String publicAddress, final plasmaSwitchboard switchboard) {
+ private String linksAndImages(String result) {
// create links
String kl, kv, alt, align;
@@ -429,7 +424,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
// or an image DATA/HTDOCS/grafics/kaskelix.jpg with [[Image:grafics/kaskelix.jpg]]
// you are free to use other sub-paths of DATA/HTDOCS
if (kl.indexOf("://")<1) {
- kl = "http://" + publicAddress.trim() + "/" + kl;
+ kl = "http://" + super.address + "/" + kl;
}
result = result.substring(0, p0) + "<img src=\"" + kl + "\"" + align + alt + ">" + result.substring(p1 + 2);
@@ -444,11 +439,11 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
} else {
kv = kl;
}
- if (switchboard != null && switchboard.wikiDB.read(kl) != null) {
+ //if (switchboard != null && switchboard.wikiDB.read(kl) != null) {
result = result.substring(0, p0) + "<a class=\"known\" href=\"Wiki.html?page=" + kl + "\">" + kv + "</a>" + result.substring(p1 + 2);
- } else {
- result = result.substring(0, p0) + "<a class=\"unknown\" href=\"Wiki.html?page=" + kl + "&edit=Edit\">" + kv + "</a>" + result.substring(p1 + 2);
- }
+ //} else {
+ // result = result.substring(0, p0) + "<a class=\"unknown\" href=\"Wiki.html?page=" + kl + "&edit=Edit\">" + kv + "</a>" + result.substring(p1 + 2);
+ //}
}
}
@@ -471,7 +466,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
// or a file DATA/HTDOCS/www/page.html with [www/page.html]
// you are free to use other sub-paths of DATA/HTDOCS
if (kl.indexOf("://") < 1) {
- kl = "http://" + publicAddress.trim() + "/" + kl;
+ kl = "http://" + super.address + "/" + kl;
}
result = result.substring(0, p0) + "<a class=\"extern\" href=\"" + kl + "\">" + kv + "</a>" + result.substring(p1 + 1);
}
@@ -480,7 +475,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
/** This method handles the escape tags [= =] */
//contributed by [MN]
- private String escapeTag(String result, final String publicAddress, final plasmaSwitchboard switchboard){
+ private String escapeTag(String result){
int p0 = 0;
int p1 = 0;
//both [= and =] in the same line
@@ -488,16 +483,16 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
if(p0<p1){
String escapeText = result.substring(p0+2,p1);
escapeText = escapeText.replaceAll("!esc!", "!esc!!");
- result = transformLine(result.substring(0,p0).replaceAll("!esc!", "!esc!!")+"!esc!txt!"+result.substring(p1+2).replaceAll("!esc!", "!esc!!"), publicAddress, switchboard);
+ result = transformLine(result.substring(0,p0).replaceAll("!esc!", "!esc!!")+"!esc!txt!"+result.substring(p1+2).replaceAll("!esc!", "!esc!!"));
result = result.replaceAll("!esc!txt!", escapeText);
result = result.replaceAll("!esc!!", "!esc!");
}
//handles cases like [=[= =]=] [= =] that would cause an exception otherwise
else{
escape = true;
- final String temp1 = transformLine(result.substring(0,p0-1).replaceAll("!tmp!","!tmp!!")+"!tmp!txt!", publicAddress, switchboard);
+ final String temp1 = transformLine(result.substring(0,p0-1).replaceAll("!tmp!","!tmp!!")+"!tmp!txt!");
nolist = true;
- final String temp2 = transformLine(result.substring(p0), publicAddress, switchboard);
+ final String temp2 = transformLine(result.substring(p0));
nolist = false;
result = temp1.replaceAll("!tmp!txt!",temp2);
result = result.replaceAll("!tmp!!", "!tmp!");
@@ -517,7 +512,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
escindented++;
bq = bq + "<blockquote>";
}
- result = transformLine(result.substring(escindented,p0).replaceAll("!esc!", "!esc!!")+"!esc!txt!", publicAddress, switchboard);
+ result = transformLine(result.substring(escindented,p0).replaceAll("!esc!", "!esc!!")+"!esc!txt!");
result = bq + result.replaceAll("!esc!txt!", escapeText);
result = result.replaceAll("!esc!!", "!esc!");
escape = false;
@@ -535,7 +530,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
bq = bq + "</blockquote>";
escindented--;
}
- result = transformLine("!esc!txt!"+result.substring(p0+2).replaceAll("!esc!", "!esc!!"), publicAddress, switchboard);
+ result = transformLine("!esc!txt!"+result.substring(p0+2).replaceAll("!esc!", "!esc!!"));
result = result.replaceAll("!esc!txt!", escapeText) + bq;
result = result.replaceAll("!esc!!", "!esc!");
escaped = false;
@@ -545,14 +540,14 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
while((p0 = result.indexOf("=]"))>=0){
result = result.substring(0,p0)+result.substring(p0+2);
}
- result = transformLine(result, publicAddress, switchboard);
+ result = transformLine(result);
}
return result;
}
/** This method handles the preformatted tags <pre> </pre> */
//contributed by [MN]
- private String preformattedTag(String result, final String publicAddress, final plasmaSwitchboard switchboard){
+ private String preformattedTag(String result){
int p0 = 0;
int p1 = 0;
//implementation very similar to escape code (see above)
@@ -561,16 +556,16 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
if(p0<p1){
String preformattedText = "<pre style=\"border:dotted;border-width:thin\">"+result.substring(p0+11,p1)+"</pre>";
preformattedText = preformattedText.replaceAll("!pre!", "!pre!!");
- result = transformLine(result.substring(0,p0).replaceAll("!pre!", "!pre!!")+"!pre!txt!"+result.substring(p1+12).replaceAll("!pre!", "!pre!!"), publicAddress, switchboard);
+ result = transformLine(result.substring(0,p0).replaceAll("!pre!", "!pre!!")+"!pre!txt!"+result.substring(p1+12).replaceAll("!pre!", "!pre!!"));
result = result.replaceAll("!pre!txt!", preformattedText);
result = result.replaceAll("!pre!!", "!pre!");
}
//handles cases like <pre><pre> </pre></pre> <pre> </pre> that would cause an exception otherwise
else{
preformatted = true;
- final String temp1 = transformLine(result.substring(0,p0-1).replaceAll("!tmp!","!tmp!!")+"!tmp!txt!", publicAddress, switchboard);
+ final String temp1 = transformLine(result.substring(0,p0-1).replaceAll("!tmp!","!tmp!!")+"!tmp!txt!");
nolist = true;
- final String temp2 = transformLine(result.substring(p0), publicAddress, switchboard);
+ final String temp2 = transformLine(result.substring(p0));
nolist = false;
result = temp1.replaceAll("!tmp!txt!",temp2);
result = result.replaceAll("!tmp!!", "!tmp!");
@@ -589,7 +584,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
preindented++;
bq = bq + "<blockquote>";
}
- result = transformLine(result.substring(preindented,p0).replaceAll("!pre!", "!pre!!")+"!pre!txt!", publicAddress, switchboard);
+ result = transformLine(result.substring(preindented,p0).replaceAll("!pre!", "!pre!!")+"!pre!txt!");
result = bq + result.replaceAll("!pre!txt!", preformattedText);
result = result.replaceAll("!pre!!", "!pre!");
preformattedSpan = true;
@@ -606,7 +601,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
bq = bq + "</blockquote>";
preindented--;
}
- result = transformLine("!pre!txt!"+result.substring(p0+12).replaceAll("!pre!", "!pre!!"), publicAddress, switchboard);
+ result = transformLine("!pre!txt!"+result.substring(p0+12).replaceAll("!pre!", "!pre!!"));
result = result.replaceAll("!pre!txt!", preformattedText) + bq;
result = result.replaceAll("!pre!!", "!pre!");
preformatted = false;
@@ -616,7 +611,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
while((p0 = result.indexOf("&lt;/pre&gt;"))>=0){
result = result.substring(0,p0)+result.substring(p0+12);
}
- result = transformLine(result, publicAddress, switchboard);
+ result = transformLine(result);
}
return result;
}
@@ -755,7 +750,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
* @param switchboard
* @return the line of text with HTML tags instead of wiki tags
*/
- public String transformLine(String result, final String publicAddress, final plasmaSwitchboard switchboard) {
+ public String transformLine(String result) {
//If HTML has not bee replaced yet (can happen if method gets called in recursion), replace now!
if (!replacedHTML || preformattedSpan){
result = htmlFilterCharacterCoding.unicode2html(result, true);
@@ -764,19 +759,19 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
//check if line contains escape symbols([= =]) or if we are in an escape sequence already.
if ((result.indexOf("[=")>=0)||(result.indexOf("=]")>=0)||(escapeSpan)){
- result = escapeTag(result, publicAddress, switchboard);
+ result = escapeTag(result);
}
//check if line contains preformatted symbols or if we are in a preformatted sequence already.
else if ((result.indexOf("&lt;pre&gt;")>=0)||(result.indexOf("&lt;/pre&gt;")>=0)||(preformattedSpan)){
- result = preformattedTag(result, publicAddress, switchboard);
+ result = preformattedTag(result);
}
//transform page as usual
else {
//tables first -> wiki-tags in cells can be treated after that
- result = processTable(result, switchboard);
+ result = processTable(result);
// format lines
if (result.startsWith(" ")) result = "<tt>" + result.substring(1) + "</tt>";
@@ -808,7 +803,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
result = orderedList(result);
result = definitionList(result);
- result = linksAndImages(result, publicAddress, switchboard);
+ result = linksAndImages(result);
}
diff --git a/source/de/anomic/data/wiki/wikiParser.java b/source/de/anomic/data/wiki/wikiParser.java
index 9ce6020b2..5fa2d0d50 100644
--- a/source/de/anomic/data/wiki/wikiParser.java
+++ b/source/de/anomic/data/wiki/wikiParser.java
@@ -2,15 +2,10 @@ package de.anomic.data.wiki;
import java.io.UnsupportedEncodingException;
-import de.anomic.plasma.plasmaSwitchboard;
-
public interface wikiParser {
public String transform(String text);
- public String transform(String text, plasmaSwitchboard switchboard);
- public String transform(String text, String publicAddress);
public String transform(byte[] text) throws UnsupportedEncodingException;
public String transform(byte[] text, String encoding) throws UnsupportedEncodingException;
- public String transform(byte[] text, String encoding, plasmaSwitchboard switchboard) throws UnsupportedEncodingException;
- public String transform(byte[] text, String encoding, String publicAddress) throws UnsupportedEncodingException;
+
}
diff --git a/source/de/anomic/plasma/parser/bzip/bzipParser.java b/source/de/anomic/plasma/parser/bzip/bzipParser.java
index 73b899218..66ddb1c9f 100644
--- a/source/de/anomic/plasma/parser/bzip/bzipParser.java
+++ b/source/de/anomic/plasma/parser/bzip/bzipParser.java
@@ -57,9 +57,7 @@ public class bzipParser extends AbstractParser implements Parser {
* a list of library names that are needed by this parser
* @see Parser#getLibxDependences()
*/
- private static final String[] LIBX_DEPENDENCIES = new String[] {
- "bzip2.jar"
- };
+ private static final String[] LIBX_DEPENDENCIES = new String[] {};
public bzipParser() {
super(LIBX_DEPENDENCIES);
diff --git a/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java b/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java
index 73b1b9abc..24209c927 100644
--- a/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java
+++ b/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java
@@ -69,8 +69,7 @@ public class mimeTypeParser extends AbstractParser implements Parser {
"commons-logging-1.1.1.jar",
"jmimemagic-0.1.0.jar",
"jakarta-oro-2.0.7.jar",
- "log4j-1.2.9.jar",
- "xerces.jar"
+ "log4j-1.2.9.jar"
};
/**
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index b3fc55476..6e7aa8816 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -130,7 +130,8 @@ import de.anomic.data.bookmarksDB;
import de.anomic.data.listManager;
import de.anomic.data.messageBoard;
import de.anomic.data.userDB;
-import de.anomic.data.wikiBoard;
+import de.anomic.data.wiki.wikiBoard;
+import de.anomic.data.wiki.wikiCode;
import de.anomic.data.wiki.wikiParser;
import de.anomic.http.httpClient;
import de.anomic.http.httpRemoteProxyConfig;
@@ -546,15 +547,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
log.logConfig("Initializing Snippet Cache");
plasmaSnippetCache.init(parser, log, this);
- final String wikiParserClassName = getConfig(plasmaSwitchboardConstants.WIKIPARSER_CLASS, plasmaSwitchboardConstants.WIKIPARSER_CLASS_DEFAULT);
- this.log.logConfig("Loading wiki parser " + wikiParserClassName + " ...");
- try {
- final Class<?> wikiParserClass = Class.forName(wikiParserClassName);
- final Constructor<?> wikiParserClassConstr = wikiParserClass.getConstructor(new Class[] { plasmaSwitchboard.class });
- wikiParser = (wikiParser)wikiParserClassConstr.newInstance(new Object[] { this });
- } catch (final Exception e) {
- this.log.logSevere("Unable to load wiki parser, the wiki won't work", e);
- }
+ // init the wiki
+ wikiParser = new wikiCode(this.webIndex.peers().mySeed().getClusterAddress());
// initializing the resourceObserver
this.observer = new ResourceObserver(this);
diff --git a/source/de/anomic/plasma/plasmaSwitchboardConstants.java b/source/de/anomic/plasma/plasmaSwitchboardConstants.java
index 322cf5413..4b37a931d 100644
--- a/source/de/anomic/plasma/plasmaSwitchboardConstants.java
+++ b/source/de/anomic/plasma/plasmaSwitchboardConstants.java
@@ -302,8 +302,6 @@ public final class plasmaSwitchboardConstants {
public static final String HTTPC_NAME_CACHE_CACHING_PATTERNS_NO = "httpc.nameCacheNoCachingPatterns";
public static final String ROBOTS_TXT = "httpd.robots.txt";
public static final String ROBOTS_TXT_DEFAULT = httpdRobotsTxtConfig.LOCKED + "," + httpdRobotsTxtConfig.DIRS;
- public static final String WIKIPARSER_CLASS = "wikiParser.class";
- public static final String WIKIPARSER_CLASS_DEFAULT = "de.anomic.data.wikiCode";
/**
* <p><code>public static final String <strong>BLACKLIST_CLASS</strong> = "Blacklist.class"</code></p>
* <p>Name of the setting which Blacklist backend shall be used. Due to different requirements of users, the
diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java
index db15d3fa6..b64dcc36b 100644
--- a/source/de/anomic/server/serverObjects.java
+++ b/source/de/anomic/server/serverObjects.java
@@ -202,16 +202,6 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
return this.put(key, "Internal error pasting wiki-code: " + e.getMessage());
}
}
- public String putWiki(final String key, final String wikiCode, final String publicAddress) {
- return this.put(key, plasmaSwitchboard.wikiParser.transform(wikiCode, publicAddress));
- }
- public String putWiki(final String key, final byte[] wikiCode, final String publicAddress) {
- try {
- return this.put(key, plasmaSwitchboard.wikiParser.transform(wikiCode, "UTF-8", publicAddress));
- } catch (final UnsupportedEncodingException e) {
- return this.put(key, "Internal error pasting wiki-code: " + e.getMessage());
- }
- }
// inc variant: for counters
public long inc(final String key) {
diff --git a/source/de/anomic/tools/mediawikiIndex.java b/source/de/anomic/tools/mediawikiIndex.java
index 3738b213b..74c9acbc8 100644
--- a/source/de/anomic/tools/mediawikiIndex.java
+++ b/source/de/anomic/tools/mediawikiIndex.java
@@ -26,7 +26,10 @@
package de.anomic.tools;
+import org.apache.tools.bzip2.CBZip2InputStream;
+
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
@@ -56,8 +59,10 @@ import de.anomic.kelondro.util.ByteBuffer;
public class mediawikiIndex {
- private static final byte[] pagestart = "<page>".getBytes();
- private static final byte[] pageend = "</page>".getBytes();
+ private static final String pagestart = "<page>";
+ private static final String pageend = "</page>";
+ private static final byte[] pagestartb = pagestart.getBytes();
+ private static final byte[] pageendb = pageend.getBytes();
public static void checkIndex(File wikimediaxml) {
File idx = idxFromWikimediaXML(wikimediaxml);
@@ -99,10 +104,10 @@ public class mediawikiIndex {
// read the wiki dump
long start, stop;
- while (in.seek(pagestart)) {
+ while (in.seek(pagestartb)) {
start = in.pos() - 6;
in.resetBuffer();
- if (!in.seek(pageend)) break;
+ if (!in.seek(pageendb)) break;
stop = in.pos();
consumer.consume(new wikiraw(in.bytes(), start, stop));
in.resetBuffer();
@@ -335,7 +340,7 @@ public class mediawikiIndex {
while (in.seek("<page ".getBytes())) {
start = in.pos() - 6;
in.resetBuffer();
- if (!in.seek(pageend)) break;
+ if (!in.seek(pageendb)) break;
s = new String(in.bytes(), "UTF-8");
in.resetBuffer();
if (s.indexOf(m) >= 0) {
@@ -363,12 +368,58 @@ public class mediawikiIndex {
public static void main(String[] s) {
if (s.length == 0) {
System.out.println("usage:");
+ System.out.println(" -more <wikipedia-dump>");
System.out.println(" -index <wikipedia-dump>");
System.out.println(" -read <start> <len> <idx-file>");
System.out.println(" -find <title> <wikipedia-dump>");
System.exit(0);
}
+ if (s[0].equals("-more")) {
+ try {
+ InputStream is = new FileInputStream(new File(s[1]));
+ if (s[1].endsWith(".bz2")) {
+ int b = is.read();
+ if (b != 'B') throw new IOException("Invalid bz2 content.");
+ b = is.read();
+ if (b != 'Z') throw new IOException("Invalid bz2 content.");
+ is = new CBZip2InputStream(is);
+ }
+ BufferedReader r = new BufferedReader(new java.io.InputStreamReader(is));
+ String t;
+ StringBuffer sb = new StringBuffer();
+ boolean read = false;
+ String title = null;
+ while ((t = r.readLine()) != null) {
+ if (t.indexOf(pagestart) >= 0) {
+ read = true;
+ continue;
+ }
+ if (t.indexOf(pageend) >= 0) {
+ read = false;
+ System.out.println("Title: " + title);
+ System.out.println(sb);
+ System.out.println();
+ sb.setLength(0);
+ continue;
+ }
+ if (t.indexOf("<title>") >= 0) {
+ title = t.substring(t.indexOf("<title>") + 7);
+ int p = title.indexOf("</title>");
+ if (p >= 0) title = title.substring(0, p);
+ continue;
+ }
+ if (read) {
+ sb.append(t);
+ sb.append('\n');
+ }
+ }
+ r.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
if (s[0].equals("-index")) {
try {
createIndex(new File(s[1]));