Example usage for java.util Dictionary get

List of usage examples for java.util Dictionary get

Introduction

In this page you can find the example usage for java.util Dictionary get.

Prototype

public abstract V get(Object key);

Source Link

Document

Returns the value to which the key is mapped in this dictionary.

Usage

From source file:com.jwdevs.ihome.openhab.binding.internal.IHomeBinding.java

/**
 * @{inheritDoc/*w  ww  .  ja  va 2  s.com*/
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {

        // to override the default refresh interval one has to add a
        // parameter to openhab.cfg like
        // <bindingName>:refresh=<intervalInMs>
        String refreshIntervalString = (String) config.get("refresh");
        if (StringUtils.isNotBlank(refreshIntervalString)) {
            refreshInterval = Long.parseLong(refreshIntervalString);
        }

        // read further config parameters here ...

        setProperlyConfigured(true);
    }
}

From source file:org.openhab.binding.jeelinkitplus.internal.JeelinkITPlusBinding.java

/**
 * @{inheritDoc}//w  ww . j  a  v  a 2  s  .c  om
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
        logger.debug("Jeelink: Reading Config");
        // to override the default refresh interval one has to add a 
        // parameter to openhab.cfg like <bindingName>:refresh=<intervalInMs>
        String refreshIntervalString = (String) config.get("refresh");
        if (StringUtils.isNotBlank(refreshIntervalString)) {
            refreshInterval = Long.parseLong(refreshIntervalString);
        }
        this.comPort = (String) config.get("port");
        serRunner.setPortName(this.comPort);
        logger.debug("DEBUG: COMPORT: " + this.comPort);
        // read further config parameters here ...

        setProperlyConfigured(true);
    }
}

From source file:org.openhab.binding.jeelinkec3k.internal.JeeLinkEC3KBinding.java

/**
 * @{inheritDoc//from  ww  w .j  a v  a 2s  . co  m
 */

public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    logger.debug("Received new config");
    if (config != null) {

        // to override the default refresh interval one has to add a
        // parameter to openhab.cfg like
        // <bindingName>:refresh=<intervalInMs>
        String refreshIntervalString = (String) config.get("refresh");
        if (StringUtils.isNotBlank(refreshIntervalString)) {
            refreshInterval = Long.parseLong(refreshIntervalString);
        }
        String deviceName = (String) config.get(KEY_DEVICE_NAME);
        if (StringUtils.isEmpty(deviceName)) {
            logger.error("No device name configured");
            setProperlyConfigured(false);
            throw new ConfigurationException(KEY_DEVICE_NAME, "The device name can't be empty");
        } else {
            try {
                serialHandler = new EC3KSerialHandler(deviceName, this);
                serialHandler.openHardware();
                setProperlyConfigured(true);
            } catch (Exception e) {
                logger.error("Failed to open hardware", e);
            }

        }
        String priceString = (String) config.get(KEY_PRICE);
        price = Double.parseDouble(priceString);

    }
}

From source file:org.jahia.services.usermanager.ldap.action.GetLdapConfigurationAction.java

@Override
public ActionResult doExecute(HttpServletRequest req, RenderContext renderContext, Resource resource,
        JCRSessionWrapper session, Map<String, List<String>> parameters, URLResolver urlResolver)
        throws Exception {
    String providerKey = req.getParameter("providerKey");
    Map<String, String> res = new HashMap<>();
    if (StringUtils.isNotBlank(providerKey)) {
        String pid = jahiaLDAPConfigFactory.getConfigPID(providerKey);
        if (pid == null) {
            return new ActionResult(HttpServletResponse.SC_NOT_FOUND);
        }//from w ww  . j a v a2s.c  om
        Configuration configuration = configurationAdmin.getConfiguration(pid);
        Dictionary<String, Object> properties = configuration.getProperties();
        Enumeration<String> keys = properties.keys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();
            if (!key.startsWith("service.") && !key.startsWith("felix.")
                    && !JahiaLDAPConfig.LDAP_PROVIDER_KEY_PROP.equals(key)) {
                res.put(key, (String) properties.get(key));
            }
        }
    } else {
        for (String f : defaultProperties) {
            res.put(f, "");
        }
    }
    return new ActionResult(HttpServletResponse.SC_OK, null, new JSONObject(res));
}

