Class ConfigDatabaseLogic
java.lang.Object
edu.internet2.middleware.grouperClient.config.db.ConfigDatabaseLogic
logic to cache and retrieve the grouper config from the DB
note: do not use any Grouper classes in this class. Cant use anything that
could use anything configurable.
This class has some config which will be injected from the outside
there should be no imports here
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
database cache keystatic int
keep this for testing -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 blankstatic boolean
booleanValue
(Object object, boolean defaultBoolean) get the boolean value for an objectstatic String
null safe classname method, gets the unenhanced namestatic void
static void
clearCache
(boolean checkConfigTableExists) static void
closeQuietly
(InputStream input) Unconditionally close anInputStream
.static void
closeQuietly
(Connection theConnection) close a connection null safe and dont throw exceptionstatic void
closeQuietly
(ResultSet resultSet) close a resultSet null safe and dont throw exceptionstatic void
closeQuietly
(Statement input) Unconditionally close anInputStream
.static String
convertUrlToDriverClassIfNeeded
(String connectionUrl, String driverClassName) if there is no driver class specified, then try to derive it from the URLstatic String
defaultString
(String str) Returns either the passed in String, or if the String isnull
, an empty String ("").static boolean
null safe string comparestatic boolean
equalsIgnoreCase
(String str1, String str2) equalsignorecasestatic boolean
See if the input is null or if string, if it is empty or blank (whitespace)static boolean
Checks if a String is whitespace, empty ("") or null.static boolean
see if the config file seems to be mysqlstatic boolean
see if the config file seems to be oraclestatic boolean
isPostgres
(String connectionUrl) see if the config file seems to be postgresstatic boolean
isSQLServer
(String connectionUrl) see if the config file seems to be sql serverstatic long
convert an object to a longstatic void
static String
mapToString
(Map map) convert a set to a string (comma separate)static boolean
nullOrBlank
(Object object) is an object null or blankstatic InputStream
retrieveConfigInputStream
(String mainConfigFileName) retrieveConfigMap
(String mainConfigFileName) static String
get hash for db credsstatic void
sleep
(long millis) sleep, if interrupted, throw runtimestatic String
toHexString
(byte[] hash) static String
uuid()
generate a uuid
-
Field Details
-
DATABASE_CACHE_KEY
database cache key -
databaseConfigRefreshCount
public static int databaseConfigRefreshCountkeep this for testing
-
-
Constructor Details
-
ConfigDatabaseLogic
public ConfigDatabaseLogic()
-
-
Method Details
-
clearCache
public static void clearCache() -
clearCache
public static void clearCache(boolean checkConfigTableExists) -
main
- Parameters:
args
-
-
assignSecondsBetweenUpdateChecksToDb
public static void assignSecondsBetweenUpdateChecksToDb(int theSeconds) seconds between checking to see if the config files are updated in the database. If anything edited, then refresh all. Note that the last edited is stored in a config property for deletes. -1 means dont check for incrementals. Note if *.config.secondsBetweenUpdateChecks is greater than this number for this config, then it wont update until that amount has passed. grouper.config.secondsBetweenUpdateChecksToDb = 60- Parameters:
theSeconds
-
-
assignReadonly
public static void assignReadonly(boolean theReadonly) set the API as readonly (e.g. during upgrades). Any updates will throw an exception grouper.api.readonly = false- Parameters:
theReadonly
-
-
assignSecondsBetweenFullRefresh
public static void assignSecondsBetweenFullRefresh(int theSeconds) - Parameters:
theSeconds
-
-
retrieveConfigInputStream
- Parameters:
mainConfigFileName
- configPropertiesCascadeBase.getMainConfigFileName() e.g. grouper.properties- Returns:
- the inputStream for this config's properties
-
retrieveConfigMap
- Parameters:
mainConfigFileName
- configPropertiesCascadeBase.getMainConfigFileName() e.g. grouper.properties- Returns:
- the inputStream for this config's properties
-
sha256
get hash for db creds- Parameters:
input
-- Returns:
- bytes
-
toHexString
- Parameters:
hash
-- Returns:
- string
-
equals
null safe string compare- Parameters:
first
-second
-- Returns:
- true if equal
-
nullOrBlank
is an object null or blank- Parameters:
object
-- Returns:
- true if null or blank
-
booleanValue
get the boolean value for an object, cant be null or blank- Parameters:
object
-- Returns:
- the boolean
-
mapToString
convert a set to a string (comma separate)- Parameters:
map
-- Returns:
- the String
-
closeQuietly
close a connection null safe and dont throw exception- Parameters:
theConnection
-
-
closeQuietly
Unconditionally close anInputStream
. Equivalent toInputStream.close()
, except any exceptions will be ignored.- Parameters:
input
- A (possibly null) InputStream
-
closeQuietly
Unconditionally close anInputStream
. Equivalent toInputStream.close()
, except any exceptions will be ignored.- Parameters:
input
- A (possibly null) InputStream
-
closeQuietly
close a resultSet null safe and dont throw exception- Parameters:
resultSet
-
-
isBlank
See if the input is null or if string, if it is empty or blank (whitespace)- Parameters:
input
-- Returns:
- true if blank
-
isBlank
Checks if a String is whitespace, empty ("") or null.
isBlank(null) = true isBlank("") = true isBlank(" ") = true isBlank("bob") = false isBlank(" bob ") = false
- Parameters:
str
- the String to check, may be null- Returns:
true
if the String is null, empty or whitespace- Since:
- 2.0
-
equalsIgnoreCase
equalsignorecase- Parameters:
str1
-str2
-- Returns:
- true if the strings are equal ignore case
-
booleanValue
get the boolean value for an object- Parameters:
object
-defaultBoolean
- if object is null or empty- Returns:
- the boolean
-
sleep
public static void sleep(long millis) sleep, if interrupted, throw runtime- Parameters:
millis
-
-
uuid
generate a uuid- Returns:
- uuid
-
className
null safe classname method, gets the unenhanced name- Parameters:
object
-- Returns:
- the classname
-
longValue
convert an object to a long- Parameters:
input
-- Returns:
- the number
-
convertUrlToDriverClassIfNeeded
if there is no driver class specified, then try to derive it from the URL- Parameters:
connectionUrl
-driverClassName
-- Returns:
- the driver class
-
isMysql
see if the config file seems to be mysql- Parameters:
connectionUrl
-- Returns:
- see if mysql
-
isOracle
see if the config file seems to be oracle- Parameters:
connectionUrl
-- Returns:
- see if oracle
-
isPostgres
see if the config file seems to be postgres- Parameters:
connectionUrl
-- Returns:
- see if postgres
-
isSQLServer
see if the config file seems to be sql server- Parameters:
connectionUrl
-- Returns:
- see if sql server
-
defaultString
Returns either the passed in String, or if the String is
null
, an empty String ("").StringUtils.defaultString(null) = "" StringUtils.defaultString("") = "" StringUtils.defaultString("bat") = "bat"
- Parameters:
str
- the String to check, may be null- Returns:
- the passed in String, or the empty String if it
was
null
- See Also:
-