Interface ServerConfigurationService
-
public interface ServerConfigurationServiceServerConfigurationService provides information about how the server is configured.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceServerConfigurationService.ConfigDataDefines the config data holding classstatic interfaceServerConfigurationService.ConfigHistoryDefines the config item history classstatic interfaceServerConfigurationService.ConfigItemDefines the config item holding classstatic interfaceServerConfigurationService.ConfigurationListenerAllows a service to be notified when configuration settings are changed, It is up to the implementor to ignore the changes they do not care about.static interfaceServerConfigurationService.ConfigurationProviderAllows registration of configuration settings (config items) from outside the Server Configuration Service and the standard set of properties files which will be loaded early on the configuration cycle NOTE: the implemented ConfigurationProvider MUST be a Spring singleton and it MUST be registered in the main Sakai application context from a component (from a webapp will not work), it also must be set explicitly to not lazy initialize (lazy-init="false"), it is always possible to update the configuration later usingServerConfigurationService.ConfigurationProvider.registerConfigItems(ConfigData)so this is mainly for loading configurations very early in the system startup
-
Field Summary
Fields Modifier and Type Field Description static StringCURRENT_PORTAL_PATHKey in the ThreadLocalManager for the path based on the current request.static StringCURRENT_SERVER_URLKey in the ThreadLocalManager for the serverUrl based on the current request.static StringSERVICE_NAMEThis string can be used to find the service in the service manager.static StringTYPE_ARRAYstatic StringTYPE_BOOLEANstatic StringTYPE_INTstatic StringTYPE_STRINGstatic String[]TYPESstatic StringUNKNOWN
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetAccessPath()Access the path to the access service on the server relative to the base URL for the server.StringgetAccessUrl()Access the URL to the access service on the server - append any additional path to the end.booleangetBoolean(String name, boolean dflt)Access some named configuration value as a boolean.List<String>getCategoryGroups(String category)KNL-989 Access the list of groups by category (site type)Set<String>getCommaSeparatedListAsSet(String key)Retrieves the string property by key, then splits it by comma.<T> TgetConfig(String name, T defaultValue)Retrieves config values from the configuration serviceServerConfigurationService.ConfigDatagetConfigData()Returns data about all the configuration values which are known to the system at the time and some stats which are usefulServerConfigurationService.ConfigItemgetConfigItem(String name)Retrieve the internally stored the config item, this is not really for general use, if you want the value of a configuration variable then you should usegetConfig(String, Object)List<String>getDefaultTools(String category)Access the list of tool ids that are selected by default for this category.StringgetGatewaySiteId()Access the site id for the gateway (public) site.StringgetHelpUrl(String helpContext)Access the URL to the help service on the server - append in the path the tool well known id for context sensitive help.intgetInt(String name, int dflt)Access some named configuration value as an int.LocalegetLocaleFromString(String localeString)Parse a string into a LocaleStringgetLoggedOutUrl()Access the URL to use as a redirect when the user has logged out.longgetLong(String name, long dflt)Access some named configuration value as a longList<Pattern>getPatternList(String name, List<String> dflt)Access some named configuration value as aList.StringgetPortalUrl()Access the URL to the portal service on the server - append any additional path to the end.StringgetRawProperty(String name)Access the undereferenced value of the given property.StringgetSakaiHomePath()Access the file path to the "sakai home" on the app server.Locale[]getSakaiLocales()Get the list of allowed locales as controlled by config params for "locales" and "locales.more" Defaults when nothing is specified in the config files come fromSakaiLocales.SAKAI_LOCALES_DEFAULTStringgetServerId()Access the unique (to the cluster) id of the server.StringgetServerIdInstance()Access the combined server / instance id.StringgetServerInstance()Access the unique (to the cluster) instance id of the server.StringgetServerName()Access the server DNS name.Collection<String>getServerNameAliases()Access alternative namesStringgetServerUrl()Access the URL to the root of the server - append any additional path to the end.StringgetString(String name)Access some named configuration value as a string. 1) IF "name=value" THEN this will return "value" 2) IF "name=" THEN this will return null 3) IF name is not defined in the config THEN this will return "" (empty string)StringgetString(String name, String dflt)Access some named configuration value as a string. 1) IF "name=value" THEN this will return "value" 2) IF "name=" THEN this will return null 3) IF name is not defined in the config THEN this will return the provided default valueList<String>getStringList(String name, List<String> dflt)Access some named configuration value as aList.String[]getStrings(String name)Access some named configuration values as an array of strings.List<String>getToolCategories(String category)access the list of tool categories for the given site typeMap<String,List<String>>getToolCategoriesAsMap(String category)access the map of tool categories to tool ids for this site typeList<String>getToolGroup(String category)KNL-989 Access the list of tools by groupList<String>getToolOrder(String category)KNL-989 Access the list of tool ids in order for this category, to impose on the displays of many toolsList<String>getToolsRequired(String category)Access the list of tool ids that are required for this category.Map<String,String>getToolToCategoryMap(String category)access a map of tool id to tool category id for this site typeStringgetToolUrl()Access the URL to the tool dispatcher service on the server - append any additional path to the end.StringgetUserHomeUrl()Access the URL to the user's "home" (My Workspace) in the service.ServerConfigurationService.ConfigItemregisterConfigItem(ServerConfigurationService.ConfigItem configItem)Register a configuration item (or override an existing config), this should be called when changing or creating a configuration settingvoidregisterListener(ServerConfigurationService.ConfigurationListener configurationListener)Register a listener which will be notified whenever there is a configuration setting change, there is no need to unregister a listener as all listener references will be held weakly (if there are no more variables which reference the listener then it will be GCed and removed from the list of listeners) Registering the sameServerConfigurationService.ConfigurationListenerobject multiple times has no effectbooleantoolGroupIsRequired(String groupName, String toolId)KNL-989 Returns true if selected tool is contained in pre-initialized list of required itemsbooleantoolGroupIsSelected(String groupName, String toolId)KNL-989 Returns true if selected tool is contained in pre-initialized list of selected items
-
-
-
Field Detail
-
SERVICE_NAME
static final String SERVICE_NAME
This string can be used to find the service in the service manager.
-
CURRENT_SERVER_URL
static final String CURRENT_SERVER_URL
Key in the ThreadLocalManager for the serverUrl based on the current request.- See Also:
- Constant Field Values
-
CURRENT_PORTAL_PATH
static final String CURRENT_PORTAL_PATH
Key in the ThreadLocalManager for the path based on the current request.- See Also:
- Constant Field Values
-
UNKNOWN
static final String UNKNOWN
- See Also:
- Constant Field Values
-
TYPE_BOOLEAN
static final String TYPE_BOOLEAN
- See Also:
- Constant Field Values
-
TYPE_INT
static final String TYPE_INT
- See Also:
- Constant Field Values
-
TYPE_ARRAY
static final String TYPE_ARRAY
- See Also:
- Constant Field Values
-
TYPE_STRING
static final String TYPE_STRING
- See Also:
- Constant Field Values
-
TYPES
static final String[] TYPES
-
-
Method Detail
-
getServerId
String getServerId()
Access the unique (to the cluster) id of the server.- Returns:
- The unique (to the cluster) id of the server.
-
getServerInstance
String getServerInstance()
Access the unique (to the cluster) instance id of the server.- Returns:
- The unique (to the cluster) instance id of the server.
-
getServerIdInstance
String getServerIdInstance()
Access the combined server / instance id.- Returns:
- The combined server / instance id.
-
getServerName
String getServerName()
Access the server DNS name.- Returns:
- The server DNS name.
-
getServerNameAliases
Collection<String> getServerNameAliases()
Access alternative names- Returns:
- The server alternative names (doesn't contain the server name) or an empty collection if there is no alternative name
-
getServerUrl
String getServerUrl()
Access the URL to the root of the server - append any additional path to the end.- Returns:
- The URL to the root of the server.
-
getHelpUrl
String getHelpUrl(String helpContext)
Access the URL to the help service on the server - append in the path the tool well known id for context sensitive help.- Parameters:
helpContext- The context string.- Returns:
- The URL to the help service on the server.
-
getAccessUrl
String getAccessUrl()
Access the URL to the access service on the server - append any additional path to the end.- Returns:
- The URL to the access service on the server.
-
getAccessPath
String getAccessPath()
Access the path to the access service on the server relative to the base URL for the server.- Returns:
- The path to the access service on the server.
-
getPortalUrl
String getPortalUrl()
Access the URL to the portal service on the server - append any additional path to the end.- Returns:
- The URL to the portal service on the server.
-
getToolUrl
String getToolUrl()
Access the URL to the tool dispatcher service on the server - append any additional path to the end.- Returns:
- The URL to the tool dispatcher service on the server.
-
getGatewaySiteId
String getGatewaySiteId()
Access the site id for the gateway (public) site.- Returns:
- The site id for the gateway (public) site.
-
getLoggedOutUrl
String getLoggedOutUrl()
Access the URL to use as a redirect when the user has logged out.- Returns:
- The URL to use as a redirect when the user has logged out.
-
getUserHomeUrl
String getUserHomeUrl()
Access the URL to the user's "home" (My Workspace) in the service.- Returns:
- The URL to the user's "home" (My Workspace) in the service.
-
getSakaiHomePath
String getSakaiHomePath()
Access the file path to the "sakai home" on the app server.- Returns:
- The file path to the "sakai home" on the app server.
-
getString
String getString(String name)
Access some named configuration value as a string. 1) IF "name=value" THEN this will return "value" 2) IF "name=" THEN this will return null 3) IF name is not defined in the config THEN this will return "" (empty string)- Parameters:
name- The configuration value name (or key).- Returns:
- The configuration value for this name OR null if defined as 'blank' OR "" (empty string) if not defined.
-
getString
String getString(String name, String dflt)
Access some named configuration value as a string. 1) IF "name=value" THEN this will return "value" 2) IF "name=" THEN this will return null 3) IF name is not defined in the config THEN this will return the provided default value- Parameters:
name- The configuration value name (or key).dflt- The value to return if not found in the config.- Returns:
- The configuration value for this name OR null if defined as 'blank' OR default value if not defined.
-
getStrings
String[] getStrings(String name)
Access some named configuration values as an array of strings. There are 2 ways this is indicated in the system: 1) The name is the base name. name + ".count" must be defined to be a positive integer - how many are defined. name + "." + i (1..count) must be defined to be the values. 2) A comma delimited list of values: name=val1,val2,val3 If count is 0 or the value is empty then an empty string array is the resulting return value. Null is returned ONLY in the case the value cannot be found at all.- Parameters:
name- The configuration value name base.- Returns:
- The configuration value with this name, empty array if no values or count=0, OR null if config name is not found.
-
getLong
long getLong(String name, long dflt)
Access some named configuration value as a long- Parameters:
name- The configuration value name.dflt- The value to return if not found.- Returns:
- The configuration value with this name, or the default value if not found.
-
getInt
int getInt(String name, int dflt)
Access some named configuration value as an int.- Parameters:
name- The configuration value name.dflt- The value to return if not found.- Returns:
- The configuration value with this name, or the default value if not found.
-
getBoolean
boolean getBoolean(String name, boolean dflt)
Access some named configuration value as a boolean.- Parameters:
name- The configuration value name.dflt- The value to return if not found.- Returns:
- The configuration value with this name, or the default value if not found.
-
getStringList
List<String> getStringList(String name, List<String> dflt)
Access some named configuration value as aList. The value must be a comma separated set of values.- Parameters:
name- The configuration value name.dflt- The value to return if not found.- Returns:
- The configuration value with this name, as
a
List, or the default value if not found.
-
getPatternList
List<Pattern> getPatternList(String name, List<String> dflt)
Access some named configuration value as aList. The value must be a comma separated set of regexes.- Parameters:
name- The configuration value name.dflt- The value to return if not found.- Returns:
- The configuration value with this name, as
a
List, or the default value if not found.
-
getRawProperty
String getRawProperty(String name)
Access the undereferenced value of the given property. That is, Spring-style property placeholders will not be expanded as they would be in other getters on this interface. For example, consider the following configuration:property1=foo property2=${property1}Invoking
getString(String), passing"property2"will return"foo". However, invoking this method with the same argument will return"${property1}".Typically, a client of this method, e.g. a dynamic configuration management tool, is interested in reporting on the system's actual state from which return values of other getters are calculated. In such cases, caller-specified default values have no utility. Thus this method does not accept an argument specifying the property's default value.
For a given undefined property "X", this method should return exactly the same value as
getString("X"). Thus it may not be possible in all cases to distinguish between defined and undefined properties.- Parameters:
name- a property name. Must not benull- Returns:
- the property value. Property placeholders will not have been dereferenced. The value representing an non-existent property is implementation dependent.
-
getToolGroup
List<String> getToolGroup(String category)
KNL-989 Access the list of tools by group- Parameters:
category- The tool category- Returns:
- An unordered list of tool ids (String) in selected group, or an empty list if there are none for this category.
-
getToolOrder
List<String> getToolOrder(String category)
KNL-989 Access the list of tool ids in order for this category, to impose on the displays of many tools- Parameters:
category- Site type- Returns:
- An unordered list of group names (String), or an empty list if there are none for this category.
-
toolGroupIsSelected
boolean toolGroupIsSelected(String groupName, String toolId)
KNL-989 Returns true if selected tool is contained in pre-initialized list of selected items
-
toolGroupIsRequired
boolean toolGroupIsRequired(String groupName, String toolId)
KNL-989 Returns true if selected tool is contained in pre-initialized list of required items
-
getCategoryGroups
List<String> getCategoryGroups(String category)
KNL-989 Access the list of groups by category (site type)- Parameters:
category- The tool category- Returns:
- An ordered list of tool ids (String) indicating the desired tool display order, or an empty list if there are none for this category.
-
getToolsRequired
List<String> getToolsRequired(String category)
Access the list of tool ids that are required for this category.- Parameters:
category- The tool category.- Returns:
- A list of tool ids (String) that are required for this category, or an empty list if there are none for this category.
-
getDefaultTools
List<String> getDefaultTools(String category)
Access the list of tool ids that are selected by default for this category.- Parameters:
category- The tool category.- Returns:
- A list of tool ids (String) for this category to use by default, or an empty list if there are none for this category.
-
getToolCategories
List<String> getToolCategories(String category)
access the list of tool categories for the given site type- Parameters:
category- the site type- Returns:
- a list of tool category ids in order
-
getToolCategoriesAsMap
Map<String,List<String>> getToolCategoriesAsMap(String category)
access the map of tool categories to tool ids for this site type- Parameters:
category- the site type- Returns:
- a map of tool category ids to tool ids
-
getToolToCategoryMap
Map<String,String> getToolToCategoryMap(String category)
access a map of tool id to tool category id for this site type- Parameters:
category- the site type- Returns:
- map with tool id as key and category id as value
-
getSakaiLocales
Locale[] getSakaiLocales()
Get the list of allowed locales as controlled by config params for "locales" and "locales.more" Defaults when nothing is specified in the config files come fromSakaiLocales.SAKAI_LOCALES_DEFAULT- Returns:
- an array of all allowed Locales for this installation
- See Also:
SakaiLocales
-
getLocaleFromString
Locale getLocaleFromString(String localeString)
Parse a string into a Locale- Returns:
- Locale based on its string representation (language_region) OR default Locale if the string cannot be parsed
-
getCommaSeparatedListAsSet
Set<String> getCommaSeparatedListAsSet(String key)
Retrieves the string property by key, then splits it by comma. The trimmed tokens are then returned in a set. If the key isn't present, an empty set will be returned.- Parameters:
key- The property key- Returns:
- A set of trimmed tokens from a comma separated list
-
getConfig
<T> T getConfig(String name, T defaultValue)
Retrieves config values from the configuration service- Parameters:
name- the name of the setting to retrieve, Should be a string name: e.g. auto.ddl, mystuff.config, etc.defaultValue- a specified default value to return if this setting cannot be found, NOTE: You can set the default value to null but you must specify the class type in parens- Returns:
- the value of the configuration setting OR the default value if none can be found
-
getConfigItem
ServerConfigurationService.ConfigItem getConfigItem(String name)
Retrieve the internally stored the config item, this is not really for general use, if you want the value of a configuration variable then you should usegetConfig(String, Object)- Parameters:
name- the name of the setting to retrieve, Should be a string name: e.g. auto.ddl, mystuff.config, etc.- Returns:
- the config item OR null if none exists
-
registerConfigItem
ServerConfigurationService.ConfigItem registerConfigItem(ServerConfigurationService.ConfigItem configItem)
Register a configuration item (or override an existing config), this should be called when changing or creating a configuration setting- Parameters:
configItem- an instance of theServerConfigurationService.ConfigIteminterface with the name, value, source params set, useBasicConfigItemas an easy way to construct aServerConfigurationService.ConfigItem- Returns:
- the registered
ServerConfigurationService.ConfigItem - Throws:
IllegalArgumentException- if theServerConfigurationService.ConfigItemis not valid (does not have all required fields set)
-
registerListener
void registerListener(ServerConfigurationService.ConfigurationListener configurationListener)
Register a listener which will be notified whenever there is a configuration setting change, there is no need to unregister a listener as all listener references will be held weakly (if there are no more variables which reference the listener then it will be GCed and removed from the list of listeners) Registering the sameServerConfigurationService.ConfigurationListenerobject multiple times has no effect- Parameters:
configurationListener- aServerConfigurationService.ConfigurationListenerobject
-
getConfigData
ServerConfigurationService.ConfigData getConfigData()
Returns data about all the configuration values which are known to the system at the time and some stats which are useful- Returns:
- a config data class with data about the known configuration values
-
-