use of org.finra.gatekeeper.services.accessrequest.model.RoleType in project Gatekeeper by FINRAOS.
the class MySQLDBConnection method getAvailableTables.
public Map<RoleType, List<String>> getAvailableTables(String address) throws SQLException {
Map<RoleType, List<String>> results = new HashMap<>();
JdbcTemplate template = connect(address);
String schemaQuery = "select concat(table_schema,'.',table_name) from information_schema.tables where table_schema not in ('information_schema', 'mysql', 'sys', 'performance_schema')";
for (RoleType roleType : RoleType.values()) {
try {
results.put(roleType, template.queryForList(schemaQuery, String.class));
} catch (Exception ex) {
logger.error("An exception was thrown while trying to fetch tables over MySQL at address " + address, ex);
results.put(roleType, Collections.singletonList("Unable to get available schemas"));
}
}
return results;
}
use of org.finra.gatekeeper.services.accessrequest.model.RoleType in project Gatekeeper by FINRAOS.
the class PostgresDBConnection method getAvailableTables.
public Map<RoleType, List<String>> getAvailableTables(String address) throws SQLException {
Map<RoleType, List<String>> results = new HashMap<>();
PGPoolingDataSource dataSource = connect(address);
JdbcTemplate conn = new JdbcTemplate(dataSource);
logger.info("Getting available schema information for " + address);
for (RoleType roleType : RoleType.values()) {
try {
List<String> schemas = conn.queryForList(getSchemas, new Object[] { roleType.getDbRole() }, String.class);
results.put(roleType, !schemas.isEmpty() ? schemas : Collections.singletonList("No Schemas are available for role " + roleType.getDbRole() + " at this time."));
logger.info("Retrieved available schema information for database " + address + " for role " + roleType.getDbRole());
} catch (Exception ex) {
logger.error("Could not retrieve available role information for database " + address + " for role " + roleType.getDbRole(), ex);
results.put(roleType, Collections.singletonList("Unable to get available schemas for role " + roleType.getDbRole()));
}
}
dataSource.close();
return results;
}
Aggregations