Class DenormalisedPermissionStateManagerImpl

    • Field Detail

      • MAX_ALLOWED_RELOAD_STATE_DELAY

        public static final long MAX_ALLOWED_RELOAD_STATE_DELAY
      • SERVICE_STATE_RELOADING_INTERVAL_WHEN_SERVICE_IS_DISABLED

        public static final int SERVICE_STATE_RELOADING_INTERVAL_WHEN_SERVICE_IS_DISABLED
        See Also:
        Constant Field Values
      • SERVICE_STATE_RELOADING_INTERVAL

        public static final int SERVICE_STATE_RELOADING_INTERVAL
        See Also:
        Constant Field Values
    • Method Detail

      • init

        @PostConstruct
        public void init()
      • onApplicationStartedEvent

        @EventListener
        public void onApplicationStartedEvent​(com.atlassian.config.lifecycle.events.ApplicationStartedEvent event)
      • reloadServiceState

        @Internal
        public void reloadServiceState()
        We need to support it's state in memory because we'd like to avoid reading this value from DB for every request denormalised permissions receive. This state is used in router to switch between real denormalised permissions and the fallback service.
      • isApiReady

        public boolean isApiReady()
        Returns true if the state of the service is "READY", if both CONTENT and SPACE services are in ready state Possible reasons for returning false: 1. Service is disabled 2. Denormalized tables are not ready
        Specified by:
        isApiReady in interface DenormalisedPermissionStateManager
        Returns:
        the state of the service
      • isSpaceApiReady

        public boolean isSpaceApiReady()
        Returns true if the state of denormalised SPACE service is "READY", which means that denormalised space permissions reflect real permissions. Possible reasons for returning false: 1. Service is disabled 2. Denormalized tables are not ready
        Specified by:
        isSpaceApiReady in interface DenormalisedPermissionStateManager
        Returns:
        the state of the SPACe service
      • isContentApiReady

        public boolean isContentApiReady()
        Returns true if the state of denormalised CONTENT service is "READY", which means that denormalised content permissions reflect real permissions. Possible reasons for returning false: 1. Service is disabled 2. Denormalized tables are not ready
        Specified by:
        isContentApiReady in interface DenormalisedPermissionStateManager
        Returns:
        the state of the SPACe service
      • enableSpaceService

        public void enableSpaceService()
      • enableContentService

        public void enableContentService()
      • createStateRecordsIfTheyDoNotExist

        @Internal
        public void createStateRecordsIfTheyDoNotExist()
                                                throws ExecutionException,
                                                       InterruptedException
        When the service is starting up for the first time, we need to create "state records". It's important to do this in separate transaction because these records will be used for cluster-wide locking.
        Throws:
        ExecutionException
        InterruptedException
      • getSpacePermissionUpdateLag

        public Long getSpacePermissionUpdateLag()
        Returns the time difference between updating regular space permissions and denormalised space permissions
        Specified by:
        getSpacePermissionUpdateLag in interface DenormalisedPermissionStateManager
        Returns:
        lag in ms, or null if the data record is not found (for example, the service has never been enabled)
      • getContentPermissionUpdateLag

        public Long getContentPermissionUpdateLag()
        Returns the time difference between updating regular content permissions and denormalised content permissions
        Specified by:
        getContentPermissionUpdateLag in interface DenormalisedPermissionStateManager
        Returns:
        lag in ms, or null if the data record is not found (for example, the service has never been enabled)
      • disableService

        public void disableService​(boolean cleanDenormalisedData)
        Disables the service and deletes all triggers/functions, so denormalised data will not be updated.
        Specified by:
        disableService in interface DenormalisedPermissionStateManager
        Parameters:
        cleanDenormalisedData - - if true, all denormalised data will be truncated
      • onApplicationStoppingEvent

        @EventListener
        public void onApplicationStoppingEvent​(com.atlassian.config.lifecycle.events.ApplicationStoppingEvent event)
      • destroy

        public void destroy()
                     throws Exception
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
        Throws:
        Exception