You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2020/01/31 06:30:56 UTC

[zeppelin] branch master updated: [ZEPPELIN-4574] Fixed rootNotebookFolder and noteFileName in VFSNotebookRepo.java to allow it to work on windows

This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new 25414f3  [ZEPPELIN-4574] Fixed rootNotebookFolder and noteFileName in VFSNotebookRepo.java to allow it to work on windows
25414f3 is described below

commit 25414f3170c3d772d8de9a1798c35adf9ded51a0
Author: Muhammad Taufiq <Mu...@morganstanley.com>
AuthorDate: Tue Jan 21 14:05:13 2020 +0000

    [ZEPPELIN-4574] Fixed rootNotebookFolder and noteFileName in VFSNotebookRepo.java to allow it to work on windows
    
    ### What is this PR for?
    The rootNotebookFolder variable in VFSNotebookRepo.java does not contain the root directory in windows. For e.g. if notebook directory is "C:/Users/zeppelin-notes", the value of rootNotebookFolder set in VFSNotebookRepo.java:91 is "/Users/zeppelin-notes", which is not found in windows and throws an exception at launch.
    Using `this.rootNotebookFolder = rootNotebookFileObject.getName().getURI().replace("file:///", "/");` instead allows us to set the correct value for rootNotebookFolder (i.e. /C:/Users/zeppelin-notes).
    
    Similarly, the noteFileName (VFSNotebookRepo.java:110) variable is missing root directory in windows and using `String noteFileName = fileObject.getName().getURI().replace("file:///", "/");` fixes this.
    
    ### What type of PR is it?
    Bug Fix
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-4574
    
    THIS SOFTWARE IS CONTRIBUTED SUBJECT TO THE TERMS OF THE APACHE SOFTWARE FOUNDATION SOFTWARE GRANT AND CORPORATE CONTRIBUTOR LICENSE AGREEMENT VERSION R190612.
    
    THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OF NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS [...]
    
    Author: Muhammad Taufiq <Mu...@morganstanley.com>
    Author: Muhammad-ms <59...@users.noreply.github.com>
    
    Closes #3615 from Muhammad-ms/zeppelin9_vfs and squashes the following commits:
    
    b0a65c0d2 [Muhammad Taufiq] [ZEPPELIN-4574] Added comments explaining the change
    81b054e92 [Muhammad Taufiq] [ZEPPELIN-4574] Fixed rootNotebookFolder and noteFileName in VFSNotebookRepo.java to allow it to work on windows
    4f532aad5 [Muhammad-ms] Merge pull request #1 from apache/master
---
 .../java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java
index d8d8df0..e452235 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java
@@ -88,7 +88,9 @@ public class VFSNotebookRepo implements NotebookRepo {
       LOGGER.info("Notebook dir doesn't exist: {}, creating it.",
           rootNotebookFileObject.getName().getPath());
     }
-    this.rootNotebookFolder = rootNotebookFileObject.getName().getPath();
+    // getPath() method returns a string without root directory in windows, so we use getURI() instead
+    // windows does not support paths with "file:///" prepended, so we replace it by "/"
+    this.rootNotebookFolder = rootNotebookFileObject.getName().getURI().replace("file:///", "/");
   }
 
   @Override
@@ -110,7 +112,9 @@ public class VFSNotebookRepo implements NotebookRepo {
         noteInfos.putAll(listFolder(child));
       }
     } else {
-      String noteFileName = fileObject.getName().getPath();
+      // getPath() method returns a string without root directory in windows, so we use getURI() instead
+      // windows does not support paths with "file:///" prepended. so we replace it by "/"
+      String noteFileName = fileObject.getName().getURI().replace("file:///", "/");
       if (noteFileName.endsWith(".zpln")) {
         try {
           String noteId = getNoteId(noteFileName);