always use a default value for boolean options to have transparency for

the outcome if the attribute is missing in servlets
pull/1/head
Michael Peter Christen 12 years ago
parent 61e015268b
commit 4c242f9af9

@ -65,7 +65,7 @@ public class AccessPicture_p {
color_grid = post.get("colorgrid", color_grid);
color_dot = post.get("colordot", color_dot);
color_line = post.get("colorline", color_line);
corona = !post.containsKey("corona") || post.getBoolean("corona");
corona = !post.containsKey("corona") || post.getBoolean("corona", false);
coronaangle = (corona) ? post.getInt("coronaangle", 0) : -1;
}
if (coronaangle < 0) corona = false;

@ -83,15 +83,15 @@ public class ConfigPortal {
sb.setConfig(SwitchboardConstants.SEARCH_ITEMS, post.getInt("maximumRecords", 10));
sb.setConfig(SwitchboardConstants.INDEX_FORWARD, post.get(SwitchboardConstants.INDEX_FORWARD, ""));
HTTPDFileHandler.indexForward = post.get(SwitchboardConstants.INDEX_FORWARD, "");
sb.setConfig("publicTopmenu", !post.containsKey("publicTopmenu") || post.getBoolean("publicTopmenu"));
sb.setConfig("publicSearchpage", !post.containsKey("publicSearchpage") || post.getBoolean("publicSearchpage"));
sb.setConfig("search.options", post.getBoolean("search.options"));
sb.setConfig("publicTopmenu", !post.containsKey("publicTopmenu") || post.getBoolean("publicTopmenu", true));
sb.setConfig("publicSearchpage", !post.containsKey("publicSearchpage") || post.getBoolean("publicSearchpage", true));
sb.setConfig("search.options", post.getBoolean("search.options", false));
sb.setConfig("interaction.userlogon.enabled", post.getBoolean("interaction.userlogon"));
sb.setConfig(SwitchboardConstants.GREEDYLEARNING_ACTIVE, post.getBoolean(SwitchboardConstants.GREEDYLEARNING_ACTIVE));
sb.setConfig("interaction.userlogon.enabled", post.getBoolean("interaction.userlogon", false));
sb.setConfig(SwitchboardConstants.GREEDYLEARNING_ACTIVE, post.getBoolean(SwitchboardConstants.GREEDYLEARNING_ACTIVE, true));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, post.get("search.verify", "ifexist"));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, post.getBoolean("search.verify.delete"));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, post.getBoolean("search.verify.delete", false));
sb.setConfig("about.headline", post.get("about.headline", ""));
sb.setConfig("about.body", post.get("about.body", ""));

