use of org.nuxeo.ecm.core.api.NuxeoException 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.ecm.core.api.NuxeoException 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);
}
use of org.nuxeo.ecm.core.api.NuxeoException in project nuxeo-drive-server by nuxeo.
the class FileSystemItemManagerImpl method updateFile.
protected FileItem updateFile(FileSystemItem fsItem, Blob blob) {
if (fsItem == null) {
throw new NuxeoException("Cannot update the content of file system item because it doesn't exist.");
}
if (!(fsItem instanceof FileItem)) {
throw new NuxeoException(String.format("Cannot update the content of file system item with id %s because it is not a file.", fsItem.getId()));
}
FileItem file = (FileItem) fsItem;
file.setBlob(blob);
return file;
}
use of org.nuxeo.ecm.core.api.NuxeoException in project nuxeo-drive-server by nuxeo.
the class FileSystemItemManagerImpl method getChildren.
@Override
public List<FileSystemItem> getChildren(String id, Principal principal) {
FileSystemItem fileSystemItem = getFileSystemItemById(id, principal);
if (fileSystemItem == null) {
throw new NuxeoException(String.format("Cannot get the children 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 children of file system item with id %s because it is not a folder.", id));
}
FolderItem folderItem = (FolderItem) fileSystemItem;
return folderItem.getChildren();
}
use of org.nuxeo.ecm.core.api.NuxeoException in project nuxeo-drive-server by nuxeo.
the class FileSystemItemManagerImpl method createFolder.
/*------------- Write operations ---------------*/
@Override
public FolderItem createFolder(String parentId, String name, Principal principal, boolean overwrite) {
FileSystemItem parentFsItem = getFileSystemItemById(parentId, principal);
if (parentFsItem == null) {
throw new NuxeoException(String.format("Cannot create a folder 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 folder in file system item with id %s because it is not a folder but is: %s", parentId, parentFsItem));
}
FolderItem parentFolder = (FolderItem) parentFsItem;
return parentFolder.createFolder(name, overwrite);
}
Aggregations