当前位置: 首页>>代码示例>>Java>>正文


Java ZeppelinApi类代码示例

本文整理汇总了Java中org.apache.zeppelin.annotation.ZeppelinApi的典型用法代码示例。如果您正苦于以下问题:Java ZeppelinApi类的具体用法?Java ZeppelinApi怎么用?Java ZeppelinApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ZeppelinApi类属于org.apache.zeppelin.annotation包,在下文中一共展示了ZeppelinApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSetting

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Get a setting
 */
@GET
@Path("setting/{settingId}")
@ZeppelinApi
public Response getSetting(@PathParam("settingId") String settingId) {
  try {
    InterpreterSetting setting = interpreterSettingManager.get(settingId);
    if (setting == null) {
      return new JsonResponse<>(Status.NOT_FOUND).build();
    } else {
      return new JsonResponse<>(Status.OK, "", setting).build();
    }
  } catch (NullPointerException e) {
    logger.error("Exception in InterpreterRestApi while creating ", e);
    return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, e.getMessage(),
        ExceptionUtils.getStackTrace(e)).build();
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:21,代码来源:InterpreterRestApi.java

示例2: getAll

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
@GET
@Path("all")
@ZeppelinApi
public Response getAll() {
  ZeppelinConfiguration conf = notebook.getConf();

  Map<String, String> configurations = conf.dumpConfigurations(conf,
      new ZeppelinConfiguration.ConfigurationKeyPredicate() {
      @Override
      public boolean apply(String key) {
        return !key.contains("password") &&
            !key.equals(ZeppelinConfiguration
                .ConfVars
                .ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING
                .getVarName());
      }
    }
  );

  return new JsonResponse(Status.OK, "", configurations).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:22,代码来源:ConfigurationsRestApi.java

示例3: deleteParagraph

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Delete paragraph REST API
 *
 * @param noteId ID of Note
 * @return JSON with status.OK
 * @throws IOException
 */
@DELETE
@Path("{noteId}/paragraph/{paragraphId}")
@ZeppelinApi
public Response deleteParagraph(@PathParam("noteId") String noteId,
    @PathParam("paragraphId") String paragraphId) throws IOException {
  LOG.info("delete paragraph {} {}", noteId, paragraphId);

  Note note = notebook.getNote(noteId);
  checkIfNoteIsNotNull(note);
  checkIfUserCanRead(noteId,
      "Insufficient privileges you cannot remove paragraph from this note");

  Paragraph p = note.getParagraph(paragraphId);
  checkIfParagraphIsNotNull(p);

  AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
  note.removeParagraph(SecurityUtils.getPrincipal(), paragraphId);
  note.persist(subject);
  notebookServer.broadcastNote(note);

  return new JsonResponse(Status.OK, "").build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:30,代码来源:NotebookRestApi.java

示例4: run

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Run paragraph by id
 * @param noteId
 * @param context
 */
@ZeppelinApi
public void run(String noteId, String paragraphId, InterpreterContext context,
                boolean checkCurrentParagraph) {
  if (paragraphId.equals(context.getParagraphId()) && checkCurrentParagraph) {
    throw new RuntimeException("Can not run current Paragraph");
  }

  List<InterpreterContextRunner> runners =
      getInterpreterContextRunner(noteId, paragraphId, context);

  if (runners.size() <= 0) {
    throw new RuntimeException("Paragraph " + paragraphId + " not found " + runners.size());
  }

  for (InterpreterContextRunner r : runners) {
    r.run();
  }

}
 
开发者ID:apache,项目名称:zeppelin,代码行数:25,代码来源:BaseZeppelinContext.java

示例5: cloneNote

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Clone note REST API
 *
 * @param noteId ID of Note
 * @return JSON with status.OK
 * @throws IOException, CloneNotSupportedException, IllegalArgumentException
 */
@POST
@Path("{noteId}")
@ZeppelinApi
public Response cloneNote(@PathParam("noteId") String noteId, String message)
    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);
  String newNoteName = null;
  if (request != null) {
    newNoteName = request.getName();
  }
  AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
  Note newNote = notebook.cloneNote(noteId, newNoteName, subject);
  notebookServer.broadcastNote(newNote);
  notebookServer.broadcastNoteList(subject, SecurityUtils.getRoles());
  return new JsonResponse<>(Status.OK, "", newNote.getId()).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:26,代码来源:NotebookRestApi.java

示例6: updateParagraphConfig

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
@PUT
@Path("{noteId}/paragraph/{paragraphId}/config")
@ZeppelinApi
public Response updateParagraphConfig(@PathParam("noteId") String noteId,
    @PathParam("paragraphId") String paragraphId, String message) throws IOException {
  String user = SecurityUtils.getPrincipal();
  LOG.info("{} will update paragraph config {} {}", user, noteId, paragraphId);

  Note note = notebook.getNote(noteId);
  checkIfNoteIsNotNull(note);
  checkIfUserCanWrite(noteId, "Insufficient privileges you cannot update this paragraph config");
  Paragraph p = note.getParagraph(paragraphId);
  checkIfParagraphIsNotNull(p);

  Map<String, Object> newConfig = gson.fromJson(message, HashMap.class);
  configureParagraph(p, newConfig, user);
  AuthenticationInfo subject = new AuthenticationInfo(user);
  note.persist(subject);
  return new JsonResponse<>(Status.OK, "", p).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:21,代码来源:NotebookRestApi.java

示例7: addRepository

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Add new repository
 *
 * @param message Repository
 */
@POST
@Path("repository")
@ZeppelinApi
public Response addRepository(String message) {
  try {
    Repository request = Repository.fromJson(message);
    interpreterSettingManager.addRepository(request.getId(), request.getUrl(),
        request.isSnapshot(), request.getAuthentication(), request.getProxy());
    logger.info("New repository {} added", request.getId());
  } catch (Exception e) {
    logger.error("Exception in InterpreterRestApi while adding repository ", e);
    return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, e.getMessage(),
        ExceptionUtils.getStackTrace(e)).build();
  }
  return new JsonResponse(Status.OK).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:22,代码来源:InterpreterRestApi.java

示例8: stopNoteJobs

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Stop(delete) note jobs REST API
 *
 * @param noteId ID of Note
 * @return JSON with status.OK
 * @throws IOException, IllegalArgumentException
 */
@DELETE
@Path("job/{noteId}")
@ZeppelinApi
public Response stopNoteJobs(@PathParam("noteId") String noteId)
    throws IOException, IllegalArgumentException {
  LOG.info("stop note jobs {} ", noteId);
  Note note = notebook.getNote(noteId);
  checkIfNoteIsNotNull(note);
  checkIfUserCanRun(noteId, "Insufficient privileges you cannot stop this job for this note");

  for (Paragraph p : note.getParagraphs()) {
    if (!p.isTerminated()) {
      p.abort();
    }
  }
  return new JsonResponse<>(Status.OK).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:25,代码来源:NotebookRestApi.java

示例9: search

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Search for a Notes with permissions
 */
@GET
@Path("search")
@ZeppelinApi
public Response search(@QueryParam("q") String queryTerm) {
  LOG.info("Searching notes for: {}", queryTerm);
  String principal = SecurityUtils.getPrincipal();
  HashSet<String> roles = SecurityUtils.getRoles();
  HashSet<String> userAndRoles = new HashSet<>();
  userAndRoles.add(principal);
  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];
    if (!notebookAuthorization.isOwner(noteId, userAndRoles) &&
        !notebookAuthorization.isReader(noteId, userAndRoles) &&
        !notebookAuthorization.isWriter(noteId, userAndRoles) &&
            !notebookAuthorization.isRunner(noteId, userAndRoles)) {
      notesFound.remove(i);
      i--;
    }
  }
  LOG.info("{} notes found", notesFound.size());
  return new JsonResponse<>(Status.OK, notesFound).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:29,代码来源:NotebookRestApi.java

示例10: getProperties

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
@ZeppelinApi
public Properties getProperties() {
  Properties p = new Properties();
  p.putAll(properties);

  RegisteredInterpreter registeredInterpreter = Interpreter.findRegisteredInterpreterByClassName(
      getClassName());
  if (null != registeredInterpreter) {
    Map<String, DefaultInterpreterProperty> defaultProperties =
        registeredInterpreter.getProperties();
    for (String k : defaultProperties.keySet()) {
      if (!p.containsKey(k)) {
        Object value = defaultProperties.get(k).getValue();
        if (value != null) {
          p.put(k, defaultProperties.get(k).getValue().toString());
        }
      }
    }
  }

  replaceContextParameters(p);

  return p;
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:25,代码来源:Interpreter.java

示例11: getByPrefix

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
@GET
@Path("prefix/{prefix}")
@ZeppelinApi
public Response getByPrefix(@PathParam("prefix") final String prefix) {
  ZeppelinConfiguration conf = notebook.getConf();

  Map<String, String> configurations = conf.dumpConfigurations(conf,
      new ZeppelinConfiguration.ConfigurationKeyPredicate() {
      @Override
      public boolean apply(String key) {
        return !key.contains("password") &&
            !key.equals(ZeppelinConfiguration
                .ConfVars
                .ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING
                .getVarName()) &&
            key.startsWith(prefix);
      }
    }
  );

  return new JsonResponse(Status.OK, "", configurations).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:23,代码来源:ConfigurationsRestApi.java

示例12: getNoteParagraphJobStatus

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * 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
 */
@GET
@Path("job/{noteId}/{paragraphId}")
@ZeppelinApi
public Response getNoteParagraphJobStatus(@PathParam("noteId") String noteId, 
    @PathParam("paragraphId") String paragraphId)
    throws IOException, IllegalArgumentException {
  LOG.info("get note paragraph job status.");
  Note note = notebook.getNote(noteId);
  checkIfNoteIsNotNull(note);
  checkIfUserCanRead(noteId, "Insufficient privileges you cannot get job status");

  Paragraph paragraph = note.getParagraph(paragraphId);
  checkIfParagraphIsNotNull(paragraph);

  return new JsonResponse<>(Status.OK, null, note.generateSingleParagraphInfo(paragraphId)).
    build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:26,代码来源:NotebookRestApi.java

示例13: updateParagraph

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Update paragraph
 *
 * @param message json containing the "text" and optionally the "title" of the paragraph, e.g.
 *                {"text" : "updated text", "title" : "Updated title" }
 *
 */
@PUT
@Path("{noteId}/paragraph/{paragraphId}")
@ZeppelinApi
public Response updateParagraph(@PathParam("noteId") String noteId,
                                @PathParam("paragraphId") String paragraphId,
                                String message) throws IOException {
  String user = SecurityUtils.getPrincipal();
  LOG.info("{} will update paragraph {} {}", user, noteId, paragraphId);

  Note note = notebook.getNote(noteId);
  checkIfNoteIsNotNull(note);
  checkIfUserCanWrite(noteId, "Insufficient privileges you cannot update this paragraph");
  Paragraph p = note.getParagraph(paragraphId);
  checkIfParagraphIsNotNull(p);

  UpdateParagraphRequest updatedParagraph = gson.fromJson(message, UpdateParagraphRequest.class);
  p.setText(updatedParagraph.getText());
  if (updatedParagraph.getTitle() != null) { p.setTitle(updatedParagraph.getTitle()); }
  AuthenticationInfo subject = new AuthenticationInfo(user);
  note.persist(subject);
  notebookServer.broadcastParagraph(note, p);
  return new JsonResponse<>(Status.OK, "").build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:31,代码来源:NotebookRestApi.java

示例14: deleteNote

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Delete note REST API
 *
 * @param noteId ID of Note
 * @return JSON with status.OK
 * @throws IOException
 */
@DELETE
@Path("{noteId}")
@ZeppelinApi
public Response deleteNote(@PathParam("noteId") String noteId) throws IOException {
  LOG.info("Delete note {} ", noteId);
  checkIfUserIsOwner(noteId, "Insufficient privileges you cannot delete this note");
  AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
  if (!(noteId.isEmpty())) {
    Note note = notebook.getNote(noteId);
    if (note != null) {
      notebook.removeNote(noteId, subject);
    }
  }

  notebookServer.broadcastNoteList(subject, SecurityUtils.getRoles());
  return new JsonResponse<>(Status.OK, "").build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:25,代码来源:NotebookRestApi.java

示例15: removeCronJob

import org.apache.zeppelin.annotation.ZeppelinApi; //导入依赖的package包/类
/**
 * Remove cron job REST API
 *
 * @param noteId ID of Note
 * @return JSON with status.OK
 * @throws IOException, IllegalArgumentException
 */
@DELETE
@Path("cron/{noteId}")
@ZeppelinApi
public Response removeCronJob(@PathParam("noteId") String noteId)
    throws IOException, IllegalArgumentException {
  LOG.info("Remove cron job note {}", noteId);

  Note note = notebook.getNote(noteId);
  checkIfNoteIsNotNull(note);
  checkIfUserIsOwner(noteId,
      "Insufficient privileges you cannot remove this cron job from this note");

  Map<String, Object> config = note.getConfig();
  config.put("cron", null);
  note.setConfig(config);
  notebook.refreshCron(note.getId());

  return new JsonResponse<>(Status.OK).build();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:NotebookRestApi.java


注:本文中的org.apache.zeppelin.annotation.ZeppelinApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。