public class ConfigDatabaseLogic extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DATABASE_CACHE_KEY
database cache key
|
static int |
databaseConfigRefreshCount
keep this for testing
|
Constructor and Description |
---|
ConfigDatabaseLogic() |
Modifier and Type | Method and Description |
---|---|
static void |
assignReadonly(boolean theReadonly)
set the API as readonly (e.g.
|
static void |
assignSecondsBetweenFullRefresh(int theSeconds) |
static void |
assignSecondsBetweenUpdateChecksToDb(int theSeconds)
seconds between checking to see if the config files are updated in the database.
|
static boolean |
booleanValue(Object object)
get the boolean value for an object, cant be null or blank
|
static boolean |
booleanValue(Object object,
boolean defaultBoolean)
get the boolean value for an object
|
static String |
className(Object object)
null safe classname method, gets the unenhanced name
|
static void |
clearCache() |
static void |
clearCache(boolean checkConfigTableExists) |
static void |
closeQuietly(Connection theConnection)
close a connection null safe and dont throw exception
|
static void |
closeQuietly(InputStream input)
Unconditionally close an
InputStream . |
static void |
closeQuietly(ResultSet resultSet)
close a resultSet null safe and dont throw exception
|
static void |
closeQuietly(Statement input)
Unconditionally close an
InputStream . |
static String |
convertUrlToDriverClassIfNeeded(String connectionUrl,
String driverClassName)
if there is no driver class specified, then try to derive it from the URL
|
static String |
defaultString(String str)
Returns either the passed in String,
or if the String is
null , an empty String (""). |
static boolean |
equals(String first,
String second)
null safe string compare
|
static boolean |
equalsIgnoreCase(String str1,
String str2)
equalsignorecase
|
static boolean |
isBlank(Object input)
See if the input is null or if string, if it is empty or blank (whitespace)
|
static boolean |
isBlank(String str)
Checks if a String is whitespace, empty ("") or null.
|
static boolean |
isHsql(String connectionUrl)
see if the config file seems to be hsql
|
static boolean |
isMysql(String connectionUrl)
see if the config file seems to be mysql
|
static boolean |
isOracle(String connectionUrl)
see if the config file seems to be oracle
|
static boolean |
isPostgres(String connectionUrl)
see if the config file seems to be postgres
|
static boolean |
isSQLServer(String connectionUrl)
see if the config file seems to be sql server
|
static long |
longValue(Object input)
convert an object to a long
|
static void |
main(String[] args) |
static String |
mapToString(Map map)
convert a set to a string (comma separate)
|
static boolean |
nullOrBlank(Object object)
is an object null or blank
|
static InputStream |
retrieveConfigInputStream(String mainConfigFileName) |
static Map<String,String> |
retrieveConfigMap(String mainConfigFileName) |
static String |
sha256(String input)
get hash for db creds
|
static void |
sleep(long millis)
sleep, if interrupted, throw runtime
|
static String |
toHexString(byte[] hash) |
static String |
uuid()
generate a uuid
|
public static String DATABASE_CACHE_KEY
public static int databaseConfigRefreshCount
public static void clearCache()
public static void clearCache(boolean checkConfigTableExists)
public static void main(String[] args)
args
- public static void assignSecondsBetweenUpdateChecksToDb(int theSeconds)
theSeconds
- public static void assignReadonly(boolean theReadonly)
theReadonly
- public static void assignSecondsBetweenFullRefresh(int theSeconds)
theSeconds
- public static InputStream retrieveConfigInputStream(String mainConfigFileName)
mainConfigFileName
- configPropertiesCascadeBase.getMainConfigFileName() e.g. grouper.propertiespublic static Map<String,String> retrieveConfigMap(String mainConfigFileName)
mainConfigFileName
- configPropertiesCascadeBase.getMainConfigFileName() e.g. grouper.propertiespublic static String sha256(String input)
input
- public static String toHexString(byte[] hash)
hash
- public static boolean equals(String first, String second)
first
- second
- public static boolean nullOrBlank(Object object)
object
- public static boolean booleanValue(Object object)
object
- public static String mapToString(Map map)
map
- public static void closeQuietly(Connection theConnection)
theConnection
- public static void closeQuietly(InputStream input)
InputStream
.
Equivalent to InputStream.close()
, except any exceptions will be ignored.input
- A (possibly null) InputStreampublic static void closeQuietly(Statement input)
InputStream
.
Equivalent to InputStream.close()
, except any exceptions will be ignored.input
- A (possibly null) InputStreampublic static void closeQuietly(ResultSet resultSet)
resultSet
- public static boolean isBlank(Object input)
input
- public static boolean isBlank(String str)
Checks if a String is whitespace, empty ("") or null.
isBlank(null) = true isBlank("") = true isBlank(" ") = true isBlank("bob") = false isBlank(" bob ") = false
str
- the String to check, may be nulltrue
if the String is null, empty or whitespacepublic static boolean equalsIgnoreCase(String str1, String str2)
str1
- str2
- public static boolean booleanValue(Object object, boolean defaultBoolean)
object
- defaultBoolean
- if object is null or emptypublic static void sleep(long millis)
millis
- public static String uuid()
public static String className(Object object)
object
- public static long longValue(Object input)
input
- public static String convertUrlToDriverClassIfNeeded(String connectionUrl, String driverClassName)
connectionUrl
- driverClassName
- public static boolean isHsql(String connectionUrl)
connectionUrl
- url to check againstpublic static boolean isMysql(String connectionUrl)
connectionUrl
- public static boolean isOracle(String connectionUrl)
connectionUrl
- public static boolean isPostgres(String connectionUrl)
connectionUrl
- public static boolean isSQLServer(String connectionUrl)
connectionUrl
- public static String defaultString(String str)
Returns either the passed in String,
or if the String is null
, an empty String ("").
StringUtils.defaultString(null) = "" StringUtils.defaultString("") = "" StringUtils.defaultString("bat") = "bat"
str
- the String to check, may be nullnull
String.valueOf(Object)
Copyright © 2016 Internet2. All rights reserved.