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.
pull/93/merge
luccioman 7 years ago
parent 30d71c6359
commit b23a563065

@ -209,7 +209,12 @@ public class yacysearchitem {
}
} 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 class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
/**
* 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);

Loading…
Cancel
Save