prevent NPE on host link for to short HeuristicCfg.OpenSearchURL

pull/1/head
reger 11 years ago
parent 5f0bb1214f
commit 1d3ea35d69

@ -101,8 +101,8 @@ public class ConfigHeuristics_p {
OpenSearchConnector osc = new OpenSearchConnector(sb,false); OpenSearchConnector osc = new OpenSearchConnector(sb,false);
osc.add (tmpname,tmpurl,false,tmpcomment); osc.add (tmpname,tmpurl,false,tmpcomment);
} else osderrmsg = "Url template must contain '{searchTerms}'"; } else osderrmsg = "Url template must contain '{searchTerms}'";
}
} }
}
if (post.containsKey("setopensearch")) { if (post.containsKey("setopensearch")) {
// read index schema table flags // read index schema table flags
@ -177,14 +177,17 @@ public class ConfigHeuristics_p {
String tmps = e.getValue(); String tmps = e.getValue();
prop.putHTML("osdcfg_" + c + "_url", tmps); prop.putHTML("osdcfg_" + c + "_url", tmps);
tmps = tmps.substring(0,tmps.lastIndexOf("/")); final int lastpos = tmps.lastIndexOf("/");
prop.putHTML("osdcfg_" + c + "_urlhostlink", tmps); if (lastpos > 6) { // after http://x or ftp://x
tmps = tmps.substring(0, lastpos);
prop.putHTML("osdcfg_" + c + "_urlhostlink", tmps);
} else prop.putHTML("osdcfg_" + c + "_urlhostlink", "#");
c++; c++;
} }
prop.put("osdcfg", c); prop.put("osdcfg", c);
} catch (final IOException e1) { } catch (final IOException e1) {
ConcurrentLog.logException(e1); ConcurrentLog.warn("OpenSearchConnector", "file not found " + f.getAbsolutePath());
prop.put("osdcfg", 0); prop.put("osdcfg", 0);
} }
prop.putHTML("osderrmsg",osderrmsg); prop.putHTML("osderrmsg",osderrmsg);
@ -208,7 +211,7 @@ public class ConfigHeuristics_p {
if (!sfn.equals(entry.getValue())) { if (!sfn.equals(entry.getValue())) {
entry.setValue(sfn); entry.setValue(sfn);
modified = true; modified = true;
} }
} }
// set enable flag // set enable flag
String v = post.get("ossys_" + entry.key()); String v = post.get("ossys_" + entry.key());
@ -232,7 +235,7 @@ public class ConfigHeuristics_p {
} }
} }
} catch (final IOException e) { } catch (final IOException e) {
ConcurrentLog.logException(e); ConcurrentLog.warn("OpenSearchConnector", "file not found " + f.getAbsolutePath());
} }
// re-read config (and create/update work table) // re-read config (and create/update work table)

Loading…
Cancel
Save