Example usage for java.util Properties isEmpty

List of usage examples for java.util Properties isEmpty

Introduction

In this page you can find the example usage for java.util Properties isEmpty.

Prototype

@Override
    public boolean isEmpty() 

Source Link

Usage

From source file:org.wso2.carbon.datasource.services.DataSourceAdminService.java

public OMElement getDataSourceInformation(String name) throws DataSourceManagementException {
    MiscellaneousHelper.validateName(name);
    try {//from w w  w . j a  v  a2s .co m
        DataSourceInformation information = dataSourceInformationManager.getDataSourceInformation(name);
        MiscellaneousHelper.validateDataSourceDescription(information);
        Properties properties = DataSourceInformationSerializer.serialize(information);
        if (properties.isEmpty()) {
            handleException("Empty Properties");
        }
        OMElement element = MiscellaneousHelper.createOMElement(properties);
        MiscellaneousHelper.validateElement(element);
        if (log.isDebugEnabled()) {
            log.debug("Returning a datasource : " + element);
        }
        return element;
    } catch (Exception e) {
        throw new DataSourceManagementException("Error loading a data source : " + e.getMessage(), e);
    }

}

From source file:org.biopax.psidev.ontology_manager.impl.OntologyManagerImpl.java

public void loadOntologies(Properties config) throws OntologyLoaderException {
    if (config != null && !config.isEmpty()) {
        for (Object ontId : config.keySet()) {
            String key = (String) ontId;
            try {
                URI uri = LOADER.getResource(config.getProperty(key)).getURI();
                log.info("Loading ontology: ID= " + ontId + ", uri=" + uri);
                OntologyAccess oa = fetchOntology(key, "OBO", uri);
                putOntology(key, oa);/*from   w  w  w . ja  v  a 2  s  . com*/
            } catch (Throwable e) { //using Throwable because StackOverflowError is also possible here
                throw new OntologyLoaderException(
                        "Failed loading/parsing ontology " + key + " from " + config.getProperty(key), e);
            }
        }
    } else {
        throw new OntologyLoaderException("OntologyAccess configuration map is missing or empty (map)!");
    }
}

From source file:org.jboss.bqt.framework.TestConfigPropertyLoader.java

/**
 * Tests {@link org.jboss.bqt.core.util.PropertiesUtils}
 * @throws Exception //from   w  ww . j a v a  2s. c  om
 */
@Test
public void test1() throws Exception {
    // add this step of removing the property because the order of
    // running is not guaranteed, and if this doesn't run first,
    // this property is set by other tests
    Properties props = System.getProperties();
    props.remove(ConfigPropertyNames.CONFIG_FILE);

    System.setProperties(props);

    System.setProperty("test", "value");

    ConfigPropertyLoader _instance = ConfigPropertyLoader.getInstance();
    Properties p = _instance.getProperties();
    assertNotNull(p);
    assertTrue(!p.isEmpty());

    assertEquals("value", p.getProperty("test")); //$NON-NLS-1$ //$NON-NLS-2$

    _instance.setProperty("override", "ovalue");

    assertEquals("ovalue", _instance.getProperty("override")); //$NON-NLS-1$ //$NON-NLS-2$

    // confirm the loader actually loaded the default-config.properties file
    assertEquals("driver", p.getProperty(ConfigPropertyNames.CONNECTION_TYPE)); //$NON-NLS-1$ //$NON-NLS-2$

    System.setProperty("username", "");

    ConfigPropertyLoader.reset();

    _instance = ConfigPropertyLoader.getInstance();
    p = _instance.getProperties();

    assertNull("should be null after reset", _instance.getProperties().getProperty("override"));

    assertEquals("failed to pickup system property", "value", p.getProperty("test")); //$NON-NLS-1$ //$NON-NLS-2$

    // confirm the loader actually loaded the default-config.properties file
    assertEquals("failed to correctly pickup the User ", "", _instance.getProperty("conn.user")); //$NON-NLS-1$ //$NON-NLS-2$

}

