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:edu.monash.merc.system.parser.xml.HPAWSXmlParser.java

private AccessionBean createIdentifiedAcBean(String accession, String actype) {
    AccessionBean accessionBean = new AccessionBean();
    accessionBean.setAccession(accession);
    if (StringUtils.containsIgnoreCase(actype, DbAcType.Ensembl.type())) {
        accessionBean.setAcType(DbAcType.Gene.type());
    }// w  ww.j a  va  2s . c  o m
    return accessionBean;
}

From source file:hydrograph.ui.dataviewer.find.FindViewDataDialog.java

private boolean isExistInTable(TableViewer tableViewer, String text) {
    boolean isDataExist = false;
    Table table = tableViewer.getTable();
    TableItem[] tableItems = table.getItems();
    for (int i = 0; i < tableItems.length; i++) {
        TableItem tableItem = tableItems[i];
        for (int j = 1; j <= table.getColumnCount() - 1; j++) {
            if (StringUtils.containsIgnoreCase(tableItem.getText(j), text)) {
                label.setVisible(false);
                isDataExist = true;/*from  w  w w.j  a va 2  s.c  o  m*/
                return isDataExist;
            } else {
                label.setVisible(true);
                label.setText(labelText);
                isDataExist = false;
            }

        }
    }
    return isDataExist;
}

From source file:com.epam.training.storefront.controllers.pages.checkout.MultiStepCheckoutController.java

/**
 * In case a cart contains subscription products only display the delivery mode for subscriptions.
 *///from  w w  w .  j a  v  a 2 s. c  om
protected List<? extends DeliveryModeData> getSupportedDeliveryMethods(final CartData cartData) {
    final List<? extends DeliveryModeData> deliveryMethods = getCheckoutFacade().getSupportedDeliveryModes();
    final List<DeliveryModeData> filteredDeliveryMethods = new ArrayList<DeliveryModeData>();
    final boolean isSubscriptionOnlyCart = cartContainsSubscriptionProductsOnly(cartData);

    for (final DeliveryModeData deliveryMethod : deliveryMethods) {
        if (isSubscriptionOnlyCart) {
            if (StringUtils.containsIgnoreCase(deliveryMethod.getCode(),
                    PREFIX_DELIVERY_MODE_SUBSCRIPTION_ONLY)) {
                filteredDeliveryMethods.add(deliveryMethod);
            }
        } else {
            if (!StringUtils.containsIgnoreCase(deliveryMethod.getCode(),
                    PREFIX_DELIVERY_MODE_SUBSCRIPTION_ONLY)) {
                filteredDeliveryMethods.add(deliveryMethod);
            }
        }
    }

    return CollectionUtils.isEmpty(filteredDeliveryMethods) ? deliveryMethods : filteredDeliveryMethods;
}

From source file:adalid.util.velocity.BaseBuilder.java

private boolean check2(String sourceFileSimpleName, String sourceFolderSimpleName, String someName) {
    String delimited = "$" + someName + "$";
    return sourceFileSimpleName.equalsIgnoreCase(someName) || sourceFolderSimpleName.equalsIgnoreCase(someName)
            || StringUtils.containsIgnoreCase(sourceFileSimpleName, delimited)
            || StringUtils.containsIgnoreCase(sourceFolderSimpleName, delimited);
}

From source file:gov.nih.nci.cabig.caaers.web.ae.CreateAdverseEventAjaxFacade.java

public List<Lov> matchLabTestNames(String testName) {
    List<Lov> lovs = new ArrayList<Lov>();
    for (Lov lov : configProperty.getMap().get("labTestNamesRefData")) {
        if (StringUtils.containsIgnoreCase(lov.getDesc(), testName))
            lovs.add(lov);/* w w w.  ja  v  a  2  s .co m*/
    }
    return ObjectTools.reduceAll(lovs, "code", "desc");
}

From source file:eu.europeana.portal2.web.presentation.model.FullDocPage.java

