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:edu.mayo.cts2.framework.webapp.rest.config.MetaTypeRestConfig.java

@Override
public void updated(@SuppressWarnings("rawtypes") Dictionary properties) throws ConfigurationException {
    if (properties != null) {
        String str_allow = (String) properties.get(ALLOW_HTML_RENDERING);
        this.allowHtmlRendering = str_allow != null ? Boolean.valueOf(str_allow) : ALLOW_HTML_RENDERING_DEFAULT;

        String str_show = (String) properties.get(SHOW_STACK_TRACE);
        this.showStackTrace = str_show != null ? Boolean.valueOf(str_show) : SHOW_STACK_TRACE_DEFAULT;

        String str_home = (String) properties.get(SHOW_HOME_PAGE);
        this.showHomePage = str_home != null ? Boolean.valueOf(str_home) : SHOW_HOME_PAGE_DEFAULT;

        this.alternateHomePage = (String) properties.get(ALTERNATE_HOME_PAGE);

        String str_maxToReturn = (String) properties.get(MAX_TO_RETURN);
        if (str_maxToReturn != null && Integer.valueOf(str_maxToReturn) != null) {
            this.maxToReturn = Integer.valueOf(str_maxToReturn);
        }/*from www  .j a  v a  2  s .  c o  m*/

    }
}

From source file:org.openhab.binding.withings.internal.WithingsBinding.java

@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
        String refreshInterval = (String) config.get("refresh");
        if (StringUtils.isNotBlank(refreshInterval)) {
            this.refreshInterval = Long.parseLong(refreshInterval);
            restartPollingThread();/* w w  w.ja va 2s. com*/
        }
    }
}

From source file:org.openhab.binding.homematic.internal.common.HomematicConfig.java

/**
 * Parses a integer property./*from ww w  . java 2  s.c o m*/
 */
private Integer parseInt(Dictionary<String, ?> properties, String key, Integer defaultValue)
        throws ConfigurationException {
    String value = (String) properties.get(key);
    if (StringUtils.isNotBlank(value)) {
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException ex) {
            throw new ConfigurationException("homematic",
                    "Parameter " + key + " in wrong format. Please check your openhab.cfg!");
        }

    } else {
        return defaultValue;
    }
}

From source file:org.openhab.binding.panasonictv.internal.PanasonicTVBinding.java

/**
 * @{inheritDoc//from w  w w  .  j a  v  a2s.  co  m
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
        String refreshIntervalString = (String) config.get("refresh");
        if (StringUtils.isNotBlank(refreshIntervalString)) {
            refreshInterval = Long.parseLong(refreshIntervalString);
        }

        for (Enumeration<?> e = config.keys(); e.hasMoreElements();) {
            String tv = (String) e.nextElement();
            if (tv.equalsIgnoreCase("service.pid") || tv.equalsIgnoreCase("refresh")) {
                continue;
            }
            logger.info("TV registered '" + tv + "' with IP '" + config.get(tv) + "'");
            registeredTVs.put(tv, config.get(tv).toString());
        }

        if (registeredTVs.isEmpty()) {
            logger.debug("No TV was registered in config file");
        }
    }
}

From source file:com.adobe.people.jedelson.aemslack.impl.Notifier.java

@Activate
private void activate(ComponentContext ctx) {
    queue = Executors.newSingleThreadExecutor();
    httpClient = new HttpClient();

    Dictionary<?, ?> props = ctx.getProperties();
    url = PropertiesUtil.toString(props.get(PROP_URL), null);
    if (url == null) {
        throw new IllegalArgumentException("URL is not defined");
    }//from  w  w w .  j  av a  2 s  . c  o m
    usernameMappings = PropertiesUtil.toMap(props.get(PROP_MAPPING), new String[0]);

    BundleContext bundleContext = ctx.getBundleContext();
    Hashtable<String, Object> serviceProps = new Hashtable<String, Object>();
    serviceProps.put(EventConstants.EVENT_TOPIC,
            CommentingEvent.EVENT_TOPIC_BASE + "/" + CommentingEvent.Type.COMMENTED.name().toLowerCase());
    commentListenerRegistration = bundleContext.registerService(EventHandler.class.getName(),
            new CommentListener(), serviceProps);

    serviceProps.put(EventConstants.EVENT_TOPIC, TaskEvent.TOPIC);
    taskListenerRegistration = bundleContext.registerService(EventHandler.class.getName(), new TaskListener(),
            serviceProps);

}

From source file:com.ibm.jaggr.service.util.BundleVersionsHashBase.java

/**
 * Returns an MD5 hash of the concatenated bundle header values from each of the specified bundles.
 * If any of the specified bundles are not found, a {@link NotFoundException} is thrown.
 *
 * @param headerNames the bundle header values to include in the hash
 * @param bundleNames the bundle names to include in the hash
 *
 * @return the computed hash/*from w  w w  .j a  va2  s . c o  m*/
 * @throws NotFoundException
 */
