Search in sources :

Example 6 with DictionaryMap

use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.

the class ActionProviderRegistryProxy method bind.

public void bind(ServiceReference<MetacardTransformer> reference) {
    LOGGER.info("New service registered [{}]", reference);
    String transformerId = null;
    if (reference.getProperty(Constants.SERVICE_ID) != null) {
        transformerId = reference.getProperty(Constants.SERVICE_ID).toString();
    // backwards compatibility
    }
    if (StringUtils.isBlank(transformerId) && reference.getProperty(Constants.SERVICE_SHORTNAME) != null) {
        transformerId = reference.getProperty(Constants.SERVICE_SHORTNAME).toString();
    }
    if (StringUtils.isBlank(transformerId)) {
        return;
    }
    String actionProviderId = ACTION_ID_PREFIX + transformerId;
    List<String> attributeNames = getAttributeNames(reference);
    ActionProvider provider = actionFactory.createActionProvider(actionProviderId, transformerId, attributeNames);
    Dictionary<String, String> actionProviderProperties = new DictionaryMap<>();
    actionProviderProperties.put(Constants.SERVICE_ID, actionProviderId);
    ServiceRegistration actionServiceRegistration = getBundleContext().registerService(PROVIDER_INTERFACE_NAME, provider, actionProviderProperties);
    LOGGER.info("Registered new {} [{}]", PROVIDER_INTERFACE_NAME, actionServiceRegistration);
    actionProviderRegistry.put(reference, actionServiceRegistration);
}
Also used : ActionProvider(ddf.action.ActionProvider) DictionaryMap(org.codice.ddf.configuration.DictionaryMap) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 7 with DictionaryMap

use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.

the class UiConfigurationPropertiesFactoryTest method testProductNameDoesNotExist.

@Test
public void testProductNameDoesNotExist() throws IOException, InvalidSyntaxException {
    DictionaryMap<String, Object> configProps = new DictionaryMap<>();
    Configuration configuration = mock(Configuration.class);
    Configuration[] configurations = { configuration };
    when(configurationAdmin.listConfigurations("(service.pid=ddf.platform.ui.config)")).thenReturn(configurations);
    when(configurationAdmin.getConfiguration("ddf.platform.ui.config", null)).thenReturn(configuration);
    when(configuration.getProperties()).thenReturn(configProps);
    UiConfigurationPropertiesFactory.getInstance().setConfigurationAdmin(configurationAdmin);
    UiConfigurationProperties props = UiConfigurationPropertiesFactory.getInstance().getProperties();
    assertThat(props.getProductName(), is(""));
}
Also used : Configuration(org.osgi.service.cm.Configuration) DictionaryMap(org.codice.ddf.configuration.DictionaryMap) Test(org.junit.Test)

Example 8 with DictionaryMap

use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.

the class UiConfigurationPropertiesFactoryTest method testProductNameExists.

@Test
public void testProductNameExists() throws IOException, InvalidSyntaxException {
    DictionaryMap<String, Object> configProps = new DictionaryMap<>();
    Configuration configuration = mock(Configuration.class);
    Configuration[] configurations = { configuration };
    when(configurationAdmin.listConfigurations("(service.pid=ddf.platform.ui.config)")).thenReturn(configurations);
    when(configurationAdmin.getConfiguration("ddf.platform.ui.config", null)).thenReturn(configuration);
    when(configuration.getProperties()).thenReturn(configProps);
    when(branding.getProductName()).thenReturn("Product Name");
    UiConfigurationPropertiesFactory.getInstance().setConfigurationAdmin(configurationAdmin);
    UiConfigurationPropertiesFactory.getInstance().setBranding(branding);
    UiConfigurationProperties props = UiConfigurationPropertiesFactory.getInstance().getProperties();
    assertThat(props.getProductName(), is("Product Name"));
}
Also used : Configuration(org.osgi.service.cm.Configuration) DictionaryMap(org.codice.ddf.configuration.DictionaryMap) Test(org.junit.Test)

Example 9 with DictionaryMap

use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.

the class UiConfigurationPropertiesFactoryTest method testInvalidTypeProperties.

@Test
public void testInvalidTypeProperties() throws IOException, InvalidSyntaxException {
    DictionaryMap<String, Object> configProps = new DictionaryMap<>();
    configProps.put("header", false);
    configProps.put("footer", false);
    configProps.put("color", false);
    configProps.put("background", false);
    configProps.put("systemUsageTitle", false);
    configProps.put("systemUsageMessage", false);
    configProps.put("systemUsageEnabled", "Unexpected text");
    configProps.put("systemUsageOncePerSession", "Unexpected text");
    Configuration configuration = mock(Configuration.class);
    Configuration[] configurations = { configuration };
    when(configurationAdmin.listConfigurations("(service.pid=ddf.platform.ui.config)")).thenReturn(configurations);
    when(configurationAdmin.getConfiguration("ddf.platform.ui.config", null)).thenReturn(configuration);
    when(configuration.getProperties()).thenReturn(configProps);
    UiConfigurationPropertiesFactory.getInstance().setConfigurationAdmin(configurationAdmin);
    UiConfigurationProperties props = UiConfigurationPropertiesFactory.getInstance().getProperties();
    assertAllBlankProps(props);
}
Also used : Configuration(org.osgi.service.cm.Configuration) DictionaryMap(org.codice.ddf.configuration.DictionaryMap) Test(org.junit.Test)

Example 10 with DictionaryMap

use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.

the class UiConfigurationPropertiesFactoryTest method testPropsCreatedProperly.

@Test
public void testPropsCreatedProperly() throws IOException, InvalidSyntaxException {
    DictionaryMap<String, Object> configProps = new DictionaryMap<>();
    configProps.put("header", "Test Header");
    configProps.put("footer", "Test Footer");
    configProps.put("color", "WHITE");
    configProps.put("background", "RED");
    configProps.put("systemUsageTitle", "Test Title");
    configProps.put("systemUsageMessage", "Test Message");
    configProps.put("systemUsageEnabled", true);
    configProps.put("systemUsageOncePerSession", false);
    Configuration configuration = mock(Configuration.class);
    Configuration[] configurations = { configuration };
    when(configurationAdmin.listConfigurations("(service.pid=ddf.platform.ui.config)")).thenReturn(configurations);
    when(configurationAdmin.getConfiguration("ddf.platform.ui.config", null)).thenReturn(configuration);
    when(configuration.getProperties()).thenReturn(configProps);
    UiConfigurationPropertiesFactory.getInstance().setConfigurationAdmin(configurationAdmin);
    UiConfigurationProperties props = UiConfigurationPropertiesFactory.getInstance().getProperties();
    assertThat(props.getHeader(), is("Test Header"));
    assertThat(props.getFooter(), is("Test Footer"));
    assertThat(props.getColor(), is("WHITE"));
    assertThat(props.getBackground(), is("RED"));
    assertThat(props.getSystemUsageTitle(), is("Test Title"));
    assertThat(props.getSystemUsageMessage(), is("Test Message"));
    assertThat(props.getSystemUsageEnabled(), is(true));
    assertThat(props.getSystemUsageOncePerSession(), is(false));
}
Also used : Configuration(org.osgi.service.cm.Configuration) DictionaryMap(org.codice.ddf.configuration.DictionaryMap) Test(org.junit.Test)

Aggregations

DictionaryMap (org.codice.ddf.configuration.DictionaryMap)17 Configuration (org.osgi.service.cm.Configuration)6 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 BundleContext (org.osgi.framework.BundleContext)3 ServiceRegistration (org.osgi.framework.ServiceRegistration)3 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)2 StringWriter (java.io.StringWriter)2 JAXBException (javax.xml.bind.JAXBException)2 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)2 JsonObject (com.google.gson.JsonObject)1 ActionProvider (ddf.action.ActionProvider)1 Constants (ddf.catalog.Constants)1 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 ContentType (ddf.catalog.data.ContentType)1 Metacard (ddf.catalog.data.Metacard)1 MetacardType (ddf.catalog.data.MetacardType)1 Result (ddf.catalog.data.Result)1