Search in sources :

Example 6 with NoteInfo

use of org.apache.zeppelin.notebook.NoteInfo 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 7 with NoteInfo

use of org.apache.zeppelin.notebook.NoteInfo in project zeppelin by apache.

the class VFSNotebookRepo method list.

@Override
public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {
    FileObject rootDir = getRootDir();
    FileObject[] children = rootDir.getChildren();
    List<NoteInfo> infos = new LinkedList<>();
    for (FileObject f : children) {
        String fileName = f.getName().getBaseName();
        if (f.isHidden() || fileName.startsWith(".") || fileName.startsWith("#") || fileName.startsWith("~")) {
            // skip hidden, temporary files
            continue;
        }
        if (!isDirectory(f)) {
            // so it must be a directory
            continue;
        }
        NoteInfo info = null;
        try {
            info = getNoteInfo(f);
            if (info != null) {
                infos.add(info);
            }
        } catch (Exception e) {
            LOG.error("Can't read note " + f.getName().toString(), e);
        }
    }
    return infos;
}
Also used : NoteInfo(org.apache.zeppelin.notebook.NoteInfo) FileObject(org.apache.commons.vfs2.FileObject) LinkedList(java.util.LinkedList) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Aggregations

NoteInfo (org.apache.zeppelin.notebook.NoteInfo)7 IOException (java.io.IOException)4 LinkedList (java.util.LinkedList)3 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Note (org.apache.zeppelin.notebook.Note)2 Document (org.bson.Document)2 AmazonClientException (com.amazonaws.AmazonClientException)1 ListObjectsRequest (com.amazonaws.services.s3.model.ListObjectsRequest)1 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)1 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)1 StorageException (com.microsoft.azure.storage.StorageException)1 CloudFileDirectory (com.microsoft.azure.storage.file.CloudFileDirectory)1 ListFileItem (com.microsoft.azure.storage.file.ListFileItem)1 MongoBulkWriteException (com.mongodb.MongoBulkWriteException)1 InsertManyOptions (com.mongodb.client.model.InsertManyOptions)1 InvalidKeyException (java.security.InvalidKeyException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1