List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:org.opencastproject.kernel.security.OrganizationDirectoryServiceImpl.java
@Override @SuppressWarnings("rawtypes") public void updated(String pid, Dictionary properties) throws ConfigurationException { if (persistence == null) { logger.debug("No persistence available: Ignoring organization update for pid='{}'", pid); unhandledOrganizations.put(pid, properties); return;//from w w w . jav a2 s . c om } logger.debug("Updating organization pid='{}'", pid); // Gather the properties final String id = (String) properties.get(ORG_ID_KEY); final String name = (String) properties.get(ORG_NAME_KEY); final String server = (String) properties.get(ORG_SERVER_KEY); // Make sure the configuration meets the minimum requirements if (StringUtils.isBlank(id)) throw new ConfigurationException(ORG_ID_KEY, ORG_ID_KEY + " must be set"); if (StringUtils.isBlank(server)) throw new ConfigurationException(ORG_SERVER_KEY, ORG_SERVER_KEY + " must be set"); final String portAsString = StringUtils.trimToNull((String) properties.get(ORG_PORT_KEY)); final int port = portAsString != null ? Integer.parseInt(portAsString) : 80; final String adminRole = (String) properties.get(ORG_ADMIN_ROLE_KEY); final String anonRole = (String) properties.get(ORG_ANONYMOUS_ROLE_KEY); // Build the properties map final Map<String, String> orgProperties = new HashMap<String, String>(); for (Enumeration<?> e = properties.keys(); e.hasMoreElements();) { final String key = (String) e.nextElement(); if (!key.startsWith(ORG_PROPERTY_PREFIX)) { continue; } orgProperties.put(key.substring(ORG_PROPERTY_PREFIX.length()), (String) properties.get(key)); } // Load the existing organization or create a new one try { JpaOrganization org; try { org = (JpaOrganization) persistence.getOrganization(id); org.setName(name); org.addServer(server, port); org.setAdminRole(adminRole); org.setAnonymousRole(anonRole); org.setProperties(orgProperties); logger.info("Registering organization '{}'", id); } catch (NotFoundException e) { org = new JpaOrganization(id, name, server, port, adminRole, anonRole, orgProperties); logger.info("Updating organization '{}'", id); } persistence.storeOrganization(org); cache.invalidate(); } catch (OrganizationDatabaseException e) { logger.error("Unable to register organization '{}': {}", id, e); } }
From source file:org.openhab.binding.hexabus.internal.HexaBusBinding.java
/** * Parses the config file for Jackdaw Interface Values *//*from w w w . j a v a 2 s. c o m*/ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { logger.debug("updated() called."); // conditions for a proper configuration boolean refreshFlag = false; boolean ipFlag = false; boolean portFlag = false; if (config != null) { String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { try { refreshInterval = Long.parseLong(refreshIntervalString); refreshFlag = true; } catch (NumberFormatException e) { logger.debug( "Could not parse the refresh interval value from the configuration file in updated()!"); e.printStackTrace(); } } if (StringUtils.isNotBlank((String) config.get("ip"))) { try { jackdaw_ip = InetAddress.getByName((String) config.get("ip")); ipFlag = true; } catch (UnknownHostException e) { logger.debug("IP address provided in configuration file is invalid! (Occured in updated())"); e.printStackTrace(); } } else { logger.debug("Hexabus device IP could not be parsed from .items-file. Might be blank."); } if (StringUtils.isNotBlank((String) config.get("port"))) { try { jackdaw_port = Integer.parseInt(((String) config.get("port"))); portFlag = true; } catch (NumberFormatException e) { logger.debug("Port provided in configuration file is invalid! (Occured in updated())"); e.printStackTrace(); } } else { logger.debug("Hexabus device port could not be parsed from .items-file. Might be blank."); } String temp = "From config file: \n IP: " + jackdaw_ip.toString() + "\n Port: " + jackdaw_port + "\n"; logger.debug(temp); // checks if requirements are met if (refreshFlag && ipFlag && portFlag) { setProperlyConfigured(true); } else { setProperlyConfigured(false); } testSwitch(); } }
From source file:org.openhab.persistence.caldav.internal.CalDavPersistenceService.java
@Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config == null) { logger.error("no configuration set for caldav-persistence"); return;/* w w w. j a v a 2s. c o m*/ } String usernameString = (String) config.get("username"); username = usernameString; if (StringUtils.isBlank(username)) { throw new ConfigurationException("caldav-persistence:username", "username must not be blank - please configure an aproppriate username in openhab.cfg"); } logger.trace("username: {}", username); String passwordString = (String) config.get("password"); password = passwordString; if (StringUtils.isBlank(password)) { throw new ConfigurationException("caldav-persistence:password", "password must not be blank - please configure an aproppriate password in openhab.cfg"); } logger.trace("password: {}", password); String hostString = (String) config.get("host"); host = hostString; if (StringUtils.isBlank(host)) { throw new ConfigurationException("caldav-persistence:host", "host must not be blank - please configure an aproppriate host in openhab.cfg"); } logger.trace("host: {}", host); String tlsString = (String) config.get("tls"); if (StringUtils.isNotBlank(tlsString)) { try { tls = Boolean.parseBoolean(tlsString); } catch (IllegalArgumentException iae) { logger.warn("couldn't parse caldav-persistence:tls '{}' to a boolean", tlsString); } } else { tls = true; } logger.trace("tls: {}", tls); String strictTlsString = (String) config.get("strict-tls"); if (StringUtils.isNotBlank(strictTlsString)) { try { strictTls = Boolean.parseBoolean(strictTlsString); } catch (IllegalArgumentException iae) { logger.warn("couldn't parse caldav-persistence:strict-tls '{}' to a boolean", strictTlsString); } } else { strictTls = true; } logger.trace("strict-tls: {}", strictTls); if (!tls) { logger.warn( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); logger.warn( "!! You have disabled tls/ssl for CalDav-Persistence. Calendar data is exchanged unencrypted. !!"); logger.warn( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } if (!strictTls && tls) { logger.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); logger.warn("!! You have disabled strict certificate checking by setting strict-tls to false. !!"); logger.warn("!! Actually all checking for certificates in CalDav-Persistence is disabled now !!"); logger.warn("!! - which means that there is no real security - as you accept any certificate, !!"); logger.warn("!! even those which might be injected for Man-In The Middle-Attacks - try to !!"); logger.warn("!! Register your certificate to your java certificate store and set strict-tls to !!"); logger.warn("!! true. Disable the tls checking is just meant for debugging purposes. !!"); logger.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } String portString = (String) config.get("port"); if (StringUtils.isNotBlank(portString)) { try { port = Integer.valueOf(portString); } catch (IllegalArgumentException iae) { logger.warn("couldn't parse caldav-persistence:port '{}' to an integer", portString); } } else { if (tls) { port = 443; } else { port = 80; } } logger.trace("port: {}", port); String urlString = (String) config.get("url"); url = urlString; if (StringUtils.isBlank(url)) { throw new ConfigurationException("caldav-persistence:url", "url must not be blank - please configure an aproppriate url in openhab.cfg"); } logger.trace("url: {}", url); String offsetString = (String) config.get("offset"); if (StringUtils.isNotBlank(offsetString)) { try { offset = Integer.valueOf(offsetString); } catch (IllegalArgumentException iae) { logger.warn("couldn't parse caldav-persistence:offset '{}' to an integer", offsetString); } } logger.trace("offset: {}", offset); String uploadIntervalString = (String) config.get("upload-interval"); if (StringUtils.isNotBlank(uploadIntervalString)) { try { uploadInterval = Integer.valueOf(uploadIntervalString); } catch (IllegalArgumentException iae) { logger.warn("couldn't parse caldav-persistence:upload-interval '{}' to an integer", uploadIntervalString); } } logger.trace("upload-interval: {}", offset); String executeScriptString = (String) config.get("executescript"); if (StringUtils.isNotBlank(executeScriptString)) { executeScript = executeScriptString; } logger.trace("executescript: {}", executeScript); initialized = true; logger.info("Initialized CalDav persistence service successfully"); }
From source file:org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.java
/** Activates this component, called by SCR before registering as a service */ protected void activate(ComponentContext componentContext) { this.componentContext = componentContext; Dictionary<?, ?> properties = componentContext.getProperties(); BidiMap virtuals = new TreeBidiMap(); String[] virtualList = (String[]) properties.get(PROP_VIRTUAL); for (int i = 0; virtualList != null && i < virtualList.length; i++) { String[] parts = Mapping.split(virtualList[i]); virtuals.put(parts[0], parts[2]); }//from w w w .j av a 2 s . c om virtualURLMap = virtuals; List<Mapping> maps = new ArrayList<Mapping>(); String[] mappingList = (String[]) properties.get(PROP_MAPPING); for (int i = 0; mappingList != null && i < mappingList.length; i++) { maps.add(new Mapping(mappingList[i])); } Mapping[] tmp = maps.toArray(new Mapping[maps.size()]); // check whether direct mappings are allowed Boolean directProp = (Boolean) properties.get(PROP_ALLOW_DIRECT); allowDirect = (directProp != null) ? directProp.booleanValue() : true; if (allowDirect) { Mapping[] tmp2 = new Mapping[tmp.length + 1]; tmp2[0] = Mapping.DIRECT; System.arraycopy(tmp, 0, tmp2, 1, tmp.length); mappings = tmp2; } else { mappings = tmp; } // from configuration if available searchPath = OsgiUtil.toStringArray(properties.get(PROP_PATH)); if (searchPath != null && searchPath.length > 0) { for (int i = 0; i < searchPath.length; i++) { // ensure leading slash if (!searchPath[i].startsWith("/")) { searchPath[i] = "/" + searchPath[i]; } // ensure trailing slash if (!searchPath[i].endsWith("/")) { searchPath[i] += "/"; } } } if (searchPath == null) { searchPath = new String[] { "/" }; } // namespace mangling mangleNamespacePrefixes = OsgiUtil.toBoolean(properties.get(PROP_MANGLE_NAMESPACES), false); // bind resource providers not bound yet for (ServiceReference reference : delayedResourceProviders) { bindResourceProvider(reference); } delayedResourceProviders.clear(); this.processDelayedJcrResourceTypeProviders(); // set up the map entries from configuration try { mapEntries = new MapEntries(this, getRepository()); plugin = new JcrResourceResolverWebConsolePlugin(componentContext.getBundleContext(), this); } catch (Exception e) { log.error("activate: Cannot access repository, failed setting up Mapping Support", e); } }
From source file:org.openhab.binding.xbmc.internal.XbmcActiveBinding.java
/** * {@inheritDoc}//from w ww . ja v a 2 s. com */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { logger.debug(getName() + " updated()"); Map<String, XbmcHost> hosts = new HashMap<String, XbmcHost>(); if (config != null) { String refreshIntervalString = (String) config.get("refreshInterval"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); } Enumeration<String> keys = config.keys(); while (keys.hasMoreElements()) { // Ignore "refreshInterval" key String key = keys.nextElement(); if ("refreshInterval".equals(key)) { continue; } if ("service.pid".equals(key)) { continue; } String[] parts = key.split("\\."); String hostname = parts[0]; XbmcHost host = hosts.get(hostname); if (host == null) { host = new XbmcHost(); } String value = ((String) config.get(key)).trim(); if ("host".equals(parts[1])) { host.setHostname(value); } if ("rsPort".equals(parts[1])) { host.setRsPort(Integer.valueOf(value)); } if ("wsPort".equals(parts[1])) { host.setWsPort(Integer.valueOf(value)); } if ("username".equals(parts[1])) { host.setUsername(value); } if ("password".equals(parts[1])) { host.setPassword(value); } hosts.put(hostname, host); } setProperlyConfigured(true); nameHostMapper = hosts; registerAllWatches(); } }
From source file:org.gatherdata.alert.notify.mail.internal.EmailNotifier.java
public void updated(Dictionary properties) throws ConfigurationException { smtpPort = Integer.parseInt(System.getProperty(SMTP_PORT_PROPERTY, DEFAULT_SMTP_PORT)); smtpHost = System.getProperty(SMTP_HOST_PROPERTY, DEFAULT_SMTP_HOST); mailUser = System.getProperty(MAIL_USER_PROPERTY, NO_AUTHENTICATION); mailPassword = System.getProperty(MAIL_PASSWORD_PROPERTY, NO_AUTHENTICATION); String mailFrom = System.getProperty(MAIL_FROM_PROPERTY, DEFAULT_MAIL_FROM); if (properties != null) { String updateSmtpPort = (String) properties.get(SMTP_PORT_PROPERTY); if (updateSmtpPort != null) smtpPort = Integer.parseInt(updateSmtpPort); String updateSmtpHost = (String) properties.get(SMTP_HOST_PROPERTY); if (updateSmtpHost != null) smtpHost = updateSmtpHost;/* w ww .j av a 2 s . c o m*/ String updateMailUser = (String) properties.get(MAIL_USER_PROPERTY); if (updateMailUser != null) mailUser = updateMailUser; String updateMailPassword = (String) properties.get(MAIL_PASSWORD_PROPERTY); if (updateMailPassword != null) mailPassword = updateMailPassword; String updateMailFrom = (String) properties.get(MAIL_FROM_PROPERTY); if (updateMailFrom != null) mailFrom = updateMailFrom; } try { senderAddress = new InternetAddress(mailFrom); } catch (AddressException e) { log.error("EmailNotifier has a bad default sender address. Contact the developers!", e); } }
From source file:org.openhab.binding.homematic.internal.bus.HomematicBinding.java
@Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { logger.debug("updated config={}", config); if (config == null) { return;/* w w w . jav a 2s. co m*/ } String checkAliveIntervallStr = (String) config.get(CONFIG_KEY_CONNECTION_REFRESH_INTERVALL); if (StringUtils.isBlank(checkAliveIntervallStr)) { checkAlifeIntervallMS = DEFAULT_INTERVALL_5_MINUTES; } else { checkAlifeIntervallMS = Integer.valueOf(checkAliveIntervallStr); } ccuHost = (String) config.get(CONFIG_KEY_CCU_HOST); ccu = new CCURF(new XmlRpcConnectionRF(ccuHost)); converterLookupByConfiguredDevices.setCcu(ccu); String callbackPortStr = (String) config.get(CONFIG_KEY_CALLBACK_PORT); if (StringUtils.isBlank(callbackPortStr)) { callbackPort = DEFAULT_CALLBACK_PORT; } else { callbackPort = Integer.valueOf(callbackPortStr); } callbackHost = (String) config.get(CONFIG_KEY_CALLBACK_HOST); if (StringUtils.isBlank(callbackHost)) { callbackHost = LocalNetworkInterface.getLocalNetworkInterface(); } if (isCallbackServerInitialized()) { removeCallbackHandler(); } registerCallbackHandler(); setProperlyConfigured(true); for (HomematicBindingProvider provider : providers) { queryAndSendAllActualStates(provider); } }
From source file:org.opencastproject.loadtest.impl.LoadTest.java
/** * Sets a new source media package location. * // w ww.ja v a2 s .c o m * @param properties * The new properties to extract the property from. * @throws InvalidConfigurationException * Thrown if property doesn't exist */ @SuppressWarnings("unchecked") private void updateSourceMediaPackageLocation(Dictionary properties) throws InvalidConfigurationException, URISyntaxException { Boolean foundSourceMediaPackageLocation = false; String sourceMediaPackageLocation = StringUtils .trimToNull((String) properties.get(SOURCE_MEDIA_PACKAGE_KEY)); if (sourceMediaPackageLocation != null) { URI newSourceMediaPackage = new URI(sourceMediaPackageLocation); if (newSourceMediaPackage != null) { this.sourceMediaPackageLocation = newSourceMediaPackage.toString(); foundSourceMediaPackageLocation = true; } } if (!foundSourceMediaPackageLocation) { // Try to get the storage location as a default. this.sourceMediaPackageLocation = StringUtils .trimToNull(componentContext.getBundleContext().getProperty(BUNDLE_CONTEXT_STORAGE_DIR)); if (this.sourceMediaPackageLocation != null) { this.sourceMediaPackageLocation += "/loadtest/source/media.zip"; foundSourceMediaPackageLocation = true; } } if (!foundSourceMediaPackageLocation) { throw new InvalidConfigurationException( "The source media package must be set in the configuration file so that loadtesting will occur. It isn't set in {FELIX_HOME}/conf/config.properties or {FELIX_HOME}/conf/services/org.opencastproject.loadtest.impl.LoadTestFactory.properties"); } }
From source file:org.codice.ddf.itests.common.ServiceManagerImpl.java
private void printInactiveBundles(Consumer<String> headerConsumer, BiConsumer<String, Object[]> logConsumer) { headerConsumer.accept("Listing inactive bundles"); for (Bundle bundle : getBundleContext().getBundles()) { if (bundle.getState() != Bundle.ACTIVE) { Dictionary<String, String> headers = bundle.getHeaders(); if (headers.get("Fragment-Host") != null) { continue; }//from w ww .jav a2 s . c o m StringBuilder headerString = new StringBuilder("[ "); Enumeration<String> keys = headers.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); headerString.append(key).append("=").append(headers.get(key)).append(", "); } headerString.append(" ]"); logConsumer.accept("\n\tBundle: {}_v{} | {}\n\tHeaders: {}", new Object[] { bundle.getSymbolicName(), bundle.getVersion(), BUNDLE_STATES.getOrDefault(bundle.getState(), "UNKNOWN"), headerString }); } } }
From source file:org.opencastproject.loadtest.impl.LoadTest.java
/** * Sets a new workspace location./* ww w . ja va 2s. c om*/ * * @param properties * The new properties to extract the property from. * @throws InvalidConfigurationException * Thrown if property doesn't exist */ @SuppressWarnings("unchecked") private void updateWorkspaceLocation(Dictionary properties) throws InvalidConfigurationException, URISyntaxException { boolean foundWorkspaceLocation = false; if (properties != null) { String newWorkspaceLocation = StringUtils.trimToNull((String) properties.get(WORKSPACE_KEY)); if (newWorkspaceLocation != null) { URI newWorkspace = new URI(newWorkspaceLocation); if (newWorkspace != null) { workspaceLocation = newWorkspace.getPath(); logger.debug("Workspace Location: " + newWorkspace); foundWorkspaceLocation = true; } } } if (!foundWorkspaceLocation && componentContext != null && componentContext.getBundleContext() != null) { // Try to get the storage location/loadtest/ as a default. workspaceLocation = StringUtils .trimToNull(componentContext.getBundleContext().getProperty(BUNDLE_CONTEXT_STORAGE_DIR)); if (workspaceLocation != null) { workspaceLocation = workspaceLocation + "/loadtest/workspace/"; foundWorkspaceLocation = true; } } if (!foundWorkspaceLocation) { throw new InvalidConfigurationException( "The workspace must be set in the configuration file so that loadtesting will occur. It isn't set in {FELIX_HOME}/conf/config.properties or {FELIX_HOME}/conf/services/org.opencastproject.loadtest.impl.LoadTestFactory.properties"); } }