Java Code Examples for java.util.Properties#isEmpty()
The following examples show how to use
java.util.Properties#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MMapURI.java From netbeans-mmd-plugin with Apache License 2.0 | 6 votes |
public MMapURI(@Nullable final File nullableBase, @Nonnull final File file, @Nullable final Properties nullableParameters) { this.fileUriFlag = true; this.parameters = new Properties(); if (nullableParameters != null && !nullableParameters.isEmpty()) { this.parameters.putAll(nullableParameters); } final Path filePath = Paths.toPath(file); if (nullableBase == null) { this.uri = ModelUtils.toURI(filePath); } else { final Path basePath = Paths.toPath(nullableBase); if (basePath.isAbsolute()) { final Path path = filePath.startsWith(basePath) ? basePath.relativize(filePath) : filePath; this.uri = ModelUtils.toURI(path); } else { this.uri = ModelUtils.toURI(filePath); } } }
Example 2
Source File: SiteBotWrapper.java From drftpd with GNU General Public License v2.0 | 6 votes |
public void startPlugin() { Properties cfg = ConfigLoader.loadPluginConfig("irc.conf"); if (cfg.isEmpty()) { logger.debug("No configuration found for the SiteBot, skipping initialization"); return; } boolean isActivated = cfg.getProperty("activated").equalsIgnoreCase("true"); if (!isActivated) return; SiteBot bot = new SiteBot(""); new Thread(bot).start(); _bots.add(bot); if (cfg.getProperty("bot.multiple.enable").equalsIgnoreCase("true")) { StringTokenizer st = new StringTokenizer(cfg.getProperty("bot.multiple.directories")); while (st.hasMoreTokens()) { bot = new SiteBot(st.nextToken()); new Thread(bot).start(); _bots.add(bot); } } }
Example 3
Source File: KettleDatabaseRepositoryDatabaseDelegate.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void insertDatabaseAttributes( ObjectId idDatabase, Properties properties ) throws KettleException { if ( properties.isEmpty() ) { return; } Database db = repository.connectionDelegate.getDatabase(); boolean firstAttribute = true; Enumeration<Object> keys = properties.keys(); while ( keys.hasMoreElements() ) { String code = (String) keys.nextElement(); String attribute = (String) properties.get( code ); RowMetaAndData attributeData = createAttributeRow( idDatabase, code, attribute ); if ( firstAttribute ) { db.prepareInsert( attributeData.getRowMeta(), KettleDatabaseRepository.TABLE_R_DATABASE_ATTRIBUTE ); firstAttribute = false; } db.setValuesInsert( attributeData ); db.insertRow( db.getPrepStatementInsert(), true, false ); } db.executeAndClearBatch( db.getPrepStatementInsert() ); db.closeInsert(); }
Example 4
Source File: VersionUtils.java From DDMQ with Apache License 2.0 | 6 votes |
public static String getVersion() { if (StringUtils.isNotEmpty(version)) { return version; } Properties properties = new Properties(); try { properties.load(VersionUtils.class.getClassLoader().getResourceAsStream("carrera_producer_sdk_version.properties")); if (!properties.isEmpty()) { version = properties.getProperty("version"); } if (StringUtils.isEmpty(version)) { version = "java"; } }catch (Exception e) { version = "java"; } return version; }
Example 5
Source File: MailManager.java From entando-components with GNU Lesser General Public License v3.0 | 6 votes |
private boolean send(String text, String subject, String[] recipientsTo, String[] recipientsCc, String[] recipientsBcc, String senderCode, Properties attachmentFiles, String contentType) throws ApsSystemException { Transport bus = null; try { Session session = this.prepareSession(this.getConfig()); bus = this.prepareTransport(session, this.getConfig()); MimeMessage msg = this.prepareVoidMimeMessage(session, subject, recipientsTo, recipientsCc, recipientsBcc, senderCode); if (attachmentFiles == null || attachmentFiles.isEmpty()) { msg.setContent(text, contentType + "; charset=utf-8"); } else { Multipart multiPart = new MimeMultipart(); this.addBodyPart(text, contentType, multiPart); this.addAttachments(attachmentFiles, multiPart); msg.setContent(multiPart); } msg.saveChanges(); bus.send(msg); } catch (Throwable t) { throw new ApsSystemException("Error sending mail", t); } finally { closeTransport(bus); } return true; }
Example 6
Source File: ProductConfig.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ProductConfProps(Properties properties) { this(properties.getProperty("slot")); if (productModuleId != null) { properties.remove("slot"); } if (!properties.isEmpty()) { for (String key : properties.stringPropertyNames()) { this.miscProperties.setProperty(key, properties.getProperty(key)); } } }
Example 7
Source File: ConfigureNotifyKeyspaceEventsAction.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
private String getNotifyOptions(RedisConnection connection) { try { Properties config = connection.getConfig(CONFIG_NOTIFY_KEYSPACE_EVENTS); if (config.isEmpty()) { return ""; } return config.getProperty(config.stringPropertyNames().iterator().next()); } catch (InvalidDataAccessApiUsageException e) { throw new IllegalStateException( "Unable to configure Redis to keyspace notifications. See http://docs.spring.io/spring-session/docs/current/reference/html5/#api-redisoperationssessionrepository-sessiondestroyedevent", e); } }
Example 8
Source File: PoolPropertiesHelper.java From dal with Apache License 2.0 | 5 votes |
public String propertiesToString(Properties properties) { String result = null; try { if (properties != null && !properties.isEmpty()) { StringBuilder sb = new StringBuilder(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { sb.append(entry.getKey().toString() + "=" + entry.getValue().toString() + ","); } result = sb.substring(0, sb.length() - 1); } } catch (Throwable e) { } return result; }
Example 9
Source File: HandlerOfResources.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
/** * Updates a properties file using the SolrParams * * @param params * @param config * @throws IOException */ public static void updatePropertiesFile(SolrParams params, File config, List<String> disallowed) { // fix configuration properties Properties properties = new Properties(); Properties extraProperties = extractCustomProperties(params); try (FileInputStream configFile = new FileInputStream(config)) { properties.load(configFile); //Allow the properties to be overidden via url params if (extraProperties != null && !extraProperties.isEmpty()) { if (!allowedProperties(extraProperties, disallowed)) { throw new IllegalArgumentException("You are not permitted to update these properties."); } properties.putAll(extraProperties); } try (FileOutputStream fileOutputStream = new FileOutputStream(config)) { properties.store(fileOutputStream, "Generated from Solr"); } } // FileInputStream is closed catch (IOException e) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unabled to update properties file, "+e.getMessage()); } }
Example 10
Source File: QueryTestUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void createCache(Properties prop) { if (null != prop && !prop.isEmpty()) { cache = new CacheFactory(prop).create(); } else{ cache = new CacheFactory().create(); } }
Example 11
Source File: SystemPropertiesTestPlugin.java From seed with Mozilla Public License 2.0 | 5 votes |
private static synchronized void overrideProperties(TestContext testContext) { Properties overridingProperties = gatherSystemProperties(testContext); if (!overridingProperties.isEmpty()) { if (previousProperties != null) { throw new IllegalStateException("Attempt to override system properties concurrently"); } else { previousProperties = new HashMap<>(); for (String propertyName : overridingProperties.stringPropertyNames()) { previousProperties.put(propertyName, System.getProperty(propertyName)); System.setProperty(propertyName, overridingProperties.getProperty(propertyName)); } } } }
Example 12
Source File: CacheXmlGenerator.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void generate(final Properties props, String elementName) throws SAXException { if (props == null || props.isEmpty()) { return; } if (elementName != null) { handler.startElement("", elementName, elementName, EMPTY); } for (Iterator iter = props.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", NAME, "", name); handler.startElement("", PARAMETER, PARAMETER, atts); if (value instanceof String) { generate((String) value); } else if (value instanceof Declarable) { generate((Declarable) value); } else { // Ignore it } handler.endElement("", PARAMETER, PARAMETER); } if (elementName != null) { handler.endElement("", elementName, elementName); } }
Example 13
Source File: SolrITInitializer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
public static void initSingleSolrServer(String testClassName, Properties solrcoreProperties) throws Throwable { initSolrServers(0,testClassName,solrcoreProperties); JettySolrRunner jsr = jettyContainers.get(testClassName); CoreContainer coreContainer = jsr.getCoreContainer(); AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler) coreContainer.getMultiCoreHandler(); assertNotNull(coreAdminHandler); String[] extras = null; if ((solrcoreProperties != null) && !solrcoreProperties.isEmpty()) { int i = 0; extras = new String[solrcoreProperties.size()*2]; for (Map.Entry<Object, Object> prop:solrcoreProperties.entrySet()) { extras[i++] = "property."+prop.getKey(); extras[i++] = (String) prop.getValue(); } } defaultCore = createCoreUsingTemplate(coreContainer, coreAdminHandler, "alfresco", "rerank", 1, 1, extras); assertNotNull(defaultCore); String url = buildUrl(jsr.getLocalPort()) + "/" + "alfresco"; SolrClient standaloneClient = createNewSolrClient(url); assertNotNull(standaloneClient); solrCollectionNameToStandaloneClient.put("alfresco", standaloneClient); }
Example 14
Source File: AutoModuleProxy.java From phoenix.webui.framework with Apache License 2.0 | 5 votes |
/** * 加载sessionStorage信息 * @param accountNameValue * @return */ private boolean loadSessionStorage(String accountNameValue, Map<String, String> customMap) { WebDriver webDriver = util.getEngine().getDriver(); if(webDriver instanceof WebStorage) { WebStorage webStorage = (WebStorage) webDriver; SessionStorage sessionStorage = webStorage.getSessionStorage(); Properties pro = new Properties(); if(PathUtil.proLoad(pro, "sessionStorage." + accountNameValue)) { if(pro.isEmpty()) { return false; } pro.putAll(customMap); pro.stringPropertyNames().parallelStream().forEach((key) -> { sessionStorage.setItem(key, pro.getProperty(key)); }); return true; } } return false; }
Example 15
Source File: Options.java From minie with GNU General Public License v3.0 | 5 votes |
/** Load options from the configuration file*/ public void setOptions(InputStream optionsStream) throws IOException { Properties prop = new Properties(); prop.load(optionsStream); // load the required options conservativeSVA = Boolean.parseBoolean(getProperty(prop, "conservativeSVA")); conservativeSVOA = Boolean.parseBoolean(getProperty(prop, "conservativeSVOA")); processCcAllVerbs = Boolean.parseBoolean(getProperty(prop, "processCcAllVerbs")); processCcNonVerbs = Boolean.parseBoolean(getProperty(prop, "processCcNonVerbs")); processAppositions = Boolean.parseBoolean(getProperty(prop, "processAppositions")); appositionVerb = getProperty(prop, "appositionVerb"); processPossessives = Boolean.parseBoolean(getProperty(prop, "processPossessives")); possessiveVerb = getProperty(prop, "possessiveVerb"); processPartmods = Boolean.parseBoolean(getProperty(prop, "processPartmods")); lemmatize = Boolean.parseBoolean(getProperty(prop, "lemmatize")); nary = Boolean.parseBoolean(getProperty(prop, "nary")); minOptionalArgs = Integer.parseInt(getProperty(prop, "minOptionalArgs")); maxOptionalArgs = Integer.parseInt(getProperty(prop, "maxOptionalArgs")); // get dictionaries dictCopular = getDictionary(prop, "dictCopular"); dictExtCopular = getDictionary(prop, "dictExtCopular"); dictNotExtCopular = getDictionary(prop, "dictNotExtCopular"); dictComplexTransitive = getDictionary(prop, "dictComplexTransitive"); dictAdverbsConj = getDictionary(prop, "dictAdverbsConj"); dictAdverbsIgnore = getDictionary(prop, "dictAdverbsIgnore"); dictAdverbsInclude = getDictionary(prop, "dictAdverbsInclude"); // check for unused properties if (!prop.isEmpty()) { System.err.println( "Unknown option(s): " + Arrays.toString( prop.keySet().toArray() )); } }
Example 16
Source File: FreeMarkerConfigurationFactory.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Prepare the FreeMarker Configuration and return it. * @return the FreeMarker Configuration object * @throws IOException if the config file wasn't found * @throws TemplateException on FreeMarker initialization failure */ public Configuration createConfiguration() throws IOException, TemplateException { Configuration config = newConfiguration(); Properties props = new Properties(); // Load config file if specified. if (this.configLocation != null) { if (logger.isInfoEnabled()) { logger.info("Loading FreeMarker configuration from " + this.configLocation); } PropertiesLoaderUtils.fillProperties(props, this.configLocation); } // Merge local properties if specified. if (this.freemarkerSettings != null) { props.putAll(this.freemarkerSettings); } // FreeMarker will only accept known keys in its setSettings and // setAllSharedVariables methods. if (!props.isEmpty()) { config.setSettings(props); } if (!CollectionUtils.isEmpty(this.freemarkerVariables)) { config.setAllSharedVariables(new SimpleHash(this.freemarkerVariables, config.getObjectWrapper())); } if (this.defaultEncoding != null) { config.setDefaultEncoding(this.defaultEncoding); } List<TemplateLoader> templateLoaders = new LinkedList<TemplateLoader>(this.templateLoaders); // Register template loaders that are supposed to kick in early. if (this.preTemplateLoaders != null) { templateLoaders.addAll(this.preTemplateLoaders); } // Register default template loaders. if (this.templateLoaderPaths != null) { for (String path : this.templateLoaderPaths) { templateLoaders.add(getTemplateLoaderForPath(path)); } } postProcessTemplateLoaders(templateLoaders); // Register template loaders that are supposed to kick in late. if (this.postTemplateLoaders != null) { templateLoaders.addAll(this.postTemplateLoaders); } TemplateLoader loader = getAggregateTemplateLoader(templateLoaders); if (loader != null) { config.setTemplateLoader(loader); } postProcessConfiguration(config); return config; }
Example 17
Source File: TeiidServer.java From teiid-spring-boot with Apache License 2.0 | 4 votes |
private ModelMetaData buildModelFromDataSource(VDBMetaData vdb, String dsBeanName, String driverName, ApplicationContext context, boolean createInitTable) throws AdminException { ModelMetaData model = new ModelMetaData(); model.setName(dsBeanName); model.setModelType(Model.Type.PHYSICAL); // note these can be overridden by specific ones in the configuration // TODO: need come up most sensible properties for this. model.addProperty("importer.useQualifiedName", "false"); model.addProperty("importer.tableTypes", "TABLE,VIEW"); SourceMappingMetadata source = new SourceMappingMetadata(); source.setName(dsBeanName); source.setConnectionJndiName(dsBeanName); ExternalSource es = this.externalSources.findByDriverName(driverName); source.setTranslatorName(es.getTranslatorName()); String dialect = es.getDialect(); if (dialect != null) { model.addProperty(DIALECT, dialect); } // load the translator class addTranslator(es, context); Properties overrideProperties = getTranslatorProperties(context, source.getTranslatorName(), dsBeanName, TranlatorPropertyType.OVERRIDE, new String[] { es.getSpringBootPropertyPrefix(), "spring.datasource", "spring.xa.datasource" }); if (!overrideProperties.isEmpty()) { source.setTranslatorName(dsBeanName); VDBTranslatorMetaData t = new VDBTranslatorMetaData(); t.setName(dsBeanName); t.setType(es.getTranslatorName()); t.setProperties(overrideProperties); vdb.addOverideTranslator(t); } // add the importer properties from the configuration // note that above defaults can be overridden with this too. Properties importProperties = getTranslatorProperties(context, source.getTranslatorName(), dsBeanName, TranlatorPropertyType.IMPORT, new String[] { es.getSpringBootPropertyPrefix(), "spring.datasource", "spring.xa.datasource" }); for (String k : importProperties.stringPropertyNames()) { model.addProperty(k, importProperties.getProperty(k)); } model.addSourceMapping(source); // This is to avoid failing on empty schema if (createInitTable) { model.addSourceMetadata("NATIVE", ""); model.addSourceMetadata("DDL", "create foreign table dual(id integer);"); } return model; }
Example 18
Source File: TrackerConfigStore.java From TNT4J with Apache License 2.0 | 4 votes |
/** * Load configuration resources from a reader. * * @param reader * configuration reader * @return map of keys and associated properties * * @throws IOException * if I/O error occurs while reading configuration */ private Map<String, Properties> loadConfigResource(BufferedReader reader) throws IOException { Map<String, Properties> map = new LinkedHashMap<>(111); Properties config = null; do { config = readStanza(reader); String key = config.getProperty(SOURCE_KEY); String like = config.getProperty(LIKE_KEY); String include = config.getProperty(IMPORT_KEY); String includePath = config.getProperty(IMPORT_PATH); String enabled = config.getProperty(ENABLED_KEY); if (enabled != null && enabled.equalsIgnoreCase("true")) { logger.log(OpLevel.WARNING, "Disabling properties for source={0}, like={1}, enabled={2}", key, like, enabled); continue; } if (include != null) { // parse and process a comma separated list of "import" elements String[] incList = include.split(","); for (String includeFile : incList) { includeFile = getConfigFromPath(includePath, includeFile); map.putAll(loadConfiguration(includeFile)); logger.log(OpLevel.DEBUG, "Import configuration source={0}, config.file={1}, import.file={2}, map.size={3}, tid={4}", key, configFile, includeFile, map.size(), Thread.currentThread().getId()); } } if (like != null) { // parse and process a comma separated list of "like" elements String[] likeList = like.split(","); Properties mergedConfig = new Properties(); for (String copyFromKey : likeList) { mergedConfig = copyConfig(key, copyFromKey, mergedConfig, map); logger.log(OpLevel.DEBUG, "Merge configuration source={0}, config.file={1}, like.source={2}, config.size={3}, tid={4}", key, configFile, copyFromKey, mergedConfig.size(), Thread.currentThread().getId()); } config = mergeConfig(key, config, mergedConfig); } if (key != null) { map.put(key, config); } } while (!config.isEmpty()); return map; }
Example 19
Source File: GenerateTestPlanCommand.java From testgrid with Apache License 2.0 | 4 votes |
/** * Generates a set of {@link org.wso2.testgrid.common.TestPlan}s from the {@link TestgridYaml}. * Here, we generate a TestPlan: * for-each Infrastructure-Provisioner/Deployment-Pattern, for-each infrastructure combination. * * @param infrastructureCombinations Set of infrastructure combination from which test-plans will be generated. * @param testgridYaml The testgrid.yaml configuration file's object model. * @return list of test-plans that instructs how a test-run need to be executed. */ private List<TestPlan> generateTestPlans(Set<InfrastructureCombination> infrastructureCombinations, TestgridYaml testgridYaml) { List<TestPlan> testConfigurations = new ArrayList<>(); List<Provisioner> provisioners = testgridYaml.getInfrastructureConfig() .getProvisioners(); for (Provisioner provisioner : provisioners) { Optional<DeploymentConfig.DeploymentPattern> deploymentPattern = getMatchingDeploymentPatternFor( provisioner, testgridYaml); for (InfrastructureCombination combination : infrastructureCombinations) { Provisioner provisioner1 = provisioner.clone(); setUniqueNamesFor(provisioner1.getScripts()); TestPlan testPlan = new TestPlan(); testPlan.setInfrastructureConfig(testgridYaml.getInfrastructureConfig().clone()); testPlan.getInfrastructureConfig().setProvisioners(Collections.singletonList(provisioner1)); Properties configAwareInfraCombination = toConfigAwareInfrastructureCombination( combination.getParameters()); testPlan.getInfrastructureConfig().setParameters(configAwareInfraCombination); deploymentPattern.ifPresent(LambdaExceptionUtils.rethrowConsumer(dp -> { setUniqueNamesFor(dp.getScripts()); testPlan.setDeploymentConfig(new DeploymentConfig(Collections.singletonList(dp))); try { testPlan.setId(TestGridUtil.deriveTestPlanId(testPlan, combination, getDeploymentPattern(createOrReturnProduct(productName), dp.getName()))); } catch (CommandExecutionException e) { throw new CommandExecutionException(StringUtil .concatStrings("Error in generating test-plan id. Can not create/find " + "product by product-name " + productName), e); } })); Properties infrastructureProperties = new Properties(); for (InfrastructureParameter infraParam: combination.getParameters()) { //Add infra-param itself as a property. infrastructureProperties.setProperty(infraParam.getType(), infraParam.getName()); //Add sub-properties of infra-param also as properties. Properties subProperties = infraParam.getSubProperties(); if (subProperties != null && !subProperties.isEmpty()) { infrastructureProperties.putAll(infraParam.getSubProperties()); } } testPlan.setInfrastructureProperties(infrastructureProperties); testPlan.setScenarioConfigs(testgridYaml.getScenarioConfigs()); testPlan.setResultFormat(testgridYaml.getResultFormat()); testPlan.setInfrastructureRepository(testgridYaml.getInfrastructureRepository()); testPlan.setDeploymentRepository(testgridYaml.getDeploymentRepository()); testPlan.setScenarioTestsRepository(testgridYaml.getScenarioTestsRepository()); testPlan.setConfigChangeSetRepository(testgridYaml.getConfigChangeSetRepository()); testPlan.setConfigChangeSetBranchName(testgridYaml.getConfigChangeSetBranchName()); testConfigurations.add(testPlan); } } return testConfigurations; }
Example 20
Source File: FreeMarkerConfigurationFactory.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Prepare the FreeMarker Configuration and return it. * @return the FreeMarker Configuration object * @throws IOException if the config file wasn't found * @throws TemplateException on FreeMarker initialization failure */ public Configuration createConfiguration() throws IOException, TemplateException { Configuration config = newConfiguration(); Properties props = new Properties(); // Load config file if specified. if (this.configLocation != null) { if (logger.isInfoEnabled()) { logger.info("Loading FreeMarker configuration from " + this.configLocation); } PropertiesLoaderUtils.fillProperties(props, this.configLocation); } // Merge local properties if specified. if (this.freemarkerSettings != null) { props.putAll(this.freemarkerSettings); } // FreeMarker will only accept known keys in its setSettings and // setAllSharedVariables methods. if (!props.isEmpty()) { config.setSettings(props); } if (!CollectionUtils.isEmpty(this.freemarkerVariables)) { config.setAllSharedVariables(new SimpleHash(this.freemarkerVariables, config.getObjectWrapper())); } if (this.defaultEncoding != null) { config.setDefaultEncoding(this.defaultEncoding); } List<TemplateLoader> templateLoaders = new LinkedList<TemplateLoader>(this.templateLoaders); // Register template loaders that are supposed to kick in early. if (this.preTemplateLoaders != null) { templateLoaders.addAll(this.preTemplateLoaders); } // Register default template loaders. if (this.templateLoaderPaths != null) { for (String path : this.templateLoaderPaths) { templateLoaders.add(getTemplateLoaderForPath(path)); } } postProcessTemplateLoaders(templateLoaders); // Register template loaders that are supposed to kick in late. if (this.postTemplateLoaders != null) { templateLoaders.addAll(this.postTemplateLoaders); } TemplateLoader loader = getAggregateTemplateLoader(templateLoaders); if (loader != null) { config.setTemplateLoader(loader); } postProcessConfiguration(config); return config; }