use of org.apache.zeppelin.notebook.repo.NotebookRepoSettingsInfo in project zeppelin by apache.
the class ZeppelinHubRepo method getSettings.
@Override
public List<NotebookRepoSettingsInfo> getSettings(AuthenticationInfo subject) {
if (!isSubjectValid(subject)) {
return Collections.emptyList();
}
List<NotebookRepoSettingsInfo> settings = Lists.newArrayList();
String user = subject.getUser();
String zeppelinHubUserSession = UserSessionContainer.instance.getSession(user);
String userToken = getUserToken(user);
List<Instance> instances;
List<Map<String, String>> values = Lists.newLinkedList();
try {
instances = getUserInstances(zeppelinHubUserSession);
} catch (IOException e) {
LOG.warn("Couldnt find instances for the session {}, returning empty collection", zeppelinHubUserSession);
// user not logged
//TODO(xxx): handle this case.
instances = Collections.emptyList();
}
NotebookRepoSettingsInfo repoSetting = NotebookRepoSettingsInfo.newInstance();
repoSetting.type = NotebookRepoSettingsInfo.Type.DROPDOWN;
for (Instance instance : instances) {
if (instance.token.equals(userToken)) {
repoSetting.selected = Integer.toString(instance.id);
}
values.add(ImmutableMap.of("name", instance.name, "value", Integer.toString(instance.id)));
}
repoSetting.value = values;
repoSetting.name = "Instance";
settings.add(repoSetting);
return settings;
}
use of org.apache.zeppelin.notebook.repo.NotebookRepoSettingsInfo in project SSM by Intel-bigdata.
the class ZeppelinHubRepo method getSettings.
@Override
public List<NotebookRepoSettingsInfo> getSettings(AuthenticationInfo subject) {
if (!isSubjectValid(subject)) {
return Collections.emptyList();
}
List<NotebookRepoSettingsInfo> settings = Lists.newArrayList();
String user = subject.getUser();
String zeppelinHubUserSession = UserSessionContainer.instance.getSession(user);
String userToken = getUserToken(user);
List<Instance> instances;
List<Map<String, String>> values = Lists.newLinkedList();
try {
instances = tokenManager.getUserInstances(zeppelinHubUserSession);
} catch (IOException e) {
LOG.warn("Couldnt find instances for the session {}, returning empty collection", zeppelinHubUserSession);
// user not logged
// TODO(xxx): handle this case.
instances = Collections.emptyList();
}
NotebookRepoSettingsInfo repoSetting = NotebookRepoSettingsInfo.newInstance();
repoSetting.type = NotebookRepoSettingsInfo.Type.DROPDOWN;
for (Instance instance : instances) {
if (instance.token.equals(userToken)) {
repoSetting.selected = Integer.toString(instance.id);
}
values.add(ImmutableMap.of("name", instance.name, "value", Integer.toString(instance.id)));
}
repoSetting.value = values;
repoSetting.name = "Instance";
settings.add(repoSetting);
return settings;
}
Aggregations