use of org.nuxeo.drive.adapter.FolderItem in project nuxeo-drive-server by nuxeo.
the class DocumentBackedFolderItem method populateAncestorCache.
protected FolderItem populateAncestorCache(Map<DocumentRef, FolderItem> cache, DocumentModel doc, CoreSession session, boolean cacheItem) {
DocumentRef parentDocRef = session.getParentDocumentRef(doc.getRef());
if (parentDocRef == null) {
throw new RootlessItemException("Reached repository root");
}
FolderItem parentItem = cache.get(parentDocRef);
if (parentItem != null) {
if (log.isTraceEnabled()) {
log.trace(String.format("Found parent FolderItem in cache for doc %s: %s", doc.getPathAsString(), parentItem.getPath()));
}
return getFolderItem(cache, doc, parentItem, cacheItem);
}
if (log.isTraceEnabled()) {
log.trace(String.format("No parent FolderItem found in cache for doc %s, computing ancestor cache", doc.getPathAsString()));
}
DocumentModel parentDoc;
try {
parentDoc = session.getDocument(parentDocRef);
} catch (DocumentSecurityException e) {
throw new RootlessItemException(String.format("User %s has no READ access on parent of document %s (%s).", principal.getName(), doc.getPathAsString(), doc.getId()), e);
}
parentItem = populateAncestorCache(cache, parentDoc, session, true);
if (parentItem == null) {
return null;
}
return getFolderItem(cache, doc, parentItem, cacheItem);
}
use of org.nuxeo.drive.adapter.FolderItem 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.drive.adapter.FolderItem in project nuxeo-drive-server by nuxeo.
the class UserWorkspaceTopLevelFolderItem method getChildren.
/*--------------------- FolderItem -----------------*/
@Override
public List<FileSystemItem> getChildren() {
// already the case
if (!getNuxeoDriveManager().isSynchronizationRoot(principal, userWorkspace)) {
try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryName, principal)) {
getNuxeoDriveManager().registerSynchronizationRoot(principal, userWorkspace, session);
}
}
List<FileSystemItem> children = new ArrayList<FileSystemItem>();
// Add user workspace children
children.addAll(super.getChildren());
// Add synchronization root parent folder
if (syncRootParentFactoryName == null) {
if (log.isDebugEnabled()) {
log.debug(String.format("No synchronization root parent factory name parameter for factory %s, the synchronization roots won't be synchronized client side.", factoryName));
}
} else {
VirtualFolderItemFactory syncRootParentFactory = getFileSystemItemAdapterService().getVirtualFolderItemFactory(syncRootParentFactoryName);
FolderItem syncRootParent = syncRootParentFactory.getVirtualFolderItem(principal);
if (syncRootParent != null) {
children.add(syncRootParent);
}
}
return children;
}
use of org.nuxeo.drive.adapter.FolderItem in project nuxeo-drive-server by nuxeo.
the class UserWorkspaceSyncRootParentFactory method getVirtualFolderItem.
@Override
public FolderItem getVirtualFolderItem(Principal principal) {
FileSystemItemManager fileSystemItemManager = Framework.getService(FileSystemItemManager.class);
FolderItem topLevelFolder = fileSystemItemManager.getTopLevelFolder(principal);
if (topLevelFolder == null) {
throw new NuxeoException("Found no top level folder item. Please check your contribution to the following extension point: <extension target=\"org.nuxeo.drive.service.FileSystemItemAdapterService\" point=\"topLevelFolderItemFactory\">.");
}
return new UserWorkspaceSyncRootParentFolderItem(getName(), principal, topLevelFolder.getId(), topLevelFolder.getPath(), folderName);
}
use of org.nuxeo.drive.adapter.FolderItem 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);
}
}
Aggregations