use of org.codice.ddf.admin.core.api.jmx.AdminConsoleServiceMBean in project ddf by codice.
the class ServiceOperation method readState.
private static Map<String, Object> readState(String pid, AdminConsoleServiceMBean adminConsoleServiceMBean) throws ConfiguratorException {
try {
Map<String, Object> configResults = adminConsoleServiceMBean.getProperties(pid);
if (configResults.isEmpty()) {
Optional<Service> defaultMetatypeValues = adminConsoleServiceMBean.listServices().stream().filter(service -> service.getId() != null && service.getId().equals(pid)).findFirst();
List<MetatypeAttribute> metatypes = new ArrayList<>();
if (defaultMetatypeValues.isPresent()) {
metatypes = defaultMetatypeValues.get().getAttributeDefinitions();
}
return metatypes.stream().collect(Collectors.toMap(MetatypeAttribute::getId, MetatypeAttribute::getDefaultValue));
} else {
return configResults;
}
} catch (IOException e) {
throw new ConfiguratorException(String.format("Unable to find configuration for pid, %s", pid), e);
}
}
use of org.codice.ddf.admin.core.api.jmx.AdminConsoleServiceMBean in project ddf by codice.
the class ManagedServiceOperation method readState.
Map<String, Map<String, Object>> readState() throws ConfiguratorException {
try {
String[][] configurations = getConfigAdminMBean().getConfigurations(String.format("(service.factoryPid=%s)", factoryPid));
if (configurations == null || configurations.length == 0) {
return Collections.emptyMap();
}
HashMap<String, Map<String, Object>> retVal = new HashMap<>();
AdminConsoleServiceMBean configAdminMBean = getConfigAdminMBean();
for (String[] configuration : configurations) {
String configPid = configuration[0];
retVal.put(configPid, configAdminMBean.getProperties(configPid));
}
return retVal;
} catch (IOException e) {
LOGGER.debug("Error retrieving configurations for factoryPid, {}", factoryPid, e);
throw new ConfiguratorException("Error retrieving configurations");
}
}
Aggregations