Permalink
Browse files

Prevent search result failure on incomplete images information.

Complements the recent modification related to images in commit 7f395ef.

Unfortunately many documents metadata fetched from the freeworld p2p
network have only partial information about embedded images. Without
proper error handling, this made many searches in p2p mode to fail
completely.
  • Loading branch information...
luccioman committed Aug 15, 2017
1 parent 30d71c6 commit b23a5630652412aae44a2a342b6dac9df967dae2
Showing with 9 additions and 3 deletions.
  1. +6 −1 htroot/yacysearchitem.java
  2. +3 −2 source/net/yacy/kelondro/data/meta/URIMetadataNode.java
@@ -209,7 +209,12 @@ public static serverObjects respond(final RequestHeader header, final serverObje
}
} else {
prop.put("content_image", 1);
prop.putXML("content_image_url", result.imageURL());
try {
prop.putXML("content_image_url", result.imageURL());
} catch(UnsupportedOperationException e) {
/* May occur when the document embedded images information is incomplete to retrieve at least an valid image url*/
prop.put("content_image", 0);
}
}
prop.put("content_urlhash", urlhash);
@@ -453,9 +453,10 @@ public int wordCount() {
/**
* in case that images are embedded in the document, get one image which can be used as thumbnail
* @return
* @return the first embedded image url
* @throws UnsupportedOperationException when there is no image URL referenced on this document
*/
public String imageURL() {
public String imageURL() throws UnsupportedOperationException {
if (limage() == 0) throw new UnsupportedOperationException();
List<String> images_protocol = CollectionConfiguration.indexedList2protocolList(getFieldValues(CollectionSchema.images_protocol_sxt.getSolrFieldName()), limage());
List<String> images_stub = getStringList(CollectionSchema.images_urlstub_sxt);

0 comments on commit b23a563

Please sign in to comment.