List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:org.openhab.binding.enphaseenergy.internal.EnphaseenergyBinding.java
/** * {@inheritDoc}/*from ww w. j a va 2s . c o m*/ */ @Override public void updated(final Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { String useridString = (String) config.get("user_id"); if (StringUtils.isNotBlank(useridString)) { this.user_id = useridString; } String keyString = (String) config.get("key"); if (StringUtils.isNotBlank(keyString)) { this.key = keyString; } String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { this.refreshInterval = Long.parseLong(refreshIntervalString); } setProperlyConfigured(true); } }
From source file:org.openhab.binding.ftpupload.internal.FtpUploadHandlerFactory.java
protected synchronized void modified(ComponentContext componentContext) { stopFtpServer();/* w w w. j av a 2 s. c om*/ Dictionary<String, Object> properties = componentContext.getProperties(); int port = DEFAULT_PORT; int idleTimeout = DEFAULT_IDLE_TIMEOUT; if (properties.get("port") != null) { String strPort = properties.get("port").toString(); if (StringUtils.isNotEmpty(strPort)) { try { port = Integer.valueOf(strPort); } catch (NumberFormatException e) { logger.warn("Invalid port number '{}', using default port {}", strPort, port); } } } if (properties.get("idleTimeout") != null) { String strIdleTimeout = properties.get("idleTimeout").toString(); if (StringUtils.isNotEmpty(strIdleTimeout)) { try { idleTimeout = Integer.valueOf(strIdleTimeout); } catch (NumberFormatException e) { logger.warn("Invalid idle timeout '{}', using default timeout {}", strIdleTimeout, idleTimeout); } } } try { logger.info("Starting FTP server, port={}, idleTimeout={}", port, idleTimeout); ftpServer.startServer(port, idleTimeout); } catch (FtpException | FtpServerConfigurationException e) { logger.warn("FTP server starting failed, reason: {}", e.getMessage()); } }
From source file:org.codice.pubsub.server.SubscriptionServer.java
public boolean subscriptionExists(String subscriptionId) { Dictionary subMap = getSubscriptionMap(); String msg = (String) subMap.get(subscriptionId); if (msg == null) { return false; } else {// w w w .j av a 2 s . c o m return true; } }
From source file:io.neba.core.logviewer.LogFiles.java
private File getConfiguredLogfile(Configuration logConfiguration) throws IOException { Dictionary properties = logConfiguration.getProperties(); if (properties == null) { return null; }//from w ww. j a va 2 s. co m String logFilePath = (String) properties.get(LOG_FILE_PROPERTY); if (isEmpty(logFilePath)) { return null; } File logFile = new File(logFilePath); if (!logFile.isAbsolute()) { logFile = new File(this.slingHomeDirectory, logFilePath); } return logFile.getCanonicalFile(); }
From source file:org.openhab.io.transport.cul.internal.serial.CULSerialConfigFactory.java
@Override public CULConfig create(String deviceType, String deviceAddress, CULMode mode, Dictionary<String, ?> config) throws ConfigurationException { int baudRate = 9600; final String configuredBaudRate = (String) config.get(KEY_BAUDRATE); Integer tmpBaudRate = baudrateFromConfig(configuredBaudRate); if (tmpBaudRate != null) { baudRate = tmpBaudRate;/* ww w . j av a 2s. co m*/ logger.info("Update config, {} = {}", KEY_BAUDRATE, baudRate); } int parityMode = SerialPort.PARITY_EVEN; final String configuredParity = (String) config.get(KEY_PARITY); Integer parsedParityNumber = parityFromConfig(configuredParity); if (parsedParityNumber != null) { parityMode = parsedParityNumber; logger.info("Update config, {} = {} ({})", KEY_PARITY, convertParityModeToString(parityMode), parityMode); } return new CULSerialConfig(deviceType, deviceAddress, mode, baudRate, parityMode); }
From source file:com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilter.java
@Activate @SuppressWarnings("squid:S1149") protected final void activate(ComponentContext context) throws Exception { Dictionary<?, ?> properties = context.getProperties(); doActivate(context);//from ww w .ja v a2s . co m String[] filters = PropertiesUtil.toStringArray(properties.get(PROP_FILTER_PATTERN)); if (filters == null || filters.length == 0) { throw new ConfigurationException(PROP_FILTER_PATTERN, "At least one filter pattern must be specified."); } for (String pattern : filters) { Dictionary<String, String> filterProps = new Hashtable<String, String>(); log.debug("Adding filter ({}) to pattern: {}", this.toString(), pattern); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX, pattern); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)"); ServiceRegistration filterReg = context.getBundleContext().registerService(Filter.class.getName(), this, filterProps); filterRegistrations.add(filterReg); } }
From source file:org.openhab.io.net.actions.Mail.java
@SuppressWarnings("rawtypes") public void updated(Dictionary config) throws ConfigurationException { if (config != null) { Mail.hostname = (String) config.get("hostname"); String portString = (String) config.get("port"); if (portString != null) { Mail.port = Integer.valueOf(portString); }// w w w. j av a 2 s . c o m Mail.username = (String) config.get("username"); Mail.password = (String) config.get("password"); Mail.from = (String) config.get("from"); String tlsString = (String) config.get("tls"); if (StringUtils.isNotBlank(tlsString)) { Mail.tls = tlsString.equalsIgnoreCase("true"); } String popBeforeSmtpString = (String) config.get("popbeforesmtp"); if (StringUtils.isNotBlank(popBeforeSmtpString)) { Mail.popBeforeSmtp = popBeforeSmtpString.equalsIgnoreCase("true"); } // check mandatory settings if (StringUtils.isBlank(hostname) || StringUtils.isBlank(from)) { throw new ConfigurationException("mail", "Parameters mail:hostname and mail:from are mandatory and must be configured. Please check your openhab.cfg!"); } // set defaults for optional settings if (port == null) { port = tls ? 587 : 25; } initialized = true; } }
From source file:org.openhab.binding.cups.internal.CupsBinding.java
@SuppressWarnings("rawtypes") public void updated(Dictionary config) throws ConfigurationException { if (config != null) { host = (String) config.get("host"); Matcher matcher = IP_PATTERN.matcher(host); if (!matcher.matches()) { try { InetAddress address = InetAddress.getByName(host); ip = address.getHostAddress(); } catch (UnknownHostException e) { throw new ConfigurationException("host", "unknown host '" + host + "'!"); }//from w w w . j ava 2 s . com } else { // host should contain an IP address ip = host; } String portString = (String) config.get("port"); if (StringUtils.isNotBlank(portString)) { port = Integer.parseInt(portString); } String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); } // there is a valid Cups-configuration, so connect to the Cups // server ... connect(ip, port); setProperlyConfigured(true); } }
From source file:org.openhab.binding.intertechno.internal.CULIntertechnoBinding.java
private Integer parseOptionalNumericParameter(String key, Dictionary<String, ?> config) throws ConfigurationException { String valueString = (String) config.get(key); int value = 0; if (!StringUtils.isEmpty(valueString)) { try {/*from w w w . j av a2 s. c om*/ value = Integer.parseInt(valueString); return value; } catch (NumberFormatException e) { setProperlyConfigured(false); throw new ConfigurationException(key, "Can't parse number"); } } return null; }
From source file:org.openhab.io.net.internal.jabber.XMPPConnect.java
@SuppressWarnings("rawtypes") public void updated(Dictionary config) throws ConfigurationException { if (config != null) { XMPPConnect.servername = (String) config.get("servername"); XMPPConnect.proxy = (String) config.get("proxy"); String portString = (String) config.get("port"); if (portString != null) { XMPPConnect.port = Integer.valueOf(portString); }/*from w w w . j a v a2 s . co m*/ XMPPConnect.username = (String) config.get("username"); XMPPConnect.password = (String) config.get("password"); String users = (String) config.get("consoleusers"); if (!StringUtils.isEmpty(users)) { XMPPConnect.consoleUsers = users.split(","); } // check mandatory settings if (servername == null || servername.isEmpty()) return; if (username == null || username.isEmpty()) return; if (password == null || password.isEmpty()) return; // set defaults for optional settings if (port == null) { port = 5222; } establishConnection(); } }