Class 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 Detail

      • 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 key
        defaultValue - 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 key
        defaultValue - 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 key
        defaultValue - 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 key
        defaultValue - 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 if ENVIRONMENT = "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.