mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Fix indentation
This commit is contained in:
parent
0b4b74a051
commit
dc7fc50a59
1 changed files with 65 additions and 66 deletions
|
|
@ -1,18 +1,16 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package org.apache.zeppelin.rest;
|
||||
|
|
@ -51,65 +49,66 @@ import com.google.gson.JsonSyntaxException;
|
|||
@Produces("application/json")
|
||||
public class NotebookRepoRestApi {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NotebookRepoRestApi.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NotebookRepoRestApi.class);
|
||||
|
||||
private Gson gson = new Gson();
|
||||
private NotebookRepoSync noteRepos;
|
||||
private NotebookServer notebookWsServer;
|
||||
private Gson gson = new Gson();
|
||||
private NotebookRepoSync noteRepos;
|
||||
private NotebookServer notebookWsServer;
|
||||
|
||||
public NotebookRepoRestApi() {}
|
||||
public NotebookRepoRestApi() {}
|
||||
|
||||
public NotebookRepoRestApi(NotebookRepoSync noteRepos, NotebookServer notebookWsServer) {
|
||||
this.noteRepos = noteRepos;
|
||||
this.notebookWsServer = notebookWsServer;
|
||||
public NotebookRepoRestApi(NotebookRepoSync noteRepos, NotebookServer notebookWsServer) {
|
||||
this.noteRepos = noteRepos;
|
||||
this.notebookWsServer = notebookWsServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* List all notebook repository
|
||||
*/
|
||||
@GET
|
||||
@ZeppelinApi
|
||||
public Response listRepoSettings() {
|
||||
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
|
||||
LOG.info("Getting list of NoteRepo with Settings for user {}", subject.getUser());
|
||||
List<NotebookRepoWithSettings> settings = noteRepos.getNotebookRepos(subject);
|
||||
return new JsonResponse<>(Status.OK, "", settings).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a specific note repo.
|
||||
*
|
||||
* @param message
|
||||
* @param settingId
|
||||
* @return
|
||||
*/
|
||||
@PUT
|
||||
@ZeppelinApi
|
||||
public Response updateRepoSetting(String payload) {
|
||||
if (StringUtils.isBlank(payload)) {
|
||||
return new JsonResponse<>(Status.NOT_FOUND, "", Collections.emptyMap()).build();
|
||||
}
|
||||
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
|
||||
NotebookRepoSettingsRequest newSettings = NotebookRepoSettingsRequest.EMPTY;
|
||||
try {
|
||||
newSettings = gson.fromJson(payload, NotebookRepoSettingsRequest.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
LOG.error("Cannot update notebook repo settings", e);
|
||||
return new JsonResponse<>(Status.NOT_ACCEPTABLE, "",
|
||||
ImmutableMap.of("error", "Invalid payload structure")).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* List all notebook repository
|
||||
*/
|
||||
@GET
|
||||
@ZeppelinApi
|
||||
public Response listRepoSettings() {
|
||||
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
|
||||
LOG.info("Getting list of NoteRepo with Settings for user {}", subject.getUser());
|
||||
List<NotebookRepoWithSettings> settings = noteRepos.getNotebookRepos(subject));
|
||||
return new JsonResponse<>(Status.OK, "", settings).build();
|
||||
if (NotebookRepoSettingsRequest.isEmpty(newSettings)) {
|
||||
LOG.error("Invalid property");
|
||||
return new JsonResponse<>(Status.NOT_ACCEPTABLE, "",
|
||||
ImmutableMap.of("error", "Invalid payload")).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a specific note repo.
|
||||
*
|
||||
* @param message
|
||||
* @param settingId
|
||||
* @return
|
||||
*/
|
||||
@PUT
|
||||
@ZeppelinApi
|
||||
public Response updateRepoSetting(String payload) {
|
||||
if (StringUtils.isBlank(payload)) {
|
||||
return new JsonResponse<>(Status.NOT_FOUND, "", Collections.emptyMap()).build();
|
||||
}
|
||||
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
|
||||
NotebookRepoSettingsRequest newSettings = NotebookRepoSettingsRequest.EMPTY;
|
||||
try {
|
||||
newSettings = gson.fromJson(payload, NotebookRepoSettingsRequest.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
LOG.error("Cannot update notebook repo settings", e);
|
||||
return new JsonResponse<>(Status.NOT_ACCEPTABLE, "",
|
||||
ImmutableMap.of("error", "Invalid payload structure")).build();
|
||||
}
|
||||
|
||||
if (NotebookRepoSettingsRequest.isEmpty(newSettings)) {
|
||||
LOG.error("Invalid property");
|
||||
return new JsonResponse<>(Status.NOT_ACCEPTABLE, "",
|
||||
ImmutableMap.of("error", "Invalid payload")).build();
|
||||
}
|
||||
LOG.info("User {} is going to change repo setting", subject.getUser());
|
||||
NotebookRepoWithSettings updatedSettings =
|
||||
noteRepos.updateNotebookRepo(newSettings.name, newSettings.settings, subject);
|
||||
if (!updatedSettings.isEmpty()) {
|
||||
notebookWsServer.broadcastReloadedNoteList(subject);
|
||||
}
|
||||
return new JsonResponse<>(Status.OK, "", updatedSettings).build();
|
||||
LOG.info("User {} is going to change repo setting", subject.getUser());
|
||||
NotebookRepoWithSettings updatedSettings =
|
||||
noteRepos.updateNotebookRepo(newSettings.name, newSettings.settings, subject);
|
||||
if (!updatedSettings.isEmpty()) {
|
||||
//TODO(anthony): need to uncomment bellow once #1537 is merged.
|
||||
// notebookWsServer.broadcastReloadedNoteList(subject);
|
||||
}
|
||||
return new JsonResponse<>(Status.OK, "", updatedSettings).build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue