http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java index 8bfaef5..a679502 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java @@ -14,11 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest; +import com.google.common.collect.Sets; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; + +import org.apache.commons.lang3.StringUtils; +import org.quartz.CronExpression; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -31,18 +43,20 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import org.apache.commons.lang3.StringUtils; import org.apache.zeppelin.annotation.ZeppelinApi; -import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.interpreter.InterpreterResult; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.Notebook; import org.apache.zeppelin.notebook.NotebookAuthorization; import org.apache.zeppelin.notebook.Paragraph; import org.apache.zeppelin.rest.exception.BadRequestException; -import org.apache.zeppelin.rest.exception.NotFoundException; import org.apache.zeppelin.rest.exception.ForbiddenException; -import org.apache.zeppelin.rest.message.*; +import org.apache.zeppelin.rest.exception.NotFoundException; +import org.apache.zeppelin.rest.message.CronRequest; +import org.apache.zeppelin.rest.message.NewNoteRequest; +import org.apache.zeppelin.rest.message.NewParagraphRequest; +import org.apache.zeppelin.rest.message.RunParagraphWithParametersRequest; +import org.apache.zeppelin.rest.message.UpdateParagraphRequest; import org.apache.zeppelin.search.SearchService; import org.apache.zeppelin.server.JsonResponse; import org.apache.zeppelin.socket.NotebookServer; @@ -50,13 +64,6 @@ import org.apache.zeppelin.types.InterpreterSettingsList; import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.utils.InterpreterBindingUtils; import org.apache.zeppelin.utils.SecurityUtils; -import org.quartz.CronExpression; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.collect.Sets; -import com.google.common.reflect.TypeToken; -import com.google.gson.Gson; /** * Rest api endpoint for the notebook. @@ -82,13 +89,12 @@ public class NotebookRestApi { } /** - * get note authorization information + * Get note authorization information. */ @GET @Path("{noteId}/permissions") @ZeppelinApi public Response getNotePermissions(@PathParam("noteId") String noteId) throws IOException { - checkIfUserIsAnon(getBlockNotAuthenticatedUserErrorMsg()); checkIfUserCanRead(noteId, "Insufficient privileges you cannot get the list of permissions for this note"); @@ -100,7 +106,7 @@ public class NotebookRestApi { return new JsonResponse<>(Status.OK, "", permissionsMap).build(); } - private String ownerPermissionError(Set<String> current, Set<String> allowed) throws IOException { + private String ownerPermissionError(Set<String> current, Set<String> allowed) { LOG.info("Cannot change permissions. Connection owners {}. Allowed owners {}", current.toString(), allowed.toString()); return "Insufficient privileges to change permissions.\n\n" + @@ -108,18 +114,18 @@ public class NotebookRestApi { "User belongs to: " + current.toString(); } - private String getBlockNotAuthenticatedUserErrorMsg() throws IOException { + private String getBlockNotAuthenticatedUserErrorMsg() { return "Only authenticated user can set the permission."; } - /** + /* * Set of utils method to check if current user can perform action to the note. * Since we only have security on notebook level, from now we keep this logic in this class. * In the future we might want to generalize this for the rest of the api enmdpoints. */ /** - * Check if the current user is not authenticated(anonymous user) or not + * Check if the current user is not authenticated(anonymous user) or not. */ private void checkIfUserIsAnon(String errorMsg) { boolean isAuthenticated = SecurityUtils.isAuthenticated(); @@ -197,13 +203,13 @@ public class NotebookRestApi { } /** - * set note authorization information + * Set note authorization information. */ @PUT @Path("{noteId}/permissions") @ZeppelinApi public Response putNotePermissions(@PathParam("noteId") String noteId, String req) - throws IOException { + throws IOException { String principal = SecurityUtils.getPrincipal(); HashSet<String> roles = SecurityUtils.getRoles(); HashSet<String> userAndRoles = new HashSet<>(); @@ -268,7 +274,7 @@ public class NotebookRestApi { } /** - * bind a setting to note + * Bind a setting to note. * * @throws IOException */ @@ -279,14 +285,13 @@ public class NotebookRestApi { checkIfUserCanWrite(noteId, "Insufficient privileges you cannot bind any interpreters to this note"); - List<String> settingIdList = gson.fromJson(req, new TypeToken<List<String>>() { - }.getType()); + List<String> settingIdList = gson.fromJson(req, new TypeToken<List<String>>() {}.getType()); notebook.bindInterpretersToNote(SecurityUtils.getPrincipal(), noteId, settingIdList); return new JsonResponse<>(Status.OK).build(); } /** - * list bound setting + * list bound setting. */ @GET @Path("interpreter/bind/{noteId}") @@ -324,7 +329,7 @@ public class NotebookRestApi { } /** - * export note REST API + * export note REST API. * * @param noteId ID of Note * @return note JSON with status.OK @@ -340,7 +345,7 @@ public class NotebookRestApi { } /** - * import new note REST API + * import new note REST API. * * @param req - note Json * @return JSON with new note ID @@ -356,7 +361,7 @@ public class NotebookRestApi { } /** - * Create new note REST API + * Create new note REST API. * * @param message - JSON with new note name * @return JSON with new note ID @@ -395,7 +400,7 @@ public class NotebookRestApi { } /** - * Delete note REST API + * Delete note REST API. * * @param noteId ID of Note * @return JSON with status.OK @@ -420,17 +425,19 @@ public class NotebookRestApi { } /** - * Clone note REST API + * Clone note REST API. * * @param noteId ID of Note * @return JSON with status.OK - * @throws IOException, CloneNotSupportedException, IllegalArgumentException + * @throws IOException + * @throws CloneNotSupportedException + * @throws IllegalArgumentException */ @POST @Path("{noteId}") @ZeppelinApi public Response cloneNote(@PathParam("noteId") String noteId, String message) - throws IOException, CloneNotSupportedException, IllegalArgumentException { + throws IOException, CloneNotSupportedException, IllegalArgumentException { LOG.info("clone note by JSON {}", message); checkIfUserCanWrite(noteId, "Insufficient privileges you cannot clone this note"); NewNoteRequest request = NewNoteRequest.fromJson(message); @@ -446,7 +453,7 @@ public class NotebookRestApi { } /** - * Insert paragraph REST API + * Insert paragraph REST API. * * @param message - JSON containing paragraph's information * @return JSON with status.OK @@ -456,7 +463,7 @@ public class NotebookRestApi { @Path("{noteId}/paragraph") @ZeppelinApi public Response insertParagraph(@PathParam("noteId") String noteId, String message) - throws IOException { + throws IOException { String user = SecurityUtils.getPrincipal(); LOG.info("insert paragraph {} {}", noteId, message); @@ -480,7 +487,7 @@ public class NotebookRestApi { } /** - * Get paragraph REST API + * Get paragraph REST API. * * @param noteId ID of Note * @return JSON with information of the paragraph @@ -490,7 +497,7 @@ public class NotebookRestApi { @Path("{noteId}/paragraph/{paragraphId}") @ZeppelinApi public Response getParagraph(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId) throws IOException { + @PathParam("paragraphId") String paragraphId) throws IOException { LOG.info("get paragraph {} {}", noteId, paragraphId); Note note = notebook.getNote(noteId); @@ -503,7 +510,7 @@ public class NotebookRestApi { } /** - * Update paragraph + * Update paragraph. * * @param message json containing the "text" and optionally the "title" of the paragraph, e.g. * {"text" : "updated text", "title" : "Updated title" } @@ -513,8 +520,7 @@ public class NotebookRestApi { @Path("{noteId}/paragraph/{paragraphId}") @ZeppelinApi public Response updateParagraph(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId, - String message) throws IOException { + @PathParam("paragraphId") String paragraphId, String message) throws IOException { String user = SecurityUtils.getPrincipal(); LOG.info("{} will update paragraph {} {}", user, noteId, paragraphId); @@ -526,7 +532,11 @@ public class NotebookRestApi { UpdateParagraphRequest updatedParagraph = gson.fromJson(message, UpdateParagraphRequest.class); p.setText(updatedParagraph.getText()); - if (updatedParagraph.getTitle() != null) { p.setTitle(updatedParagraph.getTitle()); } + + if (updatedParagraph.getTitle() != null) { + p.setTitle(updatedParagraph.getTitle()); + } + AuthenticationInfo subject = new AuthenticationInfo(user); note.persist(subject); notebookServer.broadcastParagraph(note, p); @@ -537,7 +547,7 @@ public class NotebookRestApi { @Path("{noteId}/paragraph/{paragraphId}/config") @ZeppelinApi public Response updateParagraphConfig(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId, String message) throws IOException { + @PathParam("paragraphId") String paragraphId, String message) throws IOException { String user = SecurityUtils.getPrincipal(); LOG.info("{} will update paragraph config {} {}", user, noteId, paragraphId); @@ -555,7 +565,7 @@ public class NotebookRestApi { } /** - * Move paragraph REST API + * Move paragraph REST API. * * @param newIndex - new index to move * @return JSON with status.OK @@ -565,8 +575,8 @@ public class NotebookRestApi { @Path("{noteId}/paragraph/{paragraphId}/move/{newIndex}") @ZeppelinApi public Response moveParagraph(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId, @PathParam("newIndex") String newIndex) - throws IOException { + @PathParam("paragraphId") String paragraphId, @PathParam("newIndex") String newIndex) + throws IOException { LOG.info("move paragraph {} {} {}", noteId, paragraphId, newIndex); Note note = notebook.getNote(noteId); @@ -590,7 +600,7 @@ public class NotebookRestApi { } /** - * Delete paragraph REST API + * Delete paragraph REST API. * * @param noteId ID of Note * @return JSON with status.OK @@ -600,7 +610,7 @@ public class NotebookRestApi { @Path("{noteId}/paragraph/{paragraphId}") @ZeppelinApi public Response deleteParagraph(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId) throws IOException { + @PathParam("paragraphId") String paragraphId) throws IOException { LOG.info("delete paragraph {} {}", noteId, paragraphId); Note note = notebook.getNote(noteId); @@ -620,7 +630,7 @@ public class NotebookRestApi { } /** - * Clear result of all paragraphs REST API + * Clear result of all paragraphs REST API. * * @param noteId ID of Note * @return JSON with status.ok @@ -629,7 +639,7 @@ public class NotebookRestApi { @Path("{noteId}/clear") @ZeppelinApi public Response clearAllParagraphOutput(@PathParam("noteId") String noteId) - throws IOException { + throws IOException { LOG.info("clear all paragraph output of note {}", noteId); checkIfUserCanWrite(noteId, "Insufficient privileges you cannot clear this note"); @@ -641,17 +651,18 @@ public class NotebookRestApi { } /** - * Run note jobs REST API + * Run note jobs REST API. * * @param noteId ID of Note * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @POST @Path("job/{noteId}") @ZeppelinApi public Response runNoteJobs(@PathParam("noteId") String noteId) - throws IOException, IllegalArgumentException { + throws IOException, IllegalArgumentException { LOG.info("run note jobs {} ", noteId); Note note = notebook.getNote(noteId); AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal()); @@ -669,17 +680,18 @@ public class NotebookRestApi { } /** - * Stop(delete) note jobs REST API + * Stop(delete) note jobs REST API. * * @param noteId ID of Note * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @DELETE @Path("job/{noteId}") @ZeppelinApi public Response stopNoteJobs(@PathParam("noteId") String noteId) - throws IOException, IllegalArgumentException { + throws IOException, IllegalArgumentException { LOG.info("stop note jobs {} ", noteId); Note note = notebook.getNote(noteId); checkIfNoteIsNotNull(note); @@ -694,17 +706,18 @@ public class NotebookRestApi { } /** - * Get note job status REST API + * Get note job status REST API. * * @param noteId ID of Note * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @GET @Path("job/{noteId}") @ZeppelinApi public Response getNoteJobStatus(@PathParam("noteId") String noteId) - throws IOException, IllegalArgumentException { + throws IOException, IllegalArgumentException { LOG.info("get note job status."); Note note = notebook.getNote(noteId); checkIfNoteIsNotNull(note); @@ -714,19 +727,20 @@ public class NotebookRestApi { } /** - * Get note paragraph job status REST API + * Get note paragraph job status REST API. * * @param noteId ID of Note * @param paragraphId ID of Paragraph * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @GET @Path("job/{noteId}/{paragraphId}") @ZeppelinApi public Response getNoteParagraphJobStatus(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId) - throws IOException, IllegalArgumentException { + @PathParam("paragraphId") String paragraphId) + throws IOException, IllegalArgumentException { LOG.info("get note paragraph job status."); Note note = notebook.getNote(noteId); checkIfNoteIsNotNull(note); @@ -740,19 +754,20 @@ public class NotebookRestApi { } /** - * Run asynchronously paragraph job REST API + * Run asynchronously paragraph job REST API. * * @param message - JSON with params if user wants to update dynamic form's value * null, empty string, empty json if user doesn't want to update * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @POST @Path("job/{noteId}/{paragraphId}") @ZeppelinApi public Response runParagraph(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId, String message) - throws IOException, IllegalArgumentException { + @PathParam("paragraphId") String paragraphId, String message) + throws IOException, IllegalArgumentException { LOG.info("run paragraph job asynchronously {} {} {}", noteId, paragraphId, message); Note note = notebook.getNote(noteId); @@ -773,8 +788,8 @@ public class NotebookRestApi { return new JsonResponse<>(Status.OK).build(); } -/** - * Run synchronously a paragraph REST API + /** + * Run synchronously a paragraph REST API. * * @param noteId - noteId * @param paragraphId - paragraphId @@ -782,15 +797,15 @@ public class NotebookRestApi { * null, empty string, empty json if user doesn't want to update * * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @POST @Path("run/{noteId}/{paragraphId}") @ZeppelinApi public Response runParagraphSynchronously(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId, - String message) throws - IOException, IllegalArgumentException { + @PathParam("paragraphId") String paragraphId, String message) + throws IOException, IllegalArgumentException { LOG.info("run paragraph synchronously {} {} {}", noteId, paragraphId, message); Note note = notebook.getNote(noteId); @@ -821,18 +836,20 @@ public class NotebookRestApi { } /** - * Stop(delete) paragraph job REST API + * Stop(delete) paragraph job REST API. * * @param noteId ID of Note * @param paragraphId ID of Paragraph * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @DELETE @Path("job/{noteId}/{paragraphId}") @ZeppelinApi public Response stopParagraph(@PathParam("noteId") String noteId, - @PathParam("paragraphId") String paragraphId) throws IOException, IllegalArgumentException { + @PathParam("paragraphId") String paragraphId) + throws IOException, IllegalArgumentException { LOG.info("stop paragraph job {} ", noteId); Note note = notebook.getNote(noteId); checkIfNoteIsNotNull(note); @@ -844,17 +861,18 @@ public class NotebookRestApi { } /** - * Register cron job REST API + * Register cron job REST API. * * @param message - JSON with cron expressions. * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @POST @Path("cron/{noteId}") @ZeppelinApi public Response registerCronJob(@PathParam("noteId") String noteId, String message) - throws IOException, IllegalArgumentException { + throws IOException, IllegalArgumentException { LOG.info("Register cron job note={} request cron msg={}", noteId, message); CronRequest request = CronRequest.fromJson(message); @@ -877,17 +895,18 @@ public class NotebookRestApi { } /** - * Remove cron job REST API + * Remove cron job REST API. * * @param noteId ID of Note * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @DELETE @Path("cron/{noteId}") @ZeppelinApi public Response removeCronJob(@PathParam("noteId") String noteId) - throws IOException, IllegalArgumentException { + throws IOException, IllegalArgumentException { LOG.info("Remove cron job note {}", noteId); Note note = notebook.getNote(noteId); @@ -905,17 +924,18 @@ public class NotebookRestApi { } /** - * Get cron job REST API + * Get cron job REST API. * * @param noteId ID of Note * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @GET @Path("cron/{noteId}") @ZeppelinApi public Response getCronJob(@PathParam("noteId") String noteId) - throws IOException, IllegalArgumentException { + throws IOException, IllegalArgumentException { LOG.info("Get cron job note {}", noteId); Note note = notebook.getNote(noteId); @@ -927,10 +947,11 @@ public class NotebookRestApi { } /** - * Get note jobs for job manager + * Get note jobs for job manager. * * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @GET @Path("jobmanager/") @@ -955,14 +976,14 @@ public class NotebookRestApi { * Return the `Note` change information within the post unix timestamp. * * @return JSON with status.OK - * @throws IOException, IllegalArgumentException + * @throws IOException + * @throws IllegalArgumentException */ @GET @Path("jobmanager/{lastUpdateUnixtime}/") @ZeppelinApi - public Response getUpdatedJobListforNote( - @PathParam("lastUpdateUnixtime") long lastUpdateUnixTime) - throws IOException, IllegalArgumentException { + public Response getUpdatedJobListforNote(@PathParam("lastUpdateUnixtime") long lastUpdateUnixTime) + throws IOException, IllegalArgumentException { LOG.info("Get updated note jobs lastUpdateTime {}", lastUpdateUnixTime); List<Map<String, Object>> noteJobs; @@ -977,7 +998,7 @@ public class NotebookRestApi { } /** - * Search for a Notes with permissions + * Search for a Notes with permissions. */ @GET @Path("search") @@ -991,8 +1012,8 @@ public class NotebookRestApi { userAndRoles.addAll(roles); List<Map<String, String>> notesFound = noteSearchService.query(queryTerm); for (int i = 0; i < notesFound.size(); i++) { - String[] Id = notesFound.get(i).get("id").split("/", 2); - String noteId = Id[0]; + String[] ids = notesFound.get(i).get("id").split("/", 2); + String noteId = ids[0]; if (!notebookAuthorization.isOwner(noteId, userAndRoles) && !notebookAuthorization.isReader(noteId, userAndRoles) && !notebookAuthorization.isWriter(noteId, userAndRoles) && @@ -1021,8 +1042,7 @@ public class NotebookRestApi { } } - private void initParagraph(Paragraph p, NewParagraphRequest request, String user) - throws IOException { + private void initParagraph(Paragraph p, NewParagraphRequest request, String user) { LOG.info("Init Paragraph for user {}", user); checkIfParagraphIsNotNull(p); p.setTitle(request.getTitle()); @@ -1033,8 +1053,7 @@ public class NotebookRestApi { } } - private void configureParagraph(Paragraph p, Map<String, Object> newConfig, String user) - throws IOException { + private void configureParagraph(Paragraph p, Map<String, Object> newConfig, String user) { LOG.info("Configure Paragraph for user {}", user); if (newConfig == null || newConfig.isEmpty()) { LOG.warn("{} is trying to update paragraph {} of note {} with empty config", @@ -1048,5 +1067,4 @@ public class NotebookRestApi { p.setConfig(origConfig); } - }
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java index 742af9e..587a405 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java @@ -14,31 +14,39 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest; - import org.apache.commons.lang3.StringUtils; import org.apache.shiro.realm.Realm; import org.apache.shiro.realm.jdbc.JdbcRealm; import org.apache.shiro.realm.ldap.JndiLdapRealm; import org.apache.shiro.realm.text.IniRealm; -import org.apache.zeppelin.annotation.ZeppelinApi; -import org.apache.zeppelin.conf.ZeppelinConfiguration; -import org.apache.zeppelin.realm.ActiveDirectoryGroupRealm; -import org.apache.zeppelin.realm.LdapRealm; -import org.apache.zeppelin.server.JsonResponse; -import org.apache.zeppelin.ticket.TicketContainer; -import org.apache.zeppelin.utils.SecurityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import java.util.*; + +import org.apache.zeppelin.annotation.ZeppelinApi; +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.realm.ActiveDirectoryGroupRealm; +import org.apache.zeppelin.realm.LdapRealm; +import org.apache.zeppelin.server.JsonResponse; +import org.apache.zeppelin.ticket.TicketContainer; +import org.apache.zeppelin.utils.SecurityUtils; /** * Zeppelin security rest api endpoint. @@ -73,10 +81,11 @@ public class SecurityRestApi { JsonResponse response; // ticket set to anonymous for anonymous user. Simplify testing. String ticket; - if ("anonymous".equals(principal)) + if ("anonymous".equals(principal)) { ticket = "anonymous"; - else + } else { ticket = TicketContainer.instance.getTicket(principal); + } Map<String, String> data = new HashMap<>(); data.put("principal", principal); @@ -89,7 +98,8 @@ public class SecurityRestApi { } /** - * Get userlist + * Get userlist. + * * Returns list of all user from available realms * * @return 200 response @@ -97,7 +107,6 @@ public class SecurityRestApi { @GET @Path("userlist/{searchText}") public Response getUserList(@PathParam("searchText") final String searchText) { - List<String> usersList = new ArrayList<>(); List<String> rolesList = new ArrayList<>(); try { @@ -165,8 +174,6 @@ public class SecurityRestApi { returnListMap.put("users", autoSuggestUserList); returnListMap.put("roles", autoSuggestRoleList); - return new JsonResponse<>(Response.Status.OK, "", returnListMap).build(); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java index 03e03de..2c43c2c 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java @@ -14,14 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.apache.zeppelin.annotation.ZeppelinApi; -import org.apache.zeppelin.server.JsonResponse; -import org.apache.zeppelin.util.Util; import java.util.HashMap; import java.util.Map; @@ -34,6 +30,10 @@ import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; +import org.apache.zeppelin.annotation.ZeppelinApi; +import org.apache.zeppelin.server.JsonResponse; +import org.apache.zeppelin.util.Util; + /** * Zeppelin root rest api endpoint. * @@ -41,7 +41,6 @@ import javax.ws.rs.core.Response; */ @Path("/") public class ZeppelinRestApi { - public ZeppelinRestApi() { } @@ -68,7 +67,8 @@ public class ZeppelinRestApi { } /** - * Set the log level for root logger + * Set the log level for root logger. + * * @param request * @param logLevel new log level for Rootlogger * @return http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/BadRequestException.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/BadRequestException.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/BadRequestException.java index 944cedc..9af2fdd 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/BadRequestException.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/BadRequestException.java @@ -14,21 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.exception; -import org.apache.zeppelin.utils.ExceptionUtils; +import static javax.ws.rs.core.Response.Status.BAD_REQUEST; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; -import static javax.ws.rs.core.Response.Status.BAD_REQUEST; +import org.apache.zeppelin.utils.ExceptionUtils; /** * BadRequestException handler for WebApplicationException. */ public class BadRequestException extends WebApplicationException { - public BadRequestException() { super(ExceptionUtils.jsonResponse(BAD_REQUEST)); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/ForbiddenException.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/ForbiddenException.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/ForbiddenException.java index 04deb42..0c07def 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/ForbiddenException.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/ForbiddenException.java @@ -17,7 +17,6 @@ package org.apache.zeppelin.rest.exception; import static javax.ws.rs.core.Response.Status.FORBIDDEN; -import static javax.ws.rs.core.Response.Status.UNAUTHORIZED; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; @@ -26,7 +25,6 @@ import org.apache.zeppelin.utils.ExceptionUtils; /** * UnauthorizedException handler for WebApplicationException. - * */ public class ForbiddenException extends WebApplicationException { private static final long serialVersionUID = 4394749068760407567L; @@ -47,5 +45,4 @@ public class ForbiddenException extends WebApplicationException { public ForbiddenException(String message) { super(forbiddenJson(message)); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/CronRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/CronRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/CronRequest.java index 0cd1b63..404a3c3 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/CronRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/CronRequest.java @@ -14,18 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.message; -import java.util.Map; - import com.google.gson.Gson; + import org.apache.zeppelin.common.JsonSerializable; -import org.apache.zeppelin.interpreter.InterpreterOption; /** - * CronRequest rest api request message - * + * CronRequest rest api request message. */ public class CronRequest implements JsonSerializable { private static final Gson gson = new Gson(); @@ -33,7 +29,6 @@ public class CronRequest implements JsonSerializable { String cron; public CronRequest (){ - } public String getCronString() { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java index 848a2bf..3d577ef 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java @@ -14,20 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.message; +import com.google.gson.Gson; + import java.util.List; import java.util.Map; -import com.google.gson.Gson; import org.apache.zeppelin.common.JsonSerializable; import org.apache.zeppelin.dep.Dependency; import org.apache.zeppelin.interpreter.InterpreterOption; import org.apache.zeppelin.interpreter.InterpreterProperty; /** - * NewInterpreterSetting rest api request message + * NewInterpreterSetting REST API request message. */ public class NewInterpreterSettingRequest implements JsonSerializable { private static final Gson gson = new Gson(); @@ -39,7 +39,6 @@ public class NewInterpreterSettingRequest implements JsonSerializable { private InterpreterOption option; public NewInterpreterSettingRequest() { - } public String getName() { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java index 42477e4..9cf1df1 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewNoteRequest.java @@ -14,19 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.message; +import com.google.gson.Gson; + import java.util.List; -import java.util.Map; -import com.google.gson.Gson; import org.apache.zeppelin.common.JsonSerializable; -import org.apache.zeppelin.interpreter.InterpreterOption; /** - * NewNoteRequest rest api request message - * + * NewNoteRequest rest api request message. */ public class NewNoteRequest implements JsonSerializable { private static final Gson gson = new Gson(); @@ -35,7 +32,6 @@ public class NewNoteRequest implements JsonSerializable { List<NewParagraphRequest> paragraphs; public NewNoteRequest (){ - } public String getName() { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java index b7182e9..e0cb786 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.message; import com.google.gson.Gson; -import org.apache.zeppelin.common.JsonSerializable; import java.util.HashMap; +import org.apache.zeppelin.common.JsonSerializable; + /** * NewParagraphRequest rest api request message * @@ -39,7 +39,6 @@ public class NewParagraphRequest implements JsonSerializable { HashMap< String, Object > config; public NewParagraphRequest() { - } public String getTitle() { @@ -54,7 +53,9 @@ public class NewParagraphRequest implements JsonSerializable { return index; } - public HashMap< String, Object > getConfig() { return config; } + public HashMap< String, Object > getConfig() { + return config; + } public String toJson() { return gson.toJson(this); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NotebookRepoSettingsRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NotebookRepoSettingsRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NotebookRepoSettingsRequest.java index 84b3794..31f3be8 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NotebookRepoSettingsRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NotebookRepoSettingsRequest.java @@ -16,11 +16,13 @@ */ package org.apache.zeppelin.rest.message; +import com.google.gson.Gson; + +import org.apache.commons.lang.StringUtils; + import java.util.Collections; import java.util.Map; -import com.google.gson.Gson; -import org.apache.commons.lang.StringUtils; import org.apache.zeppelin.common.JsonSerializable; /** http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RestartInterpreterRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RestartInterpreterRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RestartInterpreterRequest.java index 4a8fa44..8a6d0d0 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RestartInterpreterRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RestartInterpreterRequest.java @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.message; import com.google.gson.Gson; + import org.apache.zeppelin.common.JsonSerializable; /** - * RestartInterpreter rest api request message + * RestartInterpreter rest api request message. */ public class RestartInterpreterRequest implements JsonSerializable { private static final Gson gson = new Gson(); @@ -29,7 +29,6 @@ public class RestartInterpreterRequest implements JsonSerializable { String noteId; public RestartInterpreterRequest() { - } public String getNoteId() { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RunParagraphWithParametersRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RunParagraphWithParametersRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RunParagraphWithParametersRequest.java index ff6d314..be703da 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RunParagraphWithParametersRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/RunParagraphWithParametersRequest.java @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.message; import com.google.gson.Gson; -import org.apache.zeppelin.common.JsonSerializable; import java.util.Map; +import org.apache.zeppelin.common.JsonSerializable; + /** - * RunParagraphWithParametersRequest rest api request message + * RunParagraphWithParametersRequest rest api request message. */ public class RunParagraphWithParametersRequest implements JsonSerializable { private static final Gson gson = new Gson(); @@ -31,7 +31,6 @@ public class RunParagraphWithParametersRequest implements JsonSerializable { Map<String, Object> params; public RunParagraphWithParametersRequest() { - } public Map<String, Object> getParams() { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java index a5d113f..cc446e2 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java @@ -14,20 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.message; +import com.google.gson.Gson; + import java.util.List; import java.util.Map; -import com.google.gson.Gson; import org.apache.zeppelin.common.JsonSerializable; import org.apache.zeppelin.dep.Dependency; import org.apache.zeppelin.interpreter.InterpreterOption; import org.apache.zeppelin.interpreter.InterpreterProperty; /** - * UpdateInterpreterSetting rest api request message + * UpdateInterpreterSetting rest api request message. */ public class UpdateInterpreterSettingRequest implements JsonSerializable { private static final Gson gson = new Gson(); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateParagraphRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateParagraphRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateParagraphRequest.java index 3b4a6f6..9b0db40 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateParagraphRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateParagraphRequest.java @@ -14,18 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.rest.message; /** - * UpdateParagraphRequest + * UpdateParagraphRequest. */ public class UpdateParagraphRequest { String title; String text; public UpdateParagraphRequest() { - } public String getTitle() { @@ -35,6 +33,4 @@ public class UpdateParagraphRequest { public String getText() { return text; } - - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/server/CorsFilter.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/CorsFilter.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/CorsFilter.java index b5cca5b..cfc2efe 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/CorsFilter.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/CorsFilter.java @@ -14,11 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.server; -import org.apache.zeppelin.conf.ZeppelinConfiguration; -import org.apache.zeppelin.utils.SecurityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,12 +34,13 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.utils.SecurityUtils; + /** - * Cors filter - * + * Cors filter. */ public class CorsFilter implements Filter { - private static final Logger LOGGER = LoggerFactory.getLogger(CorsFilter.class); @Override http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonExclusionStrategy.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonExclusionStrategy.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonExclusionStrategy.java index 1eec8f3..3e7a635 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonExclusionStrategy.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonExclusionStrategy.java @@ -14,18 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.server; import com.google.gson.ExclusionStrategy; import com.google.gson.FieldAttributes; -import org.apache.zeppelin.interpreter.InterpreterOption; -/** - * Created by eranw on 8/30/15. - */ public class JsonExclusionStrategy implements ExclusionStrategy { - public boolean shouldSkipClass(Class<?> arg0) { return false; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java index 838e492..fcb4ea8 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/JsonResponse.java @@ -14,17 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.server; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + import java.util.ArrayList; import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response.ResponseBuilder; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - /** * Json response builder. * @@ -41,7 +40,6 @@ public class JsonResponse<T> { this.status = status; this.message = null; this.body = null; - } public JsonResponse(javax.ws.rs.core.Response.Status status, String message) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/1add74b4/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java index 9f3f607..0f4eedf 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java @@ -14,9 +14,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.zeppelin.server; +import org.apache.commons.lang.StringUtils; +import org.apache.shiro.web.env.EnvironmentLoaderListener; +import org.apache.shiro.web.servlet.ShiroFilter; +import org.eclipse.jetty.http.HttpVersion; +import org.eclipse.jetty.server.HttpConfiguration; +import org.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.server.SecureRequestCustomizer; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.server.handler.ContextHandlerCollection; +import org.eclipse.jetty.server.session.SessionHandler; +import org.eclipse.jetty.servlet.DefaultServlet; +import org.eclipse.jetty.servlet.FilterHolder; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.webapp.WebAppContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; import java.util.EnumSet; @@ -26,9 +46,6 @@ import java.util.Set; import javax.servlet.DispatcherType; import javax.ws.rs.core.Application; -import org.apache.commons.lang.StringUtils; -import org.apache.shiro.web.env.EnvironmentLoaderListener; -import org.apache.shiro.web.servlet.ShiroFilter; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.apache.zeppelin.helium.Helium; @@ -54,21 +71,8 @@ import org.apache.zeppelin.search.LuceneSearch; import org.apache.zeppelin.search.SearchService; import org.apache.zeppelin.socket.NotebookServer; import org.apache.zeppelin.storage.ConfigStorage; -import org.apache.zeppelin.storage.FileSystemConfigStorage; import org.apache.zeppelin.user.Credentials; import org.apache.zeppelin.utils.SecurityUtils; -import org.eclipse.jetty.http.HttpVersion; -import org.eclipse.jetty.server.*; -import org.eclipse.jetty.server.handler.ContextHandlerCollection; -import org.eclipse.jetty.server.session.SessionHandler; -import org.eclipse.jetty.servlet.DefaultServlet; -import org.eclipse.jetty.servlet.FilterHolder; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.webapp.WebAppContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Main class of Zeppelin. @@ -93,8 +97,6 @@ public class ZeppelinServer extends Application { public ZeppelinServer() throws Exception { ZeppelinConfiguration conf = ZeppelinConfiguration.create(); - - InterpreterOutput.limit = conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_OUTPUT_LIMIT); HeliumApplicationFactory heliumApplicationFactory = new HeliumApplicationFactory(); @@ -165,7 +167,6 @@ public class ZeppelinServer extends Application { } public static void main(String[] args) throws InterruptedException { - final ZeppelinConfiguration conf = ZeppelinConfiguration.create(); conf.setProperty("args", args); @@ -215,7 +216,6 @@ public class ZeppelinServer extends Application { } }); - // when zeppelin is started inside of ide (especially for eclipse) // for graceful shutdown, input any key in console window if (System.getenv("ZEPPELIN_IDENT_STRING") == null) { @@ -234,7 +234,6 @@ public class ZeppelinServer extends Application { } private static Server setupJettyServer(ZeppelinConfiguration conf) { - final Server server = new Server(); ServerConnector connector; @@ -280,15 +279,14 @@ public class ZeppelinServer extends Application { } private static void configureRequestHeaderSize(ZeppelinConfiguration conf, - ServerConnector connector) { + ServerConnector connector) { HttpConnectionFactory cf = (HttpConnectionFactory) connector.getConnectionFactory(HttpVersion.HTTP_1_1.toString()); int requestHeaderSize = conf.getJettyRequestHeaderSize(); cf.getHttpConfiguration().setRequestHeaderSize(requestHeaderSize); } - private static void setupNotebookServer(WebAppContext webapp, - ZeppelinConfiguration conf) { + private static void setupNotebookServer(WebAppContext webapp, ZeppelinConfiguration conf) { notebookWsServer = new NotebookServer(); String maxTextMessageSize = conf.getWebsocketMaxTextMessageSize(); final ServletHolder servletHolder = new ServletHolder(notebookWsServer); @@ -321,9 +319,7 @@ public class ZeppelinServer extends Application { return sslContextFactory; } - private static void setupRestApiContextHandler(WebAppContext webapp, - ZeppelinConfiguration conf) { - + private static void setupRestApiContextHandler(WebAppContext webapp, ZeppelinConfiguration conf) { final ServletHolder servletHolder = new ServletHolder( new org.glassfish.jersey.servlet.ServletContainer()); @@ -345,8 +341,7 @@ public class ZeppelinServer extends Application { } private static WebAppContext setupWebAppContext(ContextHandlerCollection contexts, - ZeppelinConfiguration conf) { - + ZeppelinConfiguration conf) { WebAppContext webApp = new WebAppContext(); webApp.setContextPath(conf.getServerContextPath()); File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR)); @@ -374,7 +369,6 @@ public class ZeppelinServer extends Application { Boolean.toString(conf.getBoolean(ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED))); return webApp; - } @Override @@ -387,12 +381,12 @@ public class ZeppelinServer extends Application { public Set<Object> getSingletons() { Set<Object> singletons = new HashSet<>(); - /** Rest-api root endpoint */ + /* Rest-api root endpoint */ ZeppelinRestApi root = new ZeppelinRestApi(); singletons.add(root); - NotebookRestApi notebookApi - = new NotebookRestApi(notebook, notebookWsServer, noteSearchService); + NotebookRestApi notebookApi = new NotebookRestApi(notebook, notebookWsServer, + noteSearchService); singletons.add(notebookApi); NotebookRepoRestApi notebookRepoApi = new NotebookRepoRestApi(notebookRepo, notebookWsServer); @@ -421,7 +415,8 @@ public class ZeppelinServer extends Application { } /** - * Check if it is source build or binary package + * Check if it is source build or binary package. + * * @return */ private static boolean isBinaryPackage(ZeppelinConfiguration conf) {