- java.lang.Object
-
- com.erudika.para.core.utils.Config
-
public final class Config extends Object
This class loads configuration settings from a file and sets defaults.- Author:
- Alex Bogdanovski [alex@erudika.com]
-
-
Field Summary
Fields Modifier and Type Field Description static String_APPID"appid".static String_CREATORID"creatorid".static String_EMAIL"email".static String_EMAIL_TOKEN"etoken".static String_GROUPS"groups".static String_ID"id".static String_IDENTIFIER"identifier".static String_KEY"key".static String_NAME"name".static String_PARENTID"parentid".static String_PASSWORD"password".static String_PROPERTIES"properties".static String_RESET_TOKEN"token".static String_TAGS"tags".static String_TIMESTAMP"timestamp".static String_TYPE"type".static String_UPDATED"updated".static String_VERSION"version".static StringADMIN_IDENTThe identifier of the first administrator (can be email, OpenID, or Facebook user id).static StringAMAZON_APP_IDAmazon app id (for authentication).static StringAMAZON_PREFIXAmazon prefix - defaults to 'az:'.static StringAMAZON_SECRETAmazon app secret (for authentication).static booleanAPI_ENABLEDEnable the RESTful API.static StringAPP_NAMEThe name of the default application.static StringAPP_SECRET_KEYThe secret key for this deployment.static StringCLUSTER_NAMEThe name of the cluster (can be used to separate deployments).static StringCORE_PACKAGE_NAMEThe package path (e.g.static booleanCORS_ENABLEDEnable the CORS filter for API requests.static StringDEFAULT_ENCODINGDefault character encoding - 'UTF-8'.static intDEFAULT_LIMIT10000.static StringDEFAULT_QUEUE_NAMEThe default queue name which will be polled for incoming JSON messages.static StringENVIRONMENTFor example: production, development, testing...static intEXECUTOR_THREADSThe number of threads to use for the ExecutorService thread pool.static StringFB_APP_IDFacebook app id (for authentication).static StringFB_PREFIXFacebook prefix - defaults to 'fb:'.static StringFB_SECRETFacebook app secret (for authentication).static StringGITHUB_APP_IDGitHub app id (for authentication).static StringGITHUB_PREFIXGitHub prefix - defaults to 'gh:'.static StringGITHUB_SECRETGitHub app secret (for authentication).static StringGPLUS_APP_IDGoogle+ app id (for authentication).static StringGPLUS_PREFIXGoogle prefix - defaults to 'gp:'.static StringGPLUS_SECRETGoogle+ app secret (for authentication).static booleanGZIP_ENABLEDEnable the GZIP filter for API requests.static intID_TOKEN_EXPIRES_AFTER_SECID token expiration in seconds.static booleanIN_DEVELOPMENTDevelopment environment flag.static booleanIN_PRODUCTIONProduction environment flag.static intJWT_EXPIRES_AFTER_SECJWT (access token) expiration in seconds.static intJWT_REFRESH_INTERVAL_SECJWT refresh interval - tokens will be auto-refreshed at this interval of time.static StringLDAP_PREFIXLDAP prefix - defaults to 'ldap:'.static StringLINKEDIN_APP_IDLinkedIn app id (for authentication).static StringLINKEDIN_PREFIXLinkedIn prefix - defaults to 'in:'.static StringLINKEDIN_SECRETLinkedIn app secret (for authentication).static StringMATTERMOST_APP_IDMattermost app id (for authentication).static StringMATTERMOST_PREFIXMattermost prefix - defaults to 'mm:'.static StringMATTERMOST_SECRETMattermost app secret (for authentication).static intMAX_DATATYPES_PER_APPMaximum number of data types that can be defined per app - default is 256.static intMAX_ENTITY_SIZE_BYTESMaximum size of incoming JSON objects - default is 1048576 (bytes).static intMAX_IMG_SIZE_PXMaximum image size (longest edge) - default is 1024 (pixels).static intMAX_ITEMS_PER_PAGEMaximum results per page - limits the number of items to show in search results.static intMAX_PAGE_LIMITPagination limit - maximum number of results per page, default is 256.static intMAX_PAGESPagination limit - highest page number, default is 1000.static StringMICROSOFT_APP_IDMicrosoft app id (for authentication).static StringMICROSOFT_PREFIXMicrosoft prefix - defaults to 'ms:'.static StringMICROSOFT_SECRETMicrosoft app secret (for authentication).static intMIN_PASS_LENGTHMinimum password length - default is 6 symbols.static StringOAUTH2_PREFIXOAuth2 generic prefix - defaults to 'oa2:'.static StringOAUTH2_SECOND_PREFIXOAuth2 second generic prefix - defaults to 'oa2second:'.static StringOAUTH2_THIRD_PREFIXOAuth2 third generic prefix - defaults to 'oa2third:'.static StringPARA"para".static intPASSRESET_TIMEOUT_SECPassword reset window in seconds.static intREQUEST_EXPIRES_AFTER_SECExpiration of signed API request, in seconds.static StringRETURNTO_COOKIEThe name of the "return to" cookie.static StringSAML_PREFIXSAML prefix - defaults to 'saml:'.static StringSEPARATORString separator - default is colon ':'.static intSESSION_TIMEOUT_SECSession timeout in seconds.static StringSLACK_APP_IDSlack app id (for authentication).static StringSLACK_PREFIXSlack prefix - defaults to 'sl:'.static StringSLACK_SECRETSlack app secret (for authentication).static StringSUPPORT_EMAILThe email address for support.static StringTWITTER_APP_IDTwitter app id (for authentication).static StringTWITTER_PREFIXTwitter prefix - defaults to 'tw:'.static StringTWITTER_SECRETTwitter app secret (for authentication).static intVOTE_EXPIRES_AFTER_SECVotes expire after X seconds.static intVOTE_LOCKED_AFTER_SECA vote can be changed within X seconds of casting.static booleanWEBHOOKS_ENABLEDEnable webhooks for CRUD methods.static StringWORKER_IDThe id of this deployment.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.typesafe.config.ConfiggetConfig()Returns the Config object.static booleangetConfigBoolean(String key, boolean defaultValue)Returns the boolean value of a configuration parameter.static doublegetConfigDouble(String key, double defaultValue)Returns the double value of a configuration parameter.static intgetConfigInt(String key, int defaultValue)Returns the integer value of a configuration parameter.static StringgetConfigParam(String key, String defaultValue)Returns the value of a configuration parameter or its default value.static StringgetRootAppIdentifier()static voidinit(com.typesafe.config.Config conf)Initializes the configuration class by loading the configuration file.static booleanisCacheEnabled()Default: true only ifENVIRONMENT= "production".static booleanisSearchEnabled()Default: true.
-
-
-
Field Detail
-
PARA
public static final String PARA
"para".- See Also:
- Constant Field Values
-
_TYPE
public static final String _TYPE
"type".- See Also:
- Constant Field Values
-
_APPID
public static final String _APPID
"appid".- See Also:
- Constant Field Values
-
_CREATORID
public static final String _CREATORID
"creatorid".- See Also:
- Constant Field Values
-
_ID
public static final String _ID
"id".- See Also:
- Constant Field Values
-
_IDENTIFIER
public static final String _IDENTIFIER
"identifier".- See Also:
- Constant Field Values
-
_KEY
public static final String _KEY
"key".- See Also:
- Constant Field Values
-
_NAME
public static final String _NAME
"name".- See Also:
- Constant Field Values
-
_PARENTID
public static final String _PARENTID
"parentid".- See Also:
- Constant Field Values
-
_PASSWORD
public static final String _PASSWORD
"password".- See Also:
- Constant Field Values
-
_RESET_TOKEN
public static final String _RESET_TOKEN
"token".- See Also:
- Constant Field Values
-
_EMAIL_TOKEN
public static final String _EMAIL_TOKEN
"etoken".- See Also:
- Constant Field Values
-
_TIMESTAMP
public static final String _TIMESTAMP
"timestamp".- See Also:
- Constant Field Values
-
_UPDATED
public static final String _UPDATED
"updated".- See Also:
- Constant Field Values
-
_TAGS
public static final String _TAGS
"tags".- See Also:
- Constant Field Values
-
_EMAIL
public static final String _EMAIL
"email".- See Also:
- Constant Field Values
-
_GROUPS
public static final String _GROUPS
"groups".- See Also:
- Constant Field Values
-
_VERSION
public static final String _VERSION
"version".- See Also:
- Constant Field Values
-
_PROPERTIES
public static final String _PROPERTIES
"properties".- See Also:
- Constant Field Values
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT
10000.- See Also:
- Constant Field Values
-
SEPARATOR
public static final String SEPARATOR
String separator - default is colon ':'.
-
FB_PREFIX
public static final String FB_PREFIX
Facebook prefix - defaults to 'fb:'.
-
GPLUS_PREFIX
public static final String GPLUS_PREFIX
Google prefix - defaults to 'gp:'.
-
LINKEDIN_PREFIX
public static final String LINKEDIN_PREFIX
LinkedIn prefix - defaults to 'in:'.
-
TWITTER_PREFIX
public static final String TWITTER_PREFIX
Twitter prefix - defaults to 'tw:'.
-
GITHUB_PREFIX
public static final String GITHUB_PREFIX
GitHub prefix - defaults to 'gh:'.
-
MICROSOFT_PREFIX
public static final String MICROSOFT_PREFIX
Microsoft prefix - defaults to 'ms:'.
-
SLACK_PREFIX
public static final String SLACK_PREFIX
Slack prefix - defaults to 'sl:'.
-
MATTERMOST_PREFIX
public static final String MATTERMOST_PREFIX
Mattermost prefix - defaults to 'mm:'.
-
AMAZON_PREFIX
public static final String AMAZON_PREFIX
Amazon prefix - defaults to 'az:'.
-
OAUTH2_PREFIX
public static final String OAUTH2_PREFIX
OAuth2 generic prefix - defaults to 'oa2:'.
-
OAUTH2_SECOND_PREFIX
public static final String OAUTH2_SECOND_PREFIX
OAuth2 second generic prefix - defaults to 'oa2second:'.
-
OAUTH2_THIRD_PREFIX
public static final String OAUTH2_THIRD_PREFIX
OAuth2 third generic prefix - defaults to 'oa2third:'.
-
LDAP_PREFIX
public static final String LDAP_PREFIX
LDAP prefix - defaults to 'ldap:'.
-
SAML_PREFIX
public static final String SAML_PREFIX
SAML prefix - defaults to 'saml:'.
-
MAX_ITEMS_PER_PAGE
public static final int MAX_ITEMS_PER_PAGE
Maximum results per page - limits the number of items to show in search results. Default is 30.
-
MAX_PAGES
public static final int MAX_PAGES
Pagination limit - highest page number, default is 1000.
-
MAX_PAGE_LIMIT
public static final int MAX_PAGE_LIMIT
Pagination limit - maximum number of results per page, default is 256.
-
MAX_IMG_SIZE_PX
public static final int MAX_IMG_SIZE_PX
Maximum image size (longest edge) - default is 1024 (pixels).
-
MIN_PASS_LENGTH
public static final int MIN_PASS_LENGTH
Minimum password length - default is 6 symbols.
-
MAX_DATATYPES_PER_APP
public static final int MAX_DATATYPES_PER_APP
Maximum number of data types that can be defined per app - default is 256.
-
MAX_ENTITY_SIZE_BYTES
public static final int MAX_ENTITY_SIZE_BYTES
Maximum size of incoming JSON objects - default is 1048576 (bytes).
-
DEFAULT_ENCODING
public static final String DEFAULT_ENCODING
Default character encoding - 'UTF-8'.
-
ENVIRONMENT
public static final String ENVIRONMENT
For example: production, development, testing... etc. Default: "embedded"
-
FB_APP_ID
public static final String FB_APP_ID
Facebook app id (for authentication).
-
FB_SECRET
public static final String FB_SECRET
Facebook app secret (for authentication).
-
GPLUS_APP_ID
public static final String GPLUS_APP_ID
Google+ app id (for authentication).
-
GPLUS_SECRET
public static final String GPLUS_SECRET
Google+ app secret (for authentication).
-
LINKEDIN_APP_ID
public static final String LINKEDIN_APP_ID
LinkedIn app id (for authentication).
-
LINKEDIN_SECRET
public static final String LINKEDIN_SECRET
LinkedIn app secret (for authentication).
-
TWITTER_APP_ID
public static final String TWITTER_APP_ID
Twitter app id (for authentication).
-
TWITTER_SECRET
public static final String TWITTER_SECRET
Twitter app secret (for authentication).
-
GITHUB_APP_ID
public static final String GITHUB_APP_ID
GitHub app id (for authentication).
-
GITHUB_SECRET
public static final String GITHUB_SECRET
GitHub app secret (for authentication).
-
MICROSOFT_APP_ID
public static final String MICROSOFT_APP_ID
Microsoft app id (for authentication).
-
MICROSOFT_SECRET
public static final String MICROSOFT_SECRET
Microsoft app secret (for authentication).
-
SLACK_APP_ID
public static final String SLACK_APP_ID
Slack app id (for authentication).
-
SLACK_SECRET
public static final String SLACK_SECRET
Slack app secret (for authentication).
-
MATTERMOST_APP_ID
public static final String MATTERMOST_APP_ID
Mattermost app id (for authentication).
-
MATTERMOST_SECRET
public static final String MATTERMOST_SECRET
Mattermost app secret (for authentication).
-
AMAZON_APP_ID
public static final String AMAZON_APP_ID
Amazon app id (for authentication).
-
AMAZON_SECRET
public static final String AMAZON_SECRET
Amazon app secret (for authentication).
-
ADMIN_IDENT
public static final String ADMIN_IDENT
The identifier of the first administrator (can be email, OpenID, or Facebook user id).
-
WORKER_ID
public static final String WORKER_ID
The id of this deployment. In a multi-node environment each node should have a unique id.
-
EXECUTOR_THREADS
public static final int EXECUTOR_THREADS
The number of threads to use for the ExecutorService thread pool. Default is 2.
-
APP_NAME
public static final String APP_NAME
The name of the default application.
-
RETURNTO_COOKIE
public static final String RETURNTO_COOKIE
The name of the "return to" cookie.
-
SUPPORT_EMAIL
public static final String SUPPORT_EMAIL
The email address for support.
-
APP_SECRET_KEY
public static final String APP_SECRET_KEY
The secret key for this deployment. Used as salt.
-
DEFAULT_QUEUE_NAME
public static final String DEFAULT_QUEUE_NAME
The default queue name which will be polled for incoming JSON messages.
-
CORE_PACKAGE_NAME
public static final String CORE_PACKAGE_NAME
The package path (e.g. org.company.app.core) where all domain objects are defined.
-
REQUEST_EXPIRES_AFTER_SEC
public static final int REQUEST_EXPIRES_AFTER_SEC
Expiration of signed API request, in seconds. Default: 15 minutes
-
JWT_EXPIRES_AFTER_SEC
public static final int JWT_EXPIRES_AFTER_SEC
JWT (access token) expiration in seconds. Default: 1 week
-
JWT_REFRESH_INTERVAL_SEC
public static final int JWT_REFRESH_INTERVAL_SEC
JWT refresh interval - tokens will be auto-refreshed at this interval of time. Default: 1 hour
-
ID_TOKEN_EXPIRES_AFTER_SEC
public static final int ID_TOKEN_EXPIRES_AFTER_SEC
ID token expiration in seconds. Default: 60 seconds
-
SESSION_TIMEOUT_SEC
public static final int SESSION_TIMEOUT_SEC
Session timeout in seconds. Default: 24 hours
-
VOTE_EXPIRES_AFTER_SEC
public static final int VOTE_EXPIRES_AFTER_SEC
Votes expire after X seconds. Default: 30 days
-
VOTE_LOCKED_AFTER_SEC
public static final int VOTE_LOCKED_AFTER_SEC
A vote can be changed within X seconds of casting. Default: 30 seconds
-
PASSRESET_TIMEOUT_SEC
public static final int PASSRESET_TIMEOUT_SEC
Password reset window in seconds. Default: 30 minutes
-
API_ENABLED
public static final boolean API_ENABLED
Enable the RESTful API. Default: true
-
CORS_ENABLED
public static final boolean CORS_ENABLED
Enable the CORS filter for API requests. Default: true
-
GZIP_ENABLED
public static final boolean GZIP_ENABLED
Enable the GZIP filter for API requests. Default: false
-
WEBHOOKS_ENABLED
public static final boolean WEBHOOKS_ENABLED
Enable webhooks for CRUD methods. Requires a queue. Default: false
-
IN_PRODUCTION
public static final boolean IN_PRODUCTION
Production environment flag.
-
IN_DEVELOPMENT
public static final boolean IN_DEVELOPMENT
Development environment flag.
-
CLUSTER_NAME
public static final String CLUSTER_NAME
The name of the cluster (can be used to separate deployments).
-
-
Method Detail
-
init
public static void init(com.typesafe.config.Config conf)
Initializes the configuration class by loading the configuration file.- Parameters:
conf- overrides the default configuration
-
getConfigBoolean
public static boolean getConfigBoolean(String key, boolean defaultValue)
Returns the boolean value of a configuration parameter.- Parameters:
key- the param keydefaultValue- the default param value- Returns:
- the value of a param
-
getConfigInt
public static int getConfigInt(String key, int defaultValue)
Returns the integer value of a configuration parameter.- Parameters:
key- the param keydefaultValue- the default param value- Returns:
- the value of a param
-
getConfigDouble
public static double getConfigDouble(String key, double defaultValue)
Returns the double value of a configuration parameter.- Parameters:
key- the param keydefaultValue- the default param value- Returns:
- the value of a param
-
getConfigParam
public static String getConfigParam(String key, String defaultValue)
Returns the value of a configuration parameter or its default value.System.getProperty(java.lang.String)has precedence.- Parameters:
key- the param keydefaultValue- the default param value- Returns:
- the value of a param
-
getConfig
public static com.typesafe.config.Config getConfig()
Returns the Config object.- Returns:
- the config object
-
isCacheEnabled
public static boolean isCacheEnabled()
Default: true only ifENVIRONMENT= "production".- Returns:
- true if caching is enabled
-
isSearchEnabled
public static boolean isSearchEnabled()
Default: true.- Returns:
- true if indexing is enabled
-
getRootAppIdentifier
public static String getRootAppIdentifier()
- Returns:
- The name of the default application without any spaces.
-
-