@ -59,34 +59,34 @@ public class ConfigSearchPage_p {
// store this call as api call
sb.tables.recordAPICall(post, "ConfigPortal.html", WorkTables.TABLE_API_TYPE_CONFIGURATION, "new portal design. greeting: " + newGreeting);
sb.setConfig("publicTopmenu", post.getBoolean("publicTopmenu"));
sb.setConfig("search.options", post.getBoolean("search.options"));
sb.setConfig("publicTopmenu", post.getBoolean("publicTopmenu", false));
sb.setConfig("search.options", post.getBoolean("search.options", false));
sb.setConfig("search.text", post.getBoolean("search.text"));
sb.setConfig("search.image", post.getBoolean("search.image"));
sb.setConfig("search.audio", post.getBoolean("search.audio"));
sb.setConfig("search.video", post.getBoolean("search.video"));
sb.setConfig("search.app", post.getBoolean("search.app"));
sb.setConfig("search.text", post.getBoolean("search.text", false));
sb.setConfig("search.image", post.getBoolean("search.image", false));
sb.setConfig("search.audio", post.getBoolean("search.audio", false));
sb.setConfig("search.video", post.getBoolean("search.video", false));
sb.setConfig("search.app", post.getBoolean("search.app", false));
sb.setConfig("search.result.show.date", post.getBoolean("search.result.show.date"));
sb.setConfig("search.result.show.size", post.getBoolean("search.result.show.size"));
sb.setConfig("search.result.show.metadata", post.getBoolean("search.result.show.metadata"));
sb.setConfig("search.result.show.parser", post.getBoolean("search.result.show.parser"));
sb.setConfig("search.result.show.citation", post.getBoolean("search.result.show.citation"));
sb.setConfig("search.result.show.pictures", post.getBoolean("search.result.show.pictures"));
sb.setConfig("search.result.show.cache", post.getBoolean("search.result.show.cache"));
sb.setConfig("search.result.show.proxy", post.getBoolean("search.result.show.proxy"));
sb.setConfig("search.result.show.hostbrowser", post.getBoolean("search.result.show.hostbrowser"));
sb.setConfig("search.result.show.tags", post.getBoolean("search.result.show.tags"));
sb.setConfig("search.result.show.date", post.getBoolean("search.result.show.date", false));
sb.setConfig("search.result.show.size", post.getBoolean("search.result.show.size", false));
sb.setConfig("search.result.show.metadata", post.getBoolean("search.result.show.metadata", false));
sb.setConfig("search.result.show.parser", post.getBoolean("search.result.show.parser", false));
sb.setConfig("search.result.show.citation", post.getBoolean("search.result.show.citation", false));
sb.setConfig("search.result.show.pictures", post.getBoolean("search.result.show.pictures", false));
sb.setConfig("search.result.show.cache", post.getBoolean("search.result.show.cache", false));
sb.setConfig("search.result.show.proxy", post.getBoolean("search.result.show.proxy", false));
sb.setConfig("search.result.show.hostbrowser", post.getBoolean("search.result.show.hostbrowser", false));
sb.setConfig("search.result.show.tags", post.getBoolean("search.result.show.tags", false));
// construct navigation String
String nav = "";
if (post.getBoolean("search.navigation.filetype")) nav += "filetype,";
if (post.getBoolean("search.navigation.protocol")) nav += "protocol,";
if (post.getBoolean("search.navigation.hosts")) nav += "hosts,";
if (post.getBoolean("search.navigation.authors")) nav += "authors,";
if (post.getBoolean("search.navigation.namespace")) nav += "namespace,";
if (post.getBoolean("search.navigation.topics")) nav += "topics,";
if (post.getBoolean("search.navigation.filetype", false)) nav += "filetype,";
if (post.getBoolean("search.navigation.protocol", false)) nav += "protocol,";
if (post.getBoolean("search.navigation.hosts", false)) nav += "hosts,";
if (post.getBoolean("search.navigation.authors", false)) nav += "authors,";
if (post.getBoolean("search.navigation.namespace", false)) nav += "namespace,";
if (post.getBoolean("search.navigation.topics", false)) nav += "topics,";
if (nav.endsWith(",")) nav = nav.substring(0, nav.length() - 1);
sb.setConfig("search.navigation", nav);
}

@ -157,7 +157,7 @@ public class ConfigUpdate_p {
sb.setConfig("update.cycle", Math.max(12, post.getLong("cycle", 168)));
sb.setConfig("update.blacklist", post.get("blacklist", ""));
sb.setConfig("update.concept", ("any".equals(post.get("releaseType", "any"))) ? "any" : "main");
sb.setConfig("update.onlySignedFiles", (post.getBoolean("onlySignedFiles")) ? "1" : "0");
sb.setConfig("update.onlySignedFiles", (post.getBoolean("onlySignedFiles", true)) ? "1" : "0");
}
}