public boolean isFormatLabels() {
    return StringUtils.containsIgnoreCase("labels", getFormat());
}

From source file:com.haulmont.cuba.gui.app.core.categories.AttributeEditor.java

protected List<Suggestion> requestHint(SourceCodeEditor sender, String text, int senderCursorPosition) {
    String joinStr = joinField.getValue();
    String whereStr = whereField.getValue();

    // CAUTION: the magic entity name!  The length is three character to match "{E}" length in query
    String entityAlias = "a39";

    int queryPosition = -1;
    Class javaClassForEntity = attribute.getJavaClassForEntity();
    if (javaClassForEntity == null)
        return new ArrayList<>();

    MetaClass metaClass = metadata.getClassNN(javaClassForEntity);
    String queryStart = "select " + entityAlias + " from " + metaClass.getName() + " " + entityAlias + " ";

    StringBuilder queryBuilder = new StringBuilder(queryStart);
    if (StringUtils.isNotEmpty(joinStr)) {
        if (sender == joinField) {
            queryPosition = queryBuilder.length() + senderCursorPosition - 1;
        }/*from  w w  w  .j a v a 2  s  .com*/
        if (!StringUtils.containsIgnoreCase(joinStr, "join") && !StringUtils.contains(joinStr, ",")) {
            queryBuilder.append("join ").append(joinStr);
            queryPosition += "join ".length();
        } else {
            queryBuilder.append(joinStr);
        }
    }
    if (StringUtils.isNotEmpty(whereStr)) {
        if (sender == whereField) {
            queryPosition = queryBuilder.length() + WHERE.length() + senderCursorPosition - 1;
        }
        queryBuilder.append(WHERE).append(whereStr);
    }
    String query = queryBuilder.toString();
    query = query.replace("{E}", entityAlias);

    return JpqlSuggestionFactory.requestHint(query, queryPosition, sender.getAutoCompleteSupport(),
            senderCursorPosition);
}

From source file:com.tesora.dve.sql.StrictForeignKeyTest.java

