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;
}
Aggregations