commonPreferredValue.put(CRAM_HMAC_ALG_PARAM, new StringValue("sha1"));
commonPreferredValue.put(SHARED_SECRET_PARAM, new StringValue(getRandomSecret()));
commonPreferredValue.put(ON_IO_ERROR_PARAM, new StringValue("detach"));
commonPreferredValue.put(PROXY_MEMLIMIT_PARAM, new StringValue("100", DrbdXml.getUnitMiBytes("")));
commonPreferredValue.put(PROXY_PLUGIN_ZLIB_PARAM, new StringValue("level 9"));
final GlobalInfo globalInfo = dri.getBrowser().getGlobalInfo();
final boolean protocolInNetSection = globalInfo.atLeastVersion("8.4");
if (globalInfo.getDrbdResources().size() <= 1) {
for (final String commonP : COMMON_PARAMS) {
if (!protocolInNetSection && DrbdXml.PROTOCOL_PARAM.equals(commonP)) {
continue;
}
final Widget widget = globalInfo.getWidget(commonP, null);
if (widget == null) {
LOG.appError("widget for param: " + commonP + " was not created");
return new JPanel();
}
/* for the first resource set common options. */
final Value commonValue = globalInfo.getResource().getValue(commonP);
if (commonPreferredValue.containsKey(commonP)) {
final Value defaultValue = globalInfo.getParamDefault(commonP);
if (Tools.areEqual(defaultValue, commonValue)) {
widget.setValue(commonPreferredValue.get(commonP));
dri.getResource().setValue(commonP, commonPreferredValue.get(commonP));
} else {
dri.getResource().setValue(commonP, commonValue);
}
}
}
} else {
/* resource options, if not defined in common section. */
for (final String commonP : COMMON_PARAMS) {
final Value commonValue = globalInfo.getResource().getValue(commonP);
if (commonValue == null || commonValue.isNothingSelected()
&& commonPreferredValue.containsKey(commonP)) {
dri.getResource().setValue(commonP, commonPreferredValue.get(commonP));
}
}