Example usage for org.apache.solr.common StringUtils isEmpty

List of usage examples for org.apache.solr.common StringUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.solr.common StringUtils isEmpty.

Prototype

public static boolean isEmpty(String s) 

Source Link

Usage

From source file:de.qaware.chronix.solr.query.analysis.JoinFunction.java

License:Apache License

/**
 * The method checks if the filter queries contains a join filter query (join=field1,field2,field3).
 * If not, it returns a function with a default join key that uses the metric field.
 * Otherwise it uses the defined fields to build a join key field1-field2-field-3.
 *
 * @param joinFields - the chronix join parameter
 *///  ww  w .j av  a 2 s.c o  m
public JoinFunction(String joinFields) {
    if (StringUtils.isEmpty(joinFields)) {
        involvedFields = new String[] { ChronixQueryParams.DEFAULT_JOIN_FIELD_1,
                ChronixQueryParams.DEFAULT_JOIN_FIELD_2 };
    } else {
        involvedFields = joinFields.split(ChronixQueryParams.JOIN_SEPARATOR);
    }
}

From source file:de.qaware.chronix.solr.query.analysis.QueryEvaluator.java

License:Apache License

/**
 * Helper to check if the given string array is empty.
 * A string is empty if it is null, or ""
 *
 * @param fqs the string array/*  w  w  w . j  av a2 s.com*/
 * @return true if empty, otherwise false
 */

private static boolean isEmpty(String[] fqs) {
    if (fqs == null || fqs.length == 0) {
        return true;
    }

    for (String fq : fqs) {
        if (!StringUtils.isEmpty(fq)) {
            return false;
        }
    }
    return true;
}

From source file:org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.java

License:Apache License

public static String getModelJson(String fileName) throws IOException {
    final String userDir = System.getProperty("user.dir");
    String filePath = userDir + "/../addons/models/" + fileName;
    File f = new File(filePath);
    String s = FileUtils.readFileToString(f);
    Assert.assertFalse(StringUtils.isEmpty(s), "Model file read correctly!");

    return s;//from   w  ww  .  ja v  a 2  s  .  c om
}

From source file:org.apache.nifi.processors.solr.TestPutSolrContentStream.java

License:Apache License

@Test
public void testJAASClientAppNameValidation() {
    final TestRunner runner = TestRunners.newTestRunner(PutSolrContentStream.class);
    runner.setProperty(SolrUtils.SOLR_TYPE, SolrUtils.SOLR_TYPE_STANDARD.getValue());
    runner.setProperty(SolrUtils.SOLR_LOCATION, "http://localhost:8443/solr");
    runner.assertValid();//from   www .  j  a  va 2s .c o  m

    // clear the jaas config system property if it was set
    final String jaasConfig = System.getProperty(Krb5HttpClientConfigurer.LOGIN_CONFIG_PROP);
    if (!StringUtils.isEmpty(jaasConfig)) {
        System.clearProperty(Krb5HttpClientConfigurer.LOGIN_CONFIG_PROP);
    }

    // should be invalid if we have a client name but not config file
    runner.setProperty(SolrUtils.JAAS_CLIENT_APP_NAME, "Client");
    runner.assertNotValid();

    // should be invalid if we have a client name that is not in the config file
    final File jaasConfigFile = new File("src/test/resources/jaas-client.conf");
    System.setProperty(Krb5HttpClientConfigurer.LOGIN_CONFIG_PROP, jaasConfigFile.getAbsolutePath());
    runner.assertNotValid();

    // should be valid now that the name matches up with the config file
    runner.setProperty(SolrUtils.JAAS_CLIENT_APP_NAME, "SolrJClient");
    runner.assertValid();
}

From source file:org.apache.ranger.patch.cliutil.ChangePasswordUtil.java

License:Apache License

public static void main(String[] args) {
    logger.info("main()");
    try {/*from w ww  . ja  va 2 s.  c om*/
        ChangePasswordUtil loader = (ChangePasswordUtil) CLIUtil.getBean(ChangePasswordUtil.class);
        loader.init();
        if (args.length == 3) {
            userLoginId = args[0];
            currentPassword = args[1];
            newPassword = args[2];
            if (StringUtils.isEmpty(userLoginId)) {
                System.out.println("Invalid login ID. Exiting!!!");
                logger.info("Invalid login ID. Exiting!!!");
                System.exit(1);
            }
            if (StringUtils.isEmpty(currentPassword)) {
                System.out.println("Invalid current password. Exiting!!!");
                logger.info("Invalid current password. Exiting!!!");
                System.exit(1);
            }
            if (StringUtils.isEmpty(newPassword)) {
                System.out.println("Invalid new password. Exiting!!!");
                logger.info("Invalid new password. Exiting!!!");
                System.exit(1);
            }
            while (loader.isMoreToProcess()) {
                loader.load();
            }
            logger.info("Load complete. Exiting!!!");
            System.exit(0);
        } else {
            System.out.println(
                    "ChangePasswordUtil: Incorrect Arguments \n Usage: \n <loginId> <current-password> <new-password>");
            logger.error(
                    "ChangePasswordUtil: Incorrect Arguments \n Usage: \n <loginId> <current-password> <new-password>");
            System.exit(1);
        }
    } catch (Exception e) {
        logger.error("Error loading", e);
        System.exit(1);
    }
}

From source file:org.apache.ranger.patch.cliutil.ChangeUserNameUtil.java

License:Apache License

public static void main(String[] args) {
    logger.info("main()");
    try {//from  w ww. j a  v  a 2s .  c  om
        ChangeUserNameUtil loader = (ChangeUserNameUtil) CLIUtil.getBean(ChangeUserNameUtil.class);
        loader.init();
        if (args.length == 3) {
            userLoginId = args[0];
            currentPassword = args[1];
            newUserName = args[2];
            if (StringUtils.isEmpty(userLoginId)) {
                System.out.println("Invalid login ID. Exiting!!!");
                logger.info("Invalid login ID. Exiting!!!");
                System.exit(1);
            }
            if (StringUtils.isEmpty(currentPassword)) {
                System.out.println("Invalid current password. Exiting!!!");
                logger.info("Invalid current password. Exiting!!!");
                System.exit(1);
            }
            if (StringUtils.isEmpty(newUserName)) {
                System.out.println("Invalid new user name. Exiting!!!");
                logger.info("Invalid new user name. Exiting!!!");
                System.exit(1);
            }
            while (loader.isMoreToProcess()) {
                loader.load();
            }
            logger.info("Load complete. Exiting!!!");
            System.exit(0);
        } else {
            System.out.println(
                    "ChangeUserNameUtil: Incorrect Arguments \n Usage: \n <loginId> <current-password> <new-username>");
            logger.error(
                    "ChangeUserNameUtil: Incorrect Arguments \n Usage: \n <loginId> <current-password> <new-username>");
            System.exit(1);
        }
    } catch (Exception e) {
        logger.error("Error loading", e);
        System.exit(1);
    }
}