com.ibm.ecm.configuration

Class ConfigurationObject

  1. java.lang.Object
  2. extended bycom.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

  1. public abstract class ConfigurationObject
  2. extends java.lang.Object
This is the superclass of all configuration objects, ie, objects stored in the configuration datastore. Subclasses should implement getObjectType and provide getter/setters that use the properties field. ICN stores its configuration data in DB. ICN DB uses ID and ATTRIBUTES two fields in configuration table to store its data. Both ID and ATTRIBUTES field are string type. ID is a key field that can store data up to 256 characters. ICN requires ID to contain only alphanumeric characters. ID has multiple parts. It is separate by "." to form a unique value in DB. The first part is configuration type for example "desktop", "repository". Second part is the application name followed by the ID field in the third part. Therefore "desktop.navigator.default" means this is a desktop configuration using by IBM Navigator application and its ID is "default". ATTRIBUTES a string type field that can hold up to 100M double bytes characters in ICN release 2.0.3. Prior to ICN 2.0.3 this filed can hold 32K of double bytes data. Data stores in this field has serialized properties file format that it has multiple key and value pair and each pair is separated by a separater, ";". In loading time, value in this field will be parsed and stored in a internal properties object by using Apache Common Configuration framework. Saving reverse this process by serialized properties object value to a string then store in the ATTRIBUTES field.

Field Summary

Modifier and Type Field and Description
  1. protected static
  2. char
ARRAY_DELIMITER
  1. protected
  2. boolean
cloned
  1. protected static
  2. char
KEY_DELIMITER
  1. protected static
  2. char
LIST_ESC_CHAR
  1. protected static
  2. java.lang.String
LIST_ESCAPE
  1. protected static
  2. java.lang.String
LIST_SEPARATOR
  1. protected static
  2. int
MODIFIER
  1. protected
  2. java.util.Properties
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
  1. void
addValueToList(java.lang.String key,java.lang.String value)
  1. java.lang.String
arrayToString(java.lang.String[] array)
Convert an array object to a string.
  1. java.lang.String
covertEmptyStringtoNull(java.lang.String value)
Utility method to convert a string to null if it is empty.
  1. void
delete()
Remove this configuration object from the DB.
  1. void
dump(java.io.OutputStreamWriter osw)
Dumps the configuration to the specified output stream (used for logging and export)
  1. org.apache.commons.configuration.Configuration
getConfigurationObject()
Return configuration object back.
  1. protected
  2. java.lang.Class
getDataType(java.lang.String key)
Returns the datatype of a configuration property.
  1. java.lang.Object
getDataTypeValue(java.lang.String field)
Returns the field's value as per the field's data type.
  1. java.lang.String
getIdPrefix()
Return the application name used as ID prefix.
  1. java.lang.String
getKey()
Return the key value back by combined configuration type, ID prefix and ID.
  1. 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.
  1. <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.
  1. java.lang.String
getName()
  1. java.lang.String
getObjectId()
Return the object ID back.
  1. abstract
  2. java.lang.String
getObjectType()
Abstract method to return object type.
  1. protected
  2. 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
  1. java.lang.String
getPropertyValue(java.lang.String key)
Return the value back from the properties.
  1. int
getPropertyValue(java.lang.String key,int defaultValue)
  1. long
getPropertyValue(java.lang.String key,long defaultValue)
  1. java.lang.String
getPropertyValue(java.lang.String key,java.lang.String defaultValue)
  1. boolean
isEmpty()
Is this configuration empty
  1. void
load()
Retrieves the latest version from the configuration store.
  1. protected
  2. java.lang.String
propertiesToString(java.util.Properties properties)
Serialized properties object value to a string.
  1. void
removeValuesFromList(java.lang.String key,java.util.List<java.lang.String> deleteValues)
Remove values from the properties object.
  1. protected
  2. void
removeValuesFromList(java.lang.String key,java.util.List<java.lang.String> deleteValues,java.util.Properties props)
  1. void
save()
Saves the object back to the configuration store.
  1. protected
  2. void
setDefaultValue(java.lang.String propertyName,java.lang.String defaultValue)
Set the default value if not found in the properties object
  1. void
setProperty(java.lang.String key,java.lang.String value)
Store value into properties directly.
  1. void
setValues(JSONObject json)
todo: add more logic to deal with JSON array.
  1. void
setValues(JSONObject json,boolean forceUpdate)
  1. void
setValues(JSONObject json,boolean forceUpdate,boolean skipEncoding)
Used by the configuration action for example addConfiguration to store value into properties object.
  1. protected
  2. boolean
