use of com.microsoft.azure.storage.file.ListFileItem in project zeppelin by apache.
the class AzureNotebookRepo method delete.
// unfortunately, we need to use a recursive delete here
private void delete(ListFileItem item) throws StorageException {
if (item.getClass() == CloudFileDirectory.class) {
CloudFileDirectory dir = (CloudFileDirectory) item;
for (ListFileItem subItem : dir.listFilesAndDirectories()) {
delete(subItem);
}
dir.deleteIfExists();
} else if (item.getClass() == CloudFile.class) {
CloudFile file = (CloudFile) item;
file.deleteIfExists();
}
}
use of com.microsoft.azure.storage.file.ListFileItem in project zeppelin by apache.
the class AzureNotebookRepo method list.
@Override
public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {
List<NoteInfo> infos = new LinkedList<>();
NoteInfo info = null;
for (ListFileItem item : rootDir.listFilesAndDirectories()) {
if (item.getClass() == CloudFileDirectory.class) {
CloudFileDirectory dir = (CloudFileDirectory) item;
try {
if (dir.getFileReference("note.json").exists()) {
info = new NoteInfo(getNote(dir.getName()));
if (info != null) {
infos.add(info);
}
}
} catch (StorageException | URISyntaxException e) {
String msg = "Error enumerating notebooks from Azure storage";
LOG.error(msg, e);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
return infos;
}
use of com.microsoft.azure.storage.file.ListFileItem in project zeppelin by apache.
the class AzureNotebookRepo method list.
private Map<String, NoteInfo> list(CloudFileDirectory folder) throws IOException {
Map<String, NoteInfo> notesInfo = new HashMap<>();
for (ListFileItem item : rootDir.listFilesAndDirectories()) {
if (item instanceof CloudFileDirectory) {
CloudFileDirectory dir = (CloudFileDirectory) item;
notesInfo.putAll(list(dir));
} else if (item instanceof CloudFile) {
CloudFile file = (CloudFile) item;
if (file.getName().endsWith(".zpln")) {
try {
String noteName = getNotePath(rootDir.getUri().getPath(), file.getUri().getPath());
String noteId = getNoteId(file.getUri().getPath());
notesInfo.put(noteId, new NoteInfo(noteId, noteName));
} catch (IOException e) {
LOGGER.warn(e.getMessage());
}
} else {
LOGGER.debug("Skip invalid note file: {}", file.getUri().getPath());
}
}
}
return notesInfo;
}
Aggregations