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
public class NuxeoDriveManagerImpl extends DefaultComponent implements NuxeoDriveManager
Manage list of NuxeoDrive synchronization roots and devices for a given nuxeo user.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CHANGE_FINDER_EP
protected FileSystemChangeFinder
changeFinder
protected ChangeFinderRegistry
changeFinderRegistry
protected static long
COLLECTION_CONTENT_PAGE_SIZE
protected Cache
collectionSyncRootMemberCache
Cache holding the collection sync root member ids for a given user (first map key) and repository (second map key).static String
DOCUMENT_CHANGE_LIMIT_PROPERTY
static String
DRIVE_COLLECTION_SYNC_ROOT_MEMBER_CACHE
static String
DRIVE_SUBSCRIPTIONS_PROPERTY
static String
DRIVE_SYNC_ROOT_CACHE
static String
LOCALLY_EDITED_COLLECTION_NAME
static String
NUXEO_DRIVE_FACET
protected Cache
syncRootCache
Cache holding the synchronization roots for a given user (first map key) and repository (second map key).static TimeZone
UTC
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description NuxeoDriveManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
clearCache()
protected Map<String,Set<String>>
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
getApplicationStartedOrder()
The component notification order forComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext)
.FileSystemChangeFinder
getChangeFinder()
Gets theFileSystemChangeFinder
member.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.protected Cache
getCollectionSyncRootMemberCache()
Map<String,Set<String>>
getCollectionSyncRootMemberIds(NuxeoPrincipal principal)
Fetch all the collection sync root member ids for a given user.Set<IdRef>
getSynchronizationRootReferences(CoreSession session)
Fetch the list of synchronization root refs for a given user and a given session repository.Map<String,SynchronizationRoots>
getSynchronizationRoots(NuxeoPrincipal principal)
Fetch all the synchronization root references and paths for a given user.protected Cache
getSyncRootCache()
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
invalidateCollectionSyncRootMemberCache()
Invalidate the collection sync root member cache for all users so as to query the repository next timeNuxeoDriveManager.getCollectionSyncRootMemberIds(NuxeoPrincipal)
is called.void
invalidateCollectionSyncRootMemberCache(String userName)
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted
-
-
-
-
Field Detail
-
CHANGE_FINDER_EP
public static final String CHANGE_FINDER_EP
- See Also:
- Constant Field Values
-
NUXEO_DRIVE_FACET
public static final String NUXEO_DRIVE_FACET
- See Also:
- Constant Field Values
-
DRIVE_SUBSCRIPTIONS_PROPERTY
public static final String DRIVE_SUBSCRIPTIONS_PROPERTY
- See Also:
- Constant Field Values
-
DOCUMENT_CHANGE_LIMIT_PROPERTY
public static final String DOCUMENT_CHANGE_LIMIT_PROPERTY
- See Also:
- Constant Field Values
-
DRIVE_SYNC_ROOT_CACHE
public static final String DRIVE_SYNC_ROOT_CACHE
- See Also:
- Constant Field Values
-
DRIVE_COLLECTION_SYNC_ROOT_MEMBER_CACHE
public static final String DRIVE_COLLECTION_SYNC_ROOT_MEMBER_CACHE
- See Also:
- Constant Field Values
-
LOCALLY_EDITED_COLLECTION_NAME
public static final String LOCALLY_EDITED_COLLECTION_NAME
- See Also:
- Constant Field Values
-
COLLECTION_CONTENT_PAGE_SIZE
protected static final long COLLECTION_CONTENT_PAGE_SIZE
- See Also:
- Constant Field Values
-
syncRootCache
protected Cache syncRootCache
Cache holding the synchronization roots for a given user (first map key) and repository (second map key).
-
collectionSyncRootMemberCache
protected Cache collectionSyncRootMemberCache
Cache holding the collection sync root member ids for a given user (first map key) and repository (second map key).
-
changeFinderRegistry
protected ChangeFinderRegistry changeFinderRegistry
-
changeFinder
protected FileSystemChangeFinder changeFinder
-
-
Constructor Detail
-
NuxeoDriveManagerImpl
public NuxeoDriveManagerImpl()
-
-
Method Detail
-
getSyncRootCache
protected Cache getSyncRootCache()
-
getCollectionSyncRootMemberCache
protected Cache getCollectionSyncRootMemberCache()
-
clearCache
protected void clearCache()
-
invalidateSynchronizationRootsCache
public void invalidateSynchronizationRootsCache(String userName)
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
public void invalidateCollectionSyncRootMemberCache(String userName)
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
public Set<IdRef> getSynchronizationRootReferences(CoreSession session)
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
public void handleFolderDeletion(IdRef deleted)
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
public Map<String,SynchronizationRoots> getSynchronizationRoots(NuxeoPrincipal principal)
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
public Map<String,Set<String>> getCollectionSyncRootMemberIds(NuxeoPrincipal principal)
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
public boolean isSynchronizationRoot(NuxeoPrincipal principal, DocumentModel doc)
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
protected Map<String,Set<String>> computeCollectionSyncRootMemberIds(NuxeoPrincipal principal)
-
checkCanUpdateSynchronizationRoot
protected void checkCanUpdateSynchronizationRoot(DocumentModel newRootContainer)
-
getChangeFinder
public FileSystemChangeFinder getChangeFinder()
Description copied from interface:NuxeoDriveManager
Gets theFileSystemChangeFinder
member.- Specified by:
getChangeFinder
in interfaceNuxeoDriveManager
-
computeSyncRootsQuery
protected String computeSyncRootsQuery(String username)
- Since:
- 5.9.5
-
addToLocallyEditedCollection
public void addToLocallyEditedCollection(CoreSession session, DocumentModel doc)
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
public void activate(ComponentContext context)
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
public void deactivate(ComponentContext context)
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.applicationStarted(org.nuxeo.runtime.model.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
public void start(ComponentContext context)
Sorts the contributed factories according to their order.- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
public void stop(ComponentContext context)
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
-
-