Search in sources :

Example 1 with ListFileItem

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();
    }
}
Also used : CloudFile(com.microsoft.azure.storage.file.CloudFile) CloudFileDirectory(com.microsoft.azure.storage.file.CloudFileDirectory) ListFileItem(com.microsoft.azure.storage.file.ListFileItem)

Example 2 with ListFileItem

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;
}
Also used : NoteInfo(org.apache.zeppelin.notebook.NoteInfo) ListFileItem(com.microsoft.azure.storage.file.ListFileItem) CloudFileDirectory(com.microsoft.azure.storage.file.CloudFileDirectory) URISyntaxException(java.net.URISyntaxException) StorageException(com.microsoft.azure.storage.StorageException) LinkedList(java.util.LinkedList) URISyntaxException(java.net.URISyntaxException) StorageException(com.microsoft.azure.storage.StorageException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException)

Example 3 with ListFileItem

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;
}
Also used : NoteInfo(org.apache.zeppelin.notebook.NoteInfo) CloudFile(com.microsoft.azure.storage.file.CloudFile) HashMap(java.util.HashMap) ListFileItem(com.microsoft.azure.storage.file.ListFileItem) CloudFileDirectory(com.microsoft.azure.storage.file.CloudFileDirectory) IOException(java.io.IOException)

Aggregations

CloudFileDirectory (com.microsoft.azure.storage.file.CloudFileDirectory)3 ListFileItem (com.microsoft.azure.storage.file.ListFileItem)3 CloudFile (com.microsoft.azure.storage.file.CloudFile)2 IOException (java.io.IOException)2 NoteInfo (org.apache.zeppelin.notebook.NoteInfo)2 StorageException (com.microsoft.azure.storage.StorageException)1 URISyntaxException (java.net.URISyntaxException)1 InvalidKeyException (java.security.InvalidKeyException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1