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 Summary
Fields Modifier and Type Field Description static long
MAX_ALLOWED_RELOAD_STATE_DELAY
static int
SERVICE_STATE_RELOADING_INTERVAL
static int
SERVICE_STATE_RELOADING_INTERVAL_WHEN_SERVICE_IS_DISABLED
-
Constructor Summary
Constructors Constructor Description DenormalisedPermissionStateManagerImpl(com.atlassian.event.api.EventPublisher eventPublisher, DenormalisedServiceStateDao denormalisedServiceStateDao, org.springframework.transaction.PlatformTransactionManager transactionManager, DenormalisedPermissionStateLogService denormalisedPermissionStateLogService, DenormalisedLockService denormalisedLockService, DenormalisedChangeLogDao denormalisedChangeLogDao)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createStateRecordsIfTheyDoNotExist()
When the service is starting up for the first time, we need to create "state records".void
destroy()
void
disableService(boolean cleanDenormalisedData)
Disables the service and deletes all triggers/functions, so denormalised data will not be updated.void
enableContentService()
void
enableService()
Enables the service.void
enableSpaceService()
Long
getContentPermissionUpdateLag()
Returns the time difference between updating regular content permissions and denormalised content permissionsDenormalisedPermissionServiceState
getContentServiceState(boolean realTimeData)
Get the state of denormalised content service.Long
getSpacePermissionUpdateLag()
Returns the time difference between updating regular space permissions and denormalised space permissionsDenormalisedPermissionServiceState
getSpaceServiceState(boolean realTimeData)
Get the state of denormalised space service.List<StateChangeInformation>
getStateChangeLog(int limit)
Returns a list of service state change eventsvoid
init()
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.boolean
isContentApiReady()
Returns true if the state of denormalised CONTENT service is "READY", which means that denormalised content permissions reflect real permissions.boolean
isSpaceApiReady()
Returns true if the state of denormalised SPACE service is "READY", which means that denormalised space permissions reflect real permissions.void
onApplicationStartedEvent(com.atlassian.config.lifecycle.events.ApplicationStartedEvent event)
void
onApplicationStoppingEvent(com.atlassian.config.lifecycle.events.ApplicationStoppingEvent event)
void
onImportFinishEvent(AsyncImportFinishedEvent event)
void
onImportStartEvent(AsyncImportStartedEvent event)
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.void
scheduled()
-
-
-
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
-
-
Constructor Detail
-
DenormalisedPermissionStateManagerImpl
public DenormalisedPermissionStateManagerImpl(com.atlassian.event.api.EventPublisher eventPublisher, DenormalisedServiceStateDao denormalisedServiceStateDao, org.springframework.transaction.PlatformTransactionManager transactionManager, DenormalisedPermissionStateLogService denormalisedPermissionStateLogService, DenormalisedLockService denormalisedLockService, DenormalisedChangeLogDao denormalisedChangeLogDao)
-
-
Method Detail
-
init
@PostConstruct public void init()
-
scheduled
@Scheduled(fixedDelay=3000L) public void scheduled()
- Specified by:
scheduled
in interfaceDenormalisedPermissionStateManager
-
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 interfaceDenormalisedPermissionStateManager
- 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 interfaceDenormalisedPermissionStateManager
- 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 interfaceDenormalisedPermissionStateManager
- 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 interfaceDenormalisedPermissionStateManager
- 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 interfaceDenormalisedPermissionStateManager
- 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 interfaceDenormalisedPermissionStateManager
-
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.
-
getSpacePermissionUpdateLag
public Long getSpacePermissionUpdateLag()
Returns the time difference between updating regular space permissions and denormalised space permissions- Specified by:
getSpacePermissionUpdateLag
in interfaceDenormalisedPermissionStateManager
- 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 interfaceDenormalisedPermissionStateManager
- 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 interfaceDenormalisedPermissionStateManager
- 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 interfaceDenormalisedPermissionStateManager
- 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(com.atlassian.config.lifecycle.events.ApplicationStoppingEvent event)
-
-