public class PreferencesManager extends java.lang.Object implements IConnectorPreferences
IConnectorPreferences to get
all the configuration settings that Cloud Connector requires.
This class uses an instance of
ConfigurationManager
class to try to get the parameters from the record store, if they are not
found it tries to read them from the configuration file
(connector_config.txt). It also stores the given values in the record
store as preferences in the device.
If any other method or strategy is going to be provided to get/set the values,
this class might be extended to override the methods
getParameterValue(java.lang.String) and setParameterValue(java.lang.String, java.lang.String).
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_DEVICE_ID_TYPE
Default value for 'Device ID type' setting: "provisioning".
|
static java.lang.String |
DEFAULT_STORAGE_DIR
Default storage directory path: "/fs".
|
static java.lang.String |
DEVICE_ID_TYPE_IMEI
'Device ID' is calculated based on the device IMEI.
|
static java.lang.String |
DEVICE_ID_TYPE_MAC
'Device ID' is calculated based on the device MAC Address.
|
static java.lang.String |
DEVICE_ID_TYPE_PROVISIONING
'Device ID' is calculated by provisioning, Device Cloud will provide a valid ID.
|
static java.lang.String |
DEVICE_ID_TYPE_STATIC
'Device ID' is a static value already configured.
|
static java.lang.String |
PARAM_DEVICE_ID_TYPE
'Device ID type' setting name: "device_id_type".
|
| Constructor and Description |
|---|
PreferencesManager(IPlatformCustomization platformCustomization)
Class constructor.
|
PreferencesManager(IPlatformCustomization platformCustomization,
java.lang.String configFile)
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getAuthorizationPassword()
Retrieves the authorization password setting value if the authorization
type is configured to
PreferencesConstants.AUTHORIZATION_TYPE_BASIC
(). |
java.lang.String |
getAuthorizationType()
Retrieves the connection authorization type.
|
java.lang.String |
getContact()
Retrieves the Cloud Connector device contact setting.
|
java.lang.String |
getDescription()
Retrieves the Cloud Connector device description setting.
|
java.lang.String |
getDeviceID()
Retrieves the device's Device ID.
|
java.lang.String |
getDeviceType()
Retrieves the device type.
|
java.lang.String |
getFileSystemRootDir()
Retrieves the file system root (sandbox) directory.
|
java.lang.String |
getFirmwareVersion()
Retrieves the 4 digit firmware version of the system.
|
int |
getKeepAliveTime()
Retrieves the keep alive time setting value in seconds.
|
java.lang.String |
getLocation()
Retrieves the Cloud Connector device location setting.
|
java.lang.String |
getParameterValue(java.lang.String parameter)
Retrieves the value of the given parameter name.
|
int |
getReconnectTime()
Retrieves the configured reconnect time delay setting in seconds.
|
int |
getServerKeepAliveTime()
Retrieves the server keep alive time setting value in seconds.
|
Location |
getStaticLocation()
Retrieves the static location to use.
|
java.lang.String |
getURLString()
Retrieves the configured Cloud Connector URL preference.
|
byte[] |
getVendorID()
Retrieves the device vendor ID.
|
int |
getWaitTimes()
Retrieves the value of the wait times preference.
|
boolean |
isCompressionEnabled()
Retrieves whether messages compression is enabled or not.
|
boolean |
isDataServiceEnabled()
Retrieves whether the data service is enabled or not.
|
boolean |
isFileSystemEnabled()
Retrieves whether file system should be enabled or not.
|
boolean |
isRCIEnabled()
Retrieves whether the RCI facility is enabled or not.
|
boolean |
isReconnectEnabled()
Retrieves whether reconnect setting is enabled or not.
|
boolean |
isSecureConnectionEnabled()
Retrieves whether secure connection is enabled or not.
|
void |
setAuthorizationPassword(java.lang.String authorizationPassword)
Sets the authorization password setting new value.
|
void |
setAuthorizationType(java.lang.String authorizationType)
Sets the new value for the connection authorization type setting.
|
void |
setCompressionEnabled(boolean compressionEnabled)
Sets the new value of the compress messages setting.
|
void |
setContact(java.lang.String contact)
Sets the Cloud Connector device contact setting.
|
void |
setDescription(java.lang.String description)
Sets the Cloud Connector device description setting.
|
void |
setDeviceID(java.lang.String deviceID)
Stores the device ID.
|
void |
setKeepAliveTime(int keepAliveTime)
Sets the new value for the Keep Alive time setting in seconds.
|
void |
setLocation(java.lang.String location)
Sets the Cloud Connector device location setting.
|
void |
setParameterValue(java.lang.String parameter,
java.lang.String value)
Sets the given parameter value.
|
void |
setReconnectEnabled(boolean reconnectEnabled)
Sets the new value of the reconnect setting.
|
void |
setReconnectTime(int reconnectTime)
Sets the new value for the reconnect time setting in seconds.
|
void |
setSecureConnectionEnabled(boolean secureConnectionEnabled)
Sets the new value for the use secure connection setting.
|
void |
setServerKeepAliveTime(int keepAliveTime)
Sets the new value for the Server Keep Alive time setting in seconds.
|
void |
setStaticLocation(Location location)
Sets the value of the static location.
|
void |
setURLString(java.lang.String url)
Sets the Cloud Connector URL preference.
|
void |
setUseStaticLocation(boolean useStaticLocation)
Sets the value of use static location preference.
|
void |
setVendorID(java.lang.String vendorID)
Sets the Cloud Connector Vendor ID setting.
|
void |
setWaitTimes(int waitTimes)
Sets the new value for the wait times setting.
|
boolean |
useStaticLocation()
Retrieves whether static location will be used or not.
|
public static final java.lang.String DEFAULT_DEVICE_ID_TYPE
public static final java.lang.String DEFAULT_STORAGE_DIR
public static final java.lang.String DEVICE_ID_TYPE_IMEI
The value of this constant is "imei".
public static final java.lang.String DEVICE_ID_TYPE_MAC
The value of this constant is "mac".
public static final java.lang.String DEVICE_ID_TYPE_PROVISIONING
The value of this constant is "provisioning".
public static final java.lang.String DEVICE_ID_TYPE_STATIC
The value of this constant is "static".
public static final java.lang.String PARAM_DEVICE_ID_TYPE
public PreferencesManager(IPlatformCustomization platformCustomization)
platformCustomization - Platform customization to read and set
some preference values.public PreferencesManager(IPlatformCustomization platformCustomization, java.lang.String configFile)
platformCustomization - Platform customization to read and set
some preference values.configFile - Path of the Cloud Connector configuration file.public java.lang.String getAuthorizationPassword()
IConnectorPreferencesPreferencesConstants.AUTHORIZATION_TYPE_BASIC
().getAuthorizationPassword in interface IConnectorPreferencesPreferencesConstants.AUTHORIZATION_TYPE_BASIC,
IConnectorPreferences.setAuthorizationPassword(java.lang.String),
IConnectorPreferences.getAuthorizationType(),
IConnectorPreferences.setAuthorizationType(java.lang.String)public java.lang.String getAuthorizationType()
IConnectorPreferencesIt should be PreferencesConstants.AUTHORIZATION_TYPE_NONE or
PreferencesConstants.AUTHORIZATION_TYPE_BASIC
().
For the PreferencesConstants.AUTHORIZATION_TYPE_BASIC
authorization type a password should be provided
IConnectorPreferences.getAuthorizationPassword().
getAuthorizationType in interface IConnectorPreferencesPreferencesConstants.AUTHORIZATION_TYPE_NONE,
PreferencesConstants.AUTHORIZATION_TYPE_BASIC,
IConnectorPreferences.setAuthorizationType(java.lang.String),
IConnectorPreferences.getAuthorizationPassword(),
IConnectorPreferences.setAuthorizationPassword(java.lang.String)public java.lang.String getContact()
IConnectorPreferencesgetContact in interface IConnectorPreferencesPreferencesConstants.DEFAULT_CONTACT
().PreferencesConstants.DEFAULT_CONTACT,
IConnectorPreferences.setContact(java.lang.String)public java.lang.String getDescription()
IConnectorPreferencesgetDescription in interface IConnectorPreferencesPreferencesConstants.DEFAULT_DESCRIPTION
().PreferencesConstants.DEFAULT_DESCRIPTION,
IConnectorPreferences.setDescription(java.lang.String)public java.lang.String getDeviceID()
IConnectorPreferencesThis method should return null to use provisioning to get the
Device ID.
getDeviceID in interface IConnectorPreferencespublic java.lang.String getDeviceType()
IConnectorPreferencesA null or empty string is an invalid value.
The maximum length of this string is
PreferencesConstants.DEVICE_TYPE_MAXIMUM_LENGTH
().
getDeviceType in interface IConnectorPreferencesPreferencesConstants.DEVICE_TYPE_MAXIMUM_LENGTHpublic java.lang.String getFileSystemRootDir()
IConnectorPreferencesgetFileSystemRootDir in interface IConnectorPreferencesIConnectorPreferences.isFileSystemEnabled()public java.lang.String getFirmwareVersion()
IConnectorPreferencesThis version will be used as Firmware Target 0x00 version
if no firmware targets are provided (see
IFirmwareUpdateImplementation.getFirmwareTargets()),
if no firmware target 0x00 is defined or it is invalid.
In these cases a virtual target 0x00 non-update-able will be
generated using the version provided by this method.
Target 0x00 represents the firmware that is running Cloud
Connector.
getFirmwareVersion in interface IConnectorPreferencespublic int getKeepAliveTime()
IConnectorPreferencesThe value should be:
time > PreferenceConstants.KEEP_ALIVE_MINIMUM_VALUE
()time < PreferenceConstants.KEEP_ALIVE_MAXIMUM_VALUE
()getKeepAliveTime in interface IConnectorPreferencesPreferencesConstants.DEFAULT_KEEP_ALIVE_TIME
().PreferencesConstants.DEFAULT_KEEP_ALIVE_TIME,
IConnectorPreferences.setKeepAliveTime(int)public java.lang.String getLocation()
IConnectorPreferencesgetLocation in interface IConnectorPreferencesPreferencesConstants.DEFAULT_LOCATION
().PreferencesConstants.DEFAULT_LOCATION,
IConnectorPreferences.setLocation(java.lang.String)public java.lang.String getParameterValue(java.lang.String parameter)
parameter - the parameter name to get its value.null if the configuration file does not exists, if it
cannot be read or if the parameter is not defined.public int getReconnectTime()
IConnectorPreferencesThe value should be:
time > PreferenceConstants.RECONNECT_TIME_MINIMUM_VALUE
()time < PreferenceConstants.RECONNECT_TIME_MAXIMUM_VALUE
()getReconnectTime in interface IConnectorPreferencesPreferencesConstants.DEFAULT_RECONNECT_TIME
()..PreferencesConstants.DEFAULT_RECONNECT_TIME,
PreferencesConstants.RECONNECT_TIME_MINIMUM_VALUE,
PreferencesConstants.RECONNECT_TIME_MAXIMUM_VALUE,
PreferencesConstants.RECONNECT_TIME_MAX_RANDOM,
IConnectorPreferences.setReconnectTime(int),
IConnectorPreferences.isReconnectEnabled(),
IConnectorPreferences.setReconnectEnabled(boolean)public int getServerKeepAliveTime()
IConnectorPreferencesThe value should be:
time > PreferenceConstants.KEEP_ALIVE_MINIMUM_VALUE
()time < PreferenceConstants.KEEP_ALIVE_MAXIMUM_VALUE
()getServerKeepAliveTime in interface IConnectorPreferencesPreferencesConstants.DEFAULT_SERVER_KEEP_ALIVE_TIME
().PreferencesConstants.DEFAULT_SERVER_KEEP_ALIVE_TIME,
IConnectorPreferences.setServerKeepAliveTime(int)public Location getStaticLocation()
IConnectorPreferencesgetStaticLocation in interface IConnectorPreferencesIConnectorPreferences.useStaticLocation(),
IConnectorPreferences.setUseStaticLocation(boolean),
IConnectorPreferences.setStaticLocation(com.etherios.connector.core.system.Location)public java.lang.String getURLString()
IConnectorPreferencesIt should be PreferencesConstants.URL_US
(PreferencesConstants.URL_US) or
PreferencesConstants.URL_UK (PreferencesConstants.URL_UK).
getURLString in interface IConnectorPreferencesnull if not
configured.PreferencesConstants.URL_US,
PreferencesConstants.URL_UK,
IConnectorPreferences.setURLString(java.lang.String)public byte[] getVendorID()
IConnectorPreferencesgetVendorID in interface IConnectorPreferencesnull if not configured.public int getWaitTimes()
IConnectorPreferencesThe value should be:
times > PreferenceConstants.WAIT_TIMES_MINIMUM_VALUE
()times < PreferenceConstants.WAIT_TIMES_MAXIMUM_VALUE
()getWaitTimes in interface IConnectorPreferencesPreferencesConstants.DEFAULT_WAIT_TIMES
()
if not configured.PreferencesConstants.DEFAULT_WAIT_TIMES,
PreferencesConstants.WAIT_TIMES_MINIMUM_VALUE,
PreferencesConstants.WAIT_TIMES_MAXIMUM_VALUE,
IConnectorPreferences.setWaitTimes(int)public boolean isCompressionEnabled()
IConnectorPreferencesThe default value is returned if it is not configured
PreferencesConstants.DEFAULT_ENABLE_COMPRESSION
().
isCompressionEnabled in interface IConnectorPreferencestrue if messages compression is enabled, false
otherwise.PreferencesConstants.DEFAULT_ENABLE_COMPRESSION,
IConnectorPreferences.setCompressionEnabled(boolean)public boolean isDataServiceEnabled()
IConnectorPreferencesThe default value is returned if it is not configured
PreferencesConstants.DEFAULT_ENABLE_DATA_SERVICE
().
isDataServiceEnabled in interface IConnectorPreferencestrue if the data service is enabled, false
otherwise.PreferencesConstants.DEFAULT_ENABLE_DATA_SERVICEpublic boolean isFileSystemEnabled()
IConnectorPreferencesThe default value is returned if it is not configured
PreferencesConstants.DEFAULT_ENABLE_FILE_SYSTEM
().
isFileSystemEnabled in interface IConnectorPreferencestrue if file system is enabled, false otherwise.PreferencesConstants.DEFAULT_ENABLE_FILE_SYSTEM,
IConnectorPreferences.getFileSystemRootDir()public boolean isRCIEnabled()
IConnectorPreferencesThe default value is returned if it is not configured
PreferencesConstants.DEFAULT_ENABLE_RCI
().
isRCIEnabled in interface IConnectorPreferencestrue if RCI facility is enabled, false otherwise.PreferencesConstants.DEFAULT_ENABLE_RCIpublic boolean isReconnectEnabled()
IConnectorPreferencesThe default value is returned if it is not configured
PreferencesConstants.DEFAULT_ENABLE_RECONNECT
().
isReconnectEnabled in interface IConnectorPreferencestrue if reconnect setting is configured, false
otherwise.PreferencesConstants.DEFAULT_ENABLE_RECONNECT,
IConnectorPreferences.setReconnectEnabled(boolean),
IConnectorPreferences.getReconnectTime(),
IConnectorPreferences.setReconnectTime(int)public boolean isSecureConnectionEnabled()
IConnectorPreferencesThe default value is returned if it is not configured
PreferencesConstants.DEFAULT_ENABLE_SECURE_CONNECTION
().
isSecureConnectionEnabled in interface IConnectorPreferencestrue if secure connection is enabled, false
otherwise.PreferencesConstants.DEFAULT_ENABLE_SECURE_CONNECTION,
IConnectorPreferences.setSecureConnectionEnabled(boolean)public void setAuthorizationPassword(java.lang.String authorizationPassword)
IConnectorPreferencesPreferencesConstants.AUTHORIZATION_TYPE_BASIC
().setAuthorizationPassword in interface IConnectorPreferencesauthorizationPassword - New value for the authorization password setting.PreferencesConstants.AUTHORIZATION_TYPE_NONE,
PreferencesConstants.AUTHORIZATION_TYPE_BASIC,
IConnectorPreferences.getAuthorizationPassword(),
IConnectorPreferences.getAuthorizationType(),
IConnectorPreferences.setAuthorizationType(java.lang.String)public void setAuthorizationType(java.lang.String authorizationType)
IConnectorPreferencesIt should be PreferencesConstants.AUTHORIZATION_TYPE_NONE or
PreferencesConstants.AUTHORIZATION_TYPE_BASIC
().
For the PreferencesConstants.AUTHORIZATION_TYPE_BASIC
authorization type a password should be provided
IConnectorPreferences.getAuthorizationPassword().
setAuthorizationType in interface IConnectorPreferencesauthorizationType - Value of connection authorization type.PreferencesConstants.AUTHORIZATION_TYPE_NONE,
PreferencesConstants.AUTHORIZATION_TYPE_BASIC,
IConnectorPreferences.getAuthorizationType(),
IConnectorPreferences.getAuthorizationPassword(),
IConnectorPreferences.setAuthorizationPassword(java.lang.String)public void setCompressionEnabled(boolean compressionEnabled)
IConnectorPreferencessetCompressionEnabled in interface IConnectorPreferencescompressionEnabled - true to compress messages, false otherwise.IConnectorPreferences.isCompressionEnabled()public void setContact(java.lang.String contact)
IConnectorPreferencessetContact in interface IConnectorPreferencescontact - The Cloud Connector device contact setting.IConnectorPreferences.getContact()public void setDescription(java.lang.String description)
IConnectorPreferencessetDescription in interface IConnectorPreferencesdescription - The Cloud Connector device description setting.IConnectorPreferences.getDescription()public void setDeviceID(java.lang.String deviceID)
IConnectorPreferencesnull device ID.setDeviceID in interface IConnectorPreferencesdeviceID - Device ID to store.public void setKeepAliveTime(int keepAliveTime)
IConnectorPreferencesThe value should be:
time > PreferenceConstants.KEEP_ALIVE_MINIMUM_VALUE
()time < PreferenceConstants.KEEP_ALIVE_MAXIMUM_VALUE
()setKeepAliveTime in interface IConnectorPreferenceskeepAliveTime - New value for the Keep Alive time setting.PreferencesConstants.DEFAULT_KEEP_ALIVE_TIME,
PreferencesConstants.KEEP_ALIVE_MINIMUM_VALUE,
PreferencesConstants.KEEP_ALIVE_MAXIMUM_VALUE,
IConnectorPreferences.getKeepAliveTime()public void setLocation(java.lang.String location)
IConnectorPreferencessetLocation in interface IConnectorPreferenceslocation - The Cloud Connector device location setting.IConnectorPreferences.getLocation()public void setParameterValue(java.lang.String parameter,
java.lang.String value)
parameter - The parameter name to be configured.value - A string that represents the value of the given parameter.public void setReconnectEnabled(boolean reconnectEnabled)
IConnectorPreferencessetReconnectEnabled in interface IConnectorPreferencesreconnectEnabled - true to enable reconnect, false otherwise.IConnectorPreferences.isReconnectEnabled(),
IConnectorPreferences.getReconnectTime(),
IConnectorPreferences.setReconnectTime(int)public void setReconnectTime(int reconnectTime)
IConnectorPreferencesThe value should be:
time > PreferenceConstants.RECONNECT_TIME_MINIMUM_VALUE
()time < PreferenceConstants.RECONNECT_TIME_MAXIMUM_VALUE
()setReconnectTime in interface IConnectorPreferencesreconnectTime - New value for the reconnect time setting.PreferencesConstants.DEFAULT_RECONNECT_TIME,
PreferencesConstants.RECONNECT_TIME_MINIMUM_VALUE,
PreferencesConstants.RECONNECT_TIME_MAXIMUM_VALUE,
PreferencesConstants.RECONNECT_TIME_MAX_RANDOM,
IConnectorPreferences.getReconnectTime(),
IConnectorPreferences.isReconnectEnabled(),
IConnectorPreferences.setReconnectEnabled(boolean)public void setSecureConnectionEnabled(boolean secureConnectionEnabled)
IConnectorPreferencessetSecureConnectionEnabled in interface IConnectorPreferencessecureConnectionEnabled - true to enable secure connection, false
otherwise.IConnectorPreferences.isSecureConnectionEnabled()public void setServerKeepAliveTime(int keepAliveTime)
IConnectorPreferencesThe value should be:
time > PreferenceConstants.KEEP_ALIVE_MINIMUM_VALUE
()time < PreferenceConstants.KEEP_ALIVE_MAXIMUM_VALUE
()setServerKeepAliveTime in interface IConnectorPreferenceskeepAliveTime - New value for the Server Keep Alive time setting.PreferencesConstants.DEFAULT_SERVER_KEEP_ALIVE_TIME,
IConnectorPreferences.getServerKeepAliveTime()public void setStaticLocation(Location location)
IConnectorPreferencessetStaticLocation in interface IConnectorPreferenceslocation - The static location value.IConnectorPreferences.useStaticLocation(),
IConnectorPreferences.setUseStaticLocation(boolean),
IConnectorPreferences.getStaticLocation()public void setURLString(java.lang.String url)
IConnectorPreferencesIt should be PreferencesConstants.URL_US
(PreferencesConstants.URL_US) or
PreferencesConstants.URL_UK (PreferencesConstants.URL_UK).
setURLString in interface IConnectorPreferencesurl - The new Cloud Connector URL.PreferencesConstants.URL_US,
PreferencesConstants.URL_UK,
IConnectorPreferences.getURLString()public void setUseStaticLocation(boolean useStaticLocation)
IConnectorPreferencessetUseStaticLocation in interface IConnectorPreferencesuseStaticLocation - true to use static location,
false otherwise.IConnectorPreferences.useStaticLocation(),
IConnectorPreferences.getStaticLocation(),
IConnectorPreferences.setStaticLocation(com.etherios.connector.core.system.Location)public void setVendorID(java.lang.String vendorID)
IConnectorPreferencessetVendorID in interface IConnectorPreferencesvendorID - The Cloud Connector VendorID setting.public void setWaitTimes(int waitTimes)
IConnectorPreferencesThe value should be:
times > PreferenceConstants.WAIT_TIMES_MINIMUM_VALUE
()times < PreferenceConstants.WAIT_TIMES_MAXIMUM_VALUE
()setWaitTimes in interface IConnectorPreferenceswaitTimes - New value of the wait times setting.PreferencesConstants.WAIT_TIMES_MINIMUM_VALUE,
PreferencesConstants.WAIT_TIMES_MAXIMUM_VALUE,
IConnectorPreferences.getWaitTimes()public boolean useStaticLocation()
IConnectorPreferencesThe default value is returned if it is not configured
PreferencesConstants.DEFAULT_USE_STATIC_LOCATION
().
useStaticLocation in interface IConnectorPreferencestrue if static location will be used, false
otherwise.PreferencesConstants.DEFAULT_USE_STATIC_LOCATION,
IConnectorPreferences.setUseStaticLocation(boolean),
IConnectorPreferences.getStaticLocation(),
IConnectorPreferences.setStaticLocation(com.etherios.connector.core.system.Location)© Copyright 2014 Etherios, Inc. All rights reserved. Etherios, Inc. is a Division of Digi International Inc.