use of org.nuxeo.ecm.core.api.repository.RepositoryManager 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.core.api.repository.RepositoryManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveGroupUpdateListener method handleUpdatedGroups.
protected void handleUpdatedGroups(List<String> groupNames) {
RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class);
for (String repositoryName : repositoryManager.getRepositoryNames()) {
CoreInstance.doPrivileged(repositoryName, (CoreSession session) -> {
DocumentModelList impactedDocuments = getImpactedDocuments(session, groupNames);
impactedDocuments.forEach(doc -> fireGroupUpdatedEvent(session, doc));
});
}
}
use of org.nuxeo.ecm.core.api.repository.RepositoryManager in project nuxeo-drive-server by nuxeo.
the class UserSyncRootParentFactory method getVirtualFolderItem.
/*------------------- VirtualFolderItemFactory ------------------- */
@Override
public FolderItem getVirtualFolderItem(Principal principal) {
RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class);
// TODO: handle multiple repositories
try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryManager.getDefaultRepositoryName(), principal)) {
UserWorkspaceService userWorkspaceService = Framework.getService(UserWorkspaceService.class);
DocumentModel userWorkspace = userWorkspaceService.getCurrentUserPersonalWorkspace(session);
if (userWorkspace == null) {
throw new NuxeoException(String.format("No personal workspace found for user %s.", principal.getName()));
}
return (FolderItem) getFileSystemItem(userWorkspace);
}
}
use of org.nuxeo.ecm.core.api.repository.RepositoryManager in project nuxeo-drive-server by nuxeo.
the class UserWorkspaceTopLevelFactory method getTopLevelFolderItem.
/*----------------------- TopLevelFolderItemFactory ---------------------*/
@Override
public FolderItem getTopLevelFolderItem(Principal principal) {
RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class);
// TODO: handle multiple repositories
try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryManager.getDefaultRepositoryName(), principal)) {
UserWorkspaceService userWorkspaceService = Framework.getService(UserWorkspaceService.class);
DocumentModel userWorkspace = userWorkspaceService.getCurrentUserPersonalWorkspace(session);
if (userWorkspace == null) {
throw new NuxeoException(String.format("No personal workspace found for user %s.", principal.getName()));
}
return (FolderItem) getFileSystemItem(userWorkspace);
}
}
use of org.nuxeo.ecm.core.api.repository.RepositoryManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveManagerImpl method computeSynchronizationRoots.
protected Map<String, SynchronizationRoots> computeSynchronizationRoots(String query, Principal principal) {
Map<String, SynchronizationRoots> syncRoots = new HashMap<String, SynchronizationRoots>();
RepositoryManager repositoryManager = Framework.getService(RepositoryManager.class);
for (String repositoryName : repositoryManager.getRepositoryNames()) {
try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryName, principal)) {
syncRoots.putAll(queryAndFetchSynchronizationRoots(session, query));
}
}
return syncRoots;
}
Aggregations