Search in sources :

Example 11 with DictionaryMap

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

the class CatalogBundle method setResourceDownloadProperty.

private void setResourceDownloadProperty(String propertyName, Object propertyValue) throws IOException {
    Map<String, Object> existingProperties;
    try {
        existingProperties = Optional.ofNullable(adminConfig.getAdminConsoleService().getProperties(CatalogBundle.RESOURCE_DOWNLOAD_MANAGER_PID)).orElse(new DictionaryMap<>());
    } catch (NotCompliantMBeanException e) {
        existingProperties = new DictionaryMap<>();
    }
    DictionaryMap<String, Object> updatedProperties = new DictionaryMap<>();
    updatedProperties.putAll(existingProperties);
    updatedProperties.put(propertyName, propertyValue);
    Configuration configuration = adminConfig.getConfiguration(RESOURCE_DOWNLOAD_MANAGER_PID, null);
    configuration.update(updatedProperties);
}
Also used : Configuration(org.osgi.service.cm.Configuration) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) DictionaryMap(org.codice.ddf.configuration.DictionaryMap)

Example 12 with DictionaryMap

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

the class WfsSource method createFeatureMetacardTypeRegistration.

private MetacardTypeRegistration createFeatureMetacardTypeRegistration(FeatureTypeType featureTypeType, String ftName, XmlSchema schema) {
    FeatureMetacardType ftMetacard = new FeatureMetacardType(schema, featureTypeType.getName(), nonQueryableProperties != null ? Arrays.stream(nonQueryableProperties).collect(toSet()) : new HashSet<>(), Wfs20Constants.GML_3_2_NAMESPACE);
    Dictionary<String, Object> props = new DictionaryMap<>();
    props.put(Metacard.CONTENT_TYPE, new String[] { ftName });
    LOGGER.debug("WfsSource {}: Registering MetacardType: {}", getId(), ftName);
    return new MetacardTypeRegistration(ftMetacard, props, featureTypeType.getDefaultCRS());
}
Also used : FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) HashSet(java.util.HashSet) DictionaryMap(org.codice.ddf.configuration.DictionaryMap)

Example 13 with DictionaryMap

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

the class LdapLoginConfig method update.

/**
 * Update method that receives new properties.
 *
 * @param props Map of properties.
 */
public void update(Map<String, ?> props) {
    if (props != null) {
        LOGGER.debug("Received an updated set of configurations for the LDAP Login Config.");
        if (connectionPoolServiceRegistration != null) {
            connectionPoolServiceRegistration.unregister();
        }
        if (ldapConnectionPool != null) {
            ldapConnectionPool.close();
        }
        ConnectionFactory ldapConnectionFactory = null;
        List<String> urls = new ArrayList<>();
        Object urlsObj = props.get(LDAP_URL);
        if (urlsObj instanceof String[]) {
            urls.addAll(Arrays.asList((String[]) urlsObj));
        } else {
            urls.add(urlsObj.toString());
        }
        List<ConnectionFactory> connectionFactories = new ArrayList<>();
        Boolean startTls = props.get(START_TLS) != null && Boolean.parseBoolean(props.get(START_TLS).toString());
        for (String url : urls) {
            connectionFactories.add(createLdapConnectionFactory(url, startTls));
        }
        String loadBalancingAlgorithm = (String) props.get(LDAP_LOAD_BALANCING);
        Options options = Options.defaultOptions();
        if (FAILOVER.equalsIgnoreCase(loadBalancingAlgorithm)) {
            ldapConnectionFactory = Connections.newFailoverLoadBalancer(connectionFactories, options);
        } else {
            ldapConnectionFactory = Connections.newRoundRobinLoadBalancer(connectionFactories, options);
        }
        ldapConnectionPool = new GenericObjectPool<>(new LdapConnectionPooledObjectFactory(ldapConnectionFactory), createGenericPoolConfig(id), createGenericPoolAbandonConfig());
        Dictionary<String, String> serviceProps = new DictionaryMap<>();
        serviceProps.put("id", id);
        LOGGER.debug("Registering LdapConnectionPool");
        connectionPoolServiceRegistration = context.registerService(GenericObjectPool.class.getName(), ldapConnectionPool, serviceProps);
        // create modules from the newly updated config
        Module ldapModule = createLdapModule(props);
        ldapService.update(ldapModule);
    }
}
Also used : Options(org.forgerock.util.Options) ArrayList(java.util.ArrayList) DictionaryMap(org.codice.ddf.configuration.DictionaryMap) ConnectionFactory(org.forgerock.opendj.ldap.ConnectionFactory) LDAPConnectionFactory(org.forgerock.opendj.ldap.LDAPConnectionFactory) Module(org.apache.karaf.jaas.config.impl.Module)

Example 14 with DictionaryMap

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

the class TransformerConsumer method doStart.

@Override
protected void doStart() throws CatalogTransformerException {
    LOGGER.debug("ENTERING: doStart");
    try {
        super.doStart();
    } catch (Exception e) {
        throw new CatalogTransformerException("Failed to start Transformer Consumer", e);
    }
    DictionaryMap<String, String> props = new DictionaryMap<>();
    if (endpoint.getTransformerId() != null) {
        props.put(MimeTypeToTransformerMapper.ID_KEY, endpoint.getTransformerId());
    }
    if (endpoint.getMimeType() != null) {
        props.put(MimeTypeToTransformerMapper.MIME_TYPE_KEY, endpoint.getMimeType());
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Registering as QueryResponseTransformer with id={}", endpoint.getTransformerId());
    }
    // Register this Catalog Consumer as an QueryResponseTransformer in the OSGi registry.
    // The transformer ID (e.g., id=text/xml;id=xml) specified in the Camel route node
    // is used as the "id" key for this QueryResponseTransformer in the OSGi registry.
    // (This is how the CatalogContentPlugin will be able to look up this transformer by
    // mimetype)
    registration = endpoint.getComponent().getBundleContext().registerService(transformerClass.getName(), this, props);
    LOGGER.debug("EXITING: doStart");
}
Also used : CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) DictionaryMap(org.codice.ddf.configuration.DictionaryMap)

Example 15 with DictionaryMap

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

the class CatalogFrameworkImpl method registerBasicMetacard.

private void registerBasicMetacard() {
    Bundle bundle = FrameworkUtil.getBundle(CatalogFrameworkImpl.class);
    if (bundle != null && bundle.getBundleContext() != null) {
        Dictionary<String, Object> properties = new DictionaryMap<>();
        properties.put("name", MetacardImpl.BASIC_METACARD.getName());
        bundle.getBundleContext().registerService(MetacardType.class, MetacardImpl.BASIC_METACARD, properties);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) DictionaryMap(org.codice.ddf.configuration.DictionaryMap)

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