@ -61,7 +61,7 @@ public final class Connections_p {
// determines if name lookup should be done or not
final boolean doNameLookup;
if (post != null) {
doNameLookup = post.getBoolean("nameLookup");
doNameLookup = post.getBoolean("nameLookup", false);
if (post.containsKey("closeServerSession")) {
final String sessionName = post.get("closeServerSession", null);
sb.closeSessions(sessionName);

@ -171,7 +171,7 @@ public class Crawler_p {
long t = timeParser(true, post.getInt("deleteIfOlderNumber", -1), post.get("deleteIfOlderUnit","year")); // year, month, day, hour
if (t > 0) deleteageDate = new Date(t);
}
final boolean deleteold = (deleteage && deleteageDate != null) || (restrictedcrawl && post.getBoolean("deleteold"));
final boolean deleteold = (deleteage && deleteageDate != null) || (restrictedcrawl && post.getBoolean("deleteold", false));
String crawlingStart0 = post.get("crawlingURL","").trim(); // the crawljob start url
String[] rootURLs0 = crawlingStart0.indexOf('\n') > 0 || crawlingStart0.indexOf('\r') > 0 ? crawlingStart0.split("[\\r\\n]+") : crawlingStart0.split(Pattern.quote("|"));
@ -207,7 +207,7 @@ public class Crawler_p {
String ipMustMatch = post.get("ipMustmatch", CrawlProfile.MATCH_ALL_STRING);
final String ipMustNotMatch = post.get("ipMustnotmatch", CrawlProfile.MATCH_NEVER_STRING);
if (ipMustMatch.length() < 2) ipMustMatch = CrawlProfile.MATCH_ALL_STRING;
final String countryMustMatch = post.getBoolean("countryMustMatchSwitch") ? post.get("countryMustMatchList", "") : "";
final String countryMustMatch = post.getBoolean("countryMustMatchSwitch", false) ? post.get("countryMustMatchList", "") : "";
sb.setConfig("crawlingIPMustMatch", ipMustMatch);
sb.setConfig("crawlingIPMustNotMatch", ipMustNotMatch);
if (countryMustMatch.length() > 0) sb.setConfig("crawlingCountryMustMatch", countryMustMatch);

@ -228,7 +228,7 @@ public class HostBrowser {
delete = true;
}
int facetcount=post.getInt("facetcount", 0);
boolean complete = post.getBoolean("complete");
boolean complete = post.getBoolean("complete", false);
if (complete) { // we want only root paths for complete lists
p = path.indexOf('/', 10);
if (p > 0) path = path.substring(0, p + 1);

@ -48,7 +48,7 @@ public class IndexFederated_p {
if (post != null && post.containsKey("set")) {
//yacy
boolean post_core_rwi = post.getBoolean(SwitchboardConstants.CORE_SERVICE_RWI);
boolean post_core_rwi = post.getBoolean(SwitchboardConstants.CORE_SERVICE_RWI, false);
final boolean previous_core_rwi = sb.index.connectedRWI() && env.getConfigBool(SwitchboardConstants.CORE_SERVICE_RWI, false);
env.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, post_core_rwi);
if (previous_core_rwi && !post_core_rwi) sb.index.disconnectRWI(); // switch off
@ -58,7 +58,7 @@ public class IndexFederated_p {
sb.index.connectRWI(wordCacheMaxCount, fileSizeMax);
} catch (final IOException e) { ConcurrentLog.logException(e); } // switch on
boolean post_core_citation = post.getBoolean(SwitchboardConstants.CORE_SERVICE_CITATION);
boolean post_core_citation = post.getBoolean(SwitchboardConstants.CORE_SERVICE_CITATION, false);
final boolean previous_core_citation = sb.index.connectedCitation() && env.getConfigBool(SwitchboardConstants.CORE_SERVICE_CITATION, false);
env.setConfig(SwitchboardConstants.CORE_SERVICE_CITATION, post_core_citation);
if (previous_core_citation && !post_core_citation) sb.index.disconnectCitation(); // switch off
@ -68,7 +68,7 @@ public class IndexFederated_p {
sb.index.connectCitation(wordCacheMaxCount, fileSizeMax);
} catch (final IOException e) { ConcurrentLog.logException(e); } // switch on
boolean post_core_fulltext = post.getBoolean(SwitchboardConstants.CORE_SERVICE_FULLTEXT);
boolean post_core_fulltext = post.getBoolean(SwitchboardConstants.CORE_SERVICE_FULLTEXT, true);
final boolean previous_core_fulltext = sb.index.fulltext().connectedLocalSolr() && env.getConfigBool(SwitchboardConstants.CORE_SERVICE_FULLTEXT, false);
env.setConfig(SwitchboardConstants.CORE_SERVICE_FULLTEXT, post_core_fulltext);
@ -83,17 +83,17 @@ public class IndexFederated_p {
try { sb.index.fulltext().connectLocalSolr(); } catch (final IOException e) { ConcurrentLog.logException(e); }
}
boolean webgraph = post.getBoolean(SwitchboardConstants.CORE_SERVICE_WEBGRAPH);
boolean webgraph = post.getBoolean(SwitchboardConstants.CORE_SERVICE_WEBGRAPH, false);
sb.index.fulltext().writeWebgraph(webgraph);
env.setConfig(SwitchboardConstants.CORE_SERVICE_WEBGRAPH, webgraph);
boolean jena = post.getBoolean(SwitchboardConstants.CORE_SERVICE_JENA);
boolean jena = post.getBoolean(SwitchboardConstants.CORE_SERVICE_JENA, false);
env.setConfig(SwitchboardConstants.CORE_SERVICE_JENA, jena);
// solr
final boolean solrRemoteWasOn = sb.index.fulltext().connectedRemoteSolr() && env.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, true);
String solrurls = post.get("solr.indexing.url", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, "http://127.0.0.1:8983/solr"));
final boolean solrRemoteIsOnAfterwards = post.getBoolean("solr.indexing.solrremote") & solrurls.length() > 0;
final boolean solrRemoteIsOnAfterwards = post.getBoolean("solr.indexing.solrremote", false) & solrurls.length() > 0;
env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, solrRemoteIsOnAfterwards);
final BufferedReader r = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(UTF8.getBytes(solrurls))));
final StringBuilder s = new StringBuilder();
@ -148,7 +148,7 @@ public class IndexFederated_p {
ConcurrentLog.severe("IndexFederated_p", "change of solr connection failed", e);
}
boolean lazy = post.getBoolean("solr.indexing.lazy");
boolean lazy = post.getBoolean("solr.indexing.lazy", true);
env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_LAZY, lazy);
}