From source file:org.jahia.configuration.configurators.JahiaGlobalConfigurator.java

public static JahiaConfigInterface getConfiguration(File configFile, AbstractLogger logger)
        throws IOException, IllegalAccessException, InvocationTargetException {
    JahiaConfigBean config = new JahiaConfigBean();
    Properties props = null;
    if (configFile != null) {
        FileInputStream is = null;
        try {/*from  w  w  w.  j av  a  2 s.co m*/
            is = new FileInputStream(configFile);
            props = new Properties();
            props.load(is);
        } finally {
            IOUtils.closeQuietly(is);
        }
    }
    if (props != null && !props.isEmpty()) {
        new BeanUtilsBean(CONVERTER_UTILS_BEAN, new PropertyUtilsBean()).populate(config, props);
    }
    if (logger != null) {
        props.put("databasePassword", "***");
        props.put("jahiaRootPassword", "***");
        props.put("jahiaToolManagerPassword", "***");
        props.put("mailServer", "***");
        logger.info("Loaded configuration from file " + configFile + ":\n" + props);
    }
    return config;
}

From source file:org.jahia.modules.ugp.showcase.DbUserGroupProvider.java

private void filterQuery(Criteria query, Properties searchCriteria) {
    if (searchCriteria == null || searchCriteria.isEmpty()) {
        return;/*from   w w w.j  a  va 2  s  .  co  m*/
    }

    String v = StringUtils.defaultIfBlank(searchCriteria.getProperty("groupname"),
            searchCriteria.getProperty("*"));
    if (StringUtils.isNotEmpty(v) && !"*".equals(v)) {
        query.add(Restrictions.ilike("groupname", StringUtils.replace(v, "*", "%")));
    }
}

From source file:org.openxdata.server.OpenXDataPropertyPlaceholderConfigurer.java

void loadContextBasedProperties(Properties props) throws IOException {
    // only attempt to load new properties if properties could not be loaded
    // from default location
    if (servletContext != null && props.isEmpty()) {
        loadFromWebappFolder(props, PROPERTIES_FILENAME);
        loadFromEnvironmentVariable(props);
    }//from w w  w.  j  a  v  a2  s  . co m
}

From source file:lu.list.itis.dkd.aig.SimilarityProvider.java

/**
 * Method for initializing the semantic similarity bridge.
 *
 * @throws ExceptionInInitializerError/*w w w  .  j a v a  2  s .co  m*/
 *         Thrown when the initialization of the bridge failed. This is most likely due to
 *         either the connection to the knowledge base failing or the engine not properly
 *         initializing.
 */
private void instantiateSemanticSimilarityBridge() throws ExceptionInInitializerError {
    final Properties properties = PropertiesFetcher.getProperties();

    if (properties.isEmpty()) {
        throw new ExceptionInInitializerError("The properties file could not be located!"); //$NON-NLS-1$
    }

    //        semanticSimilarityBridge = new SemanticSimilarityBridge(
    //                        properties.getProperty(Externalization.ONTOLOGY_PROPERTY),
    //                        properties.getProperty(Externalization.GRAPH_PROPERTY),
    //                        properties.getProperty(Externalization.SERVER_ADDRESS_PROPERTY),
    //                        properties.getProperty(Externalization.SERVER_PASSWORD_PROPERTY),
    //                        properties.getProperty(Externalization.SERVER_PORT_PROPERTY),
    //                        properties.getProperty(Externalization.SERVER_USERNAME_PROPERTY),
    //                        properties.getProperty(Externalization.SIMILARTIY_ENGINE_TYPE_PROPERTY));
}

From source file:org.wso2.carbon.webapp.authenticator.framework.Utils.OAuthTokenValidationStubFactory.java

/**
 * Creates an instance of MultiThreadedHttpConnectionManager using HttpClient 3.x APIs
 *
 * @param properties Properties to configure MultiThreadedHttpConnectionManager
 * @return An instance of properly configured MultiThreadedHttpConnectionManager
 *//*from  ww w .j a v a2 s  . c  om*/
