Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- moved triple store to net.yacy.cora.lod (should be generalized there later - added abstract add, delete, get methods in the triplestore - added generation of triples after auto-annotation - migrated all MultiProtocolURI objects to DigestURI in the parser since the url hash is needed as subject value in the triples in the triple store
Michael Peter Christen5fc6524ca873
diff --git a/.classpath b/.classpathindex 17efaa49f..45b1ff7f1 100644--- a/.classpath+++ b/.classpath@@ -51,7 +51,7 @@<classpathentry kind="lib" path="lib/icu4j-core.jar"/><classpathentry kind="lib" path="lib/htmllexer.jar"/><classpathentry kind="lib" path="lib/htmlparser.jar"/>- <classpathentry kind="lib" path="lib/jena-2.6.4.jar"/>+ <classpathentry kind="lib" path="lib/jena-2.6.4.jar" sourcepath="/Users/admin/.m2/repository/com/hp/hpl/jena/jena/2.6.4/jena-2.6.4-sources.jar"/><classpathentry kind="lib" path="lib/sax-2.0.1.jar"/><classpathentry kind="lib" path="lib/arq-2.8.7.jar"/><classpathentry kind="lib" path="lib/iri-0.8.jar"/>diff --git a/htroot/Triple_p.java b/htroot/Triple_p.javaindex 5295c34d0..376ae5e58 100644--- a/htroot/Triple_p.java+++ b/htroot/Triple_p.java@@ -3,8 +3,8 @@ import java.io.ByteArrayOutputStream;import java.io.IOException;import java.net.MalformedURLException;+import net.yacy.cora.lod.JenaTripleStore;import net.yacy.cora.protocol.RequestHeader;-import net.yacy.interaction.TripleStore;import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;@@ -58,7 +58,7 @@ public class Triple_p {newurl = d.getProtocol()+"://"+HTTPDemon.getAlternativeResolver().resolve(d.getHost())+d.getPath();System.out.println (newurl);}- TripleStore.Load(newurl);+ JenaTripleStore.load(newurl);} catch (MalformedURLException e) {Log.logException(e);} catch (IOException e) {@@ -70,7 +70,7 @@ public class Triple_p {if (post.containsKey("rdffile")) {- TripleStore.Add(post.get("rdffile$file"));+ JenaTripleStore.addFile(post.get("rdffile$file"));}if (post.containsKey("query")) {@@ -87,7 +87,7 @@ public class Triple_p {com.hp.hpl.jena.query.Query query = QueryFactory.create(queryString);// Execute the query and obtain results- QueryExecution qe = QueryExecutionFactory.create(query, TripleStore.model);+ QueryExecution qe = QueryExecutionFactory.create(query, JenaTripleStore.model);ResultSet resultSet = qe.execSelect();ByteArrayOutputStream sos = new ByteArrayOutputStream();diff --git a/htroot/User.html b/htroot/User.htmlindex 029c02eea..150266a42 100644--- a/htroot/User.html+++ b/htroot/User.html@@ -30,7 +30,7 @@You have used <strong>#[timeused]#</strong> minutes of your onlinetime limit of <strong>#[timelimit]#</strong> minutes per day.<br />#(/limit)#</p>- <form action="User.html" method="POST" accept-charset="UTF-8">+ <form action="User.html" method="post" accept-charset="UTF-8"><table border="1"><tr><td><label for="oldpass">old Password</label></td>diff --git a/htroot/interaction/GetRDF.java b/htroot/interaction/GetRDF.javaindex c2ebf8049..b8d38ad2c 100644--- a/htroot/interaction/GetRDF.java+++ b/htroot/interaction/GetRDF.java@@ -33,9 +33,9 @@ import java.io.ByteArrayOutputStream;import java.io.UnsupportedEncodingException;import net.yacy.cora.document.UTF8;+import net.yacy.cora.lod.JenaTripleStore;import net.yacy.cora.protocol.RequestHeader;import net.yacy.interaction.Interaction;-import net.yacy.interaction.TripleStore;import com.hp.hpl.jena.rdf.model.Model;@@ -64,7 +64,7 @@ public class GetRDF {fout = new ByteArrayOutputStream();- TripleStore.model.write(fout);+ JenaTripleStore.model.write(fout);try {prop.put("resultXML", fout.toString(UTF8.charset.name()));@@ -73,7 +73,7 @@ public class GetRDF {} else {- Model tmp = TripleStore.privatestorage.get(Interaction.GetLoggedOnUser(header));+ Model tmp = JenaTripleStore.privatestorage.get(Interaction.GetLoggedOnUser(header));if (tmp != null) {diff --git a/htroot/interaction/PutRDF.java b/htroot/interaction/PutRDF.javaindex 3806ee4c6..e98cf68cd 100644--- a/htroot/interaction/PutRDF.java+++ b/htroot/interaction/PutRDF.java@@ -31,9 +31,9 @@ package interaction;import java.io.ByteArrayOutputStream;+import net.yacy.cora.lod.JenaTripleStore;import net.yacy.cora.protocol.RequestHeader;import net.yacy.interaction.Interaction;-import net.yacy.interaction.TripleStore;import com.hp.hpl.jena.rdf.model.Model;@@ -63,13 +63,13 @@ public class PutRDF {fout = new ByteArrayOutputStream();- TripleStore.model.write(fout);+ JenaTripleStore.model.write(fout);prop.put("resultXML", fout.toString());} else {- Model tmp = TripleStore.privatestorage.get(Interaction.GetLoggedOnUser(header));+ Model tmp = JenaTripleStore.privatestorage.get(Interaction.GetLoggedOnUser(header));if (tmp != null) {diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.javaindex a7c55ff68..cdbec45f8 100644--- a/htroot/yacysearchtrailer.java+++ b/htroot/yacysearchtrailer.java@@ -307,7 +307,7 @@ public class yacysearchtrailer {while (i < 20 && navigatorIterator.hasNext()) {name = navigatorIterator.next();count = ve.getValue().get(name);- nav = "%2Fvocabulary%2F" + navname + "%2F" + MultiProtocolURI.escape(SimpleVocabulary.Metatag.encodePrintname(name)).toString();+ nav = "%2Fvocabulary%2F" + navname + "%2F" + MultiProtocolURI.escape(SimpleVocabulary.encodePrintname(name)).toString();queryStringForUrl = theQuery.queryStringForUrl();p = queryStringForUrl.indexOf(nav);if (p < 0) {diff --git a/source/net/yacy/interaction/TripleStore.java b/source/net/yacy/cora/lod/JenaTripleStore.javasimilarity index 63%rename from source/net/yacy/interaction/TripleStore.javarename to source/net/yacy/cora/lod/JenaTripleStore.javaindex f56d1845f..70a7a6d5a 100644--- a/source/net/yacy/interaction/TripleStore.java+++ b/source/net/yacy/cora/lod/JenaTripleStore.java@@ -1,6 +1,6 @@// Author: DL-package net.yacy.interaction;+package net.yacy.cora.lod;import java.io.ByteArrayInputStream;import java.io.File;@@ -17,10 +17,13 @@ import net.yacy.search.Switchboard;import com.hp.hpl.jena.rdf.model.Model;import com.hp.hpl.jena.rdf.model.ModelFactory;+import com.hp.hpl.jena.rdf.model.Property;+import com.hp.hpl.jena.rdf.model.Resource;+import com.hp.hpl.jena.rdf.model.StmtIterator;import com.hp.hpl.jena.util.FileManager;-public class TripleStore {+public class JenaTripleStore {public static Model model = ModelFactory.createDefaultModel();@@ -29,12 +32,12 @@ public class TripleStore {public static String file;- public static void Load(String filename) throws IOException {+ public static void load(String filename) throws IOException {if (filename.endsWith(".nt")) LoadNTriples(filename);- else LoadRDF(filename);+ else loadRDF(filename);}- public static void LoadRDF(String fileNameOrUri) throws IOException {+ public static void loadRDF(String fileNameOrUri) throws IOException {Model tmp = ModelFactory.createDefaultModel();Log.logInfo("TRIPLESTORE", "Loading from " + fileNameOrUri);InputStream is = FileManager.get().open(fileNameOrUri);@@ -62,7 +65,7 @@ public class TripleStore {}}- public static void Add (String rdffile) {+ public static void addFile(String rdffile) {Model tmp = ModelFactory.createDefaultModel();@@ -80,7 +83,7 @@ public class TripleStore {}- public static void Save (String filename) {+ public static void saveFile(String filename) {Log.logInfo("TRIPLESTORE", "Saving triplestore with " + model.size() + " triples to " + filename);FileOutputStream fout;try {@@ -93,6 +96,61 @@ public class TripleStore {}}+ /**+ * Return a Resource instance with the given URI in this model.+ * @param uri+ * @return+ */+ public static Resource getResource(String uri) {+ return model.getResource(uri);+ }++ /**+ * Return a Property instance in this model.+ * @param uri+ * @return+ */+ public static Property getProperty(String uri) {+ return model.getProperty(uri);+ }++ public static void deleteObjects(String subject, String predicate) {+ Resource r = getResource(subject);+ Property pr = getProperty(predicate);+ JenaTripleStore.model.removeAll(r, pr, (Resource) null);+ }++ public static void addTriple(String subject, String predicate, String object) {+ Resource r = getResource(subject);+ Property pr = getProperty(predicate);+ r.addProperty(pr, object);+ Log.logInfo("TRIPLElSTORE", "ADD " + subject + " - " + predicate + " - " + object);+ }++ public static Iterator<String> getObjects(final String subject, final String predicate) {+ Log.logInfo ("TRIPLESTORE", "GET " + subject + " - " + predicate + " ... ");+ final Resource r = JenaTripleStore.getResource(subject);+ final Property pr = JenaTripleStore.getProperty(predicate);+ final StmtIterator iter = JenaTripleStore.model.listStatements(r, pr, (Resource) null);+ return new Iterator<String>() {++ @Override+ public boolean hasNext() {+ return iter.hasNext();+ }++ @Override+ public String next() {+ return iter.nextStatement().getObject().toString();+ }++ @Override+ public void remove() {+ iter.remove();+ }++ };+ }public static void initPrivateStores(Switchboard switchboard) {@@ -134,9 +192,6 @@ public class TripleStore {catch (Exception anyex) {}---// create separate model}diff --git a/source/net/yacy/cora/lod/TripleStore.java b/source/net/yacy/cora/lod/MapTripleStore.javasimilarity index 95%rename from source/net/yacy/cora/lod/TripleStore.javarename to source/net/yacy/cora/lod/MapTripleStore.javaindex ec48ee894..6e431154d 100644--- a/source/net/yacy/cora/lod/TripleStore.java+++ b/source/net/yacy/cora/lod/MapTripleStore.java@@ -34,11 +34,11 @@ import net.yacy.cora.order.ByteOrder;import net.yacy.cora.order.CloneableIterator;import net.yacy.cora.storage.MapStore;-public class TripleStore {+public class MapTripleStore {MapStore store;- public TripleStore(MapStore store) {+ public MapTripleStore(MapStore store) {this.store = store;}@@ -66,7 +66,7 @@ public class TripleStore {return new Node(Rdf.Description, n);}- public void putAll(TripleStore entries) {+ public void putAll(MapTripleStore entries) {Iterator<Map.Entry<byte[], Node>> i = entries.iterator();Map.Entry<? extends byte[], ? extends Node> entry;while (i.hasNext()) {@@ -98,7 +98,7 @@ public class TripleStore {public Map.Entry<byte[], Node> next() {byte[] key = id.next();if (key == null) return null;- return new AbstractMap.SimpleImmutableEntry<byte[], Node>(key, TripleStore.this.get(key));+ return new AbstractMap.SimpleImmutableEntry<byte[], Node>(key, MapTripleStore.this.get(key));}@Overridediff --git a/source/net/yacy/cora/lod/SimpleVocabulary.java b/source/net/yacy/cora/lod/SimpleVocabulary.javaindex d8324e3e1..84bf281a7 100644--- a/source/net/yacy/cora/lod/SimpleVocabulary.java+++ b/source/net/yacy/cora/lod/SimpleVocabulary.java@@ -35,16 +35,24 @@ import net.yacy.document.geolocalization.Localization;public class SimpleVocabulary {+ public final static String DEFAULT_SUBJECT_PREFIX = "http://yacy.net/url/";+ public final static String DEFAULT_PREDICATE_PREFIX = "http://yacy.net/voc/";+private final String navigatorName;private final Map<String, String> synonym2term;private final Map<String, String> term2synonym;private final Map<String, Set<String>> synonym2synonyms;+ private String predicate, predicatePrefix, objectPrefix;+public SimpleVocabulary(String name) {this.navigatorName = name;this.synonym2term = new ConcurrentHashMap<String, String>();this.term2synonym = new ConcurrentHashMap<String, String>();this.synonym2synonyms = new ConcurrentHashMap<String, Set<String>>();+ this.predicatePrefix = DEFAULT_PREDICATE_PREFIX;+ this.predicate = this.predicatePrefix + name;+ this.objectPrefix = "";}public SimpleVocabulary(String name, File propFile) throws IOException {@@ -59,6 +67,16 @@ public class SimpleVocabulary {line = line.trim();p = line.indexOf('#');if (p >= 0) {+ String comment = line.substring(p + 1).trim();+ if (comment.startsWith("predicate-prefix:")) {+ this.predicatePrefix = comment.substring(17).trim();+ if (!this.predicatePrefix.endsWith("/")) this.predicatePrefix += "/";+ this.predicate = this.predicatePrefix + name;+ }+ if (comment.startsWith("object-prefix:")) {+ this.objectPrefix = comment.substring(14).trim();+ if (!this.objectPrefix.endsWith("/")) this.objectPrefix += "/";+ }line = line.substring(0, p).trim();}if (line.length() == 0) {@@ -104,16 +122,6 @@ public class SimpleVocabulary {}}- private final String normalizeKey(String k) {- k = k.trim();- k = k.replaceAll(" \\+", ", "); // remove symbols that are bad in a query attribute- k = k.replaceAll(" /", ", ");- k = k.replaceAll("\\+", ",");- k = k.replaceAll("/", ",");- k = k.replaceAll(" ", " ");- return k;- }-public SimpleVocabulary(String name, Localization localization) {this(name);Set<String> locNames = localization.locationNames();@@ -134,6 +142,36 @@ public class SimpleVocabulary {}}+ private final String normalizeKey(String k) {+ k = k.trim();+ k = k.replaceAll(" \\+", ", "); // remove symbols that are bad in a query attribute+ k = k.replaceAll(" /", ", ");+ k = k.replaceAll("\\+", ",");+ k = k.replaceAll("/", ",");+ k = k.replaceAll(" ", " ");+ return k;+ }++ /**+ * get the RDF predicate name+ * @return+ */+ public String getPredicate() {+ return this.predicate;+ }++ /**+ * get the prefix of the object name+ * @return+ */+ public String getObjectPrefix() {+ return this.objectPrefix;+ }++ /**+ * get the name of the navigator; this is part of the RDF predicate name (see: getPredicate())+ * @return+ */public String getName() {return this.navigatorName;}@@ -141,13 +179,13 @@ public class SimpleVocabulary {public Metatag getMetatag(char prefix, final String word) {String printname = this.synonym2term.get(word);if (printname == null) return null;- return new Metatag(prefix, this.navigatorName, printname);+ return new Metatag(prefix, this.navigatorName, this.predicate, printname);}public Set<String> getSynonyms(String term) {return this.synonym2synonyms.get(term);}-+public Set<String> tags() {return this.synonym2term.keySet();}@@ -170,15 +208,15 @@ public class SimpleVocabulary {word = PATTERN_SZ.matcher(word).replaceAll("ss");return word;}-+public static class Metatag {- private final String vocName;- private final String print;+ private final String vocName, predicate, object;private final char prefix;- public Metatag(char prefix, String vocName, String print) {+ public Metatag(char prefix, String vocName, String predicate, String object) {this.prefix = prefix;this.vocName = vocName;- this.print = print;+ this.predicate = predicate;+ this.object = object;}public Metatag(char prefix, String metatag) throws RuntimeException {this.prefix = prefix;@@ -186,55 +224,60 @@ public class SimpleVocabulary {int p = metatag.indexOf(':');if (p < 0) throw new RuntimeException("bad metatag: metatag = " + metatag);this.vocName = metatag.substring(1, p);- this.print = decodeMaskname(metatag.substring(p + 1));+ this.predicate = DEFAULT_PREDICATE_PREFIX + this.vocName;+ this.object = decodeMaskname(metatag.substring(p + 1));}-+public String getVocabularyName() {return this.vocName;}-- public String getPrintName() {- return this.print;- }-++ public String getPredicate() {+ return this.predicate;+ }++ public String getObject() {+ return this.object;+ }+@Overridepublic String toString() {- return this.prefix + this.vocName + ":" + encodePrintname(this.print);+ return this.prefix + this.vocName + ":" + encodePrintname(this.object);}-+@Overridepublic boolean equals(Object m) {Metatag m0 = (Metatag) m;- return this.vocName.equals(m0.vocName) && this.print.equals(m0.print);+ return this.vocName.equals(m0.vocName) && this.object.equals(m0.object);}-+@Overridepublic int hashCode() {- return this.vocName.hashCode() + this.print.hashCode();- }-- private final static Pattern PATTERN_UL = Pattern.compile("_");- private final static Pattern PATTERN_SP = Pattern.compile(" ");-- public static final String encodePrintname(String printname) {- return PATTERN_SP.matcher(printname).replaceAll("_");- }-- public static final String decodeMaskname(String maskname) {- return PATTERN_UL.matcher(maskname).replaceAll(" ");- }-- public static String cleanTagFromAutotagging(char prefix, final String tagString) {- if (tagString == null || tagString.length() == 0) return "";- String[] tags = PATTERN_SP.split(tagString);- StringBuilder sb = new StringBuilder(tagString.length());- for (String tag : tags) {- if (tag.length() > 0 && tag.charAt(0) != prefix) {- sb.append(tag).append(' ');- }- }- if (sb.length() == 0) return "";- return sb.substring(0, sb.length() - 1);+ return this.vocName.hashCode() + this.object.hashCode();}}++ private final static Pattern PATTERN_UL = Pattern.compile("_");+ private final static Pattern PATTERN_SP = Pattern.compile(" ");++ public static final String encodePrintname(String printname) {+ return PATTERN_SP.matcher(printname).replaceAll("_");+ }++ public static final String decodeMaskname(String maskname) {+ return PATTERN_UL.matcher(maskname).replaceAll(" ");+ }++ public static String cleanTagFromAutotagging(char prefix, final String tagString) {+ if (tagString == null || tagString.length() == 0) return "";+ String[] tags = PATTERN_SP.split(tagString);+ StringBuilder sb = new StringBuilder(tagString.length());+ for (String tag : tags) {+ if (tag.length() > 0 && tag.charAt(0) != prefix) {+ sb.append(tag).append(' ');+ }+ }+ if (sb.length() == 0) return "";+ return sb.substring(0, sb.length() - 1);+ }}diff --git a/source/net/yacy/document/Autotagging.java b/source/net/yacy/document/Autotagging.javaindex 56648e4d5..1eb812b64 100644--- a/source/net/yacy/document/Autotagging.java+++ b/source/net/yacy/document/Autotagging.java@@ -54,7 +54,7 @@ public class Autotagging {this.autotaggingPath = autotaggingPath;this.prefixChar = prefixChar;this.allTags = new ConcurrentHashMap<String, Object>();- reload();+ init();}@@ -66,7 +66,7 @@ public class Autotagging {* properties without values are allowed (the value is then set to the key)* also the value can be used as a tag*/- public void reload() {+ public void init() {this.vocabularies.clear();this.allTags.clear();if (this.autotaggingPath == null || !this.autotaggingPath.exists()) {@@ -129,19 +129,19 @@ public class Autotagging {final WordTokenizer tokens = new WordTokenizer(new ByteArrayInputStream(UTF8.getBytes(text)), LibraryProvider.dymLib);String tag;while (tokens.hasMoreElements()) {- tag = getPrintTagFromWord(tokens.nextElement().toString());+ tag = getTagFromWord(tokens.nextElement().toString()).toString();if (tag != null) as.add(tag);}return as;}- public String getPrintTagFromWord(String word) {+ public SimpleVocabulary.Metatag getTagFromWord(String word) {if (this.vocabularies.isEmpty()) return null;SimpleVocabulary.Metatag tag;word = SimpleVocabulary.normalizeWord(word);for (Map.Entry<String, SimpleVocabulary> v: this.vocabularies.entrySet()) {tag = v.getValue().getMetatag(this.prefixChar, word);- if (tag != null) return tag.toString();+ if (tag != null) return tag;}return null;}@@ -153,19 +153,15 @@ public class Autotagging {}return false;}-- public SimpleVocabulary.Metatag metatag(String vocName, String print) {- return new SimpleVocabulary.Metatag(this.prefixChar, vocName, print);- }public SimpleVocabulary.Metatag metatag(String metatag) {return new SimpleVocabulary.Metatag(this.prefixChar, metatag);}-+public String cleanTagFromAutotagging(String tagString) {- return SimpleVocabulary.Metatag.cleanTagFromAutotagging(this.prefixChar, tagString);+ return SimpleVocabulary.cleanTagFromAutotagging(this.prefixChar, tagString);}-+public static void main(String[] args) {Autotagging a = new Autotagging(new File("DATA/DICTIONARIES/" + LibraryProvider.path_to_autotagging_dictionaries), '$');for (Map.Entry<String, SimpleVocabulary> entry: a.vocabularies.entrySet()) {diff --git a/source/net/yacy/document/Condenser.java b/source/net/yacy/document/Condenser.javaindex d93939afd..a3d124755 100644--- a/source/net/yacy/document/Condenser.java+++ b/source/net/yacy/document/Condenser.java@@ -40,6 +40,7 @@ import net.yacy.cora.document.ASCII;import net.yacy.cora.document.Classification.ContentDomain;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;+import net.yacy.cora.lod.SimpleVocabulary;import net.yacy.document.language.Identificator;import net.yacy.document.parser.html.ImageEntry;import net.yacy.kelondro.data.word.Word;@@ -85,7 +86,7 @@ public final class Condenser {//private Properties analysis;private final Map<String, Word> words; // a string (the words) to (indexWord) - relation- private final Set<String> tags = new HashSet<String>(); // a set of tags, discovered from Autotagging+ private final Set<SimpleVocabulary.Metatag> tags = new HashSet<SimpleVocabulary.Metatag>(); // a set of tags, discovered from Autotagging//public int RESULT_NUMB_TEXT_BYTES = -1;public int RESULT_NUMB_WORDS = -1;@@ -235,7 +236,7 @@ public final class Condenser {// extend the tags in the document object with autotagging tagsif (!this.tags.isEmpty()) {- document.addTags(this.tags);+ document.addMetatags(this.tags);}}@@ -298,7 +299,8 @@ public final class Condenser {assert is != null;final Set<String> currsentwords = new HashSet<String>();String word = "";- String k, tag;+ String k;+ SimpleVocabulary.Metatag tag;int wordlen;Word wsp;final Word wsp1;@@ -321,7 +323,7 @@ public final class Condenser {// get tags from autotaggingif (doAutotagging) {- tag = LibraryProvider.autotagging.getPrintTagFromWord(word);+ tag = LibraryProvider.autotagging.getTagFromWord(word);if (tag != null) this.tags.add(tag);}diff --git a/source/net/yacy/document/Document.java b/source/net/yacy/document/Document.javaindex cfea34dc9..45fa6ef7c 100644--- a/source/net/yacy/document/Document.java+++ b/source/net/yacy/document/Document.java@@ -52,11 +52,15 @@ import java.util.Set;import java.util.TreeSet;import net.yacy.cora.date.ISO8601Formatter;+import net.yacy.cora.document.ASCII;import net.yacy.cora.document.Classification;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;+import net.yacy.cora.lod.JenaTripleStore;+import net.yacy.cora.lod.SimpleVocabulary;import net.yacy.document.parser.html.ContentScraper;import net.yacy.document.parser.html.ImageEntry;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.ByteBuffer;import net.yacy.kelondro.util.FileUtils;@@ -65,7 +69,7 @@ import de.anomic.crawler.retrieval.Request;public class Document {- private final MultiProtocolURI source; // the source url+ private final DigestURI source; // the source urlprivate final String mimeType; // mimeType as taken from http headerprivate final String charset; // the charset of the documentprivate final List<String> keywords; // most resources provide a keyword field@@ -90,7 +94,7 @@ public class Document {private final double lon, lat;private final Object parserObject; // the source object that was used to create the Document- public Document(final MultiProtocolURI location, final String mimeType, final String charset,+ public Document(final DigestURI location, final String mimeType, final String charset,final Object parserObject,final Set<String> languages,final String[] keywords, final String title, final String author, final String publisher,@@ -205,6 +209,27 @@ dc_rights}}+ /**+ * add the given words to the set of keywords.+ * These keywords will appear in dc_subject+ * @param tags+ */+ public void addMetatags(Set<SimpleVocabulary.Metatag> tags) {+ for (String s: this.keywords) {+ tags.remove(s);+ }+ for (SimpleVocabulary.Metatag s: tags) {+ String t = s.toString();+ if (!this.keywords.contains(t)) {+ this.keywords.add(t);+ }+ // put to triplestore+ String subject = SimpleVocabulary.DEFAULT_SUBJECT_PREFIX + ASCII.String(this.source.hash());+ JenaTripleStore.addTriple(subject, s.getPredicate(), s.getObject());+ JenaTripleStore.addTriple(subject, "http://www.w3.org/2002/07/owl#sameAs", this.source.toNormalform(true, false));+ }+ }+public String[] dc_subject() {// sort out doubles and empty wordsfinal TreeSet<String> hs = new TreeSet<String>();@@ -725,7 +750,7 @@ dc_rights* @param docs* @return*/- public static Document mergeDocuments(final MultiProtocolURI location,+ public static Document mergeDocuments(final DigestURI location,final String globalMime, final Document[] docs){if (docs == null || docs.length == 0) return null;diff --git a/source/net/yacy/document/Parser.java b/source/net/yacy/document/Parser.javaindex e7192a741..eaf2cc251 100644--- a/source/net/yacy/document/Parser.java+++ b/source/net/yacy/document/Parser.java@@ -7,12 +7,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -27,6 +27,7 @@ import java.io.InputStream;import java.util.Set;import net.yacy.cora.document.MultiProtocolURI;+import net.yacy.kelondro.data.meta.DigestURI;public interface Parser {@@ -35,13 +36,13 @@ public interface Parser {* @return a set of mime type strings that are supported*/public Set<String> supportedMimeTypes();-+/*** each parser must define a set of supported file extensions* @return a set of file name extensions that are supported*/public Set<String> supportedExtensions();-+/*** parse an input stream* @param url the url of the source@@ -53,15 +54,15 @@ public interface Parser {* @throws InterruptedException*/public Document[] parse(- MultiProtocolURI url,+ DigestURI url,String mimeType,String charset,InputStream source) throws Parser.Failure, InterruptedException;-+// methods to that shall make it possible to put Parser objects into a hashtable-+/*** get the name of the parser* @return the name of the parser@@ -75,20 +76,20 @@ public interface Parser {*/@Overridepublic boolean equals(Object o);-+/*** the hash code of a parser* @return the hash code of the parser name string*/@Overridepublic int hashCode();-+/*** a parser warning* thrown as an exception*/public class Failure extends Exception {-+private static final long serialVersionUID = 2278214953869122883L;private MultiProtocolURI url = null;public Failure() {@@ -99,12 +100,12 @@ public interface Parser {super(message + "; url = " + url.toNormalform(true, false));this.url = url;}-+public Failure(final String message, final MultiProtocolURI url, Throwable e) {super(message + "; url = " + url.toNormalform(true, false), e);this.url = url;}-+public MultiProtocolURI getURL() {return this.url;}diff --git a/source/net/yacy/document/TextParser.java b/source/net/yacy/document/TextParser.javaindex fa984ad66..cada8a776 100644--- a/source/net/yacy/document/TextParser.java+++ b/source/net/yacy/document/TextParser.java@@ -63,6 +63,7 @@ import net.yacy.document.parser.zipParser;import net.yacy.document.parser.augment.AugmentParser;import net.yacy.document.parser.images.genericImageParser;import net.yacy.document.parser.rdfa.impl.RDFaParser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.FileUtils;import net.yacy.kelondro.util.MemoryControl;@@ -148,7 +149,7 @@ public final class TextParser {}public static Document[] parseSource(- final MultiProtocolURI location,+ final DigestURI location,final String mimeType,final String charset,final File sourceFile@@ -179,7 +180,7 @@ public final class TextParser {}public static Document[] parseSource(- final MultiProtocolURI location,+ final DigestURI location,String mimeType,final String charset,final byte[] content@@ -202,7 +203,7 @@ public final class TextParser {}public static Document[] parseSource(- final MultiProtocolURI location,+ final DigestURI location,String mimeType,final String charset,final long contentLength,@@ -241,7 +242,7 @@ public final class TextParser {}private static Document[] parseSource(- final MultiProtocolURI location,+ final DigestURI location,final String mimeType,final Parser parser,final String charset,@@ -264,7 +265,7 @@ public final class TextParser {}private static Document[] parseSource(- final MultiProtocolURI location,+ final DigestURI location,final String mimeType,final List<Parser> parsers,final String charset,diff --git a/source/net/yacy/document/parser/augment/AugmentParser.java b/source/net/yacy/document/parser/augment/AugmentParser.javaindex 72023663a..55e96858e 100644--- a/source/net/yacy/document/parser/augment/AugmentParser.java+++ b/source/net/yacy/document/parser/augment/AugmentParser.java@@ -2,13 +2,10 @@ package net.yacy.document.parser.augment;import java.io.IOException;import java.io.InputStream;-import java.net.MalformedURLException;import java.util.HashSet;import java.util.Iterator;import java.util.Set;-import net.yacy.cora.document.ASCII;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.Document;import net.yacy.document.parser.rdfa.impl.RDFaParser;import net.yacy.kelondro.data.meta.DigestURI;@@ -58,7 +55,7 @@ public class AugmentParser extends RDFaParser {}@Override- public Document[] parse(MultiProtocolURI url, String mimeType,+ public Document[] parse(DigestURI url, String mimeType,String charset, InputStream source) throws Failure,InterruptedException {@@ -70,17 +67,6 @@ public class AugmentParser extends RDFaParser {e.printStackTrace();}- String urlHash = String.valueOf(url.hashCode());-- DigestURI durl;- try {- durl = new DigestURI(MultiProtocolURI.unescape(url.toString()));- urlHash = ASCII.String(durl.hash());- } catch (MalformedURLException e1) {- // TODO Auto-generated catch block- e1.printStackTrace();- }-Document alreadyParsedDocument = htmlDocs[0];Document superDoc = analyze(alreadyParsedDocument, url, mimeType, charset, source);@@ -102,7 +88,7 @@ public class AugmentParser extends RDFaParser {}- private Document analyze (Document alreadyParsedDocument, MultiProtocolURI url,+ private Document analyze (Document alreadyParsedDocument, DigestURI url,String mimeType, String charset, InputStream source) {Document newDoc = new Document(url, mimeType, charset, null, null, null, "", "",@@ -123,7 +109,7 @@ public class AugmentParser extends RDFaParser {}- private Document parseAndAugment(MultiProtocolURI url,+ private Document parseAndAugment(DigestURI url,String mimeType, String charset, InputStream source) {String all = "";diff --git a/source/net/yacy/document/parser/bzipParser.java b/source/net/yacy/document/parser/bzipParser.javaindex ff36f1f4a..3f33f974f 100644--- a/source/net/yacy/document/parser/bzipParser.java+++ b/source/net/yacy/document/parser/bzipParser.java@@ -31,11 +31,11 @@ import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.TextParser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.util.FileUtils;import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;@@ -56,7 +56,7 @@ public class bzipParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI location, final String mimeType,+ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source)throws Parser.Failure, InterruptedException {diff --git a/source/net/yacy/document/parser/csvParser.java b/source/net/yacy/document/parser/csvParser.javaindex bb8a71030..ee92b45f2 100644--- a/source/net/yacy/document/parser/csvParser.java+++ b/source/net/yacy/document/parser/csvParser.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -36,6 +36,7 @@ import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;/*** a parser for comma-separated values@@ -46,10 +47,10 @@ public class csvParser extends AbstractParser implements Parser {public csvParser() {super("Comma Separated Value Parser");- SUPPORTED_EXTENSIONS.add("csv");+ this.SUPPORTED_EXTENSIONS.add("csv");}-- public Document[] parse(MultiProtocolURI location, String mimeType, String charset, InputStream source) throws Parser.Failure, InterruptedException {++ public Document[] parse(DigestURI location, String mimeType, String charset, InputStream source) throws Parser.Failure, InterruptedException {// construct a document using all cells of the document// the first row is used as headline// all lines are artificially terminated by a '.' to separate them as sentence for the condenser.@@ -72,7 +73,7 @@ public class csvParser extends AbstractParser implements Parser {"",null,null,- 0.0f, 0.0f,+ 0.0f, 0.0f,sb.toString().getBytes(charset),null,null,@@ -92,7 +93,7 @@ public class csvParser extends AbstractParser implements Parser {sb.append('.');return sb.toString();}-+private List<String[]> getTable(MultiProtocolURI location, String mimeType, String charset, InputStream source) {final List<String[]> rows = new ArrayList<String[]>();BufferedReader reader;diff --git a/source/net/yacy/document/parser/docParser.java b/source/net/yacy/document/parser/docParser.javaindex d666132b1..4ecddf499 100644--- a/source/net/yacy/document/parser/docParser.java+++ b/source/net/yacy/document/parser/docParser.java@@ -1,4 +1,4 @@-//docParser.java+//docParser.java//------------------------//part of YaCy//(C) by Michael Peter Christen; [email protected]@@ -28,30 +28,32 @@package net.yacy.document.parser;import java.io.InputStream;-import net.yacy.cora.document.MultiProtocolURI;+import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;+import org.apache.poi.hwpf.extractor.WordExtractor;public class docParser extends AbstractParser implements Parser {public docParser() {super("Word Document Parser");- SUPPORTED_EXTENSIONS.add("doc");- SUPPORTED_MIME_TYPES.add("application/msword");- SUPPORTED_MIME_TYPES.add("application/doc");- SUPPORTED_MIME_TYPES.add("appl/text");- SUPPORTED_MIME_TYPES.add("application/vnd.msword");- SUPPORTED_MIME_TYPES.add("application/vnd.ms-word");- SUPPORTED_MIME_TYPES.add("application/winword");- SUPPORTED_MIME_TYPES.add("application/word");- SUPPORTED_MIME_TYPES.add("application/x-msw6");- SUPPORTED_MIME_TYPES.add("application/x-msword");+ this.SUPPORTED_EXTENSIONS.add("doc");+ this.SUPPORTED_MIME_TYPES.add("application/msword");+ this.SUPPORTED_MIME_TYPES.add("application/doc");+ this.SUPPORTED_MIME_TYPES.add("appl/text");+ this.SUPPORTED_MIME_TYPES.add("application/vnd.msword");+ this.SUPPORTED_MIME_TYPES.add("application/vnd.ms-word");+ this.SUPPORTED_MIME_TYPES.add("application/winword");+ this.SUPPORTED_MIME_TYPES.add("application/word");+ this.SUPPORTED_MIME_TYPES.add("application/x-msw6");+ this.SUPPORTED_MIME_TYPES.add("application/x-msword");}- public Document[] parse(final MultiProtocolURI location, final String mimeType,+ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source)throws Parser.Failure, InterruptedException {@@ -96,13 +98,13 @@ public class docParser extends AbstractParser implements Parser {extractor.getDocSummaryInformation().getCompany(), // publishernull,null,- 0.0f, 0.0f,+ 0.0f, 0.0f,UTF8.getBytes(contents.toString()),null,null,null,false)};-+return docs;}diff --git a/source/net/yacy/document/parser/dwgParser.java b/source/net/yacy/document/parser/dwgParser.javaindex c35ffa468..436396cdf 100644--- a/source/net/yacy/document/parser/dwgParser.java+++ b/source/net/yacy/document/parser/dwgParser.java@@ -25,10 +25,10 @@ package net.yacy.document.parser;import java.io.InputStream;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.util.MemoryControl;import org.apache.poi.util.StringUtil;@@ -60,7 +60,7 @@ public class dwgParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {+ public Document[] parse(final DigestURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {// check memory for parserif (!MemoryControl.request(200 * 1024 * 1024, true))diff --git a/source/net/yacy/document/parser/genericParser.java b/source/net/yacy/document/parser/genericParser.javaindex efa979d9a..a0971bd22 100644--- a/source/net/yacy/document/parser/genericParser.java+++ b/source/net/yacy/document/parser/genericParser.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -30,6 +30,7 @@ import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;/*** this parser can parse just anything because it uses only the uri/file/path information@@ -41,8 +42,8 @@ public class genericParser extends AbstractParser implements Parser {// no SUPPORTED_EXTENSIONS and no SUPPORTED_MIME_TYPES// this parser is used if no other fits. This parser fits all}-- public Document[] parse(final MultiProtocolURI location, final String mimeType,++ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source1)throws Parser.Failure, InterruptedException {@@ -54,11 +55,11 @@ public class genericParser extends AbstractParser implements Parser {null,null,location.getFileName().length() == 0 ? location.toTokens() : MultiProtocolURI.unescape(location.getFileName()), // title- "", // author+ "", // authorlocation.getHost(),null,null,- 0.0f, 0.0f,+ 0.0f, 0.0f,location.toTokens(),null,null,diff --git a/source/net/yacy/document/parser/gzipParser.java b/source/net/yacy/document/parser/gzipParser.javaindex db4097c5f..287ea5108 100644--- a/source/net/yacy/document/parser/gzipParser.java+++ b/source/net/yacy/document/parser/gzipParser.java@@ -32,11 +32,11 @@ import java.io.FileOutputStream;import java.io.InputStream;import java.util.zip.GZIPInputStream;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.TextParser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.util.FileUtils;@@ -55,7 +55,7 @@ public class gzipParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {+ public Document[] parse(final DigestURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {File tempFile = null;Document[] docs = null;diff --git a/source/net/yacy/document/parser/htmlParser.java b/source/net/yacy/document/parser/htmlParser.javaindex 3fccb3cbc..77918959e 100644--- a/source/net/yacy/document/parser/htmlParser.java+++ b/source/net/yacy/document/parser/htmlParser.java@@ -43,6 +43,7 @@ import net.yacy.document.parser.html.CharacterCoding;import net.yacy.document.parser.html.ContentScraper;import net.yacy.document.parser.html.ScraperInputStream;import net.yacy.document.parser.html.TransformerWriter;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.util.FileUtils;import com.ibm.icu.text.CharsetDetector;@@ -85,7 +86,7 @@ public class htmlParser extends AbstractParser implements Parser {@Overridepublic Document[] parse(- final MultiProtocolURI location,+ final DigestURI location,final String mimeType,final String documentCharset,final InputStream sourceStream) throws Parser.Failure, InterruptedException {@@ -109,7 +110,7 @@ public class htmlParser extends AbstractParser implements Parser {* @param scraper* @return*/- private static Document transformScraper(final MultiProtocolURI location, final String mimeType, final String charSet, final ContentScraper scraper) {+ private static Document transformScraper(final DigestURI location, final String mimeType, final String charSet, final ContentScraper scraper) {final String[] sections = new String[scraper.getHeadlines(1).length +scraper.getHeadlines(2).length +@@ -294,9 +295,9 @@ public class htmlParser extends AbstractParser implements Parser {public static void main(final String[] args) {// test parsing of a url- MultiProtocolURI url;+ DigestURI url;try {- url = new MultiProtocolURI(args[0]);+ url = new DigestURI(args[0]);final byte[] content = url.get(ClientIdentification.getUserAgent(), 3000);final Document[] document = new htmlParser("HTML Parser").parse(url, "text/html", null, new ByteArrayInputStream(content));final String title = document[0].dc_title();diff --git a/source/net/yacy/document/parser/images/genericImageParser.java b/source/net/yacy/document/parser/images/genericImageParser.javaindex 516eb6739..6083d280b 100644--- a/source/net/yacy/document/parser/images/genericImageParser.java+++ b/source/net/yacy/document/parser/images/genericImageParser.java@@ -49,6 +49,7 @@ import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.parser.html.ImageEntry;import net.yacy.document.parser.images.bmpParser.IMAGEMAP;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.FileUtils;@@ -89,7 +90,7 @@ public class genericImageParser extends AbstractParser implements Parser {@Overridepublic Document[] parse(- final MultiProtocolURI location,+ final DigestURI location,final String mimeType,final String documentCharset,final InputStream sourceStream) throws Parser.Failure, InterruptedException {@@ -294,9 +295,9 @@ public class genericImageParser extends AbstractParser implements Parser {public static void main(final String[] args) {final File image = new File(args[0]);final genericImageParser parser = new genericImageParser();- MultiProtocolURI uri;+ DigestURI uri;try {- uri = new MultiProtocolURI("http://localhost/" + image.getName());+ uri = new DigestURI("http://localhost/" + image.getName());final Document[] document = parser.parse(uri, "image/" + uri.getFileExtension(), "UTF-8", new FileInputStream(image));System.out.println(document[0].toString());} catch (final MalformedURLException e) {diff --git a/source/net/yacy/document/parser/mmParser.java b/source/net/yacy/document/parser/mmParser.javaindex d9ef630b9..bdf19aff8 100644--- a/source/net/yacy/document/parser/mmParser.java+++ b/source/net/yacy/document/parser/mmParser.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -28,28 +28,30 @@ import java.io.IOException;import java.io.InputStream;import java.util.ArrayList;import java.util.List;+import javax.xml.parsers.ParserConfigurationException;import javax.xml.parsers.SAXParser;import javax.xml.parsers.SAXParserFactory;-import org.xml.sax.Attributes;-import org.xml.sax.SAXException;-import org.xml.sax.helpers.DefaultHandler;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;++import org.xml.sax.Attributes;+import org.xml.sax.SAXException;+import org.xml.sax.helpers.DefaultHandler;// this is a new implementation of this parser idiom using multiple documents as result setpublic class mmParser extends AbstractParser implements Parser {- public mmParser() {+ public mmParser() {super("FreeMind Parser");- SUPPORTED_EXTENSIONS.add("mm");- SUPPORTED_MIME_TYPES.add("application/freemind");- SUPPORTED_MIME_TYPES.add("application/x-freemind");+ this.SUPPORTED_EXTENSIONS.add("mm");+ this.SUPPORTED_MIME_TYPES.add("application/freemind");+ this.SUPPORTED_MIME_TYPES.add("application/x-freemind");}private static final ThreadLocal<SAXParser> tlSax = new ThreadLocal<SAXParser>();@@ -65,8 +67,8 @@ public class mmParser extends AbstractParser implements Parser {}return parser;}-- public Document[] parse(final MultiProtocolURI location, final String mimeType,++ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source)throws Parser.Failure, InterruptedException{@@ -91,9 +93,9 @@ public class mmParser extends AbstractParser implements Parser {content = UTF8.getBytes(sb.toString());} catch (SAXException ex) {- log.logWarning(ex.getMessage());+ this.log.logWarning(ex.getMessage());} catch (IOException ex) {- log.logWarning(ex.getMessage());+ this.log.logWarning(ex.getMessage());}return new Document[]{new Document(@@ -108,7 +110,7 @@ public class mmParser extends AbstractParser implements Parser {null,null,null,- 0.0f, 0.0f,+ 0.0f, 0.0f,content,null,null,@@ -118,7 +120,7 @@ public class mmParser extends AbstractParser implements Parser {private class FreeMindHandler extends DefaultHandler {- private List<String> nodeText = new ArrayList<String>();+ private final List<String> nodeText = new ArrayList<String>();@Overridepublic void startElement(final String uri, final String localName,@@ -126,13 +128,13 @@ public class mmParser extends AbstractParser implements Parser {if (qName.equals("node")) {final String textValue = attributes.getValue("TEXT");if (textValue != null) {- nodeText.add(textValue);+ this.nodeText.add(textValue);}}}protected List<String> getNodeText() {- return nodeText;+ return this.nodeText;}}diff --git a/source/net/yacy/document/parser/odtParser.java b/source/net/yacy/document/parser/odtParser.javaindex 8c8e99d22..e5252abfd 100644--- a/source/net/yacy/document/parser/odtParser.java+++ b/source/net/yacy/document/parser/odtParser.java@@ -39,18 +39,18 @@ import javax.xml.parsers.ParserConfigurationException;import javax.xml.parsers.SAXParser;import javax.xml.parsers.SAXParserFactory;-import org.xml.sax.SAXException;--import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.parser.xml.ODContentHandler;import net.yacy.document.parser.xml.ODMetaHandler;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.io.CharBuffer;import net.yacy.kelondro.util.FileUtils;+import org.xml.sax.SAXException;+public class odtParser extends AbstractParser implements Parser {public final static int MAX_DOCSIZE = 200 * 1024 * 1024;@@ -103,8 +103,8 @@ public class odtParser extends AbstractParser implements Parser {}return parser;}-- private Document[] parse(final MultiProtocolURI location, final String mimeType,++ private Document[] parse(final DigestURI location, final String mimeType,final String charset, final File dest)throws Parser.Failure, InterruptedException {@@ -120,7 +120,7 @@ public class odtParser extends AbstractParser implements Parser {// opening the file as zip filefinal ZipFile zipFile = new ZipFile(dest);final Enumeration<? extends ZipEntry> zipEnum = zipFile.entries();-+// looping through all containing fileswhile (zipEnum.hasMoreElements()) {@@ -210,7 +210,7 @@ public class odtParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {+ public Document[] parse(final DigestURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {File dest = null;try {// creating a tempfilediff --git a/source/net/yacy/document/parser/ooxmlParser.java b/source/net/yacy/document/parser/ooxmlParser.javaindex 5c6aa31bb..9dcf83266 100644--- a/source/net/yacy/document/parser/ooxmlParser.java+++ b/source/net/yacy/document/parser/ooxmlParser.java@@ -39,19 +39,19 @@ import javax.xml.parsers.ParserConfigurationException;import javax.xml.parsers.SAXParser;import javax.xml.parsers.SAXParserFactory;-import org.xml.sax.SAXException;--import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.parser.xml.ODContentHandler;import net.yacy.document.parser.xml.ODMetaHandler;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.io.CharBuffer;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.FileUtils;+import org.xml.sax.SAXException;+public class ooxmlParser extends AbstractParser implements Parser {@@ -87,8 +87,8 @@ public class ooxmlParser extends AbstractParser implements Parser {}return parser;}-- private Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset, final File dest) throws Parser.Failure, InterruptedException {++ private Document[] parse(final DigestURI location, final String mimeType, final String charset, final File dest) throws Parser.Failure, InterruptedException {CharBuffer writer = null;try {@@ -102,7 +102,7 @@ public class ooxmlParser extends AbstractParser implements Parser {// opening the file as zip filefinal ZipFile zipFile= new ZipFile(dest);final Enumeration<? extends ZipEntry> zipEnum = zipFile.entries();-+// looping through all containing fileswhile (zipEnum.hasMoreElements()) {@@ -197,7 +197,7 @@ public class ooxmlParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {+ public Document[] parse(final DigestURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {File dest = null;try {// creating a tempfilediff --git a/source/net/yacy/document/parser/pdfParser.java b/source/net/yacy/document/parser/pdfParser.javaindex 3d5f93410..0f9381202 100644--- a/source/net/yacy/document/parser/pdfParser.java+++ b/source/net/yacy/document/parser/pdfParser.java@@ -37,6 +37,7 @@ import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.io.CharBuffer;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.FileUtils;@@ -67,7 +68,7 @@ public class pdfParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {+ public Document[] parse(final DigestURI location, final String mimeType, final String charset, final InputStream source) throws Parser.Failure, InterruptedException {// check memory for parserif (!MemoryControl.request(200 * 1024 * 1024, true))diff --git a/source/net/yacy/document/parser/pptParser.java b/source/net/yacy/document/parser/pptParser.javaindex e882793dd..33d66cc07 100644--- a/source/net/yacy/document/parser/pptParser.java+++ b/source/net/yacy/document/parser/pptParser.java@@ -1,4 +1,4 @@-//pptParser.java+//pptParser.java//------------------------//part of YaCy//(C) by Michael Peter Christen; [email protected]@@ -30,11 +30,11 @@ package net.yacy.document.parser;import java.io.BufferedInputStream;import java.io.InputStream;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;import org.apache.poi.hslf.extractor.PowerPointExtractor;@@ -43,23 +43,23 @@ public class pptParser extends AbstractParser implements Parser {public pptParser(){super("Microsoft Powerpoint Parser");- SUPPORTED_EXTENSIONS.add("ppt");- SUPPORTED_EXTENSIONS.add("pps");- SUPPORTED_MIME_TYPES.add("application/mspowerpoint");- SUPPORTED_MIME_TYPES.add("application/powerpoint");- SUPPORTED_MIME_TYPES.add("application/vnd.ms-powerpoint");- SUPPORTED_MIME_TYPES.add("application/ms-powerpoint");- SUPPORTED_MIME_TYPES.add("application/mspowerpnt");- SUPPORTED_MIME_TYPES.add("application/vnd-mspowerpoint");- SUPPORTED_MIME_TYPES.add("application/x-powerpoint");- SUPPORTED_MIME_TYPES.add("application/x-m");+ this.SUPPORTED_EXTENSIONS.add("ppt");+ this.SUPPORTED_EXTENSIONS.add("pps");+ this.SUPPORTED_MIME_TYPES.add("application/mspowerpoint");+ this.SUPPORTED_MIME_TYPES.add("application/powerpoint");+ this.SUPPORTED_MIME_TYPES.add("application/vnd.ms-powerpoint");+ this.SUPPORTED_MIME_TYPES.add("application/ms-powerpoint");+ this.SUPPORTED_MIME_TYPES.add("application/mspowerpnt");+ this.SUPPORTED_MIME_TYPES.add("application/vnd-mspowerpoint");+ this.SUPPORTED_MIME_TYPES.add("application/x-powerpoint");+ this.SUPPORTED_MIME_TYPES.add("application/x-m");}/** parses the source documents and returns a plasmaParserDocument containing* all extracted information about the parsed document- */- public Document[] parse(final MultiProtocolURI location, final String mimeType,+ */+ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source) throws Parser.Failure,InterruptedException {try {@@ -77,7 +77,7 @@ public class pptParser extends AbstractParser implements Parser {if (title.length() == l) break;l = title.length();}-+/** create the plasmaParserDocument for the database* and set shortText and bodyText properly@@ -94,14 +94,14 @@ public class pptParser extends AbstractParser implements Parser {pptExtractor.getDocSummaryInformation().getCompany(),null,null,- 0.0f, 0.0f,+ 0.0f, 0.0f,UTF8.getBytes(contents),null,null,null,false)};return docs;- } catch (final Exception e) {+ } catch (final Exception e) {if (e instanceof InterruptedException) throw (InterruptedException) e;/*@@ -109,7 +109,7 @@ public class pptParser extends AbstractParser implements Parser {*/Log.logException(e);final String errorMsg = "Unable to parse the ppt document '" + location + "':" + e.getMessage();- this.log.logSevere(errorMsg);+ this.log.logSevere(errorMsg);throw new Parser.Failure(errorMsg, location);}}diff --git a/source/net/yacy/document/parser/psParser.java b/source/net/yacy/document/parser/psParser.javaindex e777f16be..e354befae 100644--- a/source/net/yacy/document/parser/psParser.java+++ b/source/net/yacy/document/parser/psParser.java@@ -1,4 +1,4 @@-//psParser.java+//psParser.java//------------------------//part of YaCy//(C) by Michael Peter Christen; [email protected]@@ -35,27 +35,27 @@ import java.io.FileWriter;import java.io.InputStream;import java.io.InputStreamReader;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.util.FileUtils;public class psParser extends AbstractParser implements Parser {-+private final static Object modeScan = new Object();private static boolean modeScanDone = false;private static String parserMode = "java";-- public psParser() {- super("PostScript Document Parser");- SUPPORTED_EXTENSIONS.add("ps");- SUPPORTED_MIME_TYPES.add("application/postscript");- SUPPORTED_MIME_TYPES.add("application/ps");- SUPPORTED_MIME_TYPES.add("application/x-postscript");- SUPPORTED_MIME_TYPES.add("application/x-ps");- SUPPORTED_MIME_TYPES.add("application/x-postscript-not-eps");++ public psParser() {+ super("PostScript Document Parser");+ this.SUPPORTED_EXTENSIONS.add("ps");+ this.SUPPORTED_MIME_TYPES.add("application/postscript");+ this.SUPPORTED_MIME_TYPES.add("application/ps");+ this.SUPPORTED_MIME_TYPES.add("application/x-postscript");+ this.SUPPORTED_MIME_TYPES.add("application/x-ps");+ this.SUPPORTED_MIME_TYPES.add("application/x-postscript-not-eps");if (!modeScanDone) synchronized (modeScan) {if (testForPs2Ascii()) parserMode = "ps2ascii";else parserMode = "java";@@ -67,7 +67,7 @@ public class psParser extends AbstractParser implements Parser {try {String procOutputLine = null;final StringBuilder procOutput = new StringBuilder(80);-+final Process ps2asciiProc = Runtime.getRuntime().exec(new String[]{"ps2ascii", "--version"});final BufferedReader stdOut = new BufferedReader(new InputStreamReader(ps2asciiProc.getInputStream()));while ((procOutputLine = stdOut.readLine()) != null) {@@ -81,22 +81,22 @@ public class psParser extends AbstractParser implements Parser {return false;}}--- private Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset, final File sourceFile) throws Parser.Failure, InterruptedException {-+++ private Document[] parse(final DigestURI location, final String mimeType, final String charset, final File sourceFile) throws Parser.Failure, InterruptedException {+File outputFile = null;- try {+ try {// creating a temp file for the outputoutputFile = FileUtils.createTempFile(this.getClass(), "ascii.txt");-+// decide with parser mode to useif (parserMode.equals("ps2ascii")) {parseUsingPS2ascii(sourceFile,outputFile);} else {parseUsingJava(sourceFile,outputFile);}-+// return resultfinal Document[] docs = new Document[]{new Document(location, // url@@ -110,44 +110,44 @@ public class psParser extends AbstractParser implements Parser {"", // publishernull, // sectionsnull, // abstract- 0.0f, 0.0f,+ 0.0f, 0.0f,outputFile, // fulltextnull, // anchorsnull, // rssnull, // imagesfalse)}; // indexingdenied-+return docs;- } catch (final Exception e) {+ } catch (final Exception e) {if (e instanceof InterruptedException) throw (InterruptedException) e;if (e instanceof Parser.Failure) throw (Parser.Failure) e;-+// delete temp fileif (outputFile != null) FileUtils.deletedelete(outputFile);-+// throw exception- throw new Parser.Failure("Unexpected error while parsing ps file. " + e.getMessage(),location);- }- }-+ throw new Parser.Failure("Unexpected error while parsing ps file. " + e.getMessage(),location);+ }+ }+private void parseUsingJava(final File inputFile, final File outputFile) throws Exception {-+BufferedReader reader = null;BufferedWriter writer = null;try {reader = new BufferedReader(new FileReader(inputFile));writer = new BufferedWriter(new FileWriter(outputFile));-+final String versionInfoLine = reader.readLine();final String version = (versionInfoLine == null) ? "" : versionInfoLine.substring(versionInfoLine.length()-3);int ichar = 0;boolean isComment = false;boolean isText = false;-+if (version.length() > 0 && version.charAt(0) == '2') {boolean isConnector = false;-+while ((ichar = reader.read()) > 0) {if (isConnector) {if (ichar < 108) {@@ -155,7 +155,7 @@ public class psParser extends AbstractParser implements Parser {}isConnector = false;} else if (ichar == '%') {- isComment = true;+ isComment = true;} else if (ichar == '\n' && isComment) {isComment = false;} else if (ichar == ')' && isText ) {@@ -167,13 +167,13 @@ public class psParser extends AbstractParser implements Parser {isText = true;}}-+} else if (version.length() > 0 && version.charAt(0) == '3') {final StringBuilder stmt = new StringBuilder();boolean isBMP = false;boolean isStore = false;int store = 0;-+while ((ichar = reader.read()) > 0) {if (ichar == '%') {isComment = true;@@ -187,7 +187,7 @@ public class psParser extends AbstractParser implements Parser {isText = true;} else if (isStore) {if (store == 9 || ichar == ' ' || ichar == 10) {- isStore = false;+ isStore = false;store = 0;if (stmt.toString().equals("BEGINBITM")) {isText = false;@@ -201,23 +201,23 @@ public class psParser extends AbstractParser implements Parser {stmt.append((char)ichar);store++;}- } else if (!isComment && !isStore && (ichar == 66 || ichar == 69)) {+ } else if (!isComment && !isStore && (ichar == 66 || ichar == 69)) {isStore = true;stmt.append((char)ichar);store++;- }- }+ }+ }} else {throw new Exception("Unsupported Postscript version '" + version + "'.");- }+ }} finally {if (reader != null) try { reader.close(); } catch (final Exception e) {/* */}if (writer != null) try { writer.close(); } catch (final Exception e) {/* */}}-+}-+/*** This function requires the ghostscript-library* @param inputFile@@ -249,29 +249,30 @@ public class psParser extends AbstractParser implements Parser {this.log.logSevere(errorMsg);throw new Exception(errorMsg);}-+if (execCode != 0) throw new Exception("Unable to convert ps to ascii. ps2ascii returned statuscode " + execCode + "\n" + procErr.toString());}- public Document[] parse(final MultiProtocolURI location, final String mimeType,+ @Override+ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source)throws Parser.Failure, InterruptedException {-+File tempFile = null;try {// creating a tempfiletempFile = FileUtils.createTempFile(this.getClass(), "temp.ps");tempFile.deleteOnExit();-+// copying inputstream into fileFileUtils.copy(source,tempFile);-+// parsing the filereturn parse(location,mimeType,charset,tempFile);} catch (final Exception e) {if (e instanceof InterruptedException) throw (InterruptedException) e;- if (e instanceof Parser.Failure) throw (Parser.Failure) e;-+ if (e instanceof Parser.Failure) throw (Parser.Failure) e;+throw new Parser.Failure("Unable to parse the ps file. " + e.getMessage(), location);} finally {if (tempFile != null) FileUtils.deletedelete(tempFile);diff --git a/source/net/yacy/document/parser/rdfParser.java b/source/net/yacy/document/parser/rdfParser.javaindex ed478bc2e..f2b735e56 100644--- a/source/net/yacy/document/parser/rdfParser.java+++ b/source/net/yacy/document/parser/rdfParser.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -25,55 +25,43 @@package net.yacy.document.parser;-import java.io.IOException;import java.io.InputStream;-import java.net.MalformedURLException;import java.util.ArrayList;-import java.util.HashMap;-import java.util.HashSet;import java.util.List;-import java.util.Map;-import java.util.Properties;-import java.util.Set;--import net.yacy.cora.document.MultiProtocolURI;-import net.yacy.cora.document.RSSFeed;-import net.yacy.cora.document.RSSReader;-import net.yacy.cora.document.Hit;+import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;-import net.yacy.document.TextParser;-import net.yacy.document.parser.html.ImageEntry;+import net.yacy.kelondro.data.meta.DigestURI;public class rdfParser extends AbstractParser implements Parser {public rdfParser() {super("RDF Parser");-- SUPPORTED_EXTENSIONS.add("rdf");- SUPPORTED_MIME_TYPES.add("application/rdf+xml");++ this.SUPPORTED_EXTENSIONS.add("rdf");+ this.SUPPORTED_MIME_TYPES.add("application/rdf+xml");}-- public Document[] parse(final MultiProtocolURI url, final String mimeType,++ public Document[] parse(final DigestURI url, final String mimeType,final String charset, final InputStream source)throws Failure, InterruptedException {--++// this function currently only registers detected rdf files.-- // next step: load rdf content into triplestore.-++ // next step: load rdf content into triplestore.+final List<Document> docs = new ArrayList<Document>();-+Document doc;-+String all = "rdfdatasource";doc = new Document(url, mimeType, charset, null, null, null, "", "","", null, "", 0, 0, all.getBytes(), null, null, null, false);-+docs.add(doc);-+final Document[] da = new Document[docs.size()];docs.toArray(da);return da;diff --git a/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java b/source/net/yacy/document/parser/rdfa/impl/RDFaParser.javaindex 28097fe2a..6482ca59a 100644--- a/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java+++ b/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java@@ -1,5 +1,5 @@/**- *+ **/package net.yacy.document.parser.rdfa.impl;@@ -9,62 +9,61 @@ import java.io.InputStreamReader;import java.util.HashSet;import java.util.Set;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.Document;-import net.yacy.document.Parser.Failure;import net.yacy.document.parser.htmlParser;import net.yacy.document.parser.rdfa.IRDFaTriple;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;/*** @author fgandon- *+ **/public class RDFaParser extends htmlParser {public RDFaParser(String name) {super(name);- SUPPORTED_EXTENSIONS.remove("htm");- SUPPORTED_EXTENSIONS.remove("html");- SUPPORTED_EXTENSIONS.remove("shtml");- SUPPORTED_EXTENSIONS.remove("xhtml");- SUPPORTED_EXTENSIONS.remove("php");- SUPPORTED_EXTENSIONS.remove("php3");- SUPPORTED_EXTENSIONS.remove("php4");- SUPPORTED_EXTENSIONS.remove("php5");- SUPPORTED_EXTENSIONS.remove("cfm");- SUPPORTED_EXTENSIONS.remove("asp");- SUPPORTED_EXTENSIONS.remove("aspx");- SUPPORTED_EXTENSIONS.remove("tex");- SUPPORTED_EXTENSIONS.remove("txt");- SUPPORTED_EXTENSIONS.remove("jsp");- SUPPORTED_EXTENSIONS.remove("mf");- SUPPORTED_EXTENSIONS.remove("pl");- SUPPORTED_EXTENSIONS.remove("py");- SUPPORTED_MIME_TYPES.remove("text/html");- SUPPORTED_MIME_TYPES.remove("text/xhtml+xml");- SUPPORTED_MIME_TYPES.remove("application/xhtml+xml");- SUPPORTED_MIME_TYPES.remove("application/x-httpd-php");- SUPPORTED_MIME_TYPES.remove("application/x-tex");- SUPPORTED_MIME_TYPES.remove("text/plain");- SUPPORTED_MIME_TYPES.remove("text/sgml");- SUPPORTED_MIME_TYPES.remove("text/csv");-- SUPPORTED_EXTENSIONS.add("html");- SUPPORTED_EXTENSIONS.add("php");- SUPPORTED_MIME_TYPES.add("text/html");- SUPPORTED_MIME_TYPES.add("text/xhtml+xml");- SUPPORTED_EXTENSIONS.add("html");- SUPPORTED_EXTENSIONS.add("htm");+ this.SUPPORTED_EXTENSIONS.remove("htm");+ this.SUPPORTED_EXTENSIONS.remove("html");+ this.SUPPORTED_EXTENSIONS.remove("shtml");+ this.SUPPORTED_EXTENSIONS.remove("xhtml");+ this.SUPPORTED_EXTENSIONS.remove("php");+ this.SUPPORTED_EXTENSIONS.remove("php3");+ this.SUPPORTED_EXTENSIONS.remove("php4");+ this.SUPPORTED_EXTENSIONS.remove("php5");+ this.SUPPORTED_EXTENSIONS.remove("cfm");+ this.SUPPORTED_EXTENSIONS.remove("asp");+ this.SUPPORTED_EXTENSIONS.remove("aspx");+ this.SUPPORTED_EXTENSIONS.remove("tex");+ this.SUPPORTED_EXTENSIONS.remove("txt");+ this.SUPPORTED_EXTENSIONS.remove("jsp");+ this.SUPPORTED_EXTENSIONS.remove("mf");+ this.SUPPORTED_EXTENSIONS.remove("pl");+ this.SUPPORTED_EXTENSIONS.remove("py");+ this.SUPPORTED_MIME_TYPES.remove("text/html");+ this.SUPPORTED_MIME_TYPES.remove("text/xhtml+xml");+ this.SUPPORTED_MIME_TYPES.remove("application/xhtml+xml");+ this.SUPPORTED_MIME_TYPES.remove("application/x-httpd-php");+ this.SUPPORTED_MIME_TYPES.remove("application/x-tex");+ this.SUPPORTED_MIME_TYPES.remove("text/plain");+ this.SUPPORTED_MIME_TYPES.remove("text/sgml");+ this.SUPPORTED_MIME_TYPES.remove("text/csv");++ this.SUPPORTED_EXTENSIONS.add("html");+ this.SUPPORTED_EXTENSIONS.add("php");+ this.SUPPORTED_MIME_TYPES.add("text/html");+ this.SUPPORTED_MIME_TYPES.add("text/xhtml+xml");+ this.SUPPORTED_EXTENSIONS.add("html");+ this.SUPPORTED_EXTENSIONS.add("htm");}@Override- public Document[] parse(MultiProtocolURI url, String mimeType,+ public Document[] parse(DigestURI url, String mimeType,String charset, InputStream source) throws Failure,InterruptedException {Document[] htmlDocs = parseHtml(url, mimeType, charset, source);-+// TODO: current hardcoded restriction: apply rdfa parser only on selected sources.if (url.toString().contains(".yacy") || url.toString().contains("experiments")) {@@ -82,7 +81,7 @@ public class RDFaParser extends htmlParser {}- private Document parseRDFa(MultiProtocolURI url, String mimeType,+ private Document parseRDFa(DigestURI url, String mimeType,String charset, InputStream source) {RDFaTripleImpl triple;IRDFaTriple[] allTriples = null;@@ -111,7 +110,7 @@ public class RDFaParser extends htmlParser {}- private Document[] parseHtml(MultiProtocolURI url, String mimeType,+ private Document[] parseHtml(DigestURI url, String mimeType,String charset, InputStream source) throws Failure,InterruptedException {@@ -127,7 +126,7 @@ public class RDFaParser extends htmlParser {}- private Document convertAllTriplesToDocument(MultiProtocolURI url,+ private Document convertAllTriplesToDocument(DigestURI url,String mimeType, String charset, IRDFaTriple[] allTriples) {Set<String> languages = new HashSet<String>(2);diff --git a/source/net/yacy/document/parser/rdfa/main.java b/source/net/yacy/document/parser/rdfa/main.javaindex 6ec6710e7..50c8d2b19 100644--- a/source/net/yacy/document/parser/rdfa/main.java+++ b/source/net/yacy/document/parser/rdfa/main.java@@ -9,9 +9,9 @@ import java.io.Reader;import java.net.MalformedURLException;import java.net.URL;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.Parser.Failure;import net.yacy.document.parser.rdfa.impl.RDFaParser;+import net.yacy.kelondro.data.meta.DigestURI;public class main {/**@@ -46,7 +46,7 @@ public class main {if (aReader != null) {RDFaParser aParser = new RDFaParser("html");try {- aParser.parse(new MultiProtocolURI(args[0]),"","",aURL.openStream());+ aParser.parse(new DigestURI(args[0]),"","",aURL.openStream());} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {diff --git a/source/net/yacy/document/parser/rssParser.java b/source/net/yacy/document/parser/rssParser.javaindex 928b2f060..db798f1ee 100644--- a/source/net/yacy/document/parser/rssParser.java+++ b/source/net/yacy/document/parser/rssParser.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -36,29 +36,31 @@ import java.util.Map;import java.util.Properties;import java.util.Set;+import net.yacy.cora.document.Hit;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.RSSFeed;import net.yacy.cora.document.RSSReader;-import net.yacy.cora.document.Hit;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.TextParser;import net.yacy.document.parser.html.ImageEntry;+import net.yacy.kelondro.data.meta.DigestURI;public class rssParser extends AbstractParser implements Parser {public rssParser() {super("RSS Parser");- SUPPORTED_EXTENSIONS.add("rss");- SUPPORTED_EXTENSIONS.add("xml");- SUPPORTED_MIME_TYPES.add("XML");- SUPPORTED_MIME_TYPES.add("text/rss");- SUPPORTED_MIME_TYPES.add("application/rss+xml");- SUPPORTED_MIME_TYPES.add("application/atom+xml");+ this.SUPPORTED_EXTENSIONS.add("rss");+ this.SUPPORTED_EXTENSIONS.add("xml");+ this.SUPPORTED_MIME_TYPES.add("XML");+ this.SUPPORTED_MIME_TYPES.add("text/rss");+ this.SUPPORTED_MIME_TYPES.add("application/rss+xml");+ this.SUPPORTED_MIME_TYPES.add("application/atom+xml");}-- public Document[] parse(final MultiProtocolURI url, final String mimeType,++ @Override+ public Document[] parse(final DigestURI url, final String mimeType,final String charset, final InputStream source)throws Failure, InterruptedException {RSSReader rssReader;@@ -67,16 +69,16 @@ public class rssParser extends AbstractParser implements Parser {} catch (IOException e) {throw new Parser.Failure("Load error:" + e.getMessage(), url, e);}-+final RSSFeed feed = rssReader.getFeed();//RSSMessage channel = feed.getChannel();final List<Document> docs = new ArrayList<Document>();- MultiProtocolURI uri;+ DigestURI uri;Set<String> languages;Map<MultiProtocolURI, Properties> anchors;Document doc;for (final Hit item: feed) try {- uri = new MultiProtocolURI(item.getLink());+ uri = new DigestURI(item.getLink());languages = new HashSet<String>();languages.add(item.getLanguage());anchors = new HashMap<MultiProtocolURI, Properties>();@@ -106,7 +108,7 @@ public class rssParser extends AbstractParser implements Parser {} catch (MalformedURLException e) {continue;}-+final Document[] da = new Document[docs.size()];docs.toArray(da);return da;diff --git a/source/net/yacy/document/parser/rtfParser.java b/source/net/yacy/document/parser/rtfParser.javaindex d68bf1379..ac7ca6d4b 100644--- a/source/net/yacy/document/parser/rtfParser.java+++ b/source/net/yacy/document/parser/rtfParser.java@@ -1,4 +1,4 @@-//rtfParser.java+//rtfParser.java//------------------------//part of YaCy//(C) by Michael Peter Christen; [email protected]@@ -32,37 +32,37 @@ import java.io.InputStream;import javax.swing.text.DefaultStyledDocument;import javax.swing.text.rtf.RTFEditorKit;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;public class rtfParser extends AbstractParser implements Parser {public rtfParser() {super("Rich Text Format Parser");- SUPPORTED_EXTENSIONS.add("rtf");- SUPPORTED_MIME_TYPES.add("text/rtf");- SUPPORTED_MIME_TYPES.add("text/richtext");- SUPPORTED_MIME_TYPES.add("application/rtf");- SUPPORTED_MIME_TYPES.add("application/x-rtf");- SUPPORTED_MIME_TYPES.add("application/x-soffice");+ this.SUPPORTED_EXTENSIONS.add("rtf");+ this.SUPPORTED_MIME_TYPES.add("text/rtf");+ this.SUPPORTED_MIME_TYPES.add("text/richtext");+ this.SUPPORTED_MIME_TYPES.add("application/rtf");+ this.SUPPORTED_MIME_TYPES.add("application/x-rtf");+ this.SUPPORTED_MIME_TYPES.add("application/x-soffice");}- public Document[] parse(final MultiProtocolURI location, final String mimeType,+ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source)throws Parser.Failure, InterruptedException {- try {+ try {final DefaultStyledDocument doc = new DefaultStyledDocument();-- final RTFEditorKit theRtfEditorKit = new RTFEditorKit();- theRtfEditorKit.read(source, doc, 0);-++ final RTFEditorKit theRtfEditorKit = new RTFEditorKit();+ theRtfEditorKit.read(source, doc, 0);+final String bodyText = doc.getText(0, doc.getLength());-+return new Document[]{new Document(location,mimeType,@@ -79,17 +79,17 @@ public class rtfParser extends AbstractParser implements Parser {"", // TODO: publishernull,null,- 0.0f, 0.0f,+ 0.0f, 0.0f,UTF8.getBytes(bodyText),null,null,null,- false)};+ false)};} catch (final Exception e) {if (e instanceof InterruptedException) throw (InterruptedException) e;if (e instanceof Parser.Failure) throw (Parser.Failure) e;-- throw new Parser.Failure("Unexpected error while parsing rtf resource." + e.getMessage(),location);++ throw new Parser.Failure("Unexpected error while parsing rtf resource." + e.getMessage(),location);}}diff --git a/source/net/yacy/document/parser/sevenzipParser.java b/source/net/yacy/document/parser/sevenzipParser.javaindex 041b428f6..15040b3be 100644--- a/source/net/yacy/document/parser/sevenzipParser.java+++ b/source/net/yacy/document/parser/sevenzipParser.java@@ -38,6 +38,7 @@ import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.TextParser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.FileUtils;import SevenZip.ArchiveExtractCallback;@@ -54,7 +55,7 @@ public class sevenzipParser extends AbstractParser implements Parser {this.SUPPORTED_MIME_TYPES.add("application/x-7z-compressed");}- public Document parse(final MultiProtocolURI location, final String mimeType, final String charset, final IInStream source) throws Parser.Failure, InterruptedException {+ public Document parse(final DigestURI location, final String mimeType, final String charset, final IInStream source) throws Parser.Failure, InterruptedException {final Document doc = new Document(location,mimeType,@@ -100,7 +101,7 @@ public class sevenzipParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset,+ public Document[] parse(final DigestURI location, final String mimeType, final String charset,final InputStream source) throws Parser.Failure, InterruptedException {try {final ByteArrayOutputStream cfos = new ByteArrayOutputStream();@@ -165,7 +166,7 @@ public class sevenzipParser extends AbstractParser implements Parser {Document[] theDocs;// workaround for relative links in file, normally '#' shall be used behind the location, see// below for reversion of the effects- final MultiProtocolURI url = MultiProtocolURI.newURL(this.doc.dc_source(), this.prefix + "/" + super.filePath);+ final DigestURI url = new DigestURI(MultiProtocolURI.newURL(this.doc.dc_source(), this.prefix + "/" + super.filePath));final String mime = TextParser.mimeOf(super.filePath.substring(super.filePath.lastIndexOf('.') + 1));theDocs = TextParser.parseSource(url, mime, null, this.cfos.toByteArray());diff --git a/source/net/yacy/document/parser/sidAudioParser.java b/source/net/yacy/document/parser/sidAudioParser.javaindex dc51c5d9b..be68d8409 100644--- a/source/net/yacy/document/parser/sidAudioParser.java+++ b/source/net/yacy/document/parser/sidAudioParser.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -30,10 +30,10 @@ import java.nio.charset.Charset;import java.util.HashMap;import java.util.Map;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;// this is a new implementation of this parser idiom using multiple documents as result set@@ -47,15 +47,15 @@ public class sidAudioParser extends AbstractParser implements Parser {public sidAudioParser() {super("Commodore 64 SID Audio File Parser");- SUPPORTED_EXTENSIONS.add("sid");- SUPPORTED_MIME_TYPES.add("audio/prs.sid");- SUPPORTED_MIME_TYPES.add("audio/psid");- SUPPORTED_MIME_TYPES.add("audio/x-psid");- SUPPORTED_MIME_TYPES.add("audio/sidtune");- SUPPORTED_MIME_TYPES.add("audio/x-sidtune");+ this.SUPPORTED_EXTENSIONS.add("sid");+ this.SUPPORTED_MIME_TYPES.add("audio/prs.sid");+ this.SUPPORTED_MIME_TYPES.add("audio/psid");+ this.SUPPORTED_MIME_TYPES.add("audio/x-psid");+ this.SUPPORTED_MIME_TYPES.add("audio/sidtune");+ this.SUPPORTED_MIME_TYPES.add("audio/x-sidtune");}-- public Document[] parse(final MultiProtocolURI location, final String mimeType,++ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source)throws Parser.Failure, InterruptedException{@@ -64,7 +64,7 @@ public class sidAudioParser extends AbstractParser implements Parser {final byte[] b = new byte[available];if (available >= 128 && source.read(b) >= 128) {-+final int version = (b[4] << 2) + b[5];Map<String, String> header = new HashMap<String, String>();switch (version) {@@ -90,7 +90,7 @@ public class sidAudioParser extends AbstractParser implements Parser {header.get("publisher"),null,null,- 0.0f, 0.0f,+ 0.0f, 0.0f,null,null,null,diff --git a/source/net/yacy/document/parser/sitemapParser.java b/source/net/yacy/document/parser/sitemapParser.javaindex 9ff28f090..c7a5ab11b 100644--- a/source/net/yacy/document/parser/sitemapParser.java+++ b/source/net/yacy/document/parser/sitemapParser.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -38,13 +38,6 @@ import java.util.zip.GZIPInputStream;import javax.xml.parsers.DocumentBuilderFactory;import javax.xml.parsers.ParserConfigurationException;-import org.w3c.dom.CharacterData;-import org.w3c.dom.Element;-import org.w3c.dom.Node;-import org.w3c.dom.NodeList;-import org.xml.sax.SAXException;-import org.xml.sax.SAXParseException;-import net.yacy.cora.date.ISO8601Formatter;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.protocol.ClientIdentification;@@ -60,6 +53,13 @@ import net.yacy.document.parser.html.ImageEntry;import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.io.ByteCountInputStream;+import org.w3c.dom.CharacterData;+import org.w3c.dom.Element;+import org.w3c.dom.Node;+import org.w3c.dom.NodeList;+import org.xml.sax.SAXException;+import org.xml.sax.SAXParseException;+public class sitemapParser extends AbstractParser implements Parser {public sitemapParser() {@@ -68,8 +68,9 @@ public class sitemapParser extends AbstractParser implements Parser {//SUPPORTED_EXTENSIONS.add("php");//SUPPORTED_EXTENSIONS.add("xml");}-- public Document[] parse(final MultiProtocolURI url, final String mimeType,++ @Override+ public Document[] parse(final DigestURI url, final String mimeType,final String charset, final InputStream source)throws Failure, InterruptedException {SitemapReader sitemap;@@ -78,12 +79,12 @@ public class sitemapParser extends AbstractParser implements Parser {} catch (IOException e) {throw new Parser.Failure("Load error:" + e.getMessage(), url);}-+final List<Document> docs = new ArrayList<Document>();- MultiProtocolURI uri;+ DigestURI uri;Document doc;for (final URLEntry item: sitemap) try {- uri = new MultiProtocolURI(item.loc);+ uri = new DigestURI(item.loc);doc = new Document(uri,TextParser.mimeOf(url),@@ -96,7 +97,7 @@ public class sitemapParser extends AbstractParser implements Parser {"",new String[0],"",- 0.0f, 0.0f,+ 0.0f, 0.0f,null,null,null,@@ -106,12 +107,12 @@ public class sitemapParser extends AbstractParser implements Parser {} catch (MalformedURLException e) {continue;}-+Document[] da = new Document[docs.size()];docs.toArray(da);return da;}-+public static SitemapReader parse(final DigestURI sitemapURL) throws IOException {// download documentfinal RequestHeader requestHeader = new RequestHeader();@@ -125,11 +126,11 @@ public class sitemapParser extends AbstractParser implements Parser {throw new IOException("Unable to download the sitemap file " + sitemapURL +"\nServer returned status: " + client.getHttpResponse().getStatusLine());}-+// get some metadatafinal ResponseHeader header = new ResponseHeader(client.getHttpResponse().getAllHeaders());final String contentMimeType = header.mime();-+InputStream contentStream = client.getContentstream();if (contentMimeType != null && (contentMimeType.equals("application/x-gzip") || contentMimeType.equals("application/gzip"))) {contentStream = new GZIPInputStream(contentStream);@@ -142,7 +143,7 @@ public class sitemapParser extends AbstractParser implements Parser {client.finish();}}-+public static SitemapReader parse(final InputStream stream) throws IOException {return new SitemapReader(stream);}@@ -190,10 +191,10 @@ public class sitemapParser extends AbstractParser implements Parser {public String loc, lastmod, changefreq, priority;public URLEntry(final Element element) {- loc = val(element, "loc", "");- lastmod = val(element, "lastmod", "");- changefreq = val(element, "changefreq", "");- priority = val(element, "priority", "");+ this.loc = val(element, "loc", "");+ this.lastmod = val(element, "lastmod", "");+ this.changefreq = val(element, "changefreq", "");+ this.priority = val(element, "priority", "");}public String url() {@@ -202,28 +203,28 @@ public class sitemapParser extends AbstractParser implements Parser {public Date lastmod(final Date dflt) {try {- return ISO8601Formatter.FORMATTER.parse(lastmod);+ return ISO8601Formatter.FORMATTER.parse(this.lastmod);} catch (final ParseException e) {return dflt;}}}-+public static class SitemapEntry {public String loc, lastmod;public SitemapEntry(final Element element) {- loc = val(element, "loc", "");- lastmod = val(element, "lastmod", "");+ this.loc = val(element, "loc", "");+ this.lastmod = val(element, "lastmod", "");}public String url() {return this.loc;}-+public Date lastmod(final Date dflt) {try {- return ISO8601Formatter.FORMATTER.parse(lastmod);+ return ISO8601Formatter.FORMATTER.parse(this.lastmod);} catch (final ParseException e) {return dflt;}diff --git a/source/net/yacy/document/parser/swfParser.java b/source/net/yacy/document/parser/swfParser.javaindex 3124aca34..1e94558d5 100644--- a/source/net/yacy/document/parser/swfParser.java+++ b/source/net/yacy/document/parser/swfParser.java@@ -38,6 +38,7 @@ import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import pt.tumba.parser.swf.SWF2HTML;public class swfParser extends AbstractParser implements Parser {@@ -56,7 +57,7 @@ public class swfParser extends AbstractParser implements Parser {* all extracted information about the parsed document*/@Override- public Document[] parse(final MultiProtocolURI location, final String mimeType,+ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source)throws Parser.Failure, InterruptedException{diff --git a/source/net/yacy/document/parser/tarParser.java b/source/net/yacy/document/parser/tarParser.javaindex 7deb195e4..7005cab1b 100644--- a/source/net/yacy/document/parser/tarParser.java+++ b/source/net/yacy/document/parser/tarParser.java@@ -39,6 +39,7 @@ import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.TextParser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.util.FileUtils;import org.apache.tools.tar.TarEntry;@@ -60,7 +61,7 @@ public class tarParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI url, final String mimeType, final String charset, InputStream source) throws Parser.Failure, InterruptedException {+ public Document[] parse(final DigestURI url, final String mimeType, final String charset, InputStream source) throws Parser.Failure, InterruptedException {final List<Document> docacc = new ArrayList<Document>();Document[] subDocs = null;@@ -89,7 +90,7 @@ public class tarParser extends AbstractParser implements Parser {try {tmp = FileUtils.createTempFile(this.getClass(), name);FileUtils.copy(tis, tmp, entry.getSize());- subDocs = TextParser.parseSource(MultiProtocolURI.newURL(url,"#" + name), mime, null, tmp);+ subDocs = TextParser.parseSource(new DigestURI(MultiProtocolURI.newURL(url,"#" + name)), mime, null, tmp);if (subDocs == null) continue;for (final Document d: subDocs) docacc.add(d);} catch (final Parser.Failure e) {diff --git a/source/net/yacy/document/parser/torrentParser.java b/source/net/yacy/document/parser/torrentParser.javaindex f1cf540f6..0a9c35634 100644--- a/source/net/yacy/document/parser/torrentParser.java+++ b/source/net/yacy/document/parser/torrentParser.java@@ -39,6 +39,7 @@ import net.yacy.document.Condenser;import net.yacy.document.Document;import net.yacy.document.LibraryProvider;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.data.word.Word;import net.yacy.kelondro.util.BDecoder;import net.yacy.kelondro.util.BDecoder.BObject;@@ -55,7 +56,7 @@ public class torrentParser extends AbstractParser implements Parser {}@Override- public Document[] parse(MultiProtocolURI location, String mimeType, String charset, InputStream source)+ public Document[] parse(DigestURI location, String mimeType, String charset, InputStream source)throws Parser.Failure, InterruptedException {byte[] b = null;try {@@ -121,7 +122,7 @@ public class torrentParser extends AbstractParser implements Parser {try {byte[] b = FileUtils.read(new File(args[0]));torrentParser parser = new torrentParser();- Document[] d = parser.parse(new MultiProtocolURI("http://localhost/test.torrent"), null, "UTF-8", new ByteArrayInputStream(b));+ Document[] d = parser.parse(new DigestURI("http://localhost/test.torrent"), null, "UTF-8", new ByteArrayInputStream(b));Condenser c = new Condenser(d[0], true, true, LibraryProvider.dymLib, false);Map<String, Word> w = c.words();for (Map.Entry<String, Word> e: w.entrySet()) System.out.println("Word: " + e.getKey() + " - " + e.getValue().posInText);diff --git a/source/net/yacy/document/parser/vcfParser.java b/source/net/yacy/document/parser/vcfParser.javaindex 285ebb968..336f5a041 100644--- a/source/net/yacy/document/parser/vcfParser.java+++ b/source/net/yacy/document/parser/vcfParser.java@@ -41,6 +41,7 @@ import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.order.Base64Order;/**@@ -60,7 +61,8 @@ public class vcfParser extends AbstractParser implements Parser {this.SUPPORTED_MIME_TYPES.add("text/x-vcalendar");}- public Document[] parse(final MultiProtocolURI url, final String mimeType, final String charset, final InputStream source)+ @Override+ public Document[] parse(final DigestURI url, final String mimeType, final String charset, final InputStream source)throws Parser.Failure, InterruptedException {try {diff --git a/source/net/yacy/document/parser/vsdParser.java b/source/net/yacy/document/parser/vsdParser.javaindex bad75f8b8..50f444f72 100644--- a/source/net/yacy/document/parser/vsdParser.java+++ b/source/net/yacy/document/parser/vsdParser.java@@ -29,11 +29,11 @@ package net.yacy.document.parser;import java.io.InputStream;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;import org.apache.poi.hdgf.extractor.VisioTextExtractor;@@ -44,30 +44,30 @@ public class vsdParser extends AbstractParser implements Parser {public vsdParser() {super("Microsoft Visio Parser");- SUPPORTED_EXTENSIONS.add("vsd");- SUPPORTED_EXTENSIONS.add("vss");- SUPPORTED_EXTENSIONS.add("vst");- SUPPORTED_EXTENSIONS.add("vdx");- SUPPORTED_EXTENSIONS.add("vtx");- SUPPORTED_MIME_TYPES.add("application/visio");- SUPPORTED_MIME_TYPES.add("application/x-visio");- SUPPORTED_MIME_TYPES.add("application/vnd.visio");- SUPPORTED_MIME_TYPES.add("application/visio.drawing");- SUPPORTED_MIME_TYPES.add("application/vsd");- SUPPORTED_MIME_TYPES.add("application/x-vsd");- SUPPORTED_MIME_TYPES.add("image/x-vsd");- SUPPORTED_MIME_TYPES.add("zz-application/zz-winassoc-vsd");+ this.SUPPORTED_EXTENSIONS.add("vsd");+ this.SUPPORTED_EXTENSIONS.add("vss");+ this.SUPPORTED_EXTENSIONS.add("vst");+ this.SUPPORTED_EXTENSIONS.add("vdx");+ this.SUPPORTED_EXTENSIONS.add("vtx");+ this.SUPPORTED_MIME_TYPES.add("application/visio");+ this.SUPPORTED_MIME_TYPES.add("application/x-visio");+ this.SUPPORTED_MIME_TYPES.add("application/vnd.visio");+ this.SUPPORTED_MIME_TYPES.add("application/visio.drawing");+ this.SUPPORTED_MIME_TYPES.add("application/vsd");+ this.SUPPORTED_MIME_TYPES.add("application/x-vsd");+ this.SUPPORTED_MIME_TYPES.add("image/x-vsd");+ this.SUPPORTED_MIME_TYPES.add("zz-application/zz-winassoc-vsd");}-+/** parses the source documents and returns a plasmaParserDocument containing* all extracted information about the parsed document*/- public Document[] parse(final MultiProtocolURI location, final String mimeType, final String charset, final InputStream source)+ public Document[] parse(final DigestURI location, final String mimeType, final String charset, final InputStream source)throws Parser.Failure, InterruptedException {Document theDoc = null;-+try {String contents = "";SummaryInformation summary = null;@@ -96,7 +96,7 @@ public class vsdParser extends AbstractParser implements Parser {replaceAll("\n"," ").replaceAll("\r"," ").replaceAll("\t"," ");-+if (title == null) {title = abstrct;}@@ -114,13 +114,13 @@ public class vsdParser extends AbstractParser implements Parser {"",null, // an array of section headlinesabstrct, // an abstract- 0.0f, 0.0f,+ 0.0f, 0.0f,UTF8.getBytes(contents), // the parsed document textnull, // a map of extracted anchorsnull,null, // a treeset of image URLsfalse)};- } catch (final Exception e) {+ } catch (final Exception e) {if (e instanceof InterruptedException) throw (InterruptedException) e;// if an unexpected error occures just log the error and raise a new ParserExceptiondiff --git a/source/net/yacy/document/parser/xlsParser.java b/source/net/yacy/document/parser/xlsParser.javaindex 9ae725c3c..a1f711b88 100644--- a/source/net/yacy/document/parser/xlsParser.java+++ b/source/net/yacy/document/parser/xlsParser.java@@ -1,4 +1,4 @@-//xlsParser.java+//xlsParser.java//------------------------//part of YaCy//(C) by Michael Peter Christen; [email protected]@@ -29,11 +29,11 @@ package net.yacy.document.parser;import java.io.InputStream;-import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.document.UTF8;import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.logging.Log;import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;@@ -49,33 +49,34 @@ public class xlsParser extends AbstractParser implements Parser {public xlsParser(){super("Microsoft Excel Parser");- SUPPORTED_EXTENSIONS.add("xls");- SUPPORTED_EXTENSIONS.add("xla");- SUPPORTED_MIME_TYPES.add("application/msexcel");- SUPPORTED_MIME_TYPES.add("application/excel");- SUPPORTED_MIME_TYPES.add("application/vnd.ms-excel");- SUPPORTED_MIME_TYPES.add("application/x-excel");- SUPPORTED_MIME_TYPES.add("application/x-msexcel");- SUPPORTED_MIME_TYPES.add("application/x-ms-excel");- SUPPORTED_MIME_TYPES.add("application/x-dos_ms_excel");- SUPPORTED_MIME_TYPES.add("application/xls");+ this.SUPPORTED_EXTENSIONS.add("xls");+ this.SUPPORTED_EXTENSIONS.add("xla");+ this.SUPPORTED_MIME_TYPES.add("application/msexcel");+ this.SUPPORTED_MIME_TYPES.add("application/excel");+ this.SUPPORTED_MIME_TYPES.add("application/vnd.ms-excel");+ this.SUPPORTED_MIME_TYPES.add("application/x-excel");+ this.SUPPORTED_MIME_TYPES.add("application/x-msexcel");+ this.SUPPORTED_MIME_TYPES.add("application/x-ms-excel");+ this.SUPPORTED_MIME_TYPES.add("application/x-dos_ms_excel");+ this.SUPPORTED_MIME_TYPES.add("application/xls");}/** parses the source documents and returns a plasmaParserDocument containing* all extracted information about the parsed document- */- public Document[] parse(final MultiProtocolURI location, final String mimeType,+ */+ @Override+ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source) throws Parser.Failure,InterruptedException {return new XLSHSSFListener().parse(location, mimeType, charset, source);}-+public class XLSHSSFListener implements HSSFListener {//StringBuilder for parsed textprivate final StringBuilder sbFoundStrings;-+public XLSHSSFListener() {this.sbFoundStrings = new StringBuilder(100);@@ -84,12 +85,12 @@ public class xlsParser extends AbstractParser implements Parser {/** parses the source documents and returns a Document containing* all extracted information about the parsed document- */- public Document[] parse(final MultiProtocolURI location, final String mimeType,+ */+ public Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source) throws Parser.Failure,InterruptedException {try {-+//create a new org.apache.poi.poifs.filesystem.Filesystemfinal POIFSFileSystem poifs = new POIFSFileSystem(source);//get the Workbook (excel part) stream in a InputStream@@ -104,10 +105,10 @@ public class xlsParser extends AbstractParser implements Parser {factory.processEvents(req, din);//close our document input stream (don't want to leak these!)din.close();-+//now the parsed strings are in the StringBuilder, now convert them to a String- final String contents = sbFoundStrings.toString().trim();-+ final String contents = this.sbFoundStrings.toString().trim();+/** create the plasmaParserDocument for the database* and set shortText and bodyText properly@@ -124,13 +125,13 @@ public class xlsParser extends AbstractParser implements Parser {"", // TODO: publishernull,null,- 0.0f, 0.0f,+ 0.0f, 0.0f,UTF8.getBytes(contents),null,null,null,false)};- } catch (final Exception e) {+ } catch (final Exception e) {if (e instanceof InterruptedException) throw (InterruptedException) e;/*@@ -142,22 +143,23 @@ public class xlsParser extends AbstractParser implements Parser {}}+ @Overridepublic void processRecord(final Record record) {SSTRecord sstrec = null;switch (record.getSid()){case NumberRecord.sid: {final NumberRecord numrec = (NumberRecord) record;- sbFoundStrings.append(numrec.getValue());+ this.sbFoundStrings.append(numrec.getValue());break;}//unique string recordscase SSTRecord.sid: {sstrec = (SSTRecord) record;for (int k = 0; k < sstrec.getNumUniqueStrings(); k++){- sbFoundStrings.append( sstrec.getString(k) );-+ this.sbFoundStrings.append( sstrec.getString(k) );+//add line seperator- sbFoundStrings.append( "\n" );+ this.sbFoundStrings.append( "\n" );}break;}@@ -169,10 +171,10 @@ public class xlsParser extends AbstractParser implements Parser {}*/}-+//add line seperator- sbFoundStrings.append( "\n" );+ this.sbFoundStrings.append( "\n" );}}-+}diff --git a/source/net/yacy/document/parser/zipParser.java b/source/net/yacy/document/parser/zipParser.javaindex d1d6277cf..e0082ac6b 100644--- a/source/net/yacy/document/parser/zipParser.java+++ b/source/net/yacy/document/parser/zipParser.java@@ -37,6 +37,7 @@ import net.yacy.document.AbstractParser;import net.yacy.document.Document;import net.yacy.document.Parser;import net.yacy.document.TextParser;+import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.util.FileUtils;import net.yacy.kelondro.util.MemoryControl;@@ -60,7 +61,7 @@ public class zipParser extends AbstractParser implements Parser {}@Override- public Document[] parse(final MultiProtocolURI url, final String mimeType,+ public Document[] parse(final DigestURI url, final String mimeType,final String charset, final InputStream source)throws Parser.Failure, InterruptedException {// check memory for parser@@ -86,7 +87,7 @@ public class zipParser extends AbstractParser implements Parser {try {tmp = FileUtils.createTempFile(this.getClass(), name);FileUtils.copy(zis, tmp, entry.getSize());- final MultiProtocolURI virtualURL = MultiProtocolURI.newURL(url, "#" + name);+ final DigestURI virtualURL = new DigestURI(MultiProtocolURI.newURL(url, "#" + name));//this.log.logInfo("ZIP file parser: " + virtualURL.toNormalform(false, false));docs = TextParser.parseSource(virtualURL, mime, null, tmp);if (docs == null) continue;diff --git a/source/net/yacy/interaction/Interaction.java b/source/net/yacy/interaction/Interaction.javaindex 11f19b5c2..0ada50efa 100644--- a/source/net/yacy/interaction/Interaction.java+++ b/source/net/yacy/interaction/Interaction.java@@ -9,6 +9,7 @@ import java.util.Map;import java.util.Set;import net.yacy.cora.document.UTF8;+import net.yacy.cora.lod.JenaTripleStore;import net.yacy.cora.protocol.HeaderFramework;import net.yacy.cora.protocol.RequestHeader;import net.yacy.cora.protocol.http.HTTPClient;@@ -561,16 +562,14 @@ public static String Triple(String url, String s, String p, String o) {public static String Triple(String url, String s, String p, String o, String username) {- final Switchboard sb = Switchboard.getSwitchboard();-if (username != "") {username = "/"+username;}- Resource r = TripleStore.model.getResource(s+username);- Property pr = TripleStore.model.getProperty(p);+ Resource r = JenaTripleStore.getResource(s+username);+ Property pr = JenaTripleStore.getProperty(p);- TripleStore.model.removeAll(r, pr, (Resource) null);+ JenaTripleStore.model.removeAll(r, pr, (Resource) null);r.addProperty(pr, o);@@ -588,16 +587,14 @@ public static String TripleGet(String s, String p) {public static String TripleGet(String s, String p, String username) {- final Switchboard sb = Switchboard.getSwitchboard();-if (username != "") {username = "/"+username;}- Resource r = TripleStore.model.getResource(s+username);- Property pr = TripleStore.model.getProperty(p);+ Resource r = JenaTripleStore.getResource(s+username);+ Property pr = JenaTripleStore.getProperty(p);- StmtIterator iter = TripleStore.model.listStatements(r, pr, (Resource) null);+ StmtIterator iter = JenaTripleStore.model.listStatements(r, pr, (Resource) null);Log.logInfo ("TRIPLESTORE", "GET "+username+" / "+s+" - "+p+" ... ");diff --git a/source/net/yacy/search/query/RWIProcess.java b/source/net/yacy/search/query/RWIProcess.javaindex d1046693e..cecf71103 100644--- a/source/net/yacy/search/query/RWIProcess.java+++ b/source/net/yacy/search/query/RWIProcess.java@@ -756,7 +756,7 @@ public final class RWIProcess extends Threadvoc = new ConcurrentScoreMap<String>();this.vocabularyNavigator.put(metatag.getVocabularyName(), voc);}- voc.inc(metatag.getPrintName());+ voc.inc(metatag.getObject());} catch (RuntimeException e) {// tag may not be well-formed}diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.javaindex 899ae90b3..033160e74 100644--- a/source/net/yacy/yacy.java+++ b/source/net/yacy/yacy.java@@ -51,6 +51,7 @@ import java.util.zip.ZipOutputStream;import net.yacy.cora.date.GenericFormatter;import net.yacy.cora.document.ASCII;import net.yacy.cora.document.UTF8;+import net.yacy.cora.lod.JenaTripleStore;import net.yacy.cora.protocol.ClientIdentification;import net.yacy.cora.protocol.RequestHeader;import net.yacy.cora.protocol.http.HTTPClient;@@ -59,7 +60,6 @@ import net.yacy.cora.sorting.OrderedScoreMap;import net.yacy.cora.sorting.ScoreMap;import net.yacy.gui.YaCyApp;import net.yacy.gui.framework.Browser;-import net.yacy.interaction.TripleStore;import net.yacy.kelondro.blob.MapDataMining;import net.yacy.kelondro.data.meta.URIMetadataRow;import net.yacy.kelondro.data.word.Word;@@ -172,7 +172,7 @@ public final class yacy {System.err.println("Error creating DATA-directory in " + dataHome.toString() + " . Please check your write-permission for this folder. YaCy will now terminate.");System.exit(-1);}-+homedir = appHome.toString();// setting up logging@@ -304,15 +304,20 @@ public final class yacy {// set user-agentHTTPClient.setDefaultUserAgent(ClientIdentification.getUserAgent());-+// initial fill of the triplestore- File triplestore = new File(sb.getConfig("triplestore", new File(dataHome, "DATA/TRIPLESTORE").getAbsolutePath()));- mkdirIfNeseccary(triplestore);- for (String s: triplestore.list()) {- if ((s.endsWith(".rdf") || s.endsWith(".nt")) && !s.equals("local.rdf") && !s.endsWith("_triplestore.rdf")) TripleStore.Load(new File(triplestore, s).getAbsolutePath());- }- if (sb.getConfigBool("triplestore.persistent", false)) {- TripleStore.Load(new File(triplestore, "local.rdf").getAbsolutePath());+ try {+ File triplestore = new File(sb.getConfig("triplestore", new File(dataHome, "DATA/TRIPLESTORE").getAbsolutePath()));+ mkdirIfNeseccary(triplestore);+ for (String s: triplestore.list()) {+ if ((s.endsWith(".rdf") || s.endsWith(".nt")) && !s.equals("local.rdf") && !s.endsWith("_triplestore.rdf")) JenaTripleStore.load(new File(triplestore, s).getAbsolutePath());+ }+ if (sb.getConfigBool("triplestore.persistent", false)) {+ File local = new File(triplestore, "local.rdf");+ if (local.exists()) JenaTripleStore.load(local.getAbsolutePath());+ }+ } catch (IOException e) {+ Log.logException(e);}// start main threads@@ -433,12 +438,12 @@ public final class yacy {Log.logSevere("STARTUP", "FATAL ERROR: " + ee.getMessage(),ee);} finally {}-+if (sb.getConfigBool("triplestore.persistent", false)) {File triplestore = new File(sb.getConfig("triplestore", new File(dataHome, "DATA/TRIPLESTORE").getAbsolutePath()));- TripleStore.Save(new File(triplestore, "local.rdf").getAbsolutePath());+ JenaTripleStore.saveFile(new File(triplestore, "local.rdf").getAbsolutePath());}-+Log.logConfig("SHUTDOWN", "goodbye. (this is the last line)");Log.shutdown();shutdownSemaphore.release(1000);