@ -90,7 +90,7 @@ public class NetworkPicture
passiveLimit = post.getInt("pal", passiveLimit);
potentialLimit = post.getInt("pol", potentialLimit);
maxCount = post.getInt("max", maxCount);
corona = !post.containsKey("corona") || post.getBoolean("corona");
corona = post.getBoolean("corona", true);
coronaangle = (corona) ? post.getInt("coronaangle", 0) : -1;
communicationTimeout = post.getLong("ct", -1);
bgcolor = post.get("bgcolor", bgcolor);

@ -22,7 +22,7 @@ public class PeerLoadPicture {
if (post != null) {
width = post.getInt("width", 800);
height = post.getInt("height", 600);
showidle = post.getBoolean("showidle");
showidle = post.getBoolean("showidle", false);
}
final CircleThreadPiece idle = new CircleThreadPiece("Idle", new Color(170, 255, 170));

@ -102,11 +102,11 @@ public class Status
ByteCount.resetCount();
redirect = true;
} else if ( post.containsKey("popup") ) {
final boolean trigger_enabled = post.getBoolean("popup");
final boolean trigger_enabled = post.getBoolean("popup", false);
sb.setConfig("browserPopUpTrigger", trigger_enabled);
redirect = true;
} else if ( post.containsKey("tray") ) {
final boolean trigger_enabled = post.getBoolean("tray");
final boolean trigger_enabled = post.getBoolean("tray", false);
sb.setConfig("trayIcon", trigger_enabled);
redirect = true;
}

@ -65,7 +65,7 @@ public class Table_API_p {
startRecord = 0;
maximumRecords = 1000;
}
final boolean inline = (post != null && post.getBoolean("inline"));
final boolean inline = (post != null && post.getBoolean("inline", false));
prop.put("inline", (inline) ? 1 : 0);

@ -49,7 +49,7 @@ public class Threaddump_p {
final StringBuilder buffer = new StringBuilder(1000);
final boolean plain = post != null && post.getBoolean("plain");
final boolean plain = post != null && post.getBoolean("plain", false);
final int sleep = (post == null) ? 0 : post.getInt("sleep", 0); // a sleep before creation of a thread dump can be used for profiling
if (sleep > 0) try {Thread.sleep(sleep);} catch (final InterruptedException e) {}
prop.put("dump", "1");

@ -129,7 +129,7 @@ public class ViewFile {
// define an url by post parameter
url = new DigestURI(MultiProtocolURI.unescape(urlString));
urlHash = ASCII.String(url.hash());
pre = post.getBoolean("pre");
pre = post.getBoolean("pre", false);
} catch (final MalformedURLException e) {}
URIMetadataNode urlEntry = null;

@ -62,7 +62,7 @@ public class import_ymark {
boolean merge = false;
boolean empty = false;
final String indexing = post.get("indexing", "off");
final boolean medialink = post.getBoolean("medialink");
final boolean medialink = post.getBoolean("medialink", false);
if(post.containsKey("autotag") && !post.get("autotag", "off").equals("off")) {
autotag = true;

@ -44,8 +44,7 @@ public class opensearchdescription {
if (thisaddress.indexOf(':',0) == -1) thisaddress += ":" + serverCore.getPortNr(env.getConfig("port", "8090"));
int compareyacy = 0;
if (post != null && post.getBoolean("compare_yacy"))
compareyacy = 1;
if (post != null && post.getBoolean("compare_yacy", false)) compareyacy = 1;
final serverObjects prop = new serverObjects();
prop.put("compareyacy", compareyacy);

@ -444,13 +444,6 @@ public class serverObjects implements Serializable, Cloneable {
}
}
public boolean getBoolean(final String key) {
String s = removeByteOrderMark(get(key));
if (s == null) return false;
s = s.toLowerCase();
return s.equals("true") || s.equals("on") || s.equals("1");
}
public boolean getBoolean(final String key, final boolean dflt) {
String s = removeByteOrderMark(get(key));
if (s == null) return dflt;

Loading…
Cancel
Save