Search in sources :

Example 6 with RepositoryManager

use of org.nuxeo.ecm.core.api.repository.RepositoryManager in project nuxeo-drive-server by nuxeo.

the class MockChangeFinder method getFileSystemChanges.

@Override
public List<FileSystemItemChange> getFileSystemChanges(CoreSession session, Set<IdRef> lastActiveRootRefs, SynchronizationRoots activeRoots, long lastSuccessfulSyncDate, long syncDate, int limit) throws TooManyChangesException {
    List<FileSystemItemChange> docChanges = new ArrayList<FileSystemItemChange>();
    if (!activeRoots.paths.isEmpty()) {
        StringBuilder querySb = new StringBuilder();
        querySb.append("SELECT * FROM Document WHERE (%s) AND (%s) ORDER BY dc:modified DESC");
        String query = String.format(querySb.toString(), getRootPathClause(activeRoots.paths), getDateClause(lastSuccessfulSyncDate, syncDate));
        if (log.isDebugEnabled()) {
            log.debug("Querying repository for document changes: " + query);
        }
        NuxeoPrincipal principal = (NuxeoPrincipal) session.getPrincipal();
        RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class);
        for (String repositoryName : repositoryManager.getRepositoryNames()) {
            try (CloseableCoreSession repoSession = CoreInstance.openCoreSession(repositoryName, principal)) {
                docChanges.addAll(getDocumentChanges(repoSession, query, limit));
            }
        }
    }
    return docChanges;
}
Also used : ArrayList(java.util.ArrayList) CloseableCoreSession(org.nuxeo.ecm.core.api.CloseableCoreSession) RepositoryManager(org.nuxeo.ecm.core.api.repository.RepositoryManager) NuxeoPrincipal(org.nuxeo.ecm.core.api.NuxeoPrincipal)

Aggregations

RepositoryManager (org.nuxeo.ecm.core.api.repository.RepositoryManager)6 CloseableCoreSession (org.nuxeo.ecm.core.api.CloseableCoreSession)5 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)3 HashMap (java.util.HashMap)2 FolderItem (org.nuxeo.drive.adapter.FolderItem)2 NuxeoException (org.nuxeo.ecm.core.api.NuxeoException)2 UserWorkspaceService (org.nuxeo.ecm.platform.userworkspace.api.UserWorkspaceService)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 UserSyncRootParentFolderItem (org.nuxeo.drive.hierarchy.permission.adapter.UserSyncRootParentFolderItem)1 UserWorkspaceTopLevelFolderItem (org.nuxeo.drive.hierarchy.userworkspace.adapter.UserWorkspaceTopLevelFolderItem)1 SynchronizationRoots (org.nuxeo.drive.service.SynchronizationRoots)1 CoreSession (org.nuxeo.ecm.core.api.CoreSession)1 DocumentModelList (org.nuxeo.ecm.core.api.DocumentModelList)1 NuxeoPrincipal (org.nuxeo.ecm.core.api.NuxeoPrincipal)1 PageProvider (org.nuxeo.ecm.platform.query.api.PageProvider)1