From 7e4e9f7e328c99610fe8f7c063e11c2cc76f454a Mon Sep 17 00:00:00 2001 From: reger Date: Thu, 25 Dec 2014 02:16:19 +0100 Subject: [PATCH] improve yacysearchitem, prevent allocation of String (modifyURL) if feature not used --- htroot/yacysearchitem.java | 59 ++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index b4336675b..69206fb26 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -146,37 +146,34 @@ public class yacysearchitem { //prop.putHTML("content_link", resultUrlstring); // START interaction - String modifyURL = resultUrlstring; - if (sb.getConfigBool("proxyURL.useforresults", false) && sb.getConfigBool("proxyURL", false)) { - // check if url is allowed to view - if (sb.getConfig("proxyURL.rewriteURLs", "all").equals("all")) { - modifyURL = "./proxy.html?url="+modifyURL; - } - - // check if url is allowed to view - if (sb.getConfig("proxyURL.rewriteURLs", "all").equals("domainlist")) { - try { - if (sb.crawlStacker.urlInAcceptedDomain(new DigestURL (modifyURL)) == null) { - modifyURL = "./proxy.html?url="+modifyURL; - } - } catch (final MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - if (sb.getConfig("proxyURL.rewriteURLs", "all").equals("yacy")) { - try { - if ((new DigestURL (modifyURL).getHost().endsWith(".yacy"))) { - modifyURL = "./proxy.html?url="+modifyURL; - } - } catch (final MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - prop.putXML("content_link", modifyURL); // putXML for rss + if (sb.getConfigBool("proxyURL.useforresults", false) && sb.getConfigBool("proxyURL", false)) { + String modifyURL = resultUrlstring; + // check if url is allowed to view + final String tmprewritecfg = sb.getConfig("proxyURL.rewriteURLs", "all"); + if (tmprewritecfg.equals("all")) { + modifyURL = "./proxy.html?url=" + resultUrlstring; + } else if (tmprewritecfg.equals("domainlist")) { // check if url is allowed to view + try { + if (sb.crawlStacker.urlInAcceptedDomain(new DigestURL(resultUrlstring)) == null) { + modifyURL = "./proxy.html?url=" + resultUrlstring; + } + } catch (final MalformedURLException e) { + ConcurrentLog.logException(e); + } + } else if (tmprewritecfg.equals("yacy")) { + try { + if ((new DigestURL(resultUrlstring).getHost().endsWith(".yacy"))) { + modifyURL = "./proxy.html?url=" + resultUrlstring; + } + } catch (final MalformedURLException e) { + ConcurrentLog.logException(e); + } + } + prop.putXML("content_link", modifyURL); // putXML for rss + } else { + prop.putXML("content_link", resultUrlstring); // putXML for rss + } + // prop.putHTML("content_value", Interaction.TripleGet(result.urlstring(), "http://virtual.x/hasvalue", "anonymous")); // END interaction