com.ibm.ecm.configuration
Class ConfigurationObject
- java.lang.Object
- com.ibm.ecm.configuration.ConfigurationObject
Direct known subclasses:
ApplicationConfig, DesktopAccessConfig, DesktopConfig, DesktopFeatureConfig, FavoriteConfig, FilenetConfig, FileTypeConfig, IconConfig, IconStatusConfig, IdLabelConfig, InterfaceTextConfig, InterfaceTextLabelConfig, InterfaceTextLocaleConfig, LocaleConfig, MenuConfig, MenuTypeConfig, MobileFeatureConfig, ODLoginConfig, OfficeCustomCommandConfig, PluginConfig, PluginUserConfig, PropertyMappingConfig, RecentItemConfig, RecentSearchConfig, RecentTeamspaceConfig, RepositoryConfig, ServerConfig, SettingsConfig, SyncConfig, ThemeConfig, TreeItemConfig, UserActionMacroConfig, UserConfig, UserGroupConfig, ViewerConfig, ViewerContentTypeConfig, ViewerDefConfig, ViewerMappingConfig, ViewOneConfig
- public abstract class ConfigurationObject
- extends java.lang.Object
Field Summary
Modifier and Type | Field and Description |
---|---|
|
ARRAY_DELIMITER
|
|
cloned
|
|
KEY_DELIMITER
|
|
LIST_ESC_CHAR
|
|
LIST_ESCAPE
|
|
LIST_SEPARATOR
|
|
MODIFIER
|
|
properties
|
Constructor Summary
Constructor and Description |
---|
ConfigurationObject(org.apache.commons.configuration.Configuration configuration,java.lang.String idPrefix,java.lang.String objectId)
Constructor method that it uses configuration type in the concrete subclass, idPrefix and objectID to form a
unique key to retrieve from DB in method load.
|
Method Summary
Modifier and Type | Method and Description |
---|---|
|
addValueToList(java.lang.String key,java.lang.String value)
|
|
arrayToString(java.lang.String[] array)
Convert an array object to a string.
|
|
covertEmptyStringtoNull(java.lang.String value)
Utility method to convert a string to null if it is empty.
|
|
delete()
Remove this configuration object from the DB.
|
|
dump(java.io.OutputStreamWriter osw)
Dumps the configuration to the specified output stream (used for logging and export)
|
|
getConfigurationObject()
Return configuration object back.
|
|
getDataType(java.lang.String key)
Returns the datatype of a configuration property.
|
|
getDataTypeValue(java.lang.String field)
Returns the field's value as per the field's data type.
|
|
getIdPrefix()
Return the application name used as ID prefix.
|
|
getKey()
Return the key value back by combined configuration type, ID prefix and ID.
|
|
getList(java.lang.String type,java.lang.String appName,javax.servlet.http.HttpServletRequest request)
Abstract method that needs to be override in concrete class to a return a collection back by type.
|
|
getMap(java.lang.Class<V> configClass,java.lang.String idPrefix,java.lang.String[] ids,boolean... flags)
Return a map of configuration object identified by ids field back.
|
|
getName()
|
|
getObjectId()
Return the object ID back.
|
|
getObjectType()
Abstract method to return object type.
|
|
getPropertyNames()
Return a map of string of all the fields name in the class where field is a private static final string
|
|
getPropertyValue(java.lang.String key)
Return the value back from the properties.
|
|
getPropertyValue(java.lang.String key,int defaultValue)
|
|
getPropertyValue(java.lang.String key,long defaultValue)
|
|
getPropertyValue(java.lang.String key,java.lang.String defaultValue)
|
|
isEmpty()
Is this configuration empty
|
|
load()
Retrieves the latest version from the configuration store.
|
|
propertiesToString(java.util.Properties properties)
Serialized properties object value to a string.
|
|
removeValuesFromList(java.lang.String key,java.util.List<java.lang.String> deleteValues)
Remove values from the properties object.
|
|
removeValuesFromList(java.lang.String key,java.util.List<java.lang.String> deleteValues,java.util.Properties props)
|
|
save()
Saves the object back to the configuration store.
|
|
setDefaultValue(java.lang.String propertyName,java.lang.String defaultValue)
Set the default value if not found in the properties object
|
|
setProperty(java.lang.String key,java.lang.String value)
Store value into properties directly.
|
|
setValues(JSONObject json)
todo: add more logic to deal with JSON array.
|
|
setValues(JSONObject json,boolean forceUpdate)
|
|
setValues(JSONObject json,boolean forceUpdate,boolean skipEncoding)
Used by the configuration action for example addConfiguration to store value into properties object.
|
|
skipThisPropertyWhenSaving(java.lang.String key)
Skip this property in saving if return value is true.
|
|
stringToArray(java.lang.String string)
Convert string value to an array object.
|
|
stringToList(java.lang.String string)
Convert string value to a list object.
|
toJSON()
Convert this configuration object to JSON object to be stream back to client.
|
|
|
toString()
Override to return the object ID of this configuration back.
|
|
writeConfigurationToFile(java.io.OutputStreamWriter osw,java.util.Collection<V> configList)
Write the configuration object out to the write object
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail
ARRAY_DELIMITER
- protected static final char ARRAY_DELIMITER
See Also:
KEY_DELIMITER
- protected static final char KEY_DELIMITER
See Also:
LIST_ESC_CHAR
- protected static final char LIST_ESC_CHAR
See Also:
LIST_ESCAPE
- protected static final java.lang.String LIST_ESCAPE
LIST_SEPARATOR
- protected static final java.lang.String LIST_SEPARATOR
See Also:
MODIFIER
- protected static final int MODIFIER
See Also:
properties
- protected java.util.Properties properties
cloned
- protected boolean cloned
Constructor Detail
ConfigurationObject
- public ConfigurationObject(org.apache.commons.configuration.Configuration configuration,
- java.lang.String idPrefix,
- java.lang.String objectId)
Constructor method that it uses configuration type in the concrete subclass, idPrefix and objectID to form a
unique key to retrieve from DB in method load.
Parameters:
configuration
- - A @{org.apache.commons.configuration.Configuration} object. idPrefix
- - A string value of application name. objectId
- - A string value of object ID. Method Detail
getConfigurationObject
- public org.apache.commons.configuration.Configuration getConfigurationObject( )
Return configuration object back.
Returns:
a @{org.apache.commons.configuration.Configuration} object
getObjectType
- public abstract java.lang.String getObjectType( )
Abstract method to return object type.
Returns:
a string object type back, for example "desktop", "repository"...
getName
- public java.lang.String getName( )
getObjectId
- public java.lang.String getObjectId( )
Return the object ID back.
Returns:
a string value of object ID.
getIdPrefix
- public java.lang.String getIdPrefix( )
Return the application name used as ID prefix. ICN uses this field to identify which application this
configuration is for.
Returns:
a string value of ID prefix, for example "navigator".
getKey
- public java.lang.String getKey( )
Return the key value back by combined configuration type, ID prefix and ID.
Returns:
a string value of key.
getList
- public java.util.Collection getList( java.lang.String type,
- java.lang.String appName,
- javax.servlet.http.HttpServletRequest request)
Abstract method that needs to be override in concrete class to a return a collection back by type.
Parameters:
type
- - A string value of object type. appName
- - A string value of application name. request
- - A HttpServletRequest object. Returns:
a collection of type.
load
- public void load()
Retrieves the latest version from the configuration store.
save
- public void save()
- throws org.apache.commons.configuration.ConfigurationException
Saves the object back to the configuration store.
Throws:
org.apache.commons.configuration.ConfigurationException
dump
- public void dump(java.io.OutputStreamWriter osw)
- throws java.io.IOException
Dumps the configuration to the specified output stream (used for logging and export)
Throws:
java.io.IOException
writeConfigurationToFile
- public static <V extends ConfigurationObject> void writeConfigurationToFile( java.io.OutputStreamWriter osw,
- java.util.Collection<V> configList)
- throws java.io.IOException
- java.io.FileNotFoundException
Write the configuration object out to the write object
Parameters:
osw
- - OutputStreamWriter to be used for the config dump and it has to use "ISO-8859-1" encoding configList
- - a collection of objects inherited from ConfigurationObject for example DesktopConfig. Throws:
java.io.IOException
java.io.FileNotFoundException
delete
- public void delete()
Remove this configuration object from the DB.
isEmpty
- public boolean isEmpty()
Is this configuration empty
Returns:
a boolean value if there is no property stored in the properties object.
stringToList
- public java.util.List stringToList( java.lang.String string)
Convert string value to a list object. This string object expect to have multiple value separated by ","
ARRAY_DELIMITER.
Parameters:
string
- - A value that needs to be parsed. Returns:
a list object back with parsed value.
stringToArray
- public java.lang.String[] stringToArray( java.lang.String string)
Convert string value to an array object. This string object expect to have multiple value separated by ","
ARRAY_DELIMITER.
Parameters:
string
- - A value that needs to be parsed. Returns:
an array object back with parsed value.
arrayToString
- public java.lang.String arrayToString( java.lang.String[] array)
Convert an array object to a string. Each value in the array will be separated by a "," ARRAY_DELIMITER character
in string.
Parameters:
array
- - An array of string Returns:
a string. Each value in the array will be separated by a "," ARRAY_DELIMITER character in string.
skipThisPropertyWhenSaving
- protected boolean skipThisPropertyWhenSaving( java.lang.String key)
Skip this property in saving if return value is true. Ambient property that no need to be saved.
Parameters:
key
- - A string value of property name. Returns:
a boolean value, true to skip this property in saving and false is otherwise.
propertiesToString
- protected java.lang.String propertiesToString( java.util.Properties properties)
Serialized properties object value to a string. Each key and value pair in the properties will be separated by a
";", LIST_DELIMITER character. if property in the properties object has this character in it. It needs to be
encoded first to avoid parsing problem in load method. Move append list delimiter to the front to prevent we
might skip some properties but delimiter already appended to the end of string. That will cause parsing to throw
exception of '' with no = in front of it.
Parameters:
properties
- Returns:
a string value that has all the property in the properties object.
covertEmptyStringtoNull
- public java.lang.String covertEmptyStringtoNull( java.lang.String value)
Utility method to convert a string to null if it is empty.
Parameters:
value
- - A string value that needs to be converted. Returns:
null or original value back if not null and not empty.
getMap
- public <V extends ConfigurationObject> java.util.Map<java.lang.String,V> getMap( java.lang.Class<V> configClass,
- java.lang.String idPrefix,
- java.lang.String[] ids,
- boolean... flags)
Return a map of configuration object identified by ids field back.
Parameters:
configClass
- - A configuration class object. idPrefix
- - A string value of ID prefix. ids
- - A array of ID. All ID in this array expected to be the same type identify by the configClass
parameter. flags
- - A optional flags to skip caching. Default is true. Returns:
a map of configuration object.
getDataTypeValue
- public java.lang.Object getDataTypeValue( java.lang.String field)
Returns the field's value as per the field's data type.
Since:
2.0.3
toJSON
- public JSONObject toJSON()
Convert this configuration object to JSON object to be stream back to client. Since toJSON is using properties
object directly therefore any default value is not applicable in this case. All added property after ICN 2.0.0 is
required to add itself into upgrade method to support this method.
Returns:
A JSONObject of this configuration
getDataType
- protected java.lang.Class getDataType( java.lang.String key)
Returns the datatype of a configuration property. This is implemented in subclasses and is used to properly
serialize the properties. The default implementation returns null which indicates that compatible behavior should
be used, which inspects the property value itself and guesses at the type of the property.
Returns:
a Class instance describing the datatype of the property.
Since:
2.0.2.1
setProperty
- public void setProperty(java.lang.String key,
- java.lang.String value)
Store value into properties directly. This method is discourage to use unless it is necessary because it bypass
key validation process that validate this property is part of this configuration.
Parameters:
key
- - A string value of property name. value
- - A string value of value getPropertyValue
- public java.lang.String getPropertyValue( java.lang.String key)
Return the value back from the properties.
Parameters:
key
- - A string value of property name. Returns:
a string value.
getPropertyValue
- public java.lang.String getPropertyValue( java.lang.String key,
- java.lang.String defaultValue)
getPropertyValue
- public int getPropertyValue(java.lang.String key,
- int defaultValue)
getPropertyValue
- public long getPropertyValue(java.lang.String key,
- long defaultValue)
getPropertyNames
- protected java.util.Map<java.lang.String,java.lang.String> getPropertyNames( )
Return a map of string of all the fields name in the class where field is a private static final string
Returns:
setValues
- public void setValues(JSONObject json)
todo: add more logic to deal with JSON array.
Parameters:
json
- setValues
- public void setValues(JSONObject json,
- boolean forceUpdate)
setValues
- public void setValues(JSONObject json,
- boolean forceUpdate,
- boolean skipEncoding)
Used by the configuration action for example addConfiguration to store value into properties object. It uses json
object, a incoming parameter and published properties from a configuration to set value. A published property is
identified by property signature of private static final String. Property value will encoded to protect
"\", "," and ";".
Parameters:
json
- - A JSON object. forceUpdate
- - Set this value even there is no matching published property. skipEncoding
- - If true, backslashes are not encoded removeValuesFromList
- public void removeValuesFromList( java.lang.String key,
- java.util.List<java.lang.String> deleteValues)
Remove values from the properties object.
Parameters:
key
- - A string of property name that identified a list. deleteValues
- - values need to be removed. removeValuesFromList
- protected void removeValuesFromList( java.lang.String key,
- java.util.List<java.lang.String> deleteValues,
- java.util.Properties props)
addValueToList
- public void addValueToList(java.lang.String key,
- java.lang.String value)
Parameters:
key
- Key field name. value
- Key. Since:
2.0.3 Added additional logic to filter out duplicated key
setDefaultValue
- protected void setDefaultValue( java.lang.String propertyName,
- java.lang.String defaultValue)
Set the default value if not found in the properties object
Parameters:
propertyName
- - A string value of property name. defaultValue
- - A string value of default value if not found. toString
- public java.lang.String toString( )
Override to return the object ID of this configuration back.
Overrides:
toString
in class java.lang.Object