Package org.nuxeo.drive.service.impl
Class NuxeoDriveManagerImpl
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.drive.service.impl.NuxeoDriveManagerImpl
- All Implemented Interfaces:
NuxeoDriveManager
,Adaptable
,Component
,Extensible
,TimestampedService
Manage list of NuxeoDrive synchronization roots and devices for a given nuxeo user.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected FileSystemChangeFinder
protected ChangeFinderRegistry
protected static final long
protected Cache
Cache holding the collection sync root member ids for a given user (first map key) and repository (second map key).static final String
static final String
static final String
static final String
static final String
static final String
protected Cache
Cache holding the synchronization roots for a given user (first map key) and repository (second map key).static final TimeZone
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(ComponentContext context) Activates the component.void
addToLocallyEditedCollection
(CoreSession session, DocumentModel doc) Adds the givenDocumentModel
to theLOCALLY_EDITED_COLLECTION_NAME
collection.protected void
checkCanUpdateSynchronizationRoot
(DocumentModel newRootContainer) protected void
computeCollectionSyncRootMemberIds
(NuxeoPrincipal principal) protected Map<String,
SynchronizationRoots> computeSynchronizationRoots
(String query, NuxeoPrincipal principal) protected String
computeSyncRootsQuery
(String username) void
deactivate
(ComponentContext context) Deactivates the component.protected void
fireEvent
(DocumentModel sourceDocument, CoreSession session, String eventName, String impactedUserName) int
The component notification order forComponent.start(ComponentContext)
.Gets theFileSystemChangeFinder
member.getChangeSummary
(NuxeoPrincipal principal, Map<String, Set<IdRef>> lastSyncRootRefs, long lowerBound) Uses theAuditChangeFinder
to get the summary of document changes for the given user and lower bound.protected Cache
getCollectionSyncRootMemberIds
(NuxeoPrincipal principal) Fetch all the collection sync root member ids for a given user.Fetch the list of synchronization root refs for a given user and a given session repository.getSynchronizationRoots
(NuxeoPrincipal principal) Fetch all the synchronization root references and paths for a given user.protected Cache
void
handleFolderDeletion
(IdRef deleted) Method to be called by a CoreEvent listener monitoring documents deletions to cleanup references to recently deleted documents and invalidate the caches.void
Invalidate the collection sync root member cache for all users so as to query the repository next timeNuxeoDriveManager.getCollectionSyncRootMemberIds(NuxeoPrincipal)
is called.void
Invalidate the collection sync root member cache for a given user so as to query the repository next timeNuxeoDriveManager.getCollectionSyncRootMemberIds(NuxeoPrincipal)
is called.void
invalidateSynchronizationRootsCache
(String userName) Invalidate the synchronization roots cache for a given user so as to query the repository next timeNuxeoDriveManager.getSynchronizationRoots(NuxeoPrincipal)
is called.boolean
isSynchronizationRoot
(NuxeoPrincipal principal, DocumentModel doc) Checks if the givenDocumentModel
is a synchronization root for the given user.protected Map<String,
SynchronizationRoots> queryAndFetchSynchronizationRoots
(CoreSession session, String query) void
registerContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) void
registerSynchronizationRoot
(NuxeoPrincipal principal, DocumentModel newRootContainer, CoreSession session) void
start
(ComponentContext context) Sorts the contributed factories according to their order.void
stop
(ComponentContext context) Stop the component.void
unregisterContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) void
unregisterSynchronizationRoot
(NuxeoPrincipal principal, DocumentModel rootContainer, CoreSession session) Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterExtension
-
Field Details
-
CHANGE_FINDER_EP
- See Also:
-
NUXEO_DRIVE_FACET
- See Also:
-
DRIVE_SUBSCRIPTIONS_PROPERTY
- See Also:
-
DOCUMENT_CHANGE_LIMIT_PROPERTY
- See Also:
-
UTC
-
DRIVE_SYNC_ROOT_CACHE
- See Also:
-
DRIVE_COLLECTION_SYNC_ROOT_MEMBER_CACHE
- See Also:
-
LOCALLY_EDITED_COLLECTION_NAME
- See Also:
-
COLLECTION_CONTENT_PAGE_SIZE
protected static final long COLLECTION_CONTENT_PAGE_SIZE- See Also:
-
syncRootCache
Cache holding the synchronization roots for a given user (first map key) and repository (second map key). -
collectionSyncRootMemberCache
Cache holding the collection sync root member ids for a given user (first map key) and repository (second map key). -
changeFinderRegistry
-
changeFinder
-
-
Constructor Details
-
NuxeoDriveManagerImpl
public NuxeoDriveManagerImpl()
-
-
Method Details
-
getSyncRootCache
-
getCollectionSyncRootMemberCache
-
clearCache
protected void clearCache() -
invalidateSynchronizationRootsCache
Description copied from interface:NuxeoDriveManager
Invalidate the synchronization roots cache for a given user so as to query the repository next timeNuxeoDriveManager.getSynchronizationRoots(NuxeoPrincipal)
is called.- Specified by:
invalidateSynchronizationRootsCache
in interfaceNuxeoDriveManager
- Parameters:
userName
- the principal name of the user to invalidate the cache for.
-
invalidateCollectionSyncRootMemberCache
Description copied from interface:NuxeoDriveManager
Invalidate the collection sync root member cache for a given user so as to query the repository next timeNuxeoDriveManager.getCollectionSyncRootMemberIds(NuxeoPrincipal)
is called.- Specified by:
invalidateCollectionSyncRootMemberCache
in interfaceNuxeoDriveManager
- Parameters:
userName
- the principal name of the user to invalidate the cache for.
-
invalidateCollectionSyncRootMemberCache
public void invalidateCollectionSyncRootMemberCache()Description copied from interface:NuxeoDriveManager
Invalidate the collection sync root member cache for all users so as to query the repository next timeNuxeoDriveManager.getCollectionSyncRootMemberIds(NuxeoPrincipal)
is called.- Specified by:
invalidateCollectionSyncRootMemberCache
in interfaceNuxeoDriveManager
-
registerSynchronizationRoot
public void registerSynchronizationRoot(NuxeoPrincipal principal, DocumentModel newRootContainer, CoreSession session) - Specified by:
registerSynchronizationRoot
in interfaceNuxeoDriveManager
- Parameters:
principal
- the Nuxeo Drive usernewRootContainer
- the folderish document to be used as synchronization root: must be bound to an active session
-
unregisterSynchronizationRoot
public void unregisterSynchronizationRoot(NuxeoPrincipal principal, DocumentModel rootContainer, CoreSession session) - Specified by:
unregisterSynchronizationRoot
in interfaceNuxeoDriveManager
- Parameters:
principal
- the Nuxeo Drive userrootContainer
- the folderish document that should no longer be used as a synchronization root
-
getSynchronizationRootReferences
Description copied from interface:NuxeoDriveManager
Fetch the list of synchronization root refs for a given user and a given session repository. This list is assumed to be short enough (in the order of 100 folder max) so that no paging API is required. The user is taken from the session.getPrincipal() method.- Specified by:
getSynchronizationRootReferences
in interfaceNuxeoDriveManager
- Parameters:
session
- active CoreSession instance to the repository hosting the roots.- Returns:
- the ordered set of non deleted synchronization root references for that user
-
handleFolderDeletion
Description copied from interface:NuxeoDriveManager
Method to be called by a CoreEvent listener monitoring documents deletions to cleanup references to recently deleted documents and invalidate the caches.- Specified by:
handleFolderDeletion
in interfaceNuxeoDriveManager
-
fireEvent
protected void fireEvent(DocumentModel sourceDocument, CoreSession session, String eventName, String impactedUserName) -
getChangeSummary
public FileSystemChangeSummary getChangeSummary(NuxeoPrincipal principal, Map<String, Set<IdRef>> lastSyncRootRefs, long lowerBound) Uses theAuditChangeFinder
to get the summary of document changes for the given user and lower bound.The
DOCUMENT_CHANGE_LIMIT_PROPERTY
Framework property is used as a limit of document changes to fetch from the audit logs. Default value is 1000. IflowerBound
is missing (i.e. set to a negative value), the filesystem change summary is empty but the returned upper bound is set to the greater event log id so that the client can reuse it as a starting id for a future incremental diff request.- Specified by:
getChangeSummary
in interfaceNuxeoDriveManager
lastSyncRootRefs
- the map keyed by repository names of document refs for the synchronization roots that were active during last synchronizationlowerBound
- the lower bound sent by the user's device. Typically set to the value returned byFileSystemChangeSummary.getUpperBound()
of the previous call toNuxeoDriveManager.getChangeSummary(NuxeoPrincipal, Map, long)
or 0 for catching every event since the repository initialization.- Returns:
- the summary of document changes
-
getSynchronizationRoots
Description copied from interface:NuxeoDriveManager
Fetch all the synchronization root references and paths for a given user. This list is assumed to be short enough (in the order of 100 folder max) so that no paging API is required.- Specified by:
getSynchronizationRoots
in interfaceNuxeoDriveManager
- Parameters:
principal
- the user to fetch the roots for- Returns:
- the map keyed by repository names all active roots definitions for the current user.
-
getCollectionSyncRootMemberIds
Description copied from interface:NuxeoDriveManager
Fetch all the collection sync root member ids for a given user.- Specified by:
getCollectionSyncRootMemberIds
in interfaceNuxeoDriveManager
- Parameters:
principal
- the user to fetch the ids for- Returns:
- the map keyed by repository names all collection sync root member ids for the current user.
-
isSynchronizationRoot
Description copied from interface:NuxeoDriveManager
Checks if the givenDocumentModel
is a synchronization root for the given user.- Specified by:
isSynchronizationRoot
in interfaceNuxeoDriveManager
-
computeSynchronizationRoots
protected Map<String,SynchronizationRoots> computeSynchronizationRoots(String query, NuxeoPrincipal principal) -
queryAndFetchSynchronizationRoots
protected Map<String,SynchronizationRoots> queryAndFetchSynchronizationRoots(CoreSession session, String query) -
computeCollectionSyncRootMemberIds
-
checkCanUpdateSynchronizationRoot
-
getChangeFinder
Description copied from interface:NuxeoDriveManager
Gets theFileSystemChangeFinder
member.- Specified by:
getChangeFinder
in interfaceNuxeoDriveManager
-
computeSyncRootsQuery
- Since:
- 5.9.5
-
addToLocallyEditedCollection
Description copied from interface:NuxeoDriveManager
Adds the givenDocumentModel
to theLOCALLY_EDITED_COLLECTION_NAME
collection.- Specified by:
addToLocallyEditedCollection
in interfaceNuxeoDriveManager
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
unregisterContribution
in classDefaultComponent
-
activate
Description copied from interface:Component
Activates the component.This method is called by the runtime when a component is activated.
- Specified by:
activate
in interfaceComponent
- Overrides:
activate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
deactivate
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
getApplicationStartedOrder
public int getApplicationStartedOrder()Description copied from interface:Component
The component notification order forComponent.start(ComponentContext)
.Components are notified in increasing order. Order 1000 is the default order for components that don't care. Order 100 is the repository initialization.
- Specified by:
getApplicationStartedOrder
in interfaceComponent
- Returns:
- the order, 1000 by default
-
start
Sorts the contributed factories according to their order.- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
-