skipThisPropertyWhenSaving(java.lang.String key)
Skip this property in saving if return value is true.
  1. java.lang.String[]
stringToArray(java.lang.String string)
Convert string value to an array object.
  1. java.util.List
stringToList(java.lang.String string)
Convert string value to a list object.
  1. JSONObject
toJSON()
Convert this configuration object to JSON object to be stream back to client.
  1. java.lang.String
toString()
Override to return the object ID of this configuration back.
  1. static
  2. <V extends ConfigurationObject> void
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

  1. protected static final char ARRAY_DELIMITER
See Also:

KEY_DELIMITER

  1. protected static final char KEY_DELIMITER
See Also:

LIST_ESC_CHAR

  1. protected static final char LIST_ESC_CHAR
See Also:

LIST_ESCAPE

  1. protected static final java.lang.String LIST_ESCAPE

LIST_SEPARATOR

  1. protected static final java.lang.String LIST_SEPARATOR
See Also:

MODIFIER

  1. protected static final int MODIFIER
See Also:

properties

  1. protected java.util.Properties properties

cloned

  1. protected boolean cloned

Constructor Detail

ConfigurationObject

  1. public ConfigurationObject(org.apache.commons.configuration.Configuration configuration,
  2. java.lang.String idPrefix,
  3. 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

  1. public org.apache.commons.configuration.Configuration getConfigurationObject( )
Return configuration object back.
Returns:
a @{org.apache.commons.configuration.Configuration} object

getObjectType

  1. public abstract java.lang.String getObjectType( )
Abstract method to return object type.
Returns:
a string object type back, for example "desktop", "repository"...

getName

  1. public java.lang.String getName( )

getObjectId

  1. public java.lang.String getObjectId( )
Return the object ID back.
Returns:
a string value of object ID.

getIdPrefix

  1. 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

  1. 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

  1. public java.util.Collection getList( java.lang.String type,
  2. java.lang.String appName,
  3. 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

  1. public void load()
Retrieves the latest version from the configuration store.

save

  1. public void save()
  2. throws org.apache.commons.configuration.ConfigurationException
Saves the object back to the configuration store.
Throws:
org.apache.commons.configuration.ConfigurationException

dump

  1. public void dump(java.io.OutputStreamWriter osw)
  2. throws java.io.IOException
Dumps the configuration to the specified output stream (used for logging and export)
Throws:
java.io.IOException

writeConfigurationToFile

  1. public static <V extends ConfigurationObject> void writeConfigurationToFile( java.io.OutputStreamWriter osw,
  2. java.util.Collection<V> configList)
  3. throws java.io.IOException
  4. 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

  1. public void delete()
Remove this configuration object from the DB.

isEmpty

  1. public boolean isEmpty()
Is this configuration empty
Returns:
a boolean value if there is no property stored in the properties object.

stringToList

  1. 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

  1. 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

  1. 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

  1. 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

  1. 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

  1. 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

  1. public <V extends ConfigurationObject> java.util.Map<java.lang.String,V> getMap( java.lang.Class<V> configClass,
  2. java.lang.String idPrefix,
  3. java.lang.String[] ids,
  4. 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

  1. 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

  1. 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

  1. 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

  1. public void setProperty(java.lang.String key,
  2. 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

  1. 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

  1. public java.lang.String getPropertyValue( java.lang.String key,
  2. java.lang.String defaultValue)

getPropertyValue

  1. public int getPropertyValue(java.lang.String key,
  2. int defaultValue)

getPropertyValue

  1. public long getPropertyValue(java.lang.String key,
  2. long defaultValue)

getPropertyNames

  1. 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

  1. public void setValues(JSONObject json)
todo: add more logic to deal with JSON array.
Parameters:
json -

setValues

  1. public void setValues(JSONObject json,
  2. boolean forceUpdate)

setValues

  1. public void setValues(JSONObject json,
  2. boolean forceUpdate,
  3. 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

  1. public void removeValuesFromList( java.lang.String key,
  2. 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

  1. protected void removeValuesFromList( java.lang.String key,
  2. java.util.List<java.lang.String> deleteValues,
  3. java.util.Properties props)

addValueToList

  1. public void addValueToList(java.lang.String key,
  2. java.lang.String value)
Parameters:
key - Key field name.
value - Key.
Since:
2.0.3 Added additional logic to filter out duplicated key

setDefaultValue

  1. protected void setDefaultValue( java.lang.String propertyName,
  2. 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

  1. public java.lang.String toString( )
Override to return the object ID of this configuration back.
Overrides:
toString in class java.lang.Object