@Test
public void testConstraintName() throws Throwable {
    ProxyConnectionResource conn = new ProxyConnectionResource();
    try {/*from   ww w . ja  v  a  2 s.  co  m*/
        otherDDL.create(conn);
        checkDDL.create(conn);

        // just going to use a couple of bcast tables for this
        conn.execute("create table a (`id` int, primary key (`id`)) broadcast distribute");
        conn.execute("create table b (`id` int, primary key (`id`)) broadcast distribute");

        // expect this to fail
        try {
            conn.execute(
                    "create table c (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                            + "primary key (`id`), " + "key sameindexname (kid1), "
                            + "key sameindexname (kid2), "
                            + "constraint sameconstraintname unique sameindexname (uid1), "
                            + "constraint sameconstraintname unique sameindexname (uid2), "
                            + "constraint sameconstraintname foreign key sameindexname (aid) references a (id), "
                            + "constraint sameconstraintname foreign key sameindexname (bid) references b (id) "
                            + ") broadcast distribute");
            fail("Expected exception statement 1");
        } catch (Exception e) {
            assertTrue(StringUtils.containsIgnoreCase(e.getMessage(), "Duplicate key name: sameindexname"));
        }

        try {
            conn.execute(
                    "create table c (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                            + "primary key (`id`), " + "key sameindexname (kid1), "
                            + "key sameindexname2 (kid2), "
                            + "constraint sameconstraintname unique sameindexname (uid1), "
                            + "constraint sameconstraintname unique sameindexname (uid2), "
                            + "constraint sameconstraintname foreign key sameindexname (aid) references a (id), "
                            + "constraint sameconstraintname foreign key sameindexname (bid) references b (id) "
                            + ") broadcast distribute");
            fail("Expected exception statement 2");
        } catch (Exception e) {
            assertTrue(StringUtils.containsIgnoreCase(e.getMessage(), "Duplicate key name: sameindexname"));
        }

        try {
            conn.execute(
                    "create table c (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                            + "primary key (`id`), " + "key sameindexname (kid1), "
                            + "key sameindexname2 (kid2), "
                            + "constraint sameconstraintname unique sameindexname (uid1), "
                            + "constraint sameconstraintname unique sameindexname4 (uid2) "
                            + ") broadcast distribute");
            fail("Expected exception statement 3");
        } catch (Exception e) {
            assertTrue(StringUtils.containsIgnoreCase(e.getMessage(), "Duplicate key name: sameindexname"));
        }

        try {
            conn.execute(
                    "create table c (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                            + "primary key (`id`), " + "key sameindexname (kid1), "
                            + "key sameindexname2 (kid2), "
                            + "constraint sameconstraintname unique sameindexname3 (uid1), "
                            + "constraint sameconstraintname unique sameindexname4 (uid2), "
                            + "constraint sameconstraintname foreign key sameindexname (aid) references a (id), "
                            + "constraint sameconstraintname foreign key sameindexname (bid) references b (id) "
                            + ") broadcast distribute");
            fail("Expected exception statement 4");
        } catch (Exception e) {
            assertTrue(StringUtils.containsIgnoreCase(e.getMessage(),
                    "Duplicate foreign key name: sameconstraintname"));
        }

        try {
            conn.execute(
                    "create table c (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                            + "primary key (`id`), " + "key sameindexname (kid1), "
                            + "key sameindexname2 (kid2), "
                            + "constraint sameconstraintname unique sameindexname3 (uid1), "
                            + "constraint sameconstraintname unique sameindexname4 (uid2), "
                            + "constraint sameconstraintname foreign key sameindexname5 (aid) references a (id), "
                            + "constraint sameconstraintname foreign key sameindexname6 (bid) references b (id) "
                            + ") broadcast distribute");
            fail("Expected exception statement 5");
        } catch (Exception e) {
            assertTrue(StringUtils.containsIgnoreCase(e.getMessage(),
                    "Duplicate foreign key name: sameconstraintname"));
        }

        // this should succeed!
        conn.execute(
                "create table c (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                        + "primary key (`id`), " + "key sameindexname (kid1), " + "key sameindexname2 (kid2), "
                        + "constraint sameconstraintname unique sameindexname3 (uid1), "
                        + "constraint sameconstraintname unique sameindexname4 (uid2), "
                        + "constraint sameconstraintname foreign key sameindexname (aid) references a (id), "
                        + "constraint sameconstraintname2 foreign key sameindexname (bid) references b (id) "
                        + ") broadcast distribute");
        // this is hilarious.  on native this is:
        /*
         * mysql> select constraint_name, constraint_type from information_schema.table_constraints where table_schema = 'foo' and table_name = 'c' order by constraint_name, constraint_type;
        +---------------------+-----------------+
        | constraint_name     | constraint_type |
        +---------------------+-----------------+
        | PRIMARY             | PRIMARY KEY     |
        | sameconstraintname  | FOREIGN KEY     |
        | sameconstraintname2 | FOREIGN KEY     |
        | sameindexname3      | UNIQUE          |
        | sameindexname4      | UNIQUE          |
        +---------------------+-----------------+
        5 rows in set (0.01 sec)
                
         */
        conn.assertResults(
                "select constraint_name, constraint_type from information_schema.table_constraints where table_schema = 'adb' and table_name = 'c' order by constraint_name, constraint_type",
                br(nr, "PRIMARY", "PRIMARY KEY", nr, "sameconstraintname", "FOREIGN KEY", nr,
                        "sameconstraintname", "UNIQUE", nr, "sameconstraintname", "UNIQUE", nr,
                        "sameconstraintname2", "FOREIGN KEY"));
        /*
         * continuing with the hilarity:
         *          mysql> show keys in c;
        +-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
        | Table | Non_unique | Key_name            | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
        +-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
        | c     |          0 | PRIMARY             |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
        | c     |          0 | sameindexname3      |            1 | uid1        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | c     |          0 | sameindexname4      |            1 | uid2        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | c     |          1 | sameindexname       |            1 | kid1        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | c     |          1 | sameindexname2      |            1 | kid2        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | c     |          1 | sameconstraintname  |            1 | aid         | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | c     |          1 | sameconstraintname2 |            1 | bid         | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        +-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
        7 rows in set (0.00 sec)
                
         */
        conn.assertResults("show keys in c",
                br(nr, "c", 0, "PRIMARY", 1, "id", "A", -1L, null, null, "", "BTREE", "", "", nr, "c", 0,
                        "sameindexname3", 1, "uid1", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "c", 0,
                        "sameindexname4", 1, "uid2", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "c", 1,
                        "sameindexname", 1, "kid1", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "c", 1,
                        "sameindexname2", 1, "kid2", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "c", 1,
                        "aid", 1, "aid", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "c", 1, "bid", 1,
                        "bid", "A", -1L, null, null, "YES", "BTREE", "", ""));

        // make sure FK constraint names are unique across the database
        try {
            conn.execute(
                    "create table d (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                            + "primary key (`id`), " + "key sameindexname (kid1), "
                            + "key sameindexname2 (kid2), "
                            + "constraint sameconstraintname unique sameindexname3 (uid1), "
                            + "constraint sameconstraintname unique sameindexname4 (uid2), "
                            + "constraint sameconstraintname2 foreign key sameindexname (aid) references a (id), "
                            + "constraint sameconstraintname4 foreign key sameindexname (bid) references b (id) "
                            + ") broadcast distribute");
            fail("Expected exception statement 6");
        } catch (Exception e) {
            assertTrue(StringUtils.containsIgnoreCase(e.getMessage(),
                    "Duplicate foreign key name: sameconstraintname2"));
        }

        conn.execute(
                "create table d (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                        + "primary key (`id`), " + "key sameindexname (kid1), " + "key sameindexname2 (kid2), "
                        + "constraint sameconstraintname unique sameindexname3 (uid1), "
                        + "constraint sameconstraintname unique sameindexname4 (uid2), "
                        + "constraint sameconstraintname3 foreign key sameindexname (aid) references a (id), "
                        + "constraint sameconstraintname4 foreign key sameindexname (bid) references b (id) "
                        + ") broadcast distribute");
        /*
         * continuing the fun:
         * mysql> select constraint_name, constraint_type from information_schema.table_constraints where table_Schema = 'foo' and table_name = 'd' order by constraint_name, constraint_type;
        +---------------------+-----------------+
        | constraint_name     | constraint_type |
        +---------------------+-----------------+
        | PRIMARY             | PRIMARY KEY     |
        | sameconstraintname3 | FOREIGN KEY     |
        | sameconstraintname4 | FOREIGN KEY     |
        | sameindexname3      | UNIQUE          |
        | sameindexname4      | UNIQUE          |
        +---------------------+-----------------+
        5 rows in set (0.00 sec)         
         */
        conn.assertResults(
                "select constraint_name, constraint_type from information_schema.table_constraints where table_schema = 'adb' and table_name = 'd' order by constraint_name, constraint_type",
                br(nr, "PRIMARY", "PRIMARY KEY", nr, "sameconstraintname", "UNIQUE", nr, "sameconstraintname",
                        "UNIQUE", nr, "sameconstraintname3", "FOREIGN KEY", nr, "sameconstraintname4",
                        "FOREIGN KEY"));
        /* still incorrect:
         *    mysql> show keys in d;
        +-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
        | Table | Non_unique | Key_name            | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
        +-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
        | d     |          0 | PRIMARY             |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
        | d     |          0 | sameindexname3      |            1 | uid1        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | d     |          0 | sameindexname4      |            1 | uid2        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | d     |          1 | sameindexname       |            1 | kid1        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | d     |          1 | sameindexname2      |            1 | kid2        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | d     |          1 | sameconstraintname3 |            1 | aid         | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        | d     |          1 | sameconstraintname4 |            1 | bid         | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               |
        +-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
        7 rows in set (0.00 sec)
                      
         */
        conn.assertResults("show keys in d",
                br(nr, "d", 0, "PRIMARY", 1, "id", "A", -1L, null, null, "", "BTREE", "", "", nr, "d", 0,
                        "sameindexname3", 1, "uid1", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "d", 0,
                        "sameindexname4", 1, "uid2", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "d", 1,
                        "sameindexname", 1, "kid1", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "d", 1,
                        "sameindexname2", 1, "kid2", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "d", 1,
                        "aid", 1, "aid", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "d", 1, "bid", 1,
                        "bid", "A", -1L, null, null, "YES", "BTREE", "", ""));

        // make sure the "standard" way still works
        conn.execute(
                "create table e (`id` int, `aid` int, `bid` int, `uid1` int, `uid2` int, `kid1` int, `kid2` int, "
                        + "primary key (`id`), " + "key (kid1), " + "key (kid2), " + "unique (uid1), "
                        + "unique (uid2), " + "foreign key (aid) references a (id), "
                        + "foreign key (bid) references b (id) " + ") broadcast distribute");

        // test the case that started it all
        conn.execute(
                "CREATE TABLE `cs` (`sid` smallint(5) unsigned NOT NULL, PRIMARY KEY (`sid`)) BROADCAST DISTRIBUTE");
        conn.execute("CREATE TABLE `tg` ( " + "`tid` int(10) unsigned NOT NULL AUTO_INCREMENT, "
                + "`nm` varchar(255) DEFAULT NULL, " + "`st` smallint(6) NOT NULL DEFAULT '0', "
                + "`fci` int(10) unsigned DEFAULT NULL, " + "`fsi` smallint(5) unsigned DEFAULT NULL, "
                + "PRIMARY KEY (`tid`) USING BTREE, " + "KEY `FK_TG_FCICEEI` (`fci`), "
                + "KEY `FK_TG_FSICSSI` (`fsi`), "
                + "CONSTRAINT `FK_TG_FSICSSI` FOREIGN KEY (`fsi`) REFERENCES `cs` (`sid`) ON DELETE SET NULL ON UPDATE NO ACTION "
                + ") ENGINE=InnoDB AUTO_INCREMENT=199 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC BROADCAST DISTRIBUTE");
        conn.assertResults(
                "select constraint_name, constraint_type from information_schema.table_constraints where table_schema = 'adb' and table_name = 'tg' order by constraint_name, constraint_type",
                br(nr, "FK_TG_FSICSSI", "FOREIGN KEY", nr, "PRIMARY", "PRIMARY KEY"));
        conn.assertResults("show keys in tg",
                br(nr, "tg", 0, "PRIMARY", 1, "tid", "A", -1L, null, null, "", "BTREE", "", "", nr, "tg", 1,
                        "FK_TG_FCICEEI", 1, "fci", "A", -1L, null, null, "YES", "BTREE", "", "", nr, "tg", 1,
                        "FK_TG_FSICSSI", 1, "fsi", "A", -1L, null, null, "YES", "BTREE", "", ""));

        // make sure we can create the same table and constraint names in another database
        conn.execute("use otherdb");
        conn.execute(
                "CREATE TABLE `cs` (`sid` smallint(5) unsigned NOT NULL, PRIMARY KEY (`sid`)) BROADCAST DISTRIBUTE");
        conn.execute("CREATE TABLE `tg` ( " + "`tid` int(10) unsigned NOT NULL AUTO_INCREMENT, "
                + "`nm` varchar(255) DEFAULT NULL, " + "`st` smallint(6) NOT NULL DEFAULT '0', "
                + "`fci` int(10) unsigned DEFAULT NULL, " + "`fsi` smallint(5) unsigned DEFAULT NULL, "
                + "PRIMARY KEY (`tid`) USING BTREE, " + "KEY `FK_TAG_FSICSSI` (`fsi`), "
                + "CONSTRAINT `FK_TAG_FSICSSI` FOREIGN KEY (`fsi`) REFERENCES `cs` (`sid`) ON DELETE SET NULL ON UPDATE NO ACTION "
                + ") ENGINE=InnoDB AUTO_INCREMENT=199 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC BROADCAST DISTRIBUTE");
        conn.assertResults(
                "select constraint_name, constraint_type from information_schema.table_constraints where table_schema = 'otherdb' and table_name = 'tg' order by constraint_name, constraint_type",
                br(nr, "FK_TAG_FSICSSI", "FOREIGN KEY", nr, "PRIMARY", "PRIMARY KEY"));
        conn.assertResults("show keys in tg",
                br(nr, "tg", 0, "PRIMARY", 1, "tid", "A", -1L, null, null, "", "BTREE", "", "", nr, "tg", 1,
                        "FK_TAG_FSICSSI", 1, "fsi", "A", -1L, null, null, "YES", "BTREE", "", ""));
    } finally {
        checkDDL.destroy(conn);
        otherDDL.destroy(conn);
        conn.disconnect();
        conn = null;
    }
}