public String generateHash(String[] headerNames, String[] bundleNames) throws NotFoundException {
    final String sourceMethod = "generateCacheBustHash"; //$NON-NLS-1$
    final boolean isTraceLogging = log.isLoggable(Level.FINER);
    if (isTraceLogging) {
        log.entering(BundleVersionsHashBase.class.getName(), sourceMethod);
    }

    // Sort the input lists so result is independent of the order the names are specified
    List<String> sortedHeaderNames = Arrays.asList(headerNames);
    List<String> sortedBundleNames = Arrays.asList(bundleNames);
    Collections.sort(sortedHeaderNames);
    Collections.sort(sortedBundleNames);

    StringBuffer sb = new StringBuffer();
    for (String bundleName : sortedBundleNames) {
        Dictionary<?, ?> bundleHeaders = getBundleHeaders(bundleName);
        for (String headerName : sortedHeaderNames) {
            Object value = bundleHeaders.get(headerName);
            if (isTraceLogging) {
                log.finer("Bundle = " + bundleName + ", Header name = " + headerName + ", Header value = " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                        + value);
            }
            sb.append(sb.length() == 0 ? "" : ",").append(value); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }

    String result = null;
    if (sb.length() > 0) {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5"); //$NON-NLS-1$
            result = Base64.encodeBase64URLSafeString(md.digest(sb.toString().getBytes("UTF-8"))); //$NON-NLS-1$
        } catch (Exception e) {
            if (log.isLoggable(Level.SEVERE)) {
                log.log(Level.SEVERE, e.getMessage(), e);
            }
            throw new RuntimeException(e);
        }
    }
    if (isTraceLogging) {
        log.exiting(BundleVersionsHashBase.class.getName(), sourceMethod, result);
        ;
    }
    return result;
}

From source file:org.apache.sling.urlrewriter.internal.SlingUrlRewriteFilter.java

private void configure(final ComponentContext context) {
    logger.info("configuring URL rewriter");
    final Dictionary properties = context.getProperties();
    final String rules = PropertiesUtil.toString(properties.get(REWRITE_RULES_PARAMETER),
            DEFAULT_REWRITE_RULES);//from   ww  w  .  j  av  a 2  s .  com

    final Document document = createDocument(rules);
    if (document == null) {
        logger.error("creating rules document failed");
        return;
    }

    final Conf conf = new DocumentConf(document);
    conf.initialise();
    clearRewriter();

    if (conf.isOk()) {
        logger.info("rewrite configuration is ok");
    } else {
        logger.error("rewrite configuration is NOT ok");
        return;
    }

    rewriter = new UrlRewriter(conf);
    logger.info("rewrite engine is enabled: {}", conf.isEngineEnabled());
    if (conf.getRules() != null) {
        logger.info("number of rewrite rules: {}", conf.getRules().size());
    } else {
        logger.info("no rewrite rules");
    }
}

From source file:com.whizzosoftware.hobson.venstar.ColorTouchPlugin.java

@Override
public void onPluginConfigurationUpdate(Dictionary config) {
    addManualHostIfNotDiscovered((String) config.get(PROP_THERMOSTAT_HOST));
}

From source file:org.apache.ace.authentication.processor.password.PasswordAuthenticationProcessor.java

/**
 * {@inheritDoc}//from   w w  w  .  j  a  v  a2  s  .  c  o  m
 */
public void updated(Dictionary<String, ?> dictionary) throws ConfigurationException {
    if (dictionary != null) {
        String keyUsername = (String) dictionary.get(PROPERTY_KEY_USERNAME);
        if (keyUsername == null || "".equals(keyUsername.trim())) {
            throw new ConfigurationException(PROPERTY_KEY_USERNAME, "Missing property");
        }

        String keyPassword = (String) dictionary.get(PROPERTY_KEY_PASSWORD);
        if (keyPassword == null || "".equals(keyPassword.trim())) {
            throw new ConfigurationException(PROPERTY_KEY_PASSWORD, "Missing property");
        }

        String passwordHashType = (String) dictionary.get(PROPERTY_PASSWORD_HASHMETHOD);
        if (passwordHashType == null || "".equals(passwordHashType.trim())) {
            throw new ConfigurationException(PROPERTY_PASSWORD_HASHMETHOD, "Missing property");
        }
        if (!isValidHashMethod(passwordHashType)) {
            throw new ConfigurationException(PROPERTY_PASSWORD_HASHMETHOD, "Invalid hash method!");
        }

        m_keyUsername = keyUsername;
        m_keyPassword = keyPassword;
        m_passwordHashMethod = passwordHashType;
    } else {
        m_keyUsername = DEFAULT_PROPERTY_KEY_USERNAME;
        m_keyPassword = DEFAULT_PROPERTY_KEY_PASSWORD;
        m_passwordHashMethod = DEFAULT_PROPERTY_PASSWORD_HASHMETHOD;
    }
}

From source file:org.jahia.services.usermanager.mongo.JahiaMongoConfig.java

/**
 *
 * @param dictionary/*from  w w  w  .  j a  v  a 2s  .  co m*/
 * @return
 */
private String computeProviderKey(final Dictionary<String, ?> dictionary) {
    final String provideKey = (String) dictionary.get(MONGO_PROVIDER_KEY);
    if (provideKey != null) {
        return provideKey;
    }
    final String filename = (String) dictionary.get("felix.fileinstall.filename");
    final String factoryPid = (String) dictionary.get(ConfigurationAdmin.SERVICE_FACTORYPID);
    String confId;
    if (StringUtils.isBlank(filename)) {
        confId = (String) dictionary.get(Constants.SERVICE_PID);
        if (StringUtils.startsWith(confId, factoryPid + ".")) {
            confId = StringUtils.substringAfter(confId, factoryPid + ".");
        }
    } else {
        confId = StringUtils.removeEnd(StringUtils.substringAfter(filename, factoryPid + "-"), ".cfg");
    }
    return (StringUtils.isBlank(confId) || "config".equals(confId)) ? "mongo" : ("mongo." + confId);
}