// display properties
final TreeMap<String,String> systemConfig = new TreeMap<String,String>();
systemConfig.putAll(shellState.getConnector().instanceOperations().getSystemConfiguration());
final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
final PrintFile printFile = outputFile == null ? null : new PrintFile(outputFile);
final TreeMap<String,String> siteConfig = new TreeMap<String,String>();
siteConfig.putAll(shellState.getConnector().instanceOperations().getSiteConfiguration());
final TreeMap<String,String> defaults = new TreeMap<String,String>();
for (Entry<String,String> defaultEntry : AccumuloConfiguration.getDefaultConfiguration()) {
defaults.put(defaultEntry.getKey(), defaultEntry.getValue());
}
final TreeMap<String,String> namespaceConfig = new TreeMap<String,String>();
if (tableName != null) {
String n = Namespaces.getNamespaceName(shellState.getInstance(),
Tables.getNamespaceId(shellState.getInstance(), Tables.getTableId(shellState.getInstance(), tableName)));
for (Entry<String,String> e : shellState.getConnector().namespaceOperations().getProperties(n)) {
namespaceConfig.put(e.getKey(), e.getValue());
}
}
Iterable<Entry<String,String>> acuconf = shellState.getConnector().instanceOperations().getSystemConfiguration().entrySet();
if (tableName != null) {
acuconf = shellState.getConnector().tableOperations().getProperties(tableName);
} else if (namespace != null) {
acuconf = shellState.getConnector().namespaceOperations().getProperties(namespace);
}
final TreeMap<String,String> sortedConf = new TreeMap<String,String>();
for (Entry<String,String> propEntry : acuconf) {
sortedConf.put(propEntry.getKey(), propEntry.getValue());
}
for (Entry<String,String> propEntry : acuconf) {
final String key = propEntry.getKey();
// only show properties with similar names to that
// specified, or all of them if none specified
if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt()))) {
continue;
}
if ((tableName != null || namespace != null) && !Property.isValidTablePropertyKey(key)) {
continue;
}
COL2 = Math.max(COL2, propEntry.getKey().length() + 3);
}
final ArrayList<String> output = new ArrayList<String>();
printConfHeader(output);
for (Entry<String,String> propEntry : sortedConf.entrySet()) {
final String key = propEntry.getKey();
// only show properties with similar names to that
// specified, or all of them if none specified
if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt()))) {
continue;
}
if ((tableName != null || namespace != null) && !Property.isValidTablePropertyKey(key)) {
continue;
}
String siteVal = siteConfig.get(key);
String sysVal = systemConfig.get(key);
String curVal = propEntry.getValue();
String dfault = defaults.get(key);
String nspVal = namespaceConfig.get(key);
boolean printed = false;
if (dfault != null && key.toLowerCase().contains("password")) {
siteVal = sysVal = dfault = curVal = curVal.replaceAll(".", "*");
}
if (sysVal != null) {
if (defaults.containsKey(key) && !Property.getPropertyByKey(key).isExperimental()) {
printConfLine(output, "default", key, dfault);
printed = true;
}
if (!defaults.containsKey(key) || !defaults.get(key).equals(siteVal)) {
printConfLine(output, "site", printed ? " @override" : key, siteVal == null ? "" : siteVal);
printed = true;
}
if (!siteConfig.containsKey(key) || !siteVal.equals(sysVal)) {
printConfLine(output, "system", printed ? " @override" : key, sysVal == null ? "" : sysVal);
printed = true;
}
}
if (nspVal != null) {
if (!systemConfig.containsKey(key) || !sysVal.equals(nspVal)) {
printConfLine(output, "namespace", printed ? " @override" : key, nspVal == null ? "" : nspVal);
printed = true;
}
}
// show per-table value only if it is different (overridden)
if (tableName != null && !curVal.equals(nspVal)) {
printConfLine(output, "table", printed ? " @override" : key, curVal);
} else if (namespace != null && !curVal.equals(sysVal)) {
printConfLine(output, "namespace", printed ? " @override" : key, curVal);
}
}
printConfFooter(output);
shellState.printLines(output.iterator(), !cl.hasOption(disablePaginationOpt.getOpt()), printFile);
if (printFile != null) {
printFile.close();
}
}
return 0;
}