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 StringCHANGE_FINDER_EPprotected FileSystemChangeFinderchangeFinderprotected ChangeFinderRegistrychangeFinderRegistryprotected static longCOLLECTION_CONTENT_PAGE_SIZEprotected CachecollectionSyncRootMemberCacheCache holding the collection sync root member ids for a given user (first map key) and repository (second map key).static StringDOCUMENT_CHANGE_LIMIT_PROPERTYstatic StringDRIVE_COLLECTION_SYNC_ROOT_MEMBER_CACHEstatic StringDRIVE_SUBSCRIPTIONS_PROPERTYstatic StringDRIVE_SYNC_ROOT_CACHEstatic StringLOCALLY_EDITED_COLLECTION_NAMEstatic StringNUXEO_DRIVE_FACETprotected CachesyncRootCacheCache holding the synchronization roots for a given user (first map key) and repository (second map key).static TimeZoneUTC-
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 voidactivate(ComponentContext context)Activates the component.voidaddToLocallyEditedCollection(CoreSession session, DocumentModel doc)Adds the givenDocumentModelto theLOCALLY_EDITED_COLLECTION_NAMEcollection.protected voidcheckCanUpdateSynchronizationRoot(DocumentModel newRootContainer)protected voidclearCache()protected Map<String,Set<String>>computeCollectionSyncRootMemberIds(NuxeoPrincipal principal)protected Map<String,SynchronizationRoots>computeSynchronizationRoots(String query, NuxeoPrincipal principal)protected StringcomputeSyncRootsQuery(String username)voiddeactivate(ComponentContext context)Deactivates the component.protected voidfireEvent(DocumentModel sourceDocument, CoreSession session, String eventName, String impactedUserName)intgetApplicationStartedOrder()The component notification order forComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext).FileSystemChangeFindergetChangeFinder()Gets theFileSystemChangeFindermember.FileSystemChangeSummarygetChangeSummary(NuxeoPrincipal principal, Map<String,Set<IdRef>> lastSyncRootRefs, long lowerBound)Uses theAuditChangeFinderto get the summary of document changes for the given user and lower bound.protected CachegetCollectionSyncRootMemberCache()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 CachegetSyncRootCache()voidhandleFolderDeletion(IdRef deleted)Method to be called by a CoreEvent listener monitoring documents deletions to cleanup references to recently deleted documents and invalidate the caches.voidinvalidateCollectionSyncRootMemberCache()Invalidate the collection sync root member cache for all users so as to query the repository next timeNuxeoDriveManager.getCollectionSyncRootMemberIds(NuxeoPrincipal)is called.voidinvalidateCollectionSyncRootMemberCache(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.voidinvalidateSynchronizationRootsCache(String userName)Invalidate the synchronization roots cache for a given user so as to query the repository next timeNuxeoDriveManager.getSynchronizationRoots(NuxeoPrincipal)is called.booleanisSynchronizationRoot(NuxeoPrincipal principal, DocumentModel doc)Checks if the givenDocumentModelis a synchronization root for the given user.protected Map<String,SynchronizationRoots>queryAndFetchSynchronizationRoots(CoreSession session, String query)voidregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)voidregisterSynchronizationRoot(NuxeoPrincipal principal, DocumentModel newRootContainer, CoreSession session)voidstart(ComponentContext context)Sorts the contributed factories according to their order.voidstop(ComponentContext context)Stop the component.voidunregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)voidunregisterSynchronizationRoot(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
-
UTC
public static final TimeZone UTC
-
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
-
-
Method Detail
-
getSyncRootCache
protected Cache getSyncRootCache()
-
getCollectionSyncRootMemberCache
protected Cache getCollectionSyncRootMemberCache()
-
clearCache
protected void clearCache()
-
invalidateSynchronizationRootsCache
public void invalidateSynchronizationRootsCache(String userName)
Description copied from interface:NuxeoDriveManagerInvalidate the synchronization roots cache for a given user so as to query the repository next timeNuxeoDriveManager.getSynchronizationRoots(NuxeoPrincipal)is called.- Specified by:
invalidateSynchronizationRootsCachein interfaceNuxeoDriveManager- Parameters:
userName- the principal name of the user to invalidate the cache for.
-
invalidateCollectionSyncRootMemberCache
public void invalidateCollectionSyncRootMemberCache(String userName)
Description copied from interface:NuxeoDriveManagerInvalidate the collection sync root member cache for a given user so as to query the repository next timeNuxeoDriveManager.getCollectionSyncRootMemberIds(NuxeoPrincipal)is called.- Specified by:
invalidateCollectionSyncRootMemberCachein interfaceNuxeoDriveManager- Parameters:
userName- the principal name of the user to invalidate the cache for.
-
invalidateCollectionSyncRootMemberCache
public void invalidateCollectionSyncRootMemberCache()
Description copied from interface:NuxeoDriveManagerInvalidate the collection sync root member cache for all users so as to query the repository next timeNuxeoDriveManager.getCollectionSyncRootMemberIds(NuxeoPrincipal)is called.- Specified by:
invalidateCollectionSyncRootMemberCachein interfaceNuxeoDriveManager
-
registerSynchronizationRoot
public void registerSynchronizationRoot(NuxeoPrincipal principal, DocumentModel newRootContainer, CoreSession session)
- Specified by:
registerSynchronizationRootin 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:
unregisterSynchronizationRootin 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:NuxeoDriveManagerFetch 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:
getSynchronizationRootReferencesin 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:NuxeoDriveManagerMethod to be called by a CoreEvent listener monitoring documents deletions to cleanup references to recently deleted documents and invalidate the caches.- Specified by:
handleFolderDeletionin 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 theAuditChangeFinderto get the summary of document changes for the given user and lower bound.The
DOCUMENT_CHANGE_LIMIT_PROPERTYFramework property is used as a limit of document changes to fetch from the audit logs. Default value is 1000. IflowerBoundis 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:
getChangeSummaryin interfaceNuxeoDriveManagerlastSyncRootRefs- 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:NuxeoDriveManagerFetch 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:
getSynchronizationRootsin 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:NuxeoDriveManagerFetch all the collection sync root member ids for a given user.- Specified by:
getCollectionSyncRootMemberIdsin 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:NuxeoDriveManagerChecks if the givenDocumentModelis a synchronization root for the given user.- Specified by:
isSynchronizationRootin 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:NuxeoDriveManagerGets theFileSystemChangeFindermember.- Specified by:
getChangeFinderin interfaceNuxeoDriveManager
-
addToLocallyEditedCollection
public void addToLocallyEditedCollection(CoreSession session, DocumentModel doc)
Description copied from interface:NuxeoDriveManagerAdds the givenDocumentModelto theLOCALLY_EDITED_COLLECTION_NAMEcollection.- Specified by:
addToLocallyEditedCollectionin interfaceNuxeoDriveManager
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
registerContributionin classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContributionin classDefaultComponent
-
activate
public void activate(ComponentContext context)
Description copied from interface:ComponentActivates the component.This method is called by the runtime when a component is activated.
- Specified by:
activatein interfaceComponent- Overrides:
activatein classDefaultComponent- Parameters:
context- the runtime context
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:ComponentDeactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivatein interfaceComponent- Overrides:
deactivatein classDefaultComponent- Parameters:
context- the runtime context
-
getApplicationStartedOrder
public int getApplicationStartedOrder()
Description copied from interface:ComponentThe 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:
getApplicationStartedOrderin interfaceComponent- Returns:
- the order, 1000 by default
-
start
public void start(ComponentContext context)
Sorts the contributed factories according to their order.- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
stop
public void stop(ComponentContext context)
Description copied from interface:ComponentStop the component.- Specified by:
stopin interfaceComponent- Overrides:
stopin classDefaultComponent
-
-