mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
set new note permissions
This commit is contained in:
parent
97324096f6
commit
44297a40fd
1 changed files with 24 additions and 0 deletions
|
|
@ -62,6 +62,7 @@ public class NotebookAuthorization {
|
|||
private static ZeppelinConfiguration conf;
|
||||
private static Gson gson;
|
||||
private static String filePath;
|
||||
private static boolean isPublic;
|
||||
|
||||
private NotebookAuthorization() {}
|
||||
|
||||
|
|
@ -73,6 +74,7 @@ public class NotebookAuthorization {
|
|||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.setPrettyPrinting();
|
||||
gson = builder.create();
|
||||
isPublic = config.isNotebokPublic();
|
||||
try {
|
||||
loadFromFile();
|
||||
} catch (IOException e) {
|
||||
|
|
@ -325,4 +327,26 @@ public class NotebookAuthorization {
|
|||
}
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public void setNewNotePermissions(String noteId, AuthenticationInfo subject) {
|
||||
if (!AuthenticationInfo.isAnonymous(subject)) {
|
||||
if (isPublic) {
|
||||
// add current user to owners - can be public
|
||||
Set<String> owners = getOwners(noteId);
|
||||
owners.add(subject.getUser());
|
||||
setOwners(noteId, owners);
|
||||
} else {
|
||||
// add current user to owners, readers, writers - private note
|
||||
Set<String> entities = getOwners(noteId);
|
||||
entities.add(subject.getUser());
|
||||
setOwners(noteId, entities);
|
||||
entities = getReaders(noteId);
|
||||
entities.add(subject.getUser());
|
||||
setReaders(noteId, entities);
|
||||
entities = getWriters(noteId);
|
||||
entities.add(subject.getUser());
|
||||
setWriters(noteId, entities);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue