Skip to content

Commit

Permalink
fixes for metadata retrieval and presentation
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6855 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed May 5, 2010
1 parent 5c5e6ac commit 06ff0c5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
4 changes: 2 additions & 2 deletions htroot/CrawlResults.java
Expand Up @@ -79,7 +79,7 @@ public static serverObjects respond(final RequestHeader header, serverObjects po
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
Expand All @@ -100,7 +100,7 @@ public static serverObjects respond(final RequestHeader header, serverObjects po
}
}

if(post != null) {
if (post != null) {
// custom number of lines
if (post.containsKey("count")) {
lines = Integer.parseInt(post.get("count", "500"));
Expand Down
26 changes: 18 additions & 8 deletions htroot/ViewFile.java
Expand Up @@ -90,15 +90,12 @@ public static serverObjects respond(final RequestHeader header, final serverObje

// 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);
Expand Down Expand Up @@ -180,7 +177,20 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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) {
Expand Down
20 changes: 11 additions & 9 deletions htroot/api/yacydoc.html
Expand Up @@ -22,15 +22,17 @@
<h1 property="dc:Title">#[dc_title]#</h1>

<dl>
<dt>Author</dt><dd property="dc:Creator">#[dc_creator]#</dd>
<dt>Description</dt><dd property="dc:Description">#[dc_description]#</dd>
<dt>Subject</dt><dd property="dc:Subject">#[dc_subject]#</dd>
<dt>Publisher</dt><dd property="dc:Publisher">#[dc_publisher]#</dd>
<dt>Contributor</dt><dd property="dc:Contributor">#[dc_contributor]#</dd>
<dt>Date</dt><dd property="dc:Date">#[dc_date]#</dd>
<dt>Type</dt><dd property="dc:Type">yacy:doctype:#[dc_type]#</dd>
<dt>Identifier</dt><dd property="dc:Identifier">#[dc_identifier]#</dd>
<dt>Language</dt><dd property="dc:Language">#[dc_language]#</dd>
<dt>Title</dt><dd property="dc:title">#[dc_title]#</dd>
<dt>Author</dt><dd property="dc:creator">#[dc_creator]#</dd>
<dt>Description</dt><dd property="dc:description">#[dc_description]#</dd>
<dt>Subject</dt><dd property="dc:subject">#[dc_subject]#</dd>
<dt>Publisher</dt><dd property="dc:publisher">#[dc_publisher]#</dd>
<dt>Contributor</dt><dd property="dc:contributor">#[dc_contributor]#</dd>
<dt>Date</dt><dd property="dc:date">#[dc_date]#</dd>
<dt>Type</dt><dd property="dc:type">yacy:doctype:#[dc_type]#</dd>
<dt>YaCy Identifier</dt><dd property="dc:identifier">yacy:urlhash:#[yacy_urlhash]#</dd>
<dt>Identifier</dt><dd><a href="#[dc_identifier]# property="dc:identifier">#[dc_identifier]#</a></dd>
<dt>Language</dt><dd property="dc:language">#[dc_language]#</dd>

<dt>Load Date</dt><dd property="yacy:loaddate">#[yacy_loaddate]#</dd>
<dt>Referrer Identifier</dt><dd property="yacy:referrer.hash">yacy:urlhash:#[yacy_referrer_hash]#</dd>
Expand Down
8 changes: 5 additions & 3 deletions htroot/api/yacydoc.java
Expand Up @@ -49,7 +49,8 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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);
Expand All @@ -68,7 +69,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje

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;

Expand All @@ -93,7 +94,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje

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", "");
Expand All @@ -102,6 +103,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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));
Expand Down
4 changes: 2 additions & 2 deletions htroot/api/yacydoc.xml
Expand Up @@ -15,8 +15,8 @@ you can validate it with http://www.stg.brown.edu/service/xmlvalid/
<dc:publisher.URL>#[dc_publisher]#</dc:publisher.URL>
<dc:date>#[dc_date]#</dc:date>
<dc:type>yacy:doctype:#[dc_type]#</dc:type>
<dc:identifier SCHEME="yacy:urlhash">yacy:urlhash:#[dc_identifier]#</dc:identifier>
<dc:identifier SCHEME="URL">#[dc_publisher]#</dc:identifier>
<dc:identifier SCHEME="yacy:urlhash">yacy:urlhash:#[yacy_urlhash]#</dc:identifier>
<dc:identifier SCHEME="URL">#[dc_identifier]#</dc:identifier>
<dc:format.extent>#[yacy_size]#</dc:format.extent>
<dc:language SCHEME="ISO639-2">#[dc_language]#</dc:language>
<yacy:loaddate>#[yacy_loaddate]#</yacy:loaddate>
Expand Down

0 comments on commit 06ff0c5

Please sign in to comment.