Class AbstractIncrementalSyncService<S extends SubscriptionSpec,T extends IncrementalSyncModel>
java.lang.Object
com.atlassian.confluence.internal.api.impl.service.incrementalsync.AbstractIncrementalSyncService<S,T>
- All Implemented Interfaces:
IncrementalSyncCleaner
,IncrementalSyncService<S,
T>
- Direct Known Subclasses:
ContentManagementIncrementalSyncServiceImpl
,GlobalPermissionManagementIncrementalSyncServiceImpl
,UserManagementIncrementalSyncServiceImpl
public abstract class AbstractIncrementalSyncService<S extends SubscriptionSpec,T extends IncrementalSyncModel>
extends Object
implements IncrementalSyncService<S,T>, IncrementalSyncCleaner
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.atlassian.core.util.Clock
static final String
protected final IncrementalSyncDataFetcher<T>
protected final JournalServiceInternal
protected final org.slf4j.Logger
protected final PermissionManager
protected final ScopesRequestCacheDelegate
protected final SubscriptionJournalStateStore
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractIncrementalSyncService
(JournalServiceInternal journalService, SubscriptionJournalStateStore subscriptionJournalStateStore, com.atlassian.core.util.Clock clock, PermissionManager permissionManager, IncrementalSyncDataFetcher<T> incrementalSyncDataFetcher, ScopesRequestCacheDelegate scopesRequestCacheDelegate) -
Method Summary
Modifier and TypeMethodDescriptionvoid
This will clean both obsolete journal entry and subscription.void
This will clean up inactive/unused subscriptionGet all subscription for current serviceprotected abstract MultiSubscriptionPerJournalIdentifier
getJournalIdentifier
(long subscriptionId) protected abstract String
getMostRecentCursor
(long id) This will find and return the most recent incremental sync cursor corresponding to the provided subscription's most recent journal entry, if one exists.protected abstract String
getSubscriptionData
(S spec) <E> void
handleEventForSubscription
(E event, Consumer<JournalIdentifier> processor) Based on input event this method will find a corresponding subscription which would like to handle it.boolean
isSubscriptionActive
(long subscriptionId) processEvents
(PageRequest pageRequest) Processing eventsRegister to incremental apiboolean
unsubscribe
(SubscriptionId subscriptionId) Remove an exising subscriptionprotected void
protected void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.confluence.internal.api.service.incrementalsync.IncrementalSyncCleaner
getManagedJournalIdentifier
Methods inherited from interface com.atlassian.confluence.internal.api.service.incrementalsync.IncrementalSyncService
getEventsBatchLimit
-
Field Details
-
INCREMENTAL_SYNC_EVENTS_BATCH_LIMIT_PREFIX
- See Also:
-
logger
protected final org.slf4j.Logger logger -
permissionManager
-
journalService
-
clock
protected final com.atlassian.core.util.Clock clock -
subscriptionJournalStateStore
-
incrementalSyncDataFetcher
protected final IncrementalSyncDataFetcher<T extends IncrementalSyncModel> incrementalSyncDataFetcher -
scopesRequestCacheDelegate
-
-
Constructor Details
-
AbstractIncrementalSyncService
protected AbstractIncrementalSyncService(JournalServiceInternal journalService, SubscriptionJournalStateStore subscriptionJournalStateStore, com.atlassian.core.util.Clock clock, PermissionManager permissionManager, IncrementalSyncDataFetcher<T> incrementalSyncDataFetcher, ScopesRequestCacheDelegate scopesRequestCacheDelegate)
-
-
Method Details
-
subscribe
Description copied from interface:IncrementalSyncService
Register to incremental api- Specified by:
subscribe
in interfaceIncrementalSyncService<S extends SubscriptionSpec,
T extends IncrementalSyncModel> - Parameters:
spec
- the specification- Returns:
- an unique id
-
unsubscribe
Description copied from interface:IncrementalSyncService
Remove an exising subscription- Specified by:
unsubscribe
in interfaceIncrementalSyncService<S extends SubscriptionSpec,
T extends IncrementalSyncModel> - Returns:
- indicate the operation is success or not
-
getAvailableSubscriptions
Description copied from interface:IncrementalSyncService
Get all subscription for current service- Specified by:
getAvailableSubscriptions
in interfaceIncrementalSyncService<S extends SubscriptionSpec,
T extends IncrementalSyncModel> - Returns:
- list of available subscriptions
-
cleanUpSubscriptions
public void cleanUpSubscriptions()Description copied from interface:IncrementalSyncService
This will clean up inactive/unused subscription- Specified by:
cleanUpSubscriptions
in interfaceIncrementalSyncService<S extends SubscriptionSpec,
T extends IncrementalSyncModel>
-
processEvents
Description copied from interface:IncrementalSyncService
Processing events- Specified by:
processEvents
in interfaceIncrementalSyncService<S extends SubscriptionSpec,
T extends IncrementalSyncModel> - Parameters:
pageRequest
- Page request with cursor.- Returns:
- IncrementalSyncPageResponse which will contain the next cursor
-
getSubscriptionData
-
getJournalName
-
getJournalIdentifier
-
verifyAdminUserOrReadAllScope
protected void verifyAdminUserOrReadAllScope() -
verifyAdminUserOrManageSubscriptionScope
protected void verifyAdminUserOrManageSubscriptionScope() -
cleanObsoleteData
public void cleanObsoleteData()Description copied from interface:IncrementalSyncCleaner
This will clean both obsolete journal entry and subscription. We need to clean Journal Entry first then clean Subscription. For Subscription, there are obsolete subscription and deleted subscription- Specified by:
cleanObsoleteData
in interfaceIncrementalSyncCleaner
-
isSubscriptionActive
public boolean isSubscriptionActive(long subscriptionId) - Specified by:
isSubscriptionActive
in interfaceIncrementalSyncService<S extends SubscriptionSpec,
T extends IncrementalSyncModel> - Parameters:
subscriptionId
- the subscription id- Returns:
- {code true} if the subscription is active
-
getMostRecentCursor
Description copied from interface:IncrementalSyncService
This will find and return the most recent incremental sync cursor corresponding to the provided subscription's most recent journal entry, if one exists.- Specified by:
getMostRecentCursor
in interfaceIncrementalSyncService<S extends SubscriptionSpec,
T extends IncrementalSyncModel> - Parameters:
id
- ID of the subscription.- Returns:
- Optional incremental sync cursor pointing the latest journal entry.
-
handleEventForSubscription
Description copied from interface:IncrementalSyncService
Based on input event this method will find a corresponding subscription which would like to handle it. Then will trigger the call back to handle that- Specified by:
handleEventForSubscription
in interfaceIncrementalSyncService<S extends SubscriptionSpec,
T extends IncrementalSyncModel> - Type Parameters:
E
- an event
-