List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:org.openhab.binding.nibeheatpump.internal.NibeHeatPumpBinding.java
/** * @{inheritDoc/*from ww w . jav a 2s . co m*/ */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { logger.debug("Configuration updated, config {}", config != null ? true : false); if (config != null) { String PortString = (String) config.get("udpPort"); if (StringUtils.isNotBlank(PortString)) { udpPort = Integer.parseInt(PortString); } String modelNoString = (String) config.get("modelNo"); if (StringUtils.isNotBlank(modelNoString)) { modelNo = Integer.parseInt(modelNoString); } serialPort = (String) config.get("serialPort"); String testPortString = (String) config.get("simulate"); if (StringUtils.isNotBlank(testPortString)) { simulateHeatPump = Boolean.parseBoolean(testPortString); } if (messageListener != null) { logger.debug("Close previous message listener"); messageListener.setInterrupted(true); try { messageListener.join(); } catch (InterruptedException e) { logger.info("Previous message listener closing interrupted", e); } } messageListener = new NibeHeatPumpMessageListener(); messageListener.start(); } }
From source file:org.codice.ddf.configuration.admin.ImportMigrationConfigurationAdminContext.java
@Nullable private Path getPathFromConfiguration(@Nullable Dictionary<String, Object> properties, Supplier<String> from) { if (properties == null) { return null; }//from w ww .j a va 2 s .c om final Object o = properties.get(DirectoryWatcher.FILENAME); final Path path; if (o != null) { try { if (o instanceof URL) { path = new File(((URL) o).toURI()).toPath(); } else if (o instanceof URI) { path = new File((URI) o).toPath(); } else if (o instanceof String) { path = new File(new URL((String) o).toURI()).toPath(); } else if (o instanceof File) { path = ((File) o).toPath(); } else if (o instanceof Path) { path = (Path) o; } else { LOGGER.debug("unsupported {} property '{}' from {}", DirectoryWatcher.FILENAME, o, from.get()); return null; } } catch (MalformedURLException | URISyntaxException e) { LOGGER.debug(String.format("failed to parse %s property '%s' from %s; ", DirectoryWatcher.FILENAME, o, from.get()), e); return null; } } else { return null; } // ignore the whole path if any (there shouldn't be any other than etc) and force it to be under // etc return ImportMigrationConfigurationAdminContext.ETC_PATH.resolve(path.getFileName()); }
From source file:org.codice.pubsub.stomp.SubscriptionQueryMessageListener.java
private void processMessage(String msg) { SearchQueryMessage queryMsg = null;/* w w w . ja v a 2s .c o m*/ try { queryMsg = new ObjectMapper().readValue(msg, SearchQueryMessage.class); } catch (IOException e) { LOGGER.error("Issues processing incoming query subscription: " + e.getMessage()); } String subscriptionId = queryMsg.getSubscriptionId(); String action = queryMsg.getAction(); if (StringUtils.isNotEmpty(subscriptionId) && StringUtils.isNotEmpty(action)) { if (action.equals(ACTION_CREATE)) { //Execute Query and Create a Subscription //If subscription already exists don't create a new one Dictionary subMap = getSubscriptionMap(); if (subMap.get(subscriptionId) == null) { boolean success = createSubscription(queryMsg); } else { LOGGER.debug("Subscription: {} already exists", subscriptionId); } } else if (action.equals(ACTION_DELETE)) { removeSubscription(subscriptionId); } else if (action.equals(ACTION_UPDATE)) { removeSubscription(subscriptionId); createSubscription(queryMsg); } } }
From source file:org.openhab.binding.geolocation.internal.GeoLocationBinding.java
/** * @{inheritDoc/* w ww . j av a2 s . com*/ */ @Override public void updated(Dictionary config) throws ConfigurationException { logger.debug("GeoLocation Updated"); if (config != null) { logger.debug("GeoLocation Configuration not null"); String location_item_name = (String) config.get("location_item"); if (StringUtils.isNotBlank(location_item_name)) { try { listener = new GeoLocationListener(this); location = (GenericItem) itemRegistry.getItem(location_item_name); location.addStateChangeListener(listener); logger.debug("Registered listener for changes on {}", location_item_name); } catch (ItemNotFoundException e) { // TODO Auto-generated catch block logger.debug("Location item not found in registry"); ; } } } }
From source file:org.openhab.binding.ecotouch.internal.EcoTouchBinding.java
/** * @{inheritDoc//from w w w . j a v a 2s . c o m */ public void updated(Dictionary<String, ?> config) throws ConfigurationException { setProperlyConfigured(false); if (config != null) { String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); } String ip = (String) config.get("ip"); //$NON-NLS-1$ if (StringUtils.isBlank(ip)) { throw new ConfigurationException("ip", "The ip address must not be empty."); } this.ip = ip; String username = (String) config.get("username"); //$NON-NLS-1$ if (StringUtils.isBlank(username)) { throw new ConfigurationException("username", "The username must not be empty."); } this.username = username; String password = (String) config.get("password"); //$NON-NLS-1$ if (StringUtils.isBlank(password)) { throw new ConfigurationException("password", "The password must not be empty."); } this.password = password; setProperlyConfigured(true); } }
From source file:org.openhab.binding.tcp.protocol.internal.TCPBinding.java
@SuppressWarnings("rawtypes") @Override/* ww w.j av a 2s .c o m*/ public void updated(Dictionary config) throws ConfigurationException { super.updated(config); if (config != null) { String timeOutString = (String) config.get("timeout"); if (StringUtils.isNotBlank(timeOutString)) { timeOut = Integer.parseInt((timeOutString)); } else { logger.info( "The maximum time out for blocking write operations will be set to the default vaulue of {}", timeOut); } String blockingString = (String) config.get("blocking"); if (StringUtils.isNotBlank(blockingString)) { blocking = Boolean.parseBoolean((blockingString)); } else { logger.info("The blocking nature of read/write operations will be set to the default vaulue of {}", blocking); } String preambleString = (String) config.get("preamble"); if (StringUtils.isNotBlank(preambleString)) { preAmble = StringEscapeUtils.unescapeJava(preambleString); } else { logger.info("The preamble for all write operations will be set to the default vaulue of \"{}\"", preAmble); } String postambleString = (String) config.get("postamble"); if (StringUtils.isNotBlank(postambleString)) { postAmble = StringEscapeUtils.unescapeJava(postambleString); } else { logger.info("The postamble for all write operations will be set to the default vaulue of \"{}\"", postAmble); } String updatewithresponseString = (String) config.get("updatewithresponse"); if (StringUtils.isNotBlank(updatewithresponseString)) { updateWithResponse = Boolean.parseBoolean((updatewithresponseString)); } else { logger.info("Updating states with returned values will be set to the default vaulue of {}", updateWithResponse); } String charsetString = (String) config.get("charset"); if (StringUtils.isNotBlank(charsetString)) { charset = charsetString; } else { logger.info("The characterset will be set to the default vaulue of {}", charset); } } }
From source file:org.openhab.binding.onewire.internal.OneWireBinding.java
public void updated(Dictionary<String, ?> pvConfig) throws ConfigurationException { if (pvConfig != null) { //Basic config String lvPostOnlyChangedValues = (String) pvConfig.get("post_only_changed_values"); if (StringUtils.isNotBlank(lvPostOnlyChangedValues)) { ivPostOnlyChangedValues = Boolean.getBoolean(lvPostOnlyChangedValues); }/*from w w w.java 2 s. c o m*/ //Connection config OneWireConnection.updated(pvConfig); } for (OneWireBindingProvider lvProvider : providers) { scheduleAllBindings(lvProvider); } }
From source file:org.openhab.io.net.http.SecureHttpContext.java
@SuppressWarnings("rawtypes") public void updated(Dictionary config) throws ConfigurationException { if (config != null) { String securityOptionsString = (String) config.get("option"); if (StringUtils.isNotBlank(securityOptionsString)) { try { SecureHttpContext.securityOptions = SecurityOptions .valueOf(securityOptionsString.toUpperCase()); } catch (IllegalArgumentException iae) { logger.warn("couldn't create SecurityOption '{}' - valid values are {}", securityOptionsString, SecurityOptions.values()); SecureHttpContext.securityOptions = SecurityOptions.OFF; }//from ww w .ja v a 2 s. c om } else { SecureHttpContext.securityOptions = SecurityOptions.OFF; } // first read the netmask and try to create a SubnetUtils object String netmaskVal = (String) config.get("netmask"); ipAddressMatchers.clear(); if (StringUtils.isNotBlank(netmaskVal)) { String[] netmasks = netmaskVal.split(","); for (String netmask : netmasks) { ipAddressMatchers.add(new IpAddressMatcher(netmask)); } } // if SubnetUtils are still null something went wrong or one didn't configure a // netmask. In both cases use the default netmask ... if (ipAddressMatchers.size() == 0) { // set default a value ... ipAddressMatchers.add(new IpAddressMatcher("192.168.1.0/24")); logger.debug("couldn't find netmask configuration -> using '192.168.1.0/24' instead"); } } }
From source file:org.openhab.config.core.ConfigDispatcher.java
public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { String refreshIntervalString = (String) config.get("refresh"); if (isNotBlank(refreshIntervalString)) { try { ConfigDispatcher.refreshInterval = Integer.valueOf(refreshIntervalString); } catch (IllegalArgumentException iae) { logger.warn("couldn't parse '{}' to an integer"); }// w ww . j ava 2 s . c o m if (ConfigDispatcher.refreshInterval == -1) { cancelRefreshJob(); } else { scheduleOrRescheduleRefreshJob(); } } } }
From source file:org.openhab.binding.swegonventilation.internal.SwegonVentilationBinding.java
/** * @{inheritDoc//from w ww. j a v a 2 s . c om */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { logger.debug("Configuration updated, config {}", config != null ? true : false); if (config != null) { String portString = (String) config.get("udpPort"); if (StringUtils.isNotBlank(portString)) { udpPort = Integer.parseInt(portString); } serialPort = (String) config.get("serialPort"); String simulateString = (String) config.get("simulate"); if (StringUtils.isNotBlank(simulateString)) { simulator = Boolean.parseBoolean(simulateString); } } if (messageListener != null) { logger.debug("Close previous message listener"); messageListener.setInterrupted(true); try { messageListener.join(); } catch (InterruptedException e) { logger.info("Previous message listener closing interrupted", e); } } messageListener = new MessageListener(); messageListener.start(); }