From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactory.java

@Activate
@SuppressWarnings("squid:S1149")
protected void activate(ComponentContext componentContext) {
    final BundleContext bundleContext = componentContext.getBundleContext();
    final Dictionary<?, ?> props = componentContext.getProperties();
    final int size = PropertiesUtil.toInteger(props.get(PROP_MD5_CACHE_SIZE), DEFAULT_MD5_CACHE_SIZE);
    this.md5Cache = CacheBuilder.newBuilder().recordStats().maximumSize(size).build();
    this.disableVersioning = PropertiesUtil.toBoolean(props.get(PROP_DISABLE_VERSIONING),
            DEFAULT_DISABLE_VERSIONING);
    this.enforceMd5 = PropertiesUtil.toBoolean(props.get(PROP_ENFORCE_MD5), DEFAULT_ENFORCE_MD5);
    if (enforceMd5) {
        Dictionary<String, Object> filterProps = new Hashtable<String, Object>();
        filterProps.put("sling.filter.scope", "REQUEST");
        filterProps.put("service.ranking", Integer.valueOf(0));

        filterReg = bundleContext.registerService(Filter.class.getName(), new BadMd5VersionedClientLibsFilter(),
                filterProps);//from w w w . jav  a2s  .  co m
    }
}

From source file:net.cellar.hazelcast.HazelcastGroupManager.java

public void unRegisterGroup(Group group) {
    String groupName = group.getName();
    //1. Remove local node from group.
    group.getMembers().remove(getNode());
    listGroups().put(groupName, group);// w  w w  .java2s  . c  o m

    //2. Unregister group consumers
    if (consumerRegistrations != null && !consumerRegistrations.isEmpty()) {
        ServiceRegistration consumerRegistration = consumerRegistrations.get(groupName);
        if (consumerRegistration != null) {
            consumerRegistration.unregister();
            consumerRegistrations.remove(groupName);
        }

    }

    //3. Unregister group producers
    if (producerRegistrations != null && !producerRegistrations.isEmpty()) {
        ServiceRegistration producerRegistration = producerRegistrations.get(groupName);
        if (producerRegistration != null) {
            producerRegistration.unregister();
            producerRegistrations.remove(groupName);
        }
    }

    //Remove group from configuration
    try {
        Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE);
        Dictionary<String, String> properties = configuration.getProperties();
        String groups = properties.get(Configurations.GROUPS_KEY);
        if (groups == null || groups.isEmpty()) {
            groups = "";
        } else if (groups.contains(groupName)) {

            Set<String> groupNamesSet = convertStringToSet(groups);
            groupNamesSet.remove(groupName);
            groups = convertSetToString(groupNamesSet);

        }
        properties.put(Configurations.GROUPS_KEY, groups);
        configuration.update(properties);
    } catch (IOException e) {
        logger.error("Error reading group configuration {}", group);
    }
}

From source file:org.openhab.binding.mailcontrol.internal.MailControlBinding.java

