Class DenormalisedPermissionStateManagerImpl

java.lang.Object
com.atlassian.confluence.security.denormalisedpermissions.impl.DenormalisedPermissionStateManagerImpl
All Implemented Interfaces:
DenormalisedPermissionStateManager, org.springframework.beans.factory.DisposableBean

public class DenormalisedPermissionStateManagerImpl extends Object implements DenormalisedPermissionStateManager, org.springframework.beans.factory.DisposableBean
Since:
7.11.0
  • Field Details

    • 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:
    • SERVICE_STATE_RELOADING_INTERVAL

      public static final int SERVICE_STATE_RELOADING_INTERVAL
      See Also:
  • Constructor Details

  • Method Details

    • init

      @PostConstruct public void init()
    • scheduled

      @Scheduled(fixedDelay=3000L) public void scheduled()
      Specified by:
      scheduled in interface DenormalisedPermissionStateManager
    • onApplicationStarted

      @EventListener public void onApplicationStarted(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
    • getSpaceServiceState

      public DenormalisedPermissionServiceState getSpaceServiceState(boolean realTimeData)
      Description copied from interface: DenormalisedPermissionStateManager
      Get the state of denormalised space service.
      Specified by:
      getSpaceServiceState in interface DenormalisedPermissionStateManager
      Parameters:
      realTimeData - if true, data will be read from the DB. If false, cached data will be returned.
      Returns:
      the state of denormalised SPACE service
    • getContentServiceState

      public DenormalisedPermissionServiceState getContentServiceState(boolean realTimeData)
      Description copied from interface: DenormalisedPermissionStateManager
      Get the state of denormalised content service.
      Specified by:
      getContentServiceState in interface DenormalisedPermissionStateManager
      Parameters:
      realTimeData - if true, data will be read from the DB. If false, cached data will be returned.
      Returns:
      the state of denormalised CONTENT service
    • enableService

      public void enableService()
      Enables the service. It would take some time to update denormalised data
      Specified by:
      enableService in interface DenormalisedPermissionStateManager
    • 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
    • getStateChangeLog

      public List<StateChangeInformation> getStateChangeLog(int limit)
      Returns a list of service state change events
      Specified by:
      getStateChangeLog in interface DenormalisedPermissionStateManager
      Parameters:
      limit - limit
      Returns:
      list or events, sorted by event date (desc)
    • onImportStartEvent

      @EventListener public void onImportStartEvent(AsyncImportStartedEvent event)
    • onImportFinishEvent

      @EventListener public void onImportFinishEvent(AsyncImportFinishedEvent event)
    • onApplicationStoppingEvent

      @EventListener public void onApplicationStoppingEvent(ApplicationStoppingEvent event)
    • destroy

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