Example usage for org.apache.commons.lang StringUtils containsIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils containsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils containsIgnoreCase.

Prototype

public static boolean containsIgnoreCase(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String irrespective of case, handling null.

Usage

From source file:nl.nn.adapterframework.webcontrol.ConfigurationServlet.java

private void setDefaultApplicationServerType(IbisContext ibisContext) {
    ServletContext context = getServletContext();
    String serverInfo = context.getServerInfo();
    String defaultApplicationServerType = null;
    if (StringUtils.containsIgnoreCase(serverInfo, "WebSphere Liberty")) {
        defaultApplicationServerType = "WLP";
    } else if (StringUtils.containsIgnoreCase(serverInfo, "WebSphere")) {
        defaultApplicationServerType = "WAS";
    } else if (StringUtils.containsIgnoreCase(serverInfo, "Tomcat")) {
        defaultApplicationServerType = "TOMCAT";
    } else if (StringUtils.containsIgnoreCase(serverInfo, "JBoss")) {
        defaultApplicationServerType = "JBOSS";
    } else if (StringUtils.containsIgnoreCase(serverInfo, "jetty")) {
        String javaHome = AppConstants.getInstance().getString("java.home", "");
        if (StringUtils.containsIgnoreCase(javaHome, "tibco")) {
            defaultApplicationServerType = "TIBCOAMX";
        } else {//from  w w w  . j a v a 2s.  c  o m
            defaultApplicationServerType = "JETTYMVN";
        }
    } else {
        ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
        configWarnings.add(log, "Unknown server info [" + serverInfo
                + "] default application server type could not be determined, TOMCAT will be used as default value");
        defaultApplicationServerType = "TOMCAT";
    }
    ibisContext.setDefaultApplicationServerType(defaultApplicationServerType);
}

From source file:nl.strohalm.cyclos.utils.FormatObject.java

/**
 * Returns whether the given name is in the {@link #DEFAULT_EXCLUDES} array
 *//*www.j  a  v  a  2  s  .c  o  m*/
public static boolean shouldMask(final String name) {
    for (final String exclude : FormatObject.DEFAULT_EXCLUDES) {
        if (StringUtils.containsIgnoreCase(name, exclude)) {
            return true;
        }
    }
    return false;
}

From source file:nl.strohalm.cyclos.utils.FormatObject.java

private static boolean exclude(final List<String> list, final String string) {
    if (CollectionUtils.isEmpty(list)) {
        return false;
    }//  ww  w  .  j  a va 2 s.co  m
    for (final String exclude : list) {
        if (StringUtils.containsIgnoreCase(string, exclude)) {
            return true;
        }
    }
    return false;
}

From source file:nlp.wikipedia.lang.EnConfig.java

public static boolean matchStub(String text) {
    Matcher matcher = templateContent.matcher(text);
    while (matcher.find()) {
        String templateContent = matcher.group(1);
        if (StringUtils.containsIgnoreCase("stub", text))
            return true;
    }//w w w.java2s.  co m

    return false;
}

From source file:org.agric.oxm.utils.JpaUtils.java

/**
 * Add order by clause to queryString/*from w  ww  .  j a v a2 s  . co  m*/
 * 
 * @param queryString
 *            JPL Query String
 * @param propertyPath
 *            Order properti
 * @param asc
 *            true if ascending
 * @return JQL Query String with Order clause appened.
 */
public static String addOrder(String queryString, String propertyPath, boolean asc) {

    if (StringUtils.containsIgnoreCase(queryString, "order by")) {
        return queryString;
    }

    StringBuilder sb = new StringBuilder(queryString);
    sb.append(" ORDER BY ");
    sb.append(getAlias(queryString));
    sb.append(".");
    sb.append(propertyPath);
    sb.append(" ");
    sb.append(asc ? "ASC" : "DESC");

    return sb.toString();
}

From source file:org.andromda.dbtest.H2.java

/**
 * @param url// www. j  a v a  2  s.com
 * @param sqlFile
 */
public static void initDb(String url, String sqlFile) //throws SQLException, ClassNotFoundException
{
    long now = System.currentTimeMillis();
    try {
        Class.forName("org.h2.Driver");
        // IF there are any errors in SQL Files, the connection throws an Exception
        List<String> sqls = new ArrayList<String>();
        if (StringUtils.isNotBlank(sqlFile)) {
            // List of files separated by ; will be appended to URL and executed
            String[] files = StringUtils.split(sqlFile, ';');
            // Files contain SQL statements separated by ;
            if (files.length > 0) {
                for (int i = 0; i < files.length; i++) {
                    LOGGER.info("Parsing SQL file " + files[i]);
                    sqls.addAll(fileToStrings(files[i], ';'));
                    /*if (i==0)
                    {
                    url += ";INIT=";
                    }
                    else
                    {
                    // Separator for multiple files in the same init command
                    url += "\\;";
                    }
                    url += "RUNSCRIPT FROM '" + files[i] + "'";*/
                }
            }
        }
        // Starts H2, allowing TCP connections also, to jdbc:h2:tcp://localhost/${sql.database}
        // Must use id/password with embedded persisted mode
        Connection conn = DriverManager.getConnection(url, "sa", "sa");
        LOGGER.info("Connected to DB " + url + "\r in " + (System.currentTimeMillis() - now) + " ms");
        long now1 = System.currentTimeMillis();
        Statement stat = conn.createStatement();
        int stmtCount = 0;
        int successfulCount = 0;
        for (String sql : sqls) {
            if (StringUtils.isNotBlank(sql)) {
                stmtCount++;
                boolean resultSet = false;
                try {
                    resultSet = stat.execute(sql);
                    if (resultSet) {
                        ResultSet rset = stat.getResultSet();
                        LOGGER.info(sql + ";\r" + "ResultSet: " + rset + "\r");
                        try {
                            rset.close();
                        } catch (Exception e) {
                            LOGGER.error(e);
                        }
                    } else if (stat.getUpdateCount() > 0) {
                        LOGGER.info(sql + ";\r" + "Updated rows: " + stat.getUpdateCount() + "\r");
                    } else if (StringUtils.containsIgnoreCase(sql, "INSERT INTO ")
                            || StringUtils.containsIgnoreCase(sql, "UPDATE ")
                            || StringUtils.containsIgnoreCase(sql, "DELETE ")) {
                        LOGGER.info(sql + ";\rExecuted Successfully, no update or result\r");
                    } else {
                        LOGGER.info(sql + ";\rExecuted Successfully\r");
                    }
                    successfulCount++;
                } catch (SQLException e) {
                    LOGGER.error(e);
                }
            }
        }
        LOGGER.info("Executed " + successfulCount + " out of " + stmtCount + " sql statements in "
                + (System.currentTimeMillis() - now1) + " ms, total time = "
                + (System.currentTimeMillis() - now) + " ms");
        // Keep in-memory DB connection open after executing SQL statements
        int i = 1;
        while (i > 0) {
            // There is no Daemon option when starting DB through connection, just have to go into an infinite loop
        }
    } catch (IOException e) {
        LOGGER.error(e);
    } catch (ClassNotFoundException e) {
        LOGGER.error(e);
    } catch (SQLException e) {
        LOGGER.error(e);
    }
}

From source file:org.apache.geode.management.internal.cli.commands.QueryCommand.java

private DataCommandResult select(String query) {
    InternalCache cache = (InternalCache) CacheFactory.getAnyInstance();
    DataCommandResult dataResult;/*from   ww w .j ava  2  s.c  om*/

    if (StringUtils.isEmpty(query)) {
        dataResult = DataCommandResult.createSelectInfoResult(null, null, -1, null,
                CliStrings.QUERY__MSG__QUERY_EMPTY, false);
        return dataResult;
    }

    boolean limitAdded = false;

    if (!StringUtils.containsIgnoreCase(query, " limit") && !StringUtils.containsIgnoreCase(query, " count(")) {
        query = query + " limit " + CommandExecutionContext.getShellFetchSize();
        limitAdded = true;
    }

    @SuppressWarnings("deprecation")
    QCompiler compiler = new QCompiler();
    Set<String> regionsInQuery;
    try {
        CompiledValue compiledQuery = compiler.compileQuery(query);
        Set<String> regions = new HashSet<>();
        compiledQuery.getRegionsInQuery(regions, null);

        // authorize data read on these regions
        for (String region : regions) {
            cache.getSecurityService().authorize(Resource.DATA, Operation.READ, region);
        }

        regionsInQuery = Collections.unmodifiableSet(regions);
        if (regionsInQuery.size() > 0) {
            Set<DistributedMember> members = DataCommandsUtils.getQueryRegionsAssociatedMembers(regionsInQuery,
                    cache, false);
            if (members != null && members.size() > 0) {
                DataCommandFunction function = new DataCommandFunction();
                DataCommandRequest request = new DataCommandRequest();
                request.setCommand(CliStrings.QUERY);
                request.setQuery(query);
                Subject subject = cache.getSecurityService().getSubject();
                if (subject != null) {
                    request.setPrincipal(subject.getPrincipal());
                }
                dataResult = callFunctionForRegion(request, function, members);
                dataResult.setInputQuery(query);
                if (limitAdded) {
                    dataResult.setLimit(CommandExecutionContext.getShellFetchSize());
                }
                return dataResult;
            } else {
                return DataCommandResult.createSelectInfoResult(null, null, -1, null,
                        CliStrings.format(CliStrings.QUERY__MSG__REGIONS_NOT_FOUND, regionsInQuery.toString()),
                        false);
            }
        } else {
            return DataCommandResult.createSelectInfoResult(null, null, -1, null,
                    CliStrings.format(CliStrings.QUERY__MSG__INVALID_QUERY,
                            "Region mentioned in query probably missing /"),
                    false);
        }
    } catch (QueryInvalidException qe) {
        logger.error("{} Failed Error {}", query, qe.getMessage(), qe);
        return DataCommandResult.createSelectInfoResult(null, null, -1, null,
                CliStrings.format(CliStrings.QUERY__MSG__INVALID_QUERY, qe.getMessage()), false);
    }
}

From source file:org.apache.hadoop.crypto.key.RangerKMSDB.java

public int getDBFlavor(Configuration newConfig) {
    String[] propertyNames = { PROPERTY_PREFIX + DB_DIALECT, PROPERTY_PREFIX + DB_DRIVER,
            PROPERTY_PREFIX + DB_URL };

    for (String propertyName : propertyNames) {
        String propertyValue = DB_PROPERTIES.get(propertyName);
        if (StringUtils.isBlank(propertyValue)) {
            continue;
        }/*from ww w  .j  av  a  2 s  .  c  o m*/
        if (StringUtils.containsIgnoreCase(propertyValue, "mysql")) {
            return DB_FLAVOR_MYSQL;
        } else if (StringUtils.containsIgnoreCase(propertyValue, "oracle")) {
            return DB_FLAVOR_ORACLE;
        } else if (StringUtils.containsIgnoreCase(propertyValue, "postgresql")) {
            return DB_FLAVOR_POSTGRES;
        } else if (StringUtils.containsIgnoreCase(propertyValue, "sqlserver")) {
            return DB_FLAVOR_SQLSERVER;
        } else if (StringUtils.containsIgnoreCase(propertyValue, "mssql")) {
            return DB_FLAVOR_SQLSERVER;
        } else if (StringUtils.containsIgnoreCase(propertyValue, "sqlanywhere")) {
            return DB_FLAVOR_SQLANYWHERE;
        } else if (StringUtils.containsIgnoreCase(propertyValue, "sqla")) {
            return DB_FLAVOR_SQLANYWHERE;
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("DB Flavor could not be determined from property - " + propertyName + "="
                        + propertyValue);
            }
        }
    }
    logger.error("DB Flavor could not be determined");
    return DB_FLAVOR_UNKNOWN;
}

From source file:org.apache.jackrabbit.oak.upgrade.cli.node.Jackrabbit2Factory.java

public static boolean isRepositoryXml(String path) {
    File file = new File(path);
    if (file.isFile()) {
        BufferedReader reader = null;
        try {/*  w ww .  j a va2  s  . c om*/
            reader = new BufferedReader(new FileReader(file));
            String line;
            while ((line = reader.readLine()) != null) {
                if (StringUtils.containsIgnoreCase(line, "<Repository>")) {
                    return true;
                }
            }
        } catch (FileNotFoundException e) {
            return false;
        } catch (IOException e) {
            return false;
        } finally {
            IOUtils.closeQuietly(reader);
        }
    }
    return false;
}

From source file:org.apache.kylin.rest.service.AccessService.java

private boolean needAdd(String nameSeg, boolean isCaseSensitive, String name) {
    return isCaseSensitive && StringUtils.contains(name, nameSeg)
            || !isCaseSensitive && StringUtils.containsIgnoreCase(name, nameSeg);
}