use of org.osgi.service.cm.Configuration in project sling by apache.
the class BasicTeleportedIT method testConfigAdmin.
@Test
public void testConfigAdmin() throws IOException {
final String pid = "TEST_" + getClass().getName() + UUID.randomUUID();
// demonstrate that we can access OSGi services from such
// teleported tests
final ConfigurationAdmin ca = teleporter.getService(ConfigurationAdmin.class);
assertNotNull("Teleporter should provide a ConfigurationAdmin", ca);
final Configuration cfg = ca.getConfiguration(pid);
assertNotNull("Expecting to get a Configuration", cfg);
assertEquals("Expecting the correct pid", pid, cfg.getPid());
}
use of org.osgi.service.cm.Configuration in project sling by apache.
the class BasicTeleportedIT method testConfigAdmin.
@Test
public void testConfigAdmin() throws IOException {
final String pid = "TEST_" + getClass().getName() + UUID.randomUUID();
// demonstrate that we can access OSGi services from teleported tests
final ConfigurationAdmin ca = teleporter.getService(ConfigurationAdmin.class);
assertNotNull("Teleporter should provide a ConfigurationAdmin", ca);
final Configuration cfg = ca.getConfiguration(pid);
assertNotNull("Expecting to get a Configuration", cfg);
assertEquals("Expecting the correct pid", pid, cfg.getPid());
}
use of org.osgi.service.cm.Configuration in project sling by apache.
the class GetConfigServlet method getUniqueConfig.
private Configuration getUniqueConfig(String pid) throws ServletException {
final String filter = "(service.pid=" + pid + ")";
Configuration[] cfg = null;
try {
cfg = configAdmin.listConfigurations(filter);
} catch (Exception e) {
throw new ServletException("Error listing configs with filter " + filter, e);
}
if (cfg == null) {
throw new ServletException("No config found with filter " + filter);
}
if (cfg.length > 1) {
throw new ServletException("Expected 1 config, found " + cfg.length + " with filter " + filter);
}
return cfg[0];
}
use of org.osgi.service.cm.Configuration in project sling by apache.
the class JobHandlingDistributionQueueProviderTest method testDisableQueueProcessing.
@Test
public void testDisableQueueProcessing() throws Exception {
JobManager jobManager = mock(JobManager.class);
ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
Configuration config = mock(Configuration.class);
when(configAdmin.createFactoryConfiguration(QueueConfiguration.class.getName(), null)).thenReturn(config);
BundleContext context = mock(BundleContext.class);
JobHandlingDistributionQueueProvider jobHandlingdistributionQueueProvider = new JobHandlingDistributionQueueProvider("dummy-agent", jobManager, context);
jobHandlingdistributionQueueProvider.disableQueueProcessing();
}
use of org.osgi.service.cm.Configuration in project ddf by codice.
the class AdminPollerServiceBean method allSourceInfo.
@Override
public List<Map<String, Object>> allSourceInfo() {
// Get list of metatypes
List<Map<String, Object>> metatypes = helper.getMetatypes();
// Loop through each metatype and find its configurations
for (Map metatype : metatypes) {
try {
List<Configuration> configs = helper.getConfigurations(metatype);
ArrayList<Map<String, Object>> configurations = new ArrayList<>();
if (configs != null) {
for (Configuration config : configs) {
Map<String, Object> source = new HashMap<>();
boolean disabled = config.getPid().contains(DISABLED);
source.put(MAP_ENTRY_ID, config.getPid());
source.put(MAP_ENTRY_ENABLED, !disabled);
source.put(MAP_ENTRY_FPID, config.getFactoryPid());
if (!disabled) {
source.put(MAP_ENTRY_NAME, helper.getName(config));
source.put(MAP_ENTRY_BUNDLE_NAME, helper.getBundleName(config));
source.put(MAP_ENTRY_BUNDLE_LOCATION, config.getBundleLocation());
source.put(MAP_ENTRY_BUNDLE, helper.getBundleId(config));
} else {
source.put(MAP_ENTRY_NAME, config.getPid());
}
Dictionary<String, Object> properties = config.getProperties();
Map<String, Object> plist = new HashMap<>();
for (String key : Collections.list(properties.keys())) {
plist.put(key, properties.get(key));
}
source.put(MAP_ENTRY_PROPERTIES, plist);
source.put(MAP_ENTRY_REPORT_ACTIONS, getActions(config, reportActionProviders));
source.put(MAP_ENTRY_OPERATION_ACTIONS, getActions(config, operationActionProviders));
configurations.add(source);
}
metatype.put(MAP_ENTRY_CONFIGURATIONS, configurations);
}
} catch (Exception e) {
LOGGER.info("Error getting source info: {}", e.getMessage());
}
}
Collections.sort(metatypes, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
return ((String) o1.get("id")).compareToIgnoreCase((String) o2.get("id"));
}
});
return metatypes;
}
Aggregations