Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Added controls on mode switch when attached to remote Solr instance(s)
luccioman72808655a503
diff --git a/htroot/ConfigBasic.html b/htroot/ConfigBasic.htmlindex e8bd56d11..bef5b4775 100644--- a/htroot/ConfigBasic.html+++ b/htroot/ConfigBasic.html@@ -53,6 +53,14 @@<li><img src="env/grafics/ok.png" height="16" width="16" alt="ok" /> Use Case: what do you want to do with YaCy:<br /><fieldset>+ #(switchError)#::<div class="alert alert-danger" role="alert"><p>Can not leave from Intranet Indexing : one or more remote Solr instances are attached and may contain private documents indexed.</p>+ <p>Please first delete all index entries (see the <a href="IndexControlURLs_p.html">URL Database Administration</a> page) or disconnect the remote Solr instance(s) from YaCy (see the <a href="IndexFederated_p.html">Index Sources & Targets</a> page).</p></div>+ #(/switchError)#+ #(switchWarning)#::<div class="alert alert-warning" role="alert"><p>One or more remote Solr instances are attached and may contain indexed public documents irrelevant to your local domain.</p>+ <p>You may want to delete all indexed documents (see the <a href="IndexControlURLs_p.html">URL Database Administration</a> page), disconnect or change the remote Solr instance(s) attached (see the <a href="IndexFederated_p.html">Index Sources & Targets</a> page).</p></div>+ ::<div class="alert alert-warning" role="alert"><p>One or more remote Solr instances are attached.</p>+ <p>Please be sure you want to expose the indexed documents in this new mode. You may want to disconnect or change the remote Solr instance(s) attached (see the <a href="IndexFederated_p.html">Index Sources & Targets</a> page).</p></div>+ #(/switchWarning)#<table border="0"><tr><td style="width: 256px;"><input type="radio" name="usecase" value="freeworld" id="usecaseFreeworld" #(freeworldChecked)#::checked="checked"#(/freeworldChecked)# /><label for="usecaseFreeworld">Community-based web search</label></td>diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.javaindex 414a47908..2eb239c32 100644--- a/htroot/ConfigBasic.java+++ b/htroot/ConfigBasic.java@@ -171,33 +171,60 @@ public class ConfigBasic {}// set a use case+ prop.put("setUseCase_switchError", 0);+ prop.put("setUseCase_switchWarning", 0);String networkName = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "");if (post != null && post.containsKey("usecase")) {+ boolean hasNonEmptyRemoteSolr = sb.index.fulltext().connectedRemoteSolr()+ && (sb.index.fulltext().collectionSize() > 0 || sb.index.fulltext().webgraphSize() > 0);if ("freeworld".equals(post.get("usecase", "")) && !"freeworld".equals(networkName)) {- // switch to freeworld network- sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, true);- sb.switchNetwork("defaults/yacy.network.freeworld.unit");- // switch to p2p mode- sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, true);- sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);- sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true);- // set default behavior for search verification- sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "iffresh"); // nocache,iffresh,ifexist,cacheonly,false- sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "true");+ if("intranet".equals(networkName) && hasNonEmptyRemoteSolr) {+ /* One or more non empty remote Solr(s) attached : disallow switching from intranet to another network to prevent disclosure of indexed private documents */+ prop.put("setUseCase_switchError", 1);+ } else {+ if(hasNonEmptyRemoteSolr) {+ /* One or more non empty remote Solr(s) attached : warn the user even if not coming from intranet as indexed documents may be irrelevant for the new mode */+ prop.put("setUseCase_switchWarning", 2);+ }+ // switch to freeworld network+ sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, true);+ sb.switchNetwork("defaults/yacy.network.freeworld.unit");+ // switch to p2p mode+ sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, true);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true);+ // set default behavior for search verification+ sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "iffresh"); // nocache,iffresh,ifexist,cacheonly,false+ sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "true");+ }}if ("portal".equals(post.get("usecase", "")) && !"webportal".equals(networkName)) {- // switch to webportal network- sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, false);- sb.switchNetwork("defaults/yacy.network.webportal.unit");- // switch to robinson mode- sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, false);- sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);- sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false);- // set default behavior for search verification- sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "ifexist"); // nocache,iffresh,ifexist,cacheonly,false- sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "false");+ if("intranet".equals(networkName) && hasNonEmptyRemoteSolr) {+ /* One or more non empty remote Solr(s) attached : disallow switching from intranet to another network to prevent disclosure of indexed private documents */+ prop.put("setUseCase_switchError", 1);+ } else {+ if(hasNonEmptyRemoteSolr) {+ /* One or more non empty remote Solr(s) attached : warn the user even if not coming from intranet as indexed documents may be irrelevant for the new mode */+ prop.put("setUseCase_switchWarning", 2);+ }++ // switch to webportal network+ sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, false);+ sb.switchNetwork("defaults/yacy.network.webportal.unit");+ // switch to robinson mode+ sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, false);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);+ sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false);+ // set default behavior for search verification+ sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "ifexist"); // nocache,iffresh,ifexist,cacheonly,false+ sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "false");+ }}if ("intranet".equals(post.get("usecase", "")) && !"intranet".equals(networkName)) {+ if(hasNonEmptyRemoteSolr) {+ /* One or more non empty remote Solr(s) attached : warn the user as the indexed documents may be public external resources out of scope for intranet/localhost domain. */+ prop.put("setUseCase_switchWarning", 1);+ }// switch to intranet networksb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, false);sb.switchNetwork("defaults/yacy.network.intranet.unit");