HwangRock opened a new pull request, #5292: URL: https://github.com/apache/zeppelin/pull/5292
### What is this PR for? Deleting a folder left its notes searchable after removal. `removeFolder(String, AuthenticationInfo)` in `Notebook` called `noteManager.removeFolder` first, which detached the notes from the tree, so the following `removeNote(noteId)` loaded a `null` note and skipped `fireNoteRemoveEvent`. `SearchService.deleteNoteIndex` was therefore never invoked and the Lucene search index kept stale documents for the deleted notes, so they still showed up in search results after emptying the trash or removing a folder. This PR loads the notes non-destructively via a new `NoteManager.getNoteInfoRecursively`, runs the same per-note cleanup as `removeNote(Note, AuthenticationInfo)` (`setRemoved`, `removeNoteAuth`, `fireNoteRemoveEvent`) for each note, and only then deletes the folder. This also removes the pre-existing `NotebookRepo.remove is called twice` TODO, since the repo remove now happens once. ### What type of PR is it? Bug Fix ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-6345 ### How should this be tested? * Added `NotebookTest#testRemoveFolderFiresNoteRemoveEventForEachNote`: creates two notes under `/folder1`, registers a `NoteEventListener` counting `onNoteRemove`, calls `removeFolder("/folder1", ...)`, and asserts the event fired once per note. Fails before the change (count `0`), passes after. * Manual: create notes, move them to trash, empty the trash, then search for a deleted note. Before the fix it still appears in results; after the fix it is gone. ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
