use of org.codice.ddf.admin.core.api.ConfigurationProperties in project ddf by codice.
the class AdminPollerServiceBean method allSourceInfo.
@Override
public List<Service> allSourceInfo() {
// Get list of metatypes
List<Service> metatypes = helper.getMetatypes();
// Loop through each metatype and find its configurations
for (Service metatype : metatypes) {
try {
List<Configuration> configs = helper.getConfigurations(metatype);
List<ConfigurationDetails> configurations = new ArrayList<>();
if (configs != null) {
for (Configuration config : configs) {
ConfigurationDetails source = new ConfigurationDetailsImpl();
String pid = config.getPid();
String fPid = config.getFactoryPid();
boolean disabled = pid.endsWith(ConfigurationStatus.DISABLED_EXTENSION);
if (fPid != null) {
disabled = disabled || fPid.endsWith(ConfigurationStatus.DISABLED_EXTENSION);
}
source.setId(pid);
source.setEnabled(!disabled);
source.setFactoryPid(fPid);
if (!disabled) {
source.setName(helper.getName(config));
source.setBundleName(helper.getBundleName(config));
source.setBundleLocation(config.getBundleLocation());
source.setBundle(helper.getBundleId(config));
} else {
source.setName(config.getPid());
}
Dictionary<String, Object> properties = config.getProperties();
ConfigurationProperties plist = new ConfigurationPropertiesImpl();
for (String key : Collections.list(properties.keys())) {
plist.put(key, properties.get(key));
}
source.setConfigurationProperties(plist);
source.put(MAP_ENTRY_REPORT_ACTIONS, getActions(config, reportActionProviders));
source.put(MAP_ENTRY_OPERATION_ACTIONS, getActions(config, operationActionProviders));
configurations.add(source);
}
metatype.setConfigurations(configurations);
}
} catch (Exception e) {
LOGGER.debug("Error getting source info: {}", e.getMessage());
}
}
metatypes.sort(Comparator.comparing(Service::getId, String.CASE_INSENSITIVE_ORDER));
return metatypes;
}
use of org.codice.ddf.admin.core.api.ConfigurationProperties in project ddf by codice.
the class ConfigurationAdminImpl method addConfigurationData.
private void addConfigurationData(Service service, Configuration[] configs, Map<String, ObjectClassDefinition> objectClassDefinitions) {
for (Configuration config : configs) {
// ignore configuration object if it is invalid
final String pid = config.getPid();
if (!isAllowedPid(pid)) {
continue;
}
ConfigurationDetails configData = new ConfigurationDetailsImpl();
configData.setId(pid);
String fpid = config.getFactoryPid();
if (fpid != null) {
configData.setFactoryPid(fpid);
}
// insert an entry for the PID
try {
ObjectClassDefinition ocd = objectClassDefinitions.get(config.getPid());
if (ocd != null) {
configData.setName(ocd.getName());
} else {
// no object class definition, use plain PID
configData.setName(pid);
}
} catch (IllegalArgumentException t) {
// Catch exception thrown by getObjectClassDefinition so other configurations
// are displayed
// no object class definition, use plain PID
configData.setName(pid);
}
final Bundle bundle = getBoundBundle(config);
if (null != bundle) {
configData.setBundle(bundle.getBundleId());
configData.setBundleName(getName(bundle));
configData.setBundleLocation(bundle.getLocation());
}
ConfigurationProperties propertiesTable = new ConfigurationPropertiesImpl();
Dictionary<String, Object> properties = config.getProperties();
if (properties != null) {
Enumeration<String> keys = properties.keys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
propertiesTable.put(key, properties.get(key));
}
}
// If the configuration property is a password that has been set,
// mask its value to "password" so that the real password value will be hidden.
List<MetatypeAttribute> metatypeList = service.getAttributeDefinitions();
metatypeList.stream().filter(metatype -> AttributeDefinition.PASSWORD == metatype.getType()).forEach(metatype -> {
setPasswordMask(metatype, propertiesTable);
});
configData.setConfigurationProperties(propertiesTable);
Map<String, Object> pluginDataMap = getConfigurationPluginData(configData.getId(), Collections.unmodifiableMap(configData));
if (pluginDataMap != null && !pluginDataMap.isEmpty()) {
configData.putAll(pluginDataMap);
}
List<ConfigurationDetails> configurationDetails;
if (service.containsKey(Service.CONFIGURATIONS)) {
configurationDetails = service.getConfigurations();
} else if (service.containsKey(Service.DISABLED_CONFIGURATIONS)) {
configurationDetails = service.getDisabledConfigurations();
} else {
configurationDetails = new ArrayList<>();
}
configurationDetails.add(configData);
if (configData.getId().contains(ConfigurationDetails.DISABLED_SERVICE_IDENTIFIER)) {
configData.setEnabled(false);
} else {
configData.setEnabled(true);
}
service.setConfigurations(configurationDetails);
}
}
Aggregations