mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
apply filter from authorization in sync
that's to sync only user workbench notes
This commit is contained in:
parent
09e6723482
commit
537cc0ebad
3 changed files with 21 additions and 15 deletions
|
|
@ -482,25 +482,12 @@ public class Notebook implements NoteEventListener {
|
|||
}
|
||||
|
||||
List<NoteInfo> noteInfos = notebookRepo.list(subject);
|
||||
noteInfos = filterByUser(noteInfos, subject);
|
||||
noteInfos = notebookAuthorization.filterByUser(noteInfos, subject);
|
||||
|
||||
for (NoteInfo info : noteInfos) {
|
||||
loadNoteFromRepo(info.getId(), subject);
|
||||
}
|
||||
}
|
||||
|
||||
private List<NoteInfo> filterByUser(List<NoteInfo> notes, AuthenticationInfo subject) {
|
||||
final Set<String> entities = Sets.newHashSet();
|
||||
if (subject != null) {
|
||||
entities.add(subject.getUser());
|
||||
}
|
||||
return FluentIterable.from(notes).filter(new Predicate<NoteInfo>() {
|
||||
@Override
|
||||
public boolean apply(NoteInfo input) {
|
||||
return input != null && notebookAuthorization.isReader(input.getId(), entities);
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
|
||||
private class SnapshotAngularObject {
|
||||
String intpGroupId;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,13 @@
|
|||
|
||||
package org.apache.zeppelin.notebook;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -240,4 +244,16 @@ public class NotebookAuthorization {
|
|||
saveToFile();
|
||||
}
|
||||
|
||||
public List<NoteInfo> filterByUser(List<NoteInfo> notes, AuthenticationInfo subject) {
|
||||
final Set<String> entities = Sets.newHashSet();
|
||||
if (subject != null) {
|
||||
entities.add(subject.getUser());
|
||||
}
|
||||
return FluentIterable.from(notes).filter(new Predicate<NoteInfo>() {
|
||||
@Override
|
||||
public boolean apply(NoteInfo input) {
|
||||
return input != null && isReader(input.getId(), entities);
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
|||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
import org.apache.zeppelin.notebook.NoteInfo;
|
||||
import org.apache.zeppelin.notebook.NotebookAuthorization;
|
||||
import org.apache.zeppelin.notebook.Paragraph;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -178,9 +179,11 @@ public class NotebookRepoSync implements NotebookRepo {
|
|||
*/
|
||||
void sync(int sourceRepoIndex, int destRepoIndex, AuthenticationInfo subject) throws IOException {
|
||||
LOG.info("Sync started");
|
||||
NotebookAuthorization auth = NotebookAuthorization.getInstance();
|
||||
NotebookRepo srcRepo = getRepo(sourceRepoIndex);
|
||||
NotebookRepo dstRepo = getRepo(destRepoIndex);
|
||||
List <NoteInfo> srcNotes = srcRepo.list(subject);
|
||||
List <NoteInfo> allSrcNotes = srcRepo.list(subject);
|
||||
List <NoteInfo> srcNotes = auth.filterByUser(allSrcNotes, subject);
|
||||
List <NoteInfo> dstNotes = dstRepo.list(subject);
|
||||
|
||||
Map<String, List<String>> noteIDs = notesCheckDiff(srcNotes, srcRepo, dstNotes, dstRepo);
|
||||
|
|
|
|||
Loading…
Reference in a new issue