From source file:com.android.builder.core.AtlasBuilder.java

private File getAapt() {

    String osName = "mac";
    String fileName = "aapt";

    if (StringUtils.containsIgnoreCase(System.getProperty("os.name"), "Mac")) {
        osName = "mac";
    } else if (StringUtils.containsIgnoreCase(System.getProperty("os.name"), "Linux")) {
        osName = "linux";
    } else if (StringUtils.containsIgnoreCase(System.getProperty("os.name"), "windows")) {
        osName = "win";
        fileName = "aapt.exe";
    }/* ww  w  . ja  va  2s .c o m*/
    String aaptPath = "aapt/" + osName + "/" + fileName;
    File aaptFile = new File(AtlasBuilder.class.getClassLoader().getResource(aaptPath).getFile());
    if (aaptFile.isFile()) {
        return aaptFile;
    }

    String path = AtlasBuilder.class.getProtectionDomain().getCodeSource().getLocation().getFile();
    File jarFile = new File(path);
    File jarFolder = new File(jarFile.getParentFile(), FilenameUtils.getBaseName(jarFile.getName()));
    jarFolder.mkdirs();
    aaptFile = new File(jarFolder, fileName);

    if (!aaptFile.exists()) {
        aaptFile = ZipUtils.extractZipFileToFolder(jarFile, aaptPath, aaptFile.getParentFile());
        aaptFile.setExecutable(true);
    }
    return aaptFile;
}