/**
 * @{inheritDoc//from   w w w.  j  a va 2  s .  c om
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
        this.config = config;
        this.connectorBuilder = new ConnectorBuilder(config);
        connectorBuilder.createAndCheckMailConnector();

        // to override the default refresh interval one has to add a
        // parameter to openhab.cfg like
        // <bindingName>:refresh=<intervalInMs>
        String refreshIntervalString = (String) config.get("refresh");
        if (StringUtils.isNotBlank(refreshIntervalString)) {
            refreshInterval = Long.parseLong(refreshIntervalString);
        }

        setProperlyConfigured(true);
    }
}

From source file:org.openhab.binding.systeminfo.internal.SysteminfoBinding.java

/**
 * @{inheritDoc/*from   w  w  w . j a  v a 2  s .  co  m*/
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
        String granularityString = (String) config.get("granularity");
        if (StringUtils.isNotBlank(granularityString)) {
            granularity = Integer.parseInt(granularityString);
        }

        logger.debug("Granularity: {} ms", granularity);

        String tmp = (String) config.get("units");
        if (StringUtils.isNotBlank(tmp)) {
            if (tmp.length() != 1) {
                throw new ConfigurationException("units", "Illegal units length");
            }

            if (!tmp.matches("[BKMGT]")) {
                throw new ConfigurationException("units", "Illegal units");
            }

            units = tmp.charAt(0);
        }

        logger.debug("Using units: {}", units);
    }

    initializeSystemMonitor();
    setProperlyConfigured(true);
}

From source file:com.activecq.samples.replication.impl.ReverseReplicatorImpl.java

protected void activate(ComponentContext componentContext) {
    Dictionary properties = componentContext.getProperties();

    enabled = PropertiesUtil.toBoolean(properties.get(PROP_ENABLED), DEFAULT_ENABLED);
    log.debug("Enabled: " + enabled);

    sychronous = PropertiesUtil.toBoolean(properties.get(PROP_SYNCHRONOUS), DEFAULT_SYNCHRONOUS);
    suppressStatusUpdate = PropertiesUtil.toBoolean(properties.get(PROP_SUPRESS_STATUS_UPDATE),
            DEFAULT_SUPRESS_STATUS_UPDATE);
    supressVersioning = PropertiesUtil.toBoolean(properties.get(PROP_SUPRESS_VERSIONING),
            DEFAULT_SUPRESS_VERSIONING);

    paths = PropertiesUtil.toStringArray(properties.get(PROP_PATHS), DEFAULT_PATHS);
    paths = (String[]) ArrayUtils.removeElement(paths, "");

    pathWhitelist = PropertiesUtil.toStringArray(properties.get(PROP_PATH_WHITELIST), DEFAULT_PATH_WHITELIST);
    pathWhitelist = (String[]) ArrayUtils.removeElement(pathWhitelist, "");

    pathBlacklist = PropertiesUtil.toStringArray(properties.get(PROP_PATH_BLACKLIST), DEFAULT_PATH_BLACKLIST);
    pathBlacklist = (String[]) ArrayUtils.removeElement(pathBlacklist, "");

    primaryTypes = PropertiesUtil.toStringArray(properties.get(PROP_PRIMARY_TYPES), DEFAULT_PRIMARY_TYPES);
    primaryTypes = (String[]) ArrayUtils.removeElement(primaryTypes, "");

    String[] tmp = PropertiesUtil.toStringArray(properties.get(PROP_PROPERTY_MATCHES),
            DEFAULT_PROPERTY_MATCHES);// ww w.j  a va  2 s  . c o  m
    tmp = (String[]) ArrayUtils.removeElement(tmp, "");

    for (final String t : tmp) {
        String[] s = StringUtils.split(t, '=');
        if (s == null || s.length != 2) {
            continue;
        }
        propertyMatches.put(s[0], s[1]);
    }
}

From source file:ch.entwine.weblounge.contentrepository.impl.bundle.WritableBundleContentRepository.java

/**
 * {@inheritDoc}/*from   w w  w  .  j  a  va 2s.c o  m*/
 * 
 * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
 */
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void updated(Dictionary properties) throws ConfigurationException {

    // Since the bundle content repository is based on the file system content
    // repository, the configuration properties need to be adjusted
    String rootDirPath = (String) properties.get(OPT_ROOT_DIR);
    if (StringUtils.isNotBlank(rootDirPath)) {
        properties.put(FileSystemContentRepository.OPT_ROOT_DIR, PathUtils.trim(rootDirPath));
        logger.info("Bundle content repository data will be stored at {}", rootDirPath);
    }

    super.updated(properties);
}