private HttpConnectionManager createConnectionManager(Properties properties) {
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    if (properties == null || properties.isEmpty()) {
        throw new IllegalArgumentException("Parameters required to initialize HttpClient instances "
                + "associated with OAuth token validation service stub are not provided");
    }
    String maxConnectionsPerHostParam = properties.getProperty("MaxConnectionsPerHost");
    if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, "
                    + "which is 2, will be used");
        }
    } else {
        params.setDefaultMaxConnectionsPerHost(Integer.parseInt(maxConnectionsPerHostParam));
    }

    String maxTotalConnectionsParam = properties.getProperty("MaxTotalConnections");
    if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, "
                    + "which is 10, will be used");
        }
    } else {
        params.setMaxTotalConnections(Integer.parseInt(maxTotalConnectionsParam));
    }
    HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    connectionManager.setParams(params);
    return connectionManager;
}

From source file:com.glaf.core.service.impl.MxSysDataServiceImpl.java

@Transactional
public void reload(String path) {
    File dir = new File(path);
    if (dir.exists() && dir.isDirectory()) {
        File contents[] = dir.listFiles();
        if (contents != null) {
            for (int i = 0; i < contents.length; i++) {
                if (contents[i].isFile() && contents[i].getName().endsWith(".properties")) {
                    try {
                        Properties props = PropertiesUtils.loadFilePathResource(contents[i]);
                        if (props != null && !props.isEmpty()) {
                            Enumeration<?> e = props.keys();
                            while (e.hasMoreElements()) {
                                String key = (String) e.nextElement();
                                if (this.getSysData(key) == null) {
                                    String value = props.getProperty(key);
                                    JSONObject json = JSON.parseObject(value);
                                    SysData model = SysDataJsonFactory.jsonToObject(json);
                                    model.setId(key);
                                    model.setCreateBy("system");
                                    model.setUpdateBy("system");
                                    this.save(model);
                                }/*from  w w  w . j  av a 2 s  . co  m*/
                            }
                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        logger.error(contents[i].getName() + " load error", ex);
                    }
                }
            }
        }
    }
}

From source file:lu.list.itis.dkd.aig.SimilarityProvider.java

/**
 * Constructor initialising the comparator from properties read from a properties file.
 *
 * @throws ExceptionInInitializerError//from w  w  w  .ja  v a  2  s  . co  m
 */
private SimilarityProvider() throws ExceptionInInitializerError {
    final Properties properties = PropertiesFetcher.getProperties();

    if (properties.isEmpty()) {
        throw new ExceptionInInitializerError("The properties file could not be located!"); //$NON-NLS-1$
    }

    useSemanticSimilarity = Boolean.parseBoolean(
            properties.getProperty(Externalization.SEMANTIC_SIMILARITY_PROPERTY, Externalization.FALSE_STRING));
    useStringSimilarity = Boolean.parseBoolean(
            properties.getProperty(Externalization.STRING_SIMILARITY_PROPERTY, Externalization.FALSE_STRING));
    useSoundexSimilarity = Boolean.parseBoolean(
            properties.getProperty(Externalization.SOUNDEX_SIMILARITY_PROPERTY, Externalization.FALSE_STRING));

    semanticSimilarityWeight = Float.parseFloat(properties
            .getProperty(Externalization.SEMANTIC_SIMILARITY_WEIGHT_PROPERTY, Externalization.ZERO_INTEGER));
    stringSimilarityWeight = Float.parseFloat(properties
            .getProperty(Externalization.STRING_SIMILARITY_WEIGHT_PROPERTY, Externalization.ZERO_INTEGER));
    soundexSimilarityWeight = Float.parseFloat(properties
            .getProperty(Externalization.SOUNDEX_SIMILARITY_WEIGHT_PROPERTY, Externalization.ZERO_INTEGER));

    if (useSemanticSimilarity) {
        throw new NotImplementedException("semantic similarity not yet available");
        //instantiateSemanticSimilarityBridge();
    }
}