List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:org.colombbus.tangara.Configuration.java
private boolean testExecutionMode() { executionMode = false;// w ww . j a v a 2s . c o m JarFile file = null; try { file = new JarFile(getTangaraPath()); ZipEntry entry = file.getEntry(EXECUTION_PROPERTIES_FILENAME); if (entry != null) { executionMode = true; System.out.println("execution mode detected"); Properties executionProperties = new Properties(); InputStream ips = ClassLoader.getSystemResourceAsStream(EXECUTION_PROPERTIES_FILENAME); executionProperties.load(ips); if (executionProperties.containsKey("main-program")) { String mainTangaraFile = executionProperties.getProperty("main-program"); System.out.println("main tangara file: " + mainTangaraFile); properties.setProperty("main-program", mainTangaraFile); } else { System.err.println("error : main program not specified"); } if (executionProperties.containsKey("language")) { String language = executionProperties.getProperty("language"); properties.setProperty("language", language); System.out.println("language: " + language); } else { System.err.println("error : language not specified"); } if (executionProperties.containsKey("resources")) { String resources = executionProperties.getProperty("resources"); properties.setProperty("program.resources", resources); System.out.println("resources: " + resources); } else { System.err.println("error : resources not specified"); } } } catch (IOException e) { e.printStackTrace(); } finally { if (file != null) { try { file.close(); } catch (IOException e) { System.err.println("error while closing tangara JAR file"); } } } return executionMode; }
From source file:org.jahia.services.usermanager.ldap.LDAPUserGroupProvider.java
/** * Construct the filters for queries/*from ww w .j a v a 2s .com*/ * * @param ldapfilters * @param config * @param isOrOperator * @return */ private ContainerCriteria getQueryFilters(Properties ldapfilters, AbstractConfig config, boolean isOrOperator) { ContainerCriteria filterQuery = null; if (ldapfilters.containsKey("*")) { // Search on all wildcards attributes String filterValue = ldapfilters.getProperty("*"); if (CollectionUtils.isNotEmpty(config.getSearchWildcardsAttributes())) { for (String wildcardAttribute : config.getSearchWildcardsAttributes()) { if (filterQuery == null) { filterQuery = query().where(wildcardAttribute).like(filterValue); } else { addCriteriaToQuery(filterQuery, true, wildcardAttribute).like(filterValue); } } } } else { // consider the attributes Iterator<?> filterKeys = ldapfilters.keySet().iterator(); while (filterKeys.hasNext()) { String filterName = (String) filterKeys.next(); String filterValue = ldapfilters.getProperty(filterName); if (filterQuery == null) { filterQuery = query().where(filterName).like(filterValue); } else { addCriteriaToQuery(filterQuery, isOrOperator, filterName).like(filterValue); } } } return filterQuery; }
From source file:org.apache.geode.distributed.internal.SharedConfiguration.java
private void putSecurityPropsIntoClusterConfig(final Region<String, Configuration> configRegion) { Properties securityProps = cache.getDistributedSystem().getSecurityProperties(); Configuration clusterPropertiesConfig = configRegion.get(SharedConfiguration.CLUSTER_CONFIG); if (clusterPropertiesConfig == null) { clusterPropertiesConfig = new Configuration(SharedConfiguration.CLUSTER_CONFIG); configRegion.put(SharedConfiguration.CLUSTER_CONFIG, clusterPropertiesConfig); }//from ww w .ja v a 2 s .com // put security-manager and security-post-processor in the cluster config Properties clusterProperties = clusterPropertiesConfig.getGemfireProperties(); if (securityProps.containsKey(SECURITY_MANAGER)) { clusterProperties.setProperty(SECURITY_MANAGER, securityProps.getProperty(SECURITY_MANAGER)); } if (securityProps.containsKey(SECURITY_POST_PROCESSOR)) { clusterProperties.setProperty(SECURITY_POST_PROCESSOR, securityProps.getProperty(SECURITY_POST_PROCESSOR)); } }
From source file:org.apache.ws.scout.registry.RegistryImpl.java
/** * @throws InvalidRequestException /*from w ww .ja v a 2 s. co m*/ * */ private void init(Properties props) throws InvalidRequestException { // We need to have a non-null Properties // instance so initialization takes place. if (props == null) props = new Properties(); // Override defaults with specific specific values try { setInquiryURI(new URI(props.getProperty(ConnectionFactoryImpl.QUERYMANAGER_PROPERTY))); if (props.containsKey(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY)) { setPublishURI(new URI(props.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY))); } String securityURL = props.getProperty(ConnectionFactoryImpl.SECURITYMANAGER_PROPERTY, props.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY)); if (securityURL != null) setSecurityURI(new URI(securityURL)); setAdminURI(new URI( props.getProperty(ConnectionFactoryImpl.ADMIN_ENDPOINT_PROPERTY, DEFAULT_ADMIN_ENDPOINT))); setSecurityProvider( props.getProperty(ConnectionFactoryImpl.SECURITY_PROVIDER_PROPERTY, DEFAULT_SECURITY_PROVIDER)); setProtocolHandler( props.getProperty(ConnectionFactoryImpl.PROTOCOL_HANDLER_PROPERTY, DEFAULT_PROTOCOL_HANDLER)); setUddiVersion(props.getProperty(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY, DEFAULT_UDDI_VERSION)); setUddiNamespace( props.getProperty(ConnectionFactoryImpl.UDDI_NAMESPACE_PROPERTY, DEFAULT_UDDI_NAMESPACE)); setTransport(getTransport( props.getProperty(ConnectionFactoryImpl.TRANSPORT_CLASS_PROPERTY, DEFAULT_TRANSPORT_CLASS))); JAXBContext context = JAXBContextUtil.getContext(JAXBContextUtil.UDDI_V2_VERSION); unmarshaller = context.createUnmarshaller(); marshaller = context.createMarshaller(); } catch (URISyntaxException muex) { throw new InvalidRequestException(muex.getMessage(), muex); } catch (JAXBException e) { throw new RuntimeException(e); } }
From source file:com.googlecode.fascinator.HarvestClient.java
/** * Process each objects/*from w w w.j ava 2s . co m*/ * * @param oid Object Id * @param commit Flag to commit after indexing * @throws StorageException If storage is not found * @throws TransformerException If transformer fail to transform the object * @throws MessagingException If the object could not be queue'd */ private void processObject(String oid, boolean commit) throws TransformerException, StorageException, MessagingException { // get the object DigitalObject object = storage.getObject(oid); String isNew = "false"; String isModified = "false"; // update object metadata Properties props = object.getMetadata(); // TODO - objectId is redundant now? props.setProperty("objectId", object.getId()); props.setProperty("scriptType", config.getString(null, "indexer", "script", "type")); // Set our config and rules data as properties on the object props.setProperty("rulesOid", rulesObject.getId()); props.setProperty("rulesPid", rulesObject.getSourceId()); props.setProperty("jsonConfigOid", configObject.getId()); props.setProperty("jsonConfigPid", configObject.getSourceId()); if (fileOwner != null) { props.setProperty("owner", fileOwner); } JsonObject params = config.getObject("indexer", "params"); for (Object key : params.keySet()) { props.setProperty(key.toString(), params.get(key).toString()); } // check this object's status (i.e. new or modified) and count if (props.containsKey("isNew") && Boolean.parseBoolean(props.getProperty("isNew"))) { isNew = "true"; } else if (props.containsKey("isModified")) { if (Boolean.parseBoolean(props.getProperty("isModified"))) { isModified = "true"; } } // now remove these properties. We don't need them anymore props.remove("isNew"); props.remove("isModified"); // done with the object object.close(); // put in event log Map<String, String> msgs = new LinkedHashMap<String, String>(); msgs.put("harvestId", harvestId); msgs.put("isNew", isNew); msgs.put("isModified", isModified); msgs.put("repository_type", repoType); msgs.put("repository_name", repoName); sentMessage(oid, "modify", msgs); // queue the object for indexing queueHarvest(oid, configFile, commit); }
From source file:org.jahia.services.usermanager.ldap.LDAPUserGroupProvider.java
/** * Map jahia properties to ldap properties * * @param searchCriteria/*from w w w. jav a 2s .co m*/ * @param configProperties * @return */ private Properties mapJahiaPropertiesToLDAP(Properties searchCriteria, Map<String, String> configProperties) { if (searchCriteria.size() == 0) { return searchCriteria; } Properties p = new Properties(); if (searchCriteria.containsKey("*")) { p.setProperty("*", searchCriteria.getProperty("*")); if (searchCriteria.size() == 1) { return p; } } for (Map.Entry<Object, Object> entry : searchCriteria.entrySet()) { if (configProperties.containsKey(entry.getKey())) { p.setProperty(configProperties.get(entry.getKey()), (String) entry.getValue()); } else if (!entry.getKey().equals("*") && !entry.getKey().equals(JahiaUserManagerService.MULTI_CRITERIA_SEARCH_OPERATION)) { return null; } } return p; }
From source file:org.acmsl.queryj.tools.maven.QueryJMojo.java
/** * Retrieves the version of QueryJ currently running. * @param properties the pom.properties information. * @return the version entry.//from ww w . j av a2s .c o m */ protected String retrieveVersion(@Nullable final Properties properties) { String result = UNKNOWN_LITERAL; if ((properties != null) && (properties.containsKey(VERSION_LITERAL))) { result = properties.getProperty(VERSION_LITERAL); } return result; }
From source file:sk.openhouse.web.recaptcha.LocaleReCaptchaImpl.java
@Override public String createRecaptchaHtml(String errorMessage, Properties options) { String errorPart = ""; if (errorMessage != null) { String encoding = "UTF-8"; try {/* ww w . ja v a2 s . c om*/ errorPart = "&error=" + URLEncoder.encode(errorMessage, encoding); } catch (UnsupportedEncodingException ex) { logger.fatal(encoding + " encoding is not supported", ex); } } if (options == null) { options = new Properties(); } String prefix = "reCaptcha."; /* message key with default value */ Map<String, String> keys = new HashMap<String, String>(); keys.put("visual_challenge", "Get a visual challenge"); keys.put("audio_challenge", "Get an audio challenge"); keys.put("refresh_btn", "Get a new challenge"); keys.put("instructions_visual", "Type the two words:"); keys.put("instructions_context", "Type the words in the boxes:"); keys.put("instructions_audio", "Type what you hear:"); keys.put("help_btn", "Help"); keys.put("play_again", "Play sound again"); keys.put("cant_hear_this", "Download sound as MP3"); keys.put("incorrect_try_again", "Incorrect. Try again."); /* get locale from properties if set */ Locale locale = null; String langKey = "lang"; if (options.containsKey(langKey)) { List<String> langs = Arrays.asList(Locale.getISOLanguages()); String lang = options.getProperty(langKey); if (langs.contains(lang)) { locale = new Locale(lang); } } /* if locale is not set, get it from context */ if (locale == null) { locale = LocaleContextHolder.getLocale(); } /* load messages for a given locale, if it fails, default to EN */ StringBuilder sb = new StringBuilder("{"); try { for (Map.Entry<String, String> entry : keys.entrySet()) { String key = entry.getKey(); sb.append(key); sb.append(":\""); sb.append(messages.getMessage(prefix + key, locale)); sb.append("\","); } } catch (NoSuchMessageException ex) { locale = Locale.ENGLISH; for (Map.Entry<String, String> entry : keys.entrySet()) { String key = entry.getKey(); sb.append(key); sb.append(":\""); sb.append(messages.getMessage(prefix + key, entry.getValue(), locale)); sb.append("\","); } } sb.deleteCharAt(sb.length() - 1); sb.append("}"); options.put("custom_translations", sb.toString()); options.put("lang", locale.getLanguage()); String message = fetchJSOptions(options); message += "<script type=\"text/javascript\" src=\"" + recaptchaServer + "/challenge?k=" + publicKey + errorPart + "\"></script>\r\n"; if (includeNoscript) { String noscript = "<noscript>\r\n" + " <iframe src=\"" + recaptchaServer + "/noscript?k=" + publicKey + errorPart + "\" height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\r\n" + " <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\"></textarea>\r\n" + " <input type=\"hidden\" name=\"recaptcha_response_field\" value=\"manual_challenge\">\r\n" + "</noscript>"; message += noscript; } return message; }
From source file:com.googlecode.fascinator.redbox.plugins.curation.mint.CurationManager.java
/** * Get the requested object ready for publication. This would typically * just involve setting a flag/*from www. j a va 2 s . co m*/ * * @param message The incoming message * @param oid The object identifier to publish * @return JsonSimple The response object * @throws TransactionException If an error occurred */ private JsonSimple publish(JsonSimple message, String oid) throws TransactionException { log.debug("Publishing '{}'", oid); JsonSimple response = new JsonSimple(); try { DigitalObject object = storage.getObject(oid); Properties metadata = object.getMetadata(); // Already published? if (!metadata.containsKey(PUBLISH_PROPERTY)) { metadata.setProperty(PUBLISH_PROPERTY, "true"); object.close(); log.info("Publication flag set '{}'", oid); audit(response, oid, "Publication flag set"); } else { log.info("Publication flag is already set '{}'", oid); } } catch (StorageException ex) { throw new TransactionException("Error setting publish property: ", ex); } // Make a final pass through the curation tool(s), // allows for external publication. eg. VITAL JsonSimple itemConfig = getConfigFromStorage(oid); if (itemConfig == null) { log.error("Error accessing item configuration!"); } else { List<String> list = itemConfig.getStringList("transformer", "curation"); if (list != null && !list.isEmpty()) { for (String id : list) { JsonObject order = newTransform(response, id, oid); JsonObject config = (JsonObject) order.get("config"); JsonObject overrides = itemConfig.getObject("transformerOverrides", id); if (overrides != null) { config.putAll(overrides); } } } } // Don't forget to publish children publishRelations(response, oid); return response; }
From source file:org.apache.pig.tools.grunt.GruntParser.java
@Override protected void processSet() throws IOException, ParseException { filter.validate(PigCommandFilter.Command.SET); Properties jobProps = mPigServer.getPigContext().getProperties(); Properties sysProps = System.getProperties(); List<String> jobPropsList = Lists.newArrayList(); List<String> sysPropsList = Lists.newArrayList(); for (Object key : jobProps.keySet()) { String propStr = key + "=" + jobProps.getProperty((String) key); if (sysProps.containsKey(key)) { sysPropsList.add("system: " + propStr); } else {/*from w ww . j a va 2 s . c om*/ jobPropsList.add(propStr); } } Collections.sort(jobPropsList); Collections.sort(sysPropsList); jobPropsList.addAll(sysPropsList); for (String prop : jobPropsList) { System.out.println(prop); } }