From 06ff0c5b0697f79c769068efb0aa1c5ad43bd64c Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 5 May 2010 22:45:54 +0000 Subject: [PATCH] fixes for metadata retrieval and presentation git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6855 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/CrawlResults.java | 4 ++-- htroot/ViewFile.java | 26 ++++++++++++++++++-------- htroot/api/yacydoc.html | 20 +++++++++++--------- htroot/api/yacydoc.java | 8 +++++--- htroot/api/yacydoc.xml | 4 ++-- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/htroot/CrawlResults.java b/htroot/CrawlResults.java index 7efe7dd8c..bbe60a8a7 100644 --- a/htroot/CrawlResults.java +++ b/htroot/CrawlResults.java @@ -79,7 +79,7 @@ public class CrawlResults { tabletype == EventOrigin.LOCAL_CRAWLING && sb.crawlResults.getStackSize(EventOrigin.LOCAL_CRAWLING) == 0) { // the main menu does a request to the local crawler page, but in case this table is empty, the overview page is shown - tabletype = EventOrigin.UNKNOWN; + tabletype = (sb.crawlResults.getStackSize(EventOrigin.SURROGATES) == 0) ? EventOrigin.UNKNOWN : EventOrigin.SURROGATES; } // check if authorization is needed and/or given @@ -100,7 +100,7 @@ public class CrawlResults { } } - if(post != null) { + if (post != null) { // custom number of lines if (post.containsKey("count")) { lines = Integer.parseInt(post.get("count", "500")); diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java index cf7b70952..7fb777695 100644 --- a/htroot/ViewFile.java +++ b/htroot/ViewFile.java @@ -90,15 +90,12 @@ public class ViewFile { // get segment Segment indexSegment = null; - if (post.containsKey("segment")) { - String segmentName = post.get("segment"); - if (sb.indexSegments.segmentExist(segmentName)) { - indexSegment = sb.indexSegments.segment(segmentName); - } + boolean authorized = sb.verifyAuthentication(header, false); + if (post != null && post.containsKey("segment") && authorized) { + indexSegment = sb.indexSegments.segment(post.get("segment")); } else { - // take default segment indexSegment = sb.indexSegments.segment(Segments.Process.PUBLIC); - } + } prop.put("display", display); prop.put("error_display", display); @@ -180,7 +177,20 @@ public class ViewFile { Log.logException(e); resource = null; } - responseHeader = Cache.getResponseHeader(url); + + if (resource == null && authorized) { + // load resource from net + Response response = null; + try { + response = sb.loader.load(url, true, false); + } catch (IOException e) { + Log.logException(e); + } + if (response != null) resource = response.getContent(); + responseHeader = response.getResponseHeader(); + } + + if (responseHeader == null) responseHeader = Cache.getResponseHeader(url); // if the resource body was not cached we try to load it from web if (resource == null) { diff --git a/htroot/api/yacydoc.html b/htroot/api/yacydoc.html index 46f3ae45d..475bf2eef 100644 --- a/htroot/api/yacydoc.html +++ b/htroot/api/yacydoc.html @@ -22,15 +22,17 @@ you can validate it with http://validator.w3.org/

#[dc_title]#

-
Author
#[dc_creator]#
-
Description
#[dc_description]#
-
Subject
#[dc_subject]#
-
Publisher
#[dc_publisher]#
-
Contributor
#[dc_contributor]#
-
Date
#[dc_date]#
-
Type
yacy:doctype:#[dc_type]#
-
Identifier
#[dc_identifier]#
-
Language
#[dc_language]#
+
Title
#[dc_title]#
+
Author
#[dc_creator]#
+
Description
#[dc_description]#
+
Subject
#[dc_subject]#
+
Publisher
#[dc_publisher]#
+
Contributor
#[dc_contributor]#
+
Date
#[dc_date]#
+
Type
yacy:doctype:#[dc_type]#
+
YaCy Identifier
yacy:urlhash:#[yacy_urlhash]#
+
Identifier
#[dc_identifier]#
+
Language
#[dc_language]#
Load Date
#[yacy_loaddate]#
Referrer Identifier
yacy:urlhash:#[yacy_referrer_hash]#
diff --git a/htroot/api/yacydoc.java b/htroot/api/yacydoc.java index 82bb372d8..a6f485bdd 100644 --- a/htroot/api/yacydoc.java +++ b/htroot/api/yacydoc.java @@ -49,7 +49,8 @@ public class yacydoc { final Segment segment; boolean html = post != null && post.containsKey("html"); prop.setLocalized(html); - if (post != null && post.containsKey("segment") && sb.verifyAuthentication(header, false)) { + boolean authorized = sb.verifyAuthentication(header, false); + if (post != null && post.containsKey("segment") && authorized) { segment = sb.indexSegments.segment(post.get("segment")); } else { segment = sb.indexSegments.segment(Segments.Process.PUBLIC); @@ -68,7 +69,7 @@ public class yacydoc { if (post == null) return prop; - String urlstring = post.get("urlstring", "").trim(); + String urlstring = post.get("url", "").trim(); String urlhash = post.get("urlhash", "").trim(); if (urlstring.length() == 0 && urlhash.length() == 0) return prop; @@ -93,7 +94,7 @@ public class yacydoc { prop.putXML("dc_title", metadata.dc_title()); prop.putXML("dc_creator", metadata.dc_creator()); - prop.putXML("dc_description", ""); + prop.putXML("dc_description", ""); // this is the fulltext part in the surrogate prop.putXML("dc_subject", metadata.dc_subject()); prop.putXML("dc_publisher", ""); prop.putXML("dc_contributor", ""); @@ -102,6 +103,7 @@ public class yacydoc { prop.putXML("dc_identifier", metadata.url().toNormalform(false, true)); prop.putXML("dc_language", entry.language()); + prop.put("yacy_urlhash", metadata.url().hash()); prop.putXML("yacy_loaddate", entry.loaddate().toString()); prop.putXML("yacy_referrer_hash", (le == null) ? "" : new String(le.hash())); prop.putXML("yacy_referrer_url", (le == null) ? "" : le.metadata().url().toNormalform(false, true)); diff --git a/htroot/api/yacydoc.xml b/htroot/api/yacydoc.xml index 7a93b3aad..c65651bab 100644 --- a/htroot/api/yacydoc.xml +++ b/htroot/api/yacydoc.xml @@ -15,8 +15,8 @@ you can validate it with http://www.stg.brown.edu/service/xmlvalid/ #[dc_publisher]# #[dc_date]# yacy:doctype:#[dc_type]# - yacy:urlhash:#[dc_identifier]# - #[dc_publisher]# + yacy:urlhash:#[yacy_urlhash]# + #[dc_identifier]# #[yacy_size]# #[dc_language]# #[yacy_loaddate]#