List of usage examples for java.util Properties isEmpty
@Override public boolean isEmpty()
From source file:org.ngrinder.infra.config.Config.java
/** * Load system related properties. (system.conf) *//* w w w. j a v a 2 s . c o m*/ public synchronized void loadProperties() { Properties properties = checkNotNull(home).getProperties("system.conf"); properties.put("NGRINDER_HOME", home.getDirectory().getAbsolutePath()); if (exHome.exists()) { Properties exProperties = exHome.getProperties("system-ex.conf"); if (exProperties.isEmpty()) { exProperties = exHome.getProperties("system.conf"); } properties.putAll(exProperties); } properties.putAll(System.getProperties()); // Override if exists controllerProperties = new PropertiesWrapper(properties, controllerPropertiesKeyMapper); clusterProperties = new PropertiesWrapper(properties, clusterPropertiesKeyMapper); }
From source file:org.jboss.jbossset.CommandLineParser.java
private Map<String, String> getValidDomains(CommandLine cmd) throws ParseException { Properties properties = new Properties(); if (cmd.hasOption("domainFile")) { String url = cmd.getOptionValue("domainFile"); File file = new File(url); if (!file.exists()) throw new ParseException("The specified file does not exist"); try (InputStream in = new FileInputStream(file)) { properties.load(in);/*w w w.ja va 2s.c om*/ } catch (IOException e) { throw new ParseException(e.getMessage() + ": " + e.getCause()); } if (properties.isEmpty()) throw new ParseException("The specified file does not contain any domain pairs"); } else { try (InputStream in = JiraReporter.class.getClassLoader().getResourceAsStream("domains")) { properties.load(in); } catch (IOException e) { throw new ParseException("Default domains file could not be read: " + e); } } @SuppressWarnings("unchecked") Map<String, String> map = (Map) properties; return map; }
From source file:org.artifactory.storage.db.build.service.BuildStoreServiceImpl.java
private Set<BuildProperty> createProperties(long buildId, Build build) { Properties properties = build.getProperties(); Set<BuildProperty> buildProperties; if (properties != null && !properties.isEmpty()) { buildProperties = new HashSet<>(properties.size()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { buildProperties.add(new BuildProperty(dbService.nextId(), buildId, entry.getKey().toString(), entry.getValue().toString())); }//from w ww .ja v a2s .co m } else { buildProperties = new HashSet<>(1); } return buildProperties; }
From source file:com.wabacus.config.ConfigLoadManager.java
public static Map convertPropertiesToResources(Properties props) { Map mResults = new HashMap(); if (props == null || props.isEmpty()) { return null; }//from w ww. ja v a2 s . co m Iterator itKeys = props.keySet().iterator(); while (itKeys.hasNext()) { String key = (String) itKeys.next(); String value = (String) props.get(key); // try // e.printStackTrace(); if (mResults.containsKey(key)) { throw new WabacusConfigLoadingException( "??key" + key + "???"); } mResults.put(key, value); } return mResults; }
From source file:com.ibm.watson.app.common.codegen.languages.WatsonAppJaxRSServerCodegen.java
private Properties loadConfiguration() { final Properties config = new Properties(); // First, try the system property final String configFilename = System.getProperty(CONFIG_FILE_SYS_PROP); if (configFilename != null) { try (InputStream is = new FileInputStream(new File(configFilename))) { config.load(is);//from www.j av a 2s. c o m System.out.println("Loaded configuration from: " + configFilename); } catch (IOException e) { System.err.println("Unable to read configuration file '" + configFilename + "', attempting to load from classpath"); } } if (config.isEmpty()) { try (InputStream is = getClass().getClassLoader().getResourceAsStream(CONFIG_FILE_CLASSPATH_NAME)) { if (is != null) { config.load(is); } } catch (IOException e) { System.err.println("Unable to read configuration file '" + CONFIG_FILE_CLASSPATH_NAME + "' from classpath, using defaults"); } } return config; }
From source file:com.erudika.scoold.utils.LanguageUtils.java
private Map<String, String> readLanguageFromFile(String langCode) { if (langCode != null) { Properties lang = new Properties(); String file = "lang_" + langCode.toLowerCase() + ".properties"; InputStream ins = null;/*from w ww . j av a2 s. c om*/ try { ins = LanguageUtils.class.getClassLoader().getResourceAsStream(file); if (ins != null) { lang.load(ins); if (!lang.isEmpty()) { int progress = 0; Map<String, String> langmap = new TreeMap<String, String>(); for (String propKey : lang.stringPropertyNames()) { String propVal = lang.getProperty(propKey); if (!langCode.equalsIgnoreCase(getDefaultLanguageCode())) { String defaultVal = getDefaultLanguage().get(propKey); if (!StringUtils.isBlank(propVal) && !StringUtils.equalsIgnoreCase(propVal, defaultVal)) { progress++; } } langmap.put(propKey, propVal); } if (langCode.equalsIgnoreCase(getDefaultLanguageCode())) { progress = langmap.size(); // 100% } if (progress > 0) { updateTranslationProgressMap(langCode, progress); } return langmap; } } } catch (Exception e) { logger.info("Could not read language file " + file + ": ", e); } finally { try { if (ins != null) { ins.close(); } } catch (IOException ex) { logger.error(null, ex); } } } return null; }
From source file:org.rhq.modules.plugins.wildfly10.BaseProcessDiscovery.java
private void setUserAndPasswordPluginConfigProps(ServerPluginConfiguration serverPluginConfig, HostConfiguration hostConfig) {//from w w w . ja v a2 s .co m Properties mgmtUsers = getManagementUsers(hostConfig, serverPluginConfig); String user; String password; if (!mgmtUsers.isEmpty()) { if (mgmtUsers.containsKey(RHQADMIN)) { user = RHQADMIN; String encryptedPassword = mgmtUsers.getProperty(user); if (RHQADMIN_ENCRYPTED.equals(encryptedPassword)) { // If the password is "rhqadmin" encrypted, set the "password" prop to "rhqadmin". password = RHQADMIN; } else { password = null; } } else { // No "rhqadmin" user is defined - just grab an arbitrary user. user = (String) mgmtUsers.keySet().iterator().next(); // Note, we don't set the "password" prop, since the password we've read from mgmt-users.properties is // encrypted, and we need to return an unencrypted value. password = null; } } else { // Either no users are defined, or we failed to read the mgmt-users.properties file - default both user and // password to "rhqadmin", so that if the end user runs the "createRhqUser" operation, their conn props will // already be ready to go. user = RHQADMIN; password = RHQADMIN; } serverPluginConfig.setUser(user); serverPluginConfig.setPassword(password); }
From source file:org.sakaiproject.mailarchive.entityprovider.MailArchiveEntityProvider.java
/** * Helper to get the channels for a site. * <p>/*from w ww. j av a 2 s.c om*/ * If user site and not superuser, returns all available channels for this * user.<br /> * * @param siteId * @return */ private List<String> getChannels(String siteId) { List<String> channels = new ArrayList<String>(); Site site = null; try { site = siteService.getSite(siteId); } catch (IdUnusedException e) { // this should have been caught and dealt with already so just // return empty list return channels; } if (site != null) { ToolConfiguration toolConfig = site.getToolForCommonId("sakai.mailbox"); if (toolConfig != null) { Properties props = toolConfig.getPlacementConfig(); if (props.isEmpty()) { props = toolConfig.getConfig(); } if (props != null) { channels = Collections .singletonList(mailArchiveService.channelReference(siteId, SiteService.MAIN_CONTAINER)); } } } return channels; }
From source file:org.artifactory.storage.db.build.service.BuildStoreServiceImpl.java
private void insertModules(long buildId, Build build) throws SQLException { List<Module> modules = build.getModules(); if (modules == null || modules.isEmpty()) { // Nothing to do here return;/*from w w w.j a v a 2 s . c om*/ } for (Module module : modules) { BuildModule dbModule = new BuildModule(dbService.nextId(), buildId, module.getId()); Properties properties = module.getProperties(); Set<ModuleProperty> moduleProperties; if (properties != null && !properties.isEmpty()) { moduleProperties = Sets.newHashSetWithExpectedSize(properties.size()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { moduleProperties.add(new ModuleProperty(dbService.nextId(), dbModule.getModuleId(), entry.getKey().toString(), entry.getValue().toString())); } } else { moduleProperties = Sets.newHashSetWithExpectedSize(1); } dbModule.setProperties(moduleProperties); buildModulesDao.createBuildModule(dbModule); List<Artifact> artifacts = module.getArtifacts(); List<BuildArtifact> dbArtifacts; if (artifacts != null && !artifacts.isEmpty()) { dbArtifacts = Lists.newArrayListWithExpectedSize(artifacts.size()); for (Artifact artifact : artifacts) { // Artifact properties are not inserted in DB dbArtifacts.add(new BuildArtifact(dbService.nextId(), dbModule.getModuleId(), artifact.getName(), artifact.getType(), artifact.getSha1(), artifact.getMd5())); } } else { dbArtifacts = Lists.newArrayListWithExpectedSize(1); } buildArtifactsDao.createBuildArtifacts(dbArtifacts); List<Dependency> dependencies = module.getDependencies(); List<BuildDependency> dbDependencies; if (dependencies != null && !dependencies.isEmpty()) { dbDependencies = Lists.newArrayListWithExpectedSize(dependencies.size()); for (Dependency dependency : dependencies) { // Dependency properties are not inserted in DB dbDependencies.add(new BuildDependency(dbService.nextId(), dbModule.getModuleId(), dependency.getId(), dependency.getScopes(), dependency.getType(), dependency.getSha1(), dependency.getMd5())); } } else { dbDependencies = Lists.newArrayListWithExpectedSize(1); } buildDependenciesDao.createBuildDependencies(dbDependencies); } }