List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:com.adobe.acs.commons.twitter.impl.TwitterFeedUpdaterImpl.java
protected void activate(ComponentContext ctx) { final Dictionary<?, ?> props = ctx.getProperties(); twitterComponentPaths = PropertiesUtil.toStringArray(props.get(TWITTER_COMPONENT_PATHS)); }
From source file:eu.spaziodati.datatxt.stanbol.enhancer.engines.DatatxtNexEngine.java
private ITranslator outputOntology(ComponentContext context, Dictionary<String, Object> properties) throws ConfigurationException { String s = (String) properties.get(PROPERTY_OUTPUT_ONTOLOGY); OutputOntology outputOntology = s == null ? OutputOntology.FAM : OutputOntology.valueOf(s.toUpperCase()); TranslationSupport support = new TranslationSupport(fPrefixService); switch (outputOntology) { case FISE:/*w w w . ja v a 2s . co m*/ return new FiseTranslator(support); case FAM: return new FamTranslator(support); default: throw new IllegalStateException(); } }
From source file:org.openhab.persistence.ibmiot.internal.IbmIotPersistenceService.java
/** * Get a value from the given properties. * //from w w w. j a v a 2s .c om * @param properties * dictionary to load property from. * @param name * of the property * @return property value * @throws ConfigurationException * if the property is empty */ private String getProperty(Dictionary<String, ?> properties, String name) throws ConfigurationException { value = (String) properties.get(name); if (StringUtils.isNotBlank(value)) { return value.trim(); } else { throw new ConfigurationException("ibmiot-persistence:" + name, "Missing or invalid property '" + name + "'"); } }
From source file:org.openhab.binding.hdl.internal.HdlBinding.java
/** * @{inheritDoc}//from w ww . ja v a 2s . c o m */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { gateway = (String) config.get("gateway"); } if (gateway == null) { gateway = "255.255.255.255"; } logger.info("gateway is {}", gateway); try { server.start("0.0.0.0", gateway); } catch (IOException e) { logger.error("Can't start HDL server: {}", e.getMessage()); } }
From source file:org.openhab.binding.homematic.internal.common.HomematicConfig.java
/** * Parses and validates the properties in the openhab.cfg. *//*from w w w . ja v a2 s . c om*/ public void parse(Dictionary<String, ?> properties) throws ConfigurationException { valid = false; host = (String) properties.get(CONFIG_KEY_HOMEMATIC_HOST); if (StringUtils.isBlank(host)) { throw new ConfigurationException("homematic", "Parameter host is mandatory and must be configured. Please check your openhab.cfg!"); } timeout = parseInt(properties, CONFIG_KEY_HOMEMATIC_HOST_TIMEOUT, DEFAULT_HOST_TIMEOUT); callbackHost = (String) properties.get(CONFIG_KEY_CALLBACK_HOST); if (StringUtils.isBlank(callbackHost)) { callbackHost = LocalNetworkInterface.getLocalNetworkInterface(); } callbackPort = parseInt(properties, CONFIG_KEY_CALLBACK_PORT, DEFAULT_CALLBACK_PORT); aliveInterval = parseInt(properties, CONFIG_KEY_ALIVE_INTERVAL, DEFAULT_ALIVE_INTERVAL); reconnectInterval = parseInt(properties, CONFIG_KEY_RECONNECT_INTERVAL, null); valid = true; }
From source file:org.apache.ace.authentication.processor.basicauth.BasicHttpAuthenticationProcessor.java
/** * {@inheritDoc}//from www .ja v a2 s . c om */ 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"); } m_keyUsername = keyUsername; m_keyPassword = keyPassword; } else { m_keyUsername = DEFAULT_PROPERTY_KEY_USERNAME; m_keyPassword = DEFAULT_PROPERTY_KEY_PASSWORD; } }
From source file:io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackageOsgiConfigPostProcessorTest.java
@Test public void testPostProcess() throws Exception { // prepare provisioning file File target = new File("target/" + ContentPackageOsgiConfigPostProcessor.NAME + "-test"); if (target.exists()) { FileUtils.deleteDirectory(target); }/*from ww w . j a v a 2 s . c o m*/ File contentPackageFile = new File(target, "test.txt"); FileUtils.copyFile(new File(getClass().getResource("/provisioning/provisioning.txt").toURI()), contentPackageFile); // post-process FileContext fileContext = new FileContext().file(contentPackageFile).charset(StandardCharsets.UTF_8); PluginContextOptions pluginContextOptions = new PluginContextOptions() .pluginManager(new PluginManagerImpl()) .logger(LoggerFactory.getLogger(ProvisioningOsgiConfigPostProcessor.class)); PostProcessorContext context = new PostProcessorContext().pluginContextOptions(pluginContextOptions) .options(PACKAGE_OPTIONS); assertTrue(underTest.accepts(fileContext, context)); underTest.apply(fileContext, context); // validate assertFalse(contentPackageFile.exists()); File zipFile = new File(target, "test.zip"); assertTrue(zipFile.exists()); try (InputStream is = new ByteArrayInputStream( getDataFromZip(zipFile, "jcr_root/apps/test/config/my.pid.config"))) { // check for initial comment line is.mark(256); final int firstChar = is.read(); if (firstChar == '#') { int b; while ((b = is.read()) != '\n') { if (b == -1) { throw new IOException("Unable to read configuration."); } } } else { is.reset(); } Dictionary<?, ?> config = ConfigurationHandler.read(is); assertEquals("value1", config.get("stringProperty")); assertArrayEquals(new String[] { "v1", "v2", "v3" }, (String[]) config.get("stringArrayProperty")); assertEquals(true, config.get("booleanProperty")); assertEquals(999999999999L, config.get("longProperty")); } assertTrue(ZipUtil.containsEntry(zipFile, "jcr_root/apps/test/config/my.factory-my.pid.config")); assertTrue(ZipUtil.containsEntry(zipFile, "jcr_root/apps/test/config.mode1/my.factory-my.pid2.config")); assertTrue(ZipUtil.containsEntry(zipFile, "jcr_root/apps/test/config.mode2/my.pid2.config")); Document filterXml = getXmlFromZip(zipFile, "META-INF/vault/filter.xml"); assertXpathEvaluatesTo("/apps/test/config", "/workspaceFilter/filter[1]/@root", filterXml); Document propsXml = getXmlFromZip(zipFile, "META-INF/vault/properties.xml"); assertXpathEvaluatesTo("myGroup", "/properties/entry[@key='group']", propsXml); assertXpathEvaluatesTo("myName", "/properties/entry[@key='name']", propsXml); assertXpathEvaluatesTo("myDesc\n---\nSample comment in provisioning.txt", "/properties/entry[@key='description']", propsXml); assertXpathEvaluatesTo("1.5", "/properties/entry[@key='version']", propsXml); }
From source file:org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl.java
/** * Starts a bundle./*from www .ja v a 2 s. c o m*/ * * @param bundle bundle to be started * * @throws BundleException - If bundle cannot be started */ private void startBundle(final Bundle bundle) throws BundleException { // Don't start if bundle already active int bundleState = bundle.getState(); if (bundleState == Bundle.ACTIVE) { return; } // Don't start if bundle is a fragment bundle Dictionary bundleHeaders = bundle.getHeaders(); if (bundleHeaders.get(Constants.FRAGMENT_HOST) != null) { return; } // Start bundle bundle.start(); bundleState = bundle.getState(); if (bundleState != Bundle.ACTIVE) { long bundleId = bundle.getBundleId(); String bundleName = bundle.getSymbolicName(); String bundleStateStr = bundleStateToString(bundleState); throw new BundleException( "Bundle (" + bundleId + ", " + bundleName + ") not started (still " + bundleStateStr + ")"); } }
From source file:org.codice.pubsub.server.SubscriptionServer.java
public String getSubscriptionMsg(String subscriptionId) { Dictionary subMap = getSubscriptionMap(); String msg = (String) subMap.get(subscriptionId); return msg;/*ww w. j ava 2s. c o m*/ }
From source file:org.apache.sling.auth.xing.login.impl.DefaultXingLoginUserManager.java
protected synchronized void configure(final ComponentContext componentContext) { final Dictionary properties = componentContext.getProperties(); secretKey = PropertiesUtil.toString(properties.get(SECRET_KEY_PARAMETER), "").trim(); userDataProperty = PropertiesUtil/*from w w w .j a v a 2 s . c o m*/ .toString(properties.get(USER_DATA_PROPERTY_PARAMETER), DEFAULT_USER_DATA_PROPERTY).trim(); userHashProperty = PropertiesUtil .toString(properties.get(USER_HASH_PROPERTY_PARAMETER), DEFAULT_USER_HASH_PROPERTY).trim(); autoCreateUser = PropertiesUtil.toBoolean(properties.get(AUTO_CREATE_USER_PARAMETER), DEFAULT_AUTO_CREATE_USER); autoUpdateUser = PropertiesUtil.toBoolean(properties.get(AUTO_UPDATE_USER_PARAMETER), DEFAULT_AUTO_UPDATE_USER); if (StringUtils.isEmpty(secretKey)) { logger.warn("configured secret key is empty"); } }