use of org.nuxeo.drive.adapter.FolderItem in project nuxeo-drive-server by nuxeo.
the class PermissionTopLevelFolderItem method getChildren.
@Override
public List<FileSystemItem> getChildren() {
List<FileSystemItem> children = new ArrayList<FileSystemItem>();
for (String childFactoryName : childrenFactoryNames) {
VirtualFolderItemFactory factory = getFileSystemItemAdapterService().getVirtualFolderItemFactory(childFactoryName);
FolderItem child = factory.getVirtualFolderItem(principal);
if (child != null) {
children.add(child);
}
}
return children;
}
use of org.nuxeo.drive.adapter.FolderItem in project nuxeo-drive-server by nuxeo.
the class AbstractFileSystemItemFactory method getFileSystemItemById.
@Override
public FileSystemItem getFileSystemItemById(String id, String parentId, Principal principal) {
String[] idFragments = parseFileSystemId(id);
String repositoryName = idFragments[1];
String docId = idFragments[2];
try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryName, principal)) {
FileSystemItem parentItem = Framework.getService(FileSystemItemAdapterService.class).getFileSystemItemFactoryForId(parentId).getFileSystemItemById(parentId, principal);
if (!(parentItem instanceof FolderItem)) {
throw new NuxeoException(String.format("FileSystemItem with id %s should be a FolderItem", parentId));
}
DocumentModel doc = getDocumentById(docId, session);
return getFileSystemItem(doc, (FolderItem) parentItem);
} catch (DocumentNotFoundException e) {
if (log.isDebugEnabled()) {
log.debug(String.format("No doc related to id %s, returning null.", docId));
}
return null;
} catch (DocumentSecurityException e) {
if (log.isDebugEnabled()) {
log.debug(String.format("User %s cannot access doc %s, returning null.", principal.getName(), docId));
}
return null;
}
}
use of org.nuxeo.drive.adapter.FolderItem in project nuxeo-drive-server by nuxeo.
the class FileSystemItemManagerImpl method move.
@Override
public FileSystemItem move(String srcId, String destId, Principal principal) {
FileSystemItem srcFsItem = getFileSystemItemById(srcId, principal);
if (srcFsItem == null) {
throw new NuxeoException(String.format("Cannot move file system item with id %s because it doesn't exist.", srcId));
}
FileSystemItem destFsItem = getFileSystemItemById(destId, principal);
if (destFsItem == null) {
throw new NuxeoException(String.format("Cannot move a file system item to file system item with id %s because it doesn't exist.", destId));
}
if (!(destFsItem instanceof FolderItem)) {
throw new NuxeoException(String.format("Cannot move a file system item to file system item with id %s because it is not a folder.", destId));
}
return srcFsItem.move((FolderItem) destFsItem);
}
use of org.nuxeo.drive.adapter.FolderItem in project nuxeo-drive-server by nuxeo.
the class FileSystemItemManagerImpl method scrollDescendants.
@Override
public ScrollFileSystemItemList scrollDescendants(String id, Principal principal, String scrollId, int batchSize, long keepAlive) {
FileSystemItem fileSystemItem = getFileSystemItemById(id, principal);
if (fileSystemItem == null) {
throw new NuxeoException(String.format("Cannot get the descendants of file system item with id %s because it doesn't exist.", id));
}
if (!(fileSystemItem instanceof FolderItem)) {
throw new NuxeoException(String.format("Cannot get the descendants of file system item with id %s because it is not a folder.", id));
}
FolderItem folderItem = (FolderItem) fileSystemItem;
return folderItem.scrollDescendants(scrollId, batchSize, keepAlive);
}
use of org.nuxeo.drive.adapter.FolderItem in project nuxeo-drive-server by nuxeo.
the class FileSystemItemManagerImpl method createFile.
@Override
public FileItem createFile(String parentId, Blob blob, Principal principal, boolean overwrite) {
FileSystemItem parentFsItem = getFileSystemItemById(parentId, principal);
if (parentFsItem == null) {
throw new NuxeoException(String.format("Cannot create a file in file system item with id %s because it doesn't exist.", parentId));
}
if (!(parentFsItem instanceof FolderItem)) {
throw new NuxeoException(String.format("Cannot create a file in file system item with id %s because it is not a folder but is: %s", parentId, parentFsItem));
}
FolderItem parentFolder = (FolderItem) parentFsItem;
return parentFolder.createFile(blob, overwrite);
}
Aggregations