use of org.nuxeo.ecm.platform.query.api.PageProvider in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveManagerImpl method computeCollectionSyncRootMemberIds.
@SuppressWarnings("unchecked")
protected Map<String, Set<String>> computeCollectionSyncRootMemberIds(Principal principal) {
Map<String, Set<String>> collectionSyncRootMemberIds = new HashMap<String, Set<String>>();
PageProviderService pageProviderService = Framework.getService(PageProviderService.class);
RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class);
for (String repositoryName : repositoryManager.getRepositoryNames()) {
Set<String> collectionMemberIds = new HashSet<String>();
try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryName, principal)) {
Map<String, Serializable> props = new HashMap<String, Serializable>();
props.put(CORE_SESSION_PROPERTY, (Serializable) session);
PageProvider<DocumentModel> collectionPageProvider = (PageProvider<DocumentModel>) pageProviderService.getPageProvider(CollectionConstants.ALL_COLLECTIONS_PAGE_PROVIDER, null, null, 0L, props);
List<DocumentModel> collections = collectionPageProvider.getCurrentPage();
for (DocumentModel collection : collections) {
if (isSynchronizationRoot(principal, collection)) {
PageProvider<DocumentModel> collectionMemberPageProvider = (PageProvider<DocumentModel>) pageProviderService.getPageProvider(CollectionConstants.COLLECTION_CONTENT_PAGE_PROVIDER, null, COLLECTION_CONTENT_PAGE_SIZE, 0L, props, collection.getId());
List<DocumentModel> collectionMembers = collectionMemberPageProvider.getCurrentPage();
for (DocumentModel collectionMember : collectionMembers) {
collectionMemberIds.add(collectionMember.getId());
}
}
}
collectionSyncRootMemberIds.put(repositoryName, collectionMemberIds);
}
}
return collectionSyncRootMemberIds;
}
use of org.nuxeo.ecm.platform.query.api.PageProvider in project nuxeo-drive-server by nuxeo.
the class DocumentBackedFolderItem method getChildren.
/*--------------------- FolderItem -----------------*/
@Override
@SuppressWarnings("unchecked")
public List<FileSystemItem> getChildren() {
try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryName, principal)) {
PageProviderService pageProviderService = Framework.getService(PageProviderService.class);
Map<String, Serializable> props = new HashMap<>();
props.put(CORE_SESSION_PROPERTY, (Serializable) session);
PageProvider<DocumentModel> childrenPageProvider = (PageProvider<DocumentModel>) pageProviderService.getPageProvider(FOLDER_ITEM_CHILDREN_PAGE_PROVIDER, null, null, 0L, props, docId);
long pageSize = childrenPageProvider.getPageSize();
List<FileSystemItem> children = new ArrayList<>();
int nbChildren = 0;
boolean reachedPageSize = false;
boolean hasNextPage = true;
// FileSystemItems
while (nbChildren < pageSize && hasNextPage) {
List<DocumentModel> dmChildren = childrenPageProvider.getCurrentPage();
for (DocumentModel dmChild : dmChildren) {
// NXP-19442: Avoid useless and costly call to DocumentModel#getLockInfo
FileSystemItem child = getFileSystemItemAdapterService().getFileSystemItem(dmChild, this, false, false, false);
if (child != null) {
children.add(child);
nbChildren++;
if (nbChildren == pageSize) {
reachedPageSize = true;
break;
}
}
}
if (!reachedPageSize) {
hasNextPage = childrenPageProvider.isNextPageAvailable();
if (hasNextPage) {
childrenPageProvider.nextPage();
}
}
}
return children;
}
}
use of org.nuxeo.ecm.platform.query.api.PageProvider in project nuxeo-drive-server by nuxeo.
the class CollectionSyncRootFolderItem method getChildren.
@Override
@SuppressWarnings("unchecked")
public List<FileSystemItem> getChildren() {
try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryName, principal)) {
PageProviderService pageProviderService = Framework.getService(PageProviderService.class);
Map<String, Serializable> props = new HashMap<String, Serializable>();
props.put(CORE_SESSION_PROPERTY, (Serializable) session);
PageProvider<DocumentModel> childrenPageProvider = (PageProvider<DocumentModel>) pageProviderService.getPageProvider(CollectionConstants.COLLECTION_CONTENT_PAGE_PROVIDER, null, null, 0L, props, docId);
List<DocumentModel> dmChildren = childrenPageProvider.getCurrentPage();
List<FileSystemItem> children = new ArrayList<FileSystemItem>(dmChildren.size());
for (DocumentModel dmChild : dmChildren) {
// NXP-19442: Avoid useless and costly call to DocumentModel#getLockInfo
FileSystemItem child = getFileSystemItemAdapterService().getFileSystemItem(dmChild, this, false, false, false);
if (child != null) {
children.add(child);
}
}
return children;
}
}
Aggregations