@Requirement(reqId="DOI_CONFIG_010", reqName="Configuration du serveur central") public final class DoiSettings extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
DoiSettings.DoiSettingsHolder
Holder
|
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_PROPERTIES
Configuration files in JAR.
|
private static String |
INIST_TEST_DOI
Test DOI : "10.5072".
|
private static org.apache.logging.log4j.Logger |
LOG
Logger.
|
private static ConcurrentHashMap<String,String> |
MAP_PROPERTIES
Settings loaded in memory.
|
private String |
pathApp
Path where the Java application inputStream located.
|
private String |
secretKey
Secret key to decrypt login and password.
|
Modifier | Constructor and Description |
---|---|
private |
DoiSettings()
private constructor Loads the defautl configuration properties
"config.properties"
|
Modifier and Type | Method and Description |
---|---|
private void |
computePathOfTheApplication()
Computes path of the application.
|
private void |
copyStream(InputStream inputStream,
OutputStream outputStream)
Copy input stream to output stream.
|
void |
displayConfigFile()
Displays the configuration file.
|
private void |
fillConcurrentMap(Properties properties,
org.apache.logging.log4j.Level level)
Sets the configuration as a MAP_PROPERTIES.
|
boolean |
getBoolean(String key)
Returns the value of the key as a boolean.
|
static DoiSettings |
getInstance()
Access to unique INSTANCE of Settings
|
int |
getInt(String key)
Returns the value of the key as an integer.
|
int |
getInt(String key,
String defaultValue)
Returns the value of the key as an integer.
|
Long |
getLong(String key)
Returns the value of the key as a long.
|
Long |
getLong(String key,
String defaultValue)
Returns the value of the key as a long.
|
String |
getPathApp()
Returns the path of the application on the file system.
|
String |
getSecret(String key)
Returns the decoded value of the key.
|
String |
getSecretKey()
Returns the secret key.
|
String |
getSecretValue(String value)
Returns the decoded value of the value.
|
String |
getString(String key)
Returns the value of the key or null if no mapping for the key.
|
String |
getString(String key,
String defaultValue)
Returns the value of the key as string.
|
boolean |
hasValue(String key)
Tests if the key has a value.
|
private void |
init(Properties properties,
org.apache.logging.log4j.Level level)
Loads configuration file and set it in memory.
|
private boolean |
isExist(ConcurrentHashMap<String,String> properties,
String keyword)
Tests if the keyword exists in properties.
|
private boolean |
isNotExist(ConcurrentHashMap<String,String> properties,
String keyword)
Test if the keyword does not exist in properties
|
private boolean |
isPassword(String key)
Tests if the value of the key is a password
|
private Properties |
loadConfigurationFile()
Load configuration file.
|
void |
setPropertiesFile(InputStream inputStream)
Sets a custom properties file.
|
void |
setPropertiesFile(String path)
Sets a custom properties file.
|
void |
setSecretKey(String secretKey)
Sets the secret key.
|
void |
validConfigurationFile()
Validates the configuration file.
|
public static final String CONFIG_PROPERTIES
private static final org.apache.logging.log4j.Logger LOG
private static final String INIST_TEST_DOI
private static final ConcurrentHashMap<String,String> MAP_PROPERTIES
private String secretKey
private String pathApp
private DoiSettings()
public static DoiSettings getInstance()
private void init(Properties properties, org.apache.logging.log4j.Level level)
properties
- Configuration filelevel
- LOG levelprivate void computePathOfTheApplication()
private Properties loadConfigurationFile()
public void validConfigurationFile()
private boolean isExist(ConcurrentHashMap<String,String> properties, String keyword)
properties
- configurationkeyword
- keyword to testprivate boolean isNotExist(ConcurrentHashMap<String,String> properties, String keyword)
properties
- configurationkeyword
- keyword to testprivate void fillConcurrentMap(Properties properties, org.apache.logging.log4j.Level level)
properties
- the configuration file contentlevel
- log levelprivate boolean isPassword(String key)
key
- key to testpublic boolean hasValue(String key)
key
- key to testpublic String getSecretKey()
public void setSecretKey(String secretKey)
secretKey
- the secret key.public String getString(String key, String defaultValue)
key
- key to searchdefaultValue
- Default value if the key inputStream not foundpublic String getString(String key)
key
- key to searchpublic String getSecret(String key)
key
- key to searchpublic String getSecretValue(String value)
value
- value to decryptpublic int getInt(String key)
key
- key to searchNumberFormatException
- if the string does not contain a
parsable integer.public int getInt(String key, String defaultValue)
key
- key to searchdefaultValue
- default valueNumberFormatException
- if the string does not contain a
parsable integer.public boolean getBoolean(String key)
key
- key to searchIllegalArgumentException
- - if key not foundpublic Long getLong(String key)
key
- key to searchNumberFormatException
- - if the string does not contain a
parsable longpublic Long getLong(String key, String defaultValue)
key
- key to searchdefaultValue
- default valueNumberFormatException
- - if the string does not contain a
parsable longpublic void displayConfigFile()
public void setPropertiesFile(String path) throws IOException
path
- Path to the properties fileIOException
- - if an error occurred when reading from the input
stream.public void setPropertiesFile(InputStream inputStream) throws IOException
inputStream
- Input streamIOException
- - if an error occurred when reading from the
input stream.public String getPathApp()
private void copyStream(InputStream inputStream, OutputStream outputStream)
inputStream
- input streamoutputStream
- output streamCopyright © 2017–2020 CNES. All rights reserved.