List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:io.fabric8.karaf.core.properties.PlaceholderResolverImpl.java
@Override public boolean replaceAll(Dictionary<String, Object> dictionary) { int replacedCount = 0; Enumeration<String> keys = dictionary.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); final Object val = dictionary.get(key); if (val instanceof String) { StringBuilder sb = Support.acquireStringBuilder((String) val); if (substitutor.replaceIn(sb)) { replacedCount++;// w w w . j ava 2s . c o m dictionary.put(key, sb.toString()); } } } return replacedCount > 0; }
From source file:com.adobe.acs.commons.rewriter.impl.StaticReferenceRewriteTransformerFactory.java
@Activate protected void activate(final ComponentContext componentContext) { final Dictionary<?, ?> properties = componentContext.getProperties(); final String[] attrProp = PropertiesUtil.toStringArray(properties.get(PROP_ATTRIBUTES), DEFAULT_ATTRIBUTES); this.attributes = ParameterUtil.toMap(attrProp, ":", ","); final String[] matchingPatternsProp = PropertiesUtil.toStringArray(properties.get(PROP_MATCHING_PATTERNS)); this.matchingPatterns = initializeMatchingPatterns(matchingPatternsProp); this.prefixes = PropertiesUtil.toStringArray(properties.get(PROP_PREFIXES), new String[0]); this.staticHostPattern = PropertiesUtil.toStringArray(properties.get(PROP_HOST_NAME_PATTERN), null); this.staticHostCount = PropertiesUtil.toInteger(properties.get(PROP_HOST_COUNT), DEFAULT_HOST_COUNT); }
From source file:org.opencastproject.ingest.scanner.InboxScanner.java
/** * {@inheritDoc}//from w ww.j a va 2s . co m * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ @SuppressWarnings("rawtypes") @Override public void updated(Dictionary properties) throws ConfigurationException { // Set the organization first organizationId = (String) properties.get(USER_ORG); if (StringUtils.isBlank(organizationId)) throw new ConfigurationException(USER_ORG, USER_ORG + " must be specified"); // Now that we have the organization to run as, we can load the user userId = (String) properties.get(USER_NAME); if (StringUtils.isBlank(userId)) throw new ConfigurationException(USER_NAME, USER_NAME + " must be specified"); // Now load the workflow definition ID String workflowConfig = (String) properties.get(WORKFLOW_DEFINITION); if (StringUtils.isNotBlank(workflowConfig)) { workflowDefinition = workflowConfig; } }
From source file:ch.entwine.weblounge.bridge.oaipmh.WebloungeHarvester.java
/** * {@inheritDoc}/*from w w w .j a va2 s . c o m*/ * * @see ch.entwine.weblounge.common.scheduler.JobWorker#execute(java.lang.String, * java.util.Dictionary) */ @SuppressWarnings("unchecked") public void execute(String name, Dictionary<String, Serializable> ctx) throws JobException { Site site = (Site) ctx.get(Site.class.getName()); // Get hold of the content repository WritableContentRepository contentRepository = null; if (site.getContentRepository().isReadOnly()) throw new JobException(this, "Content repository of site '" + site + "' is read only"); contentRepository = (WritableContentRepository) site.getContentRepository(); // Read the configuration value for the repository url String repositoryUrl = (String) ctx.get(OPT_REPOSITORY_URL); if (StringUtils.isBlank(repositoryUrl)) throw new JobException(this, "Configuration option '" + OPT_REPOSITORY_URL + "' is missing from the job configuration"); // Make sure the url is well formed URL url = null; try { url = new URL(repositoryUrl); } catch (MalformedURLException e) { throw new JobException(this, "Repository url '" + repositoryUrl + "' is malformed: " + e.getMessage()); } // Read the configuration value for the flavors String presentationTrackFlavor = (String) ctx.get(OPT_PRSENTATION_TRACK_FLAVORS); if (StringUtils.isBlank(presentationTrackFlavor)) throw new JobException(this, "Configuration option '" + OPT_PRSENTATION_TRACK_FLAVORS + "' is missing from the job configuration"); String presenterTrackFlavor = (String) ctx.get(OPT_PRESENTER_TRACK_FLAVORS); if (StringUtils.isBlank(presenterTrackFlavor)) throw new JobException(this, "Configuration option '" + OPT_PRESENTER_TRACK_FLAVORS + "' is missing from the job configuration"); String dcEpisodeFlavor = (String) ctx.get(OPT_EPISODE_DC_FLAVORS); if (StringUtils.isBlank(dcEpisodeFlavor)) throw new JobException(this, "Configuration option '" + OPT_EPISODE_DC_FLAVORS + "' is missing from the job configuration"); String dcSeriesFlavor = (String) ctx.get(OPT_SERIES_DC_FLAVORS); if (StringUtils.isBlank(dcSeriesFlavor)) throw new JobException(this, "Configuration option '" + OPT_SERIES_DC_FLAVORS + "' is missing from the job configuration"); String mimesTypes = (String) ctx.get(OPT_MIMETYPES); if (StringUtils.isBlank(mimesTypes)) throw new JobException(this, "Configuration option '" + OPT_MIMETYPES + "' is missing from the job configuration"); // Read the configuration value for the handler class String handlerClass = (String) ctx.get(OPT_HANDLER_CLASS); if (StringUtils.isBlank(handlerClass)) throw new JobException(this, "Configuration option '" + OPT_HANDLER_CLASS + "' is missing from the job configuration"); UserImpl harvesterUser = new UserImpl(name, site.getIdentifier(), "Harvester"); RecordHandler handler; try { Class<? extends AbstractWebloungeRecordHandler> c = (Class<? extends AbstractWebloungeRecordHandler>) Thread .currentThread().getContextClassLoader().loadClass(handlerClass); Class<?> paramTypes[] = new Class[8]; paramTypes[0] = Site.class; paramTypes[1] = WritableContentRepository.class; paramTypes[2] = User.class; paramTypes[3] = String.class; paramTypes[4] = String.class; paramTypes[5] = String.class; paramTypes[6] = String.class; paramTypes[7] = String.class; Constructor<? extends AbstractWebloungeRecordHandler> constructor = c.getConstructor(paramTypes); Object arglist[] = new Object[8]; arglist[0] = site; arglist[1] = contentRepository; arglist[2] = harvesterUser; arglist[3] = presentationTrackFlavor; arglist[4] = presenterTrackFlavor; arglist[5] = dcEpisodeFlavor; arglist[6] = dcSeriesFlavor; arglist[7] = mimesTypes; handler = constructor.newInstance(arglist); } catch (Throwable t) { throw new IllegalStateException("Unable to instantiate class " + handlerClass + ": " + t.getMessage(), t); } SearchResult searchResult; SearchQuery q = new SearchQueryImpl(site); q.withTypes(MovieResource.TYPE); q.sortByPublishingDate(Order.Descending); q.withPublisher(harvesterUser); try { searchResult = contentRepository.find(q); } catch (ContentRepositoryException e) { logger.error("Error searching for resources with harvester publisher."); throw new RuntimeException(e); } Option<Date> harvestingDate = Option.<Date>none(); if (searchResult.getHitCount() > 0) { MovieResourceSearchResultItemImpl resultItem = (MovieResourceSearchResultItemImpl) searchResult .getItems()[0]; Date lastDate = resultItem.getMovieResource().getPublishFrom(); // To not include the resources updated, 1 second is added to the last // update date lastDate.setTime(lastDate.getTime() + 1000); harvestingDate = some(lastDate); } try { harvest(repositoryUrl, harvestingDate, handler); } catch (Exception e) { logger.warn("An error occured while harvesting " + url + ". Skipping this repository for now...", e.getMessage()); } }
From source file:ch.entwine.weblounge.kernel.runtime.EnvironmentService.java
/** * {@inheritDoc}//from w w w. j a v a2s .c o m * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ @SuppressWarnings("rawtypes") public void updated(Dictionary properties) throws ConfigurationException { if (properties == null) return; // Environment Environment env = null; String environmentValue = StringUtils.trimToNull((String) properties.get(OPT_ENVIRONMENT)); if (StringUtils.isNotBlank(environmentValue)) { try { env = Environment.valueOf(StringUtils.capitalize(environmentValue)); logger.debug("Configured value for the default runtime environment is '{}'", env.toString().toLowerCase()); } catch (IllegalArgumentException e) { throw new ConfigurationException(OPT_ENVIRONMENT, environmentValue); } } else { env = DEFAULT_ENVIRONMENT; logger.debug("Using default value '{}' for runtime environment", env.toString().toLowerCase()); } // Did the setting change? if (!env.equals(environment)) { this.environment = env; if (registration != null) { try { registration.unregister(); } catch (IllegalStateException e) { // Never mind, the service has been unregistered already } catch (Throwable t) { logger.error("Unregistering runtime environment failed: {}", t.getMessage()); } } registration = bundleContext.registerService(Environment.class.getName(), environment, null); logger.info("Runtime environment set to '{}'", environment.toString().toLowerCase()); } }
From source file:de.joerghoh.cq5.healthcheck.impl.providers.MBeanStatusProvider.java
@Activate protected void activate(ComponentContext ctx) throws RepositoryException { Dictionary<?, ?> props = ctx.getProperties(); category = PropertiesUtil.toString(props.get(CATEGORY), null); mbeanName = PropertiesUtil.toString(props.get(MBEAN_NAME), null); properties = PropertiesUtil.toStringArray(props.get(MBEAN_PROPERTY)); providerHint = PropertiesUtil.toString(props.get(MBEAN_PROVIDER_HINT), null); mbean = buildObjectName(mbeanName);/*from w ww.j ava 2s . com*/ if (mbean != null && mbeanExists(mbean)) { log.info("Instantiate healtcheck for MBean {}", mbeanName); } else { log.warn("Cannot instantiate healthcheck for MBean {}", mbeanName); } providerName = mbeanName; if (providerHint != null) { providerName += " (" + providerHint + ")"; } }
From source file:org.opencastproject.inspection.ffmpeg.MediaInspectionServiceImpl.java
/** * {@inheritDoc}/*from w w w.j a v a2 s .com*/ * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ @Override @SuppressWarnings("unchecked") public void updated(Dictionary properties) throws ConfigurationException { if (properties == null) return; final String path = StringUtils.trimToNull((String) properties.get(FFmpegAnalyzer.FFPROBE_BINARY_CONFIG)); if (path != null) { logger.info("Setting the path to ffprobe to " + path); inspector = new MediaInspector(workspace, tikaParser, path); } }
From source file:de.filiberry.bathcontrol.Activator.java
/** * /* www . java2 s.c o m*/ */ public void updated(@SuppressWarnings("rawtypes") Dictionary properties) throws ConfigurationException { LOGGER.debug("Bundle " + BUNDLE_ID + " config set or updated ..."); mqttHost = (String) properties.get("mqtt.listen.host"); mqttTopic = (String) properties.get("mqtt.listen.topic"); mqttTopicMoistureBadezimmer = (String) properties.get("mqtt.topic.moisture.badezimmer"); mqttTopicTempBadezimmer = (String) properties.get("mqtt.topic.temp.badezimmer"); mqttTopicTempAussen = (String) properties.get("mqtt.topic.temp.aussen"); mqttTopicTempWintergarten = (String) properties.get("mqtt.topic.temp.wintergarten"); // Set the Actor config to the Worker bathControlWorker.setMqttGPIOActorHost((String) properties.get("mqtt.publish.actor.host")); bathControlWorker.setMqttGPIOActorZuluftTopic((String) properties.get("mqtt.publish.actor.zuluft.topic")); bathControlWorker.setMqttGPIOActorAbluftTopic((String) properties.get("mqtt.publish.actor.abluft.topic")); // Set the GUI config to the Worker bathControlWorker.setMqttGuiHost((String) properties.get("mqtt.publish.gui.host")); bathControlWorker.setMqttGuiTopic((String) properties.get("mqtt.publish.gui.topic")); String scriptFile = FileUtils.getUserDirectoryPath() + "/bathControl.js"; if (!BathControlWorker.checkConfigFile(scriptFile)) { try { IOUtils.copy(context.getBundle().getResource("/bathControl.js").openStream(), new FileOutputStream(new File(scriptFile))); } catch (Exception e) { LOGGER.error(e.getMessage()); } } bathControlWorker.setRuleScriptFile(scriptFile); new Thread(bathControlWorker).start(); connectToBroker(); }
From source file:org.apache.sling.hc.core.impl.servlet.HealthCheckExecutorServlet.java
@Activate protected final void activate(final ComponentContext context) { final Dictionary<?, ?> properties = context.getProperties(); this.servletPath = (String) properties.get(PROPERTY_SERVLET_PATH); this.disabled = PropertiesUtil.toBoolean(properties.get(PROPERTY_DISABLED), false); if (disabled) { LOG.info("Health Check Servlet is disabled by configuration"); return;/*from w w w . java 2s . c o m*/ } try { LOG.debug("Registering {} to path {}", getClass().getSimpleName(), this.servletPath); this.httpService.registerServlet(this.servletPath, this, null, null); } catch (Exception e) { LOG.error("Could not register health check servlet: " + e, e); } }
From source file:org.fcrepo.apix.registry.HttpClientFactory.java
/** * Set props as a dictionary, eww.//from w w w .j a v a 2 s . c o m * * @param dict Dictionaty */ public void setDictionary(final Dictionary<String, Object> dict) { props = new HashMap<>(); final Enumeration<String> keys = dict.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); props.put(key, dict.get(key).toString()); } }