Search in sources :

Example 36 with UserConfig

use of io.mycat.config.model.UserConfig in project Mycat-Server by MyCATApache.

the class ShowTables method getTableSet.

private static Set<String> getTableSet(ServerConnection c, Map<String, String> parm) {
    TreeSet<String> tableSet = new TreeSet<String>();
    MycatConfig conf = MycatServer.getInstance().getConfig();
    Map<String, UserConfig> users = conf.getUsers();
    UserConfig user = users == null ? null : users.get(c.getUser());
    if (user != null) {
        Map<String, SchemaConfig> schemas = conf.getSchemas();
        for (String name : schemas.keySet()) {
            if (null != parm.get(SCHEMA_KEY) && parm.get(SCHEMA_KEY).toUpperCase().equals(name.toUpperCase())) {
                if (null == parm.get("LIKE_KEY")) {
                    tableSet.addAll(schemas.get(name).getTables().keySet());
                } else {
                    String p = "^" + parm.get("LIKE_KEY").replaceAll("%", ".*");
                    Pattern pattern = Pattern.compile(p, Pattern.CASE_INSENSITIVE);
                    Matcher ma;
                    for (String tname : schemas.get(name).getTables().keySet()) {
                        ma = pattern.matcher(tname);
                        if (ma.matches()) {
                            tableSet.add(tname);
                        }
                    }
                }
            }
        }
        ;
    }
    return tableSet;
}
Also used : Pattern(java.util.regex.Pattern) SchemaConfig(io.mycat.config.model.SchemaConfig) Matcher(java.util.regex.Matcher) TreeSet(java.util.TreeSet) MycatConfig(io.mycat.config.MycatConfig) UserConfig(io.mycat.config.model.UserConfig)

Aggregations

UserConfig (io.mycat.config.model.UserConfig)36 MycatConfig (io.mycat.config.MycatConfig)10 SchemaConfig (io.mycat.config.model.SchemaConfig)10 FirewallConfig (io.mycat.config.model.FirewallConfig)8 ArrayList (java.util.ArrayList)8 Pattern (java.util.regex.Pattern)8 PhysicalDBNode (io.mycat.backend.datasource.PhysicalDBNode)6 PhysicalDBPool (io.mycat.backend.datasource.PhysicalDBPool)6 MycatCluster (io.mycat.config.MycatCluster)6 ConfigException (io.mycat.config.util.ConfigException)6 List (java.util.List)6 TreeSet (java.util.TreeSet)6 ConfigInitializer (io.mycat.config.ConfigInitializer)4 EOFPacket (io.mycat.net.mysql.EOFPacket)4 FieldPacket (io.mycat.net.mysql.FieldPacket)4 RowDataPacket (io.mycat.net.mysql.RowDataPacket)4 ByteBuffer (java.nio.ByteBuffer)4 Matcher (java.util.regex.Matcher)4 Element (org.w3c.dom.Element)4 Node (org.w3c.dom.Node)4