Class DefaultEndpointRestrictionsConfigStrategy

  • All Implemented Interfaces:
    EndpointRestrictionsConfigStrategy

    public class DefaultEndpointRestrictionsConfigStrategy
    extends java.lang.Object
    implements EndpointRestrictionsConfigStrategy
    Strategy used to determine whether the API endpoint is disabled, based on property in the configuration.

    The endpoint is disabled if its ID exists in the identifier list of the configuration property.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected ConfigurationService getConfigurationService()  
      protected java.lang.String[] getDisabledEndpoints​(java.lang.String configKeyPrefix)
      Reads array of disabled endpoint identifiers from the configuration file.
      protected java.lang.String getDisabledEndpointsPropertyKey​(java.lang.String configKeyPrefix)
      Creates configuration property key based on a given configuration prefix.
      protected java.lang.String getPropertyKey​(java.lang.String configKeyPrefix, java.lang.String propertyKey)
      Creates configuration property key based on a given configuration prefix and key postfix.
      boolean isDisabledEndpointListEmpty​(java.lang.String configKeyPrefix)
      Verifies whether the configuration list of disabled endpoints is empty for the given config prefix.
      boolean isEndpointDisabled​(java.lang.String configKeyPrefix, java.lang.String endpointId)
      Verifies whether the endpoint is disabled in the configuration, based on given configuration key prefix and endpoint identifier.
      protected boolean isEndpointIdDisabled​(java.lang.String endpointId, java.lang.String[] disabledEndpoints)
      Verifies whether endpoint identifier exists in the disabled endpoints array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultEndpointRestrictionsConfigStrategy

        public DefaultEndpointRestrictionsConfigStrategy​(ConfigurationService configurationService)
        Strategy constructor
        Parameters:
        configurationService - configuration service
    • Method Detail

      • isEndpointDisabled

        public boolean isEndpointDisabled​(java.lang.String configKeyPrefix,
                                          java.lang.String endpointId)
        Verifies whether the endpoint is disabled in the configuration, based on given configuration key prefix and endpoint identifier.

        Throws IllegalArgumentException in case the configKeyPrefix or the endpointId argument is null.

        Specified by:
        isEndpointDisabled in interface EndpointRestrictionsConfigStrategy
        Parameters:
        configKeyPrefix - configuration key prefix
        endpointId - endpoint identifier
        Returns:
        true - means the endpoint is disabled
      • isDisabledEndpointListEmpty

        public boolean isDisabledEndpointListEmpty​(java.lang.String configKeyPrefix)
        Verifies whether the configuration list of disabled endpoints is empty for the given config prefix.

        Throws IllegalArgumentException in case the config prefix is null.

        Specified by:
        isDisabledEndpointListEmpty in interface EndpointRestrictionsConfigStrategy
        Parameters:
        configKeyPrefix - configuration key prefix used to create configuration property key
        Returns:
        true if the list is empty
      • isEndpointIdDisabled

        protected boolean isEndpointIdDisabled​(java.lang.String endpointId,
                                               java.lang.String[] disabledEndpoints)
        Verifies whether endpoint identifier exists in the disabled endpoints array.
        Parameters:
        endpointId - endpoint identifier
        disabledEndpoints - array of disabled endpoint identifiers
        Returns:
      • getDisabledEndpoints

        protected java.lang.String[] getDisabledEndpoints​(java.lang.String configKeyPrefix)
        Reads array of disabled endpoint identifiers from the configuration file.

        Returns empty array if there is no property in the configuration.

        Parameters:
        configKeyPrefix - prefix used to create configuration key
        Returns:
        array of disabled endpoint identifiers or empty array
      • getDisabledEndpointsPropertyKey

        protected java.lang.String getDisabledEndpointsPropertyKey​(java.lang.String configKeyPrefix)
        Creates configuration property key based on a given configuration prefix.

        The key is used to read array of disabled endpoint identifiers.

        Parameters:
        configKeyPrefix - prefix used to create configuration key
        Returns:
        configuration property key
      • getPropertyKey

        protected java.lang.String getPropertyKey​(java.lang.String configKeyPrefix,
                                                  java.lang.String propertyKey)
        Creates configuration property key based on a given configuration prefix and key postfix.
        Parameters:
        configKeyPrefix - prefix used to create configuration key
        propertyKey - key postfix, that defines specified property
        Returns:
        property key