Search in sources :

Example 1 with UserWorkspaceService

use of org.nuxeo.ecm.platform.userworkspace.api.UserWorkspaceService 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);
    }
}
Also used : FolderItem(org.nuxeo.drive.adapter.FolderItem) UserSyncRootParentFolderItem(org.nuxeo.drive.hierarchy.permission.adapter.UserSyncRootParentFolderItem) UserWorkspaceService(org.nuxeo.ecm.platform.userworkspace.api.UserWorkspaceService) CloseableCoreSession(org.nuxeo.ecm.core.api.CloseableCoreSession) RepositoryManager(org.nuxeo.ecm.core.api.repository.RepositoryManager) NuxeoException(org.nuxeo.ecm.core.api.NuxeoException) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel)

Example 2 with UserWorkspaceService

use of org.nuxeo.ecm.platform.userworkspace.api.UserWorkspaceService 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);
    }
}
Also used : FolderItem(org.nuxeo.drive.adapter.FolderItem) UserWorkspaceTopLevelFolderItem(org.nuxeo.drive.hierarchy.userworkspace.adapter.UserWorkspaceTopLevelFolderItem) UserWorkspaceService(org.nuxeo.ecm.platform.userworkspace.api.UserWorkspaceService) CloseableCoreSession(org.nuxeo.ecm.core.api.CloseableCoreSession) RepositoryManager(org.nuxeo.ecm.core.api.repository.RepositoryManager) NuxeoException(org.nuxeo.ecm.core.api.NuxeoException) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel)

Aggregations

FolderItem (org.nuxeo.drive.adapter.FolderItem)2 CloseableCoreSession (org.nuxeo.ecm.core.api.CloseableCoreSession)2 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)2 NuxeoException (org.nuxeo.ecm.core.api.NuxeoException)2 RepositoryManager (org.nuxeo.ecm.core.api.repository.RepositoryManager)2 UserWorkspaceService (org.nuxeo.ecm.platform.userworkspace.api.UserWorkspaceService)2 UserSyncRootParentFolderItem (org.nuxeo.drive.hierarchy.permission.adapter.UserSyncRootParentFolderItem)1 UserWorkspaceTopLevelFolderItem (org.nuxeo.drive.hierarchy.userworkspace.adapter.UserWorkspaceTopLevelFolderItem)1