From source file:edu.ku.brc.dbsupport.MySQLDMBSUserMgr.java

/**
 * @param username//w  ww. ja  va 2s  . c o m
 * @param serverName
 * @param dbName
 * @return
 */
public int getPermissionsUsingGrants(final String username, final String serverName, final String dbName) {
    try {
        if (connection != null) {
            //String sql = String.format("SHOW GRANTS FOR '%s'@'%s'", username, serverName);
            String uNameStr = String.format("'%s'@'", username);
            //log.debug(sql);
            Vector<Object[]> list = BasicSQLUtils.query(connection, "SHOW GRANTS");
            if (list != null) {
                int perms = PERM_NONE;
                for (Object[] row : list) {
                    String line = row[0].toString();
                    if (StringUtils.contains(line, uNameStr) && StringUtils.contains(line, dbName)) {
                        if (StringUtils.containsIgnoreCase(line, "GRANT ALL")) {
                            return PERM_ALL;
                        }

                        String pStr = line;
                        int eInx = pStr.indexOf(" ON ");
                        if (eInx > -1) {
                            pStr = pStr.substring(5, eInx).trim();
                            String[] tokens = StringUtils.split(pStr, ",");
                            for (String tok : tokens) {
                                perms = addPerm(tok.trim(), perms);
                            }
                        }
                    }
                }
                //log.debug("PERMS: "+perms);

                if (perms == 0 && username.equalsIgnoreCase("root")) {
                    perms = PERM_ALL;
                }
                return perms;
            }
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return PERM_NONE;
}