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
FieldsModifier and TypeFieldDescriptionstatic Stringdatabase cache keystatic intkeep this for testing -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassignReadonly(boolean theReadonly) set the API as readonly (e.g. during upgrades).static voidassignSecondsBetweenFullRefresh(int theSeconds) static voidassignSecondsBetweenUpdateChecksToDb(int theSeconds) seconds between checking to see if the config files are updated in the database.static booleanbooleanValue(Object object) get the boolean value for an object, cant be null or blankstatic booleanbooleanValue(Object object, boolean defaultBoolean) get the boolean value for an objectstatic Stringnull safe classname method, gets the unenhanced namestatic voidstatic voidclearCache(boolean checkConfigTableExists) static voidcloseQuietly(InputStream input) Unconditionally close anInputStream.static voidcloseQuietly(Connection theConnection) close a connection null safe and dont throw exceptionstatic voidcloseQuietly(ResultSet resultSet) close a resultSet null safe and dont throw exceptionstatic voidcloseQuietly(Statement input) Unconditionally close anInputStream.static StringconvertUrlToDriverClassIfNeeded(String connectionUrl, String driverClassName) if there is no driver class specified, then try to derive it from the URLstatic StringdefaultString(String str) Returns either the passed in String, or if the String isnull, an empty String ("").static booleannull safe string comparestatic booleanequalsIgnoreCase(String str1, String str2) equalsignorecasestatic booleanSee if the input is null or if string, if it is empty or blank (whitespace)static booleanChecks if a String is whitespace, empty ("") or null.static booleansee if the config file seems to be mysqlstatic booleansee if the config file seems to be oraclestatic booleanisPostgres(String connectionUrl) see if the config file seems to be postgresstatic booleanisSQLServer(String connectionUrl) see if the config file seems to be sql serverstatic longconvert an object to a longstatic voidstatic StringmapToString(Map map) convert a set to a string (comma separate)static booleannullOrBlank(Object object) is an object null or blankstatic InputStreamretrieveConfigInputStream(String mainConfigFileName) retrieveConfigMap(String mainConfigFileName) static Stringget hash for db credsstatic voidsleep(long millis) sleep, if interrupted, throw runtimestatic StringtoHexString(byte[] hash) static Stringuuid()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:
trueif 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:
-