mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
set perms for pulling notes - make them private
This commit is contained in:
parent
585a675300
commit
1a54cc0571
1 changed files with 23 additions and 3 deletions
|
|
@ -24,8 +24,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
|
|
@ -200,7 +202,7 @@ public class NotebookRepoSync implements NotebookRepo {
|
|||
for (String id : pushNoteIDs) {
|
||||
LOG.info("ID : " + id);
|
||||
}
|
||||
pushNotes(subject, pushNoteIDs, srcRepo, dstRepo);
|
||||
pushNotes(subject, pushNoteIDs, srcRepo, dstRepo, false);
|
||||
} else {
|
||||
LOG.info("Nothing to push");
|
||||
}
|
||||
|
|
@ -210,7 +212,7 @@ public class NotebookRepoSync implements NotebookRepo {
|
|||
for (String id : pullNoteIDs) {
|
||||
LOG.info("ID : " + id);
|
||||
}
|
||||
pushNotes(subject, pullNoteIDs, dstRepo, srcRepo);
|
||||
pushNotes(subject, pullNoteIDs, dstRepo, srcRepo, true);
|
||||
} else {
|
||||
LOG.info("Nothing to pull");
|
||||
}
|
||||
|
|
@ -233,16 +235,34 @@ public class NotebookRepoSync implements NotebookRepo {
|
|||
}
|
||||
|
||||
private void pushNotes(AuthenticationInfo subject, List<String> ids, NotebookRepo localRepo,
|
||||
NotebookRepo remoteRepo) {
|
||||
NotebookRepo remoteRepo, boolean setPermissions) {
|
||||
for (String id : ids) {
|
||||
try {
|
||||
remoteRepo.save(localRepo.get(id, subject), subject);
|
||||
if (setPermissions) {
|
||||
makePrivate(id, subject);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to push note to storage, moving onto next one", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makePrivate(String noteId, AuthenticationInfo subject) {
|
||||
if (subject != null && !"anonymous".equals(subject.getUser())) {
|
||||
NotebookAuthorization notebookAuthorization = NotebookAuthorization.getInstance();
|
||||
Set<String> users = notebookAuthorization.getOwners(noteId);
|
||||
users.add(subject.getUser());
|
||||
notebookAuthorization.setOwners(noteId, users);
|
||||
users = notebookAuthorization.getReaders(noteId);
|
||||
users.add(subject.getUser());
|
||||
notebookAuthorization.setReaders(noteId, users);
|
||||
users = notebookAuthorization.getWriters(noteId);
|
||||
users.add(subject.getUser());
|
||||
notebookAuthorization.setWriters(noteId, users);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteNotes(AuthenticationInfo subject, List<String> ids, NotebookRepo repo)
|
||||
throws IOException {
|
||||
for (String id : ids) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue