in config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java [55:125]
protected Object doExecute() throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
ConfigurationSupport support = new ConfigurationSupport();
support.setClusterManager(clusterManager);
support.setGroupManager(groupManager);
support.setConfigurationAdmin(configurationAdmin);
Map<String, ConfigurationState> configurations = gatherConfigurations();
if (configurations != null && !configurations.isEmpty()) {
for (String pid : configurations.keySet()) {
if (searchPid == null || (searchPid != null && searchPid.equals(pid))) {
ConfigurationState state = configurations.get(pid);
String located = "";
boolean cluster = state.isCluster();
boolean local = state.isLocal();
if (cluster && local)
located = "cluster/local";
if (cluster && ! local) {
located = "cluster";
if (onlyLocal)
continue;
}
if (local && !cluster) {
located = "local";
if (onlyCluster)
continue;
}
if (state.getClusterPids() != null && !state.getClusterPids().isEmpty()) {
located += " (cluster = " + state.getClusterPids() + ")";
}
String blocked = "";
boolean inbound = support.isAllowed(group, Constants.CATEGORY, pid, EventType.INBOUND);
boolean outbound = support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND);
if (inbound && outbound && onlyBlocked)
continue;
if (!inbound && !outbound)
blocked = "in/out";
if (!inbound && outbound)
blocked = "in";
if (!outbound && inbound)
blocked = "out";
System.out.println("----------------------------------------------------------------");
System.out.println("Pid: " + pid);
System.out.println("Located: " + located);
System.out.println("Blocked: " + blocked);
if (!minimal) {
Properties properties = state.getProperties();
if (properties != null) {
System.out.println("Properties:");
for (Enumeration e = properties.keys(); e.hasMoreElements(); ) {
Object key = e.nextElement();
System.out.println(" " + key + " = " + properties.get(key));
}
}
}
}
}
} else System.err.println("No configuration PID found in cluster group " + groupName);
return null;
}