Skip to content

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

moved Edge class out of linkstructure servlet as this does not work on non-eclipse driven environments (all non-dev cases)

orbiter18f9c4030230
diff --git a/htroot/api/linkstructure.java b/htroot/api/linkstructure.java
index 878a9efd1..692388b19 100644
--- a/htroot/api/linkstructure.java
+++ b/htroot/api/linkstructure.java
@@ -38,25 +38,12 @@ import net.yacy.kelondro.data.meta.URIMetadataNode;
import net.yacy.search.Switchboard;
import net.yacy.search.index.Fulltext;
import net.yacy.search.schema.CollectionSchema;
+import net.yacy.search.schema.HyperlinkEdge;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
import net.yacy.server.servletProperties;
public class linkstructure {
-
- public static enum Edgetype {
- InboundOk, InboundNofollow, Outbound, Dead;
- }
-
- public static class Edge {
- public DigestURL source, target;
- public Edgetype type;
- public Edge(DigestURL source, DigestURL target, Edgetype type) {
- this.source = source;
- this.target = target;
- this.type = type;
- }
- }
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final servletProperties prop = new servletProperties();
@@ -105,7 +92,7 @@ public class linkstructure {
);
SolrDocument doc;
Map<String, FailType> errorDocs = new HashMap<String, FailType>();
- Map<String, Edge> edges = new HashMap<String, Edge>();
+ Map<String, HyperlinkEdge> edges = new HashMap<String, HyperlinkEdge>();
try {
while ((doc = docs.take()) != AbstractSolrConnector.POISON_DOCUMENT) {
String u = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());
@@ -123,7 +110,7 @@ public class linkstructure {
try {
DigestURL linkurl = new DigestURL(link, null);
String edgehash = ids + ASCII.String(linkurl.hash());
- edges.put(edgehash, new Edge(from, linkurl, Edgetype.InboundOk));
+ edges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkEdge.Type.InboundOk));
} catch (MalformedURLException e) {}
}
links = URIMetadataNode.getLinks(doc, false); // outbound
@@ -132,7 +119,7 @@ public class linkstructure {
try {
DigestURL linkurl = new DigestURL(link, null);
String edgehash = ids + ASCII.String(linkurl.hash());
- edges.put(edgehash, new Edge(from, linkurl, Edgetype.Outbound));
+ edges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkEdge.Type.Outbound));
} catch (MalformedURLException e) {}
}
}
@@ -142,15 +129,15 @@ public class linkstructure {
} catch (MalformedURLException e) {
}
// we use the errorDocs to mark all edges with endpoint to error documents
- for (Map.Entry<String, Edge> edge: edges.entrySet()) {
- if (errorDocs.containsKey(edge.getValue().target)) edge.getValue().type = Edgetype.Dead;
+ for (Map.Entry<String, HyperlinkEdge> edge: edges.entrySet()) {
+ if (errorDocs.containsKey(edge.getValue().target)) edge.getValue().type = HyperlinkEdge.Type.Dead;
}
// finally just write out the edge array
int c = 0;
- for (Map.Entry<String, Edge> edge: edges.entrySet()) {
+ for (Map.Entry<String, HyperlinkEdge> edge: edges.entrySet()) {
prop.putJSON("list_" + c + "_source", edge.getValue().source.getPath());
- prop.putJSON("list_" + c + "_target", edge.getValue().type.equals(Edgetype.Outbound) ? edge.getValue().target.toNormalform(true) : edge.getValue().target.getPath());
+ prop.putJSON("list_" + c + "_target", edge.getValue().type.equals(HyperlinkEdge.Type.Outbound) ? edge.getValue().target.toNormalform(true) : edge.getValue().target.getPath());
prop.putJSON("list_" + c + "_type", edge.getValue().type.name());
prop.put("list_" + c + "_eol", 1);
c++;
diff --git a/source/net/yacy/search/schema/HyperlinkEdge.java b/source/net/yacy/search/schema/HyperlinkEdge.java
new file mode 100644
index 000000000..712cb9b4c
--- /dev/null
+++ b/source/net/yacy/search/schema/HyperlinkEdge.java
@@ -0,0 +1,40 @@
+/**
+ * HyperlinkEdge
+ * Copyright 2014 by Michael Peter Christen
+ * First released 04.04.2014 at http://yacy.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * 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/>.
+ */
+
+package net.yacy.search.schema;
+
+import net.yacy.cora.document.id.DigestURL;
+
+public class HyperlinkEdge {
+
+ public static enum Type {
+ InboundOk, InboundNofollow, Outbound, Dead;
+ }
+
+ public DigestURL source, target;
+ public Type type;
+
+ public HyperlinkEdge(DigestURL source, DigestURL target, Type type) {
+ this.source = source;
+ this.target = target;
+ this.type = type;
+ }
+
+}