• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MimeType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: warnUserPage

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 * Warn the user that the link may not be safe!
 * @param resp the http response
 * @param link the link to point to
 * @param user the user that owns the link.
 * @throws IOException on any error.
 */
private static void warnUserPage(HttpServletResponse resp, String link, 
    String user, ApplicationId id) throws IOException {
  //Set the cookie when we warn which overrides the query parameter
  //This is so that if a user passes in the approved query parameter without
  //having first visited this page then this page will still be displayed 
  resp.addCookie(makeCheckCookie(id, false));
  resp.setContentType(MimeType.HTML);
  Page p = new Page(resp.getWriter());
  p.html().
    h1("WARNING: The following page may not be safe!").
    h3().
    _("click ").a(link, "here").
    _(" to continue to an Application Master web interface owned by ", user).
    _().
  _();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:WebAppProxyServlet.java


示例2: sendRedirect

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 * Handle redirects with a status code that can in future support verbs other
 * than GET, thus supporting full REST functionality.
 * <p>
 * The target URL is included in the redirect text returned
 * <p>
 * At the end of this method, the output stream is closed.
 * 
 * @param request request (hence: the verb and any other information
 * relevant to a redirect)
 * @param response the response
 * @param target the target URL -unencoded
 *
 */
public static void sendRedirect(HttpServletRequest request,
    HttpServletResponse response,
    String target)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Redirecting {} {} to {}",
        request.getMethod(), 
        request.getRequestURI(),
        target);
  }
  String location = response.encodeRedirectURL(target);
  response.setStatus(HttpServletResponse.SC_FOUND);
  response.setHeader(LOCATION, location);
  response.setContentType(MimeType.HTML);
  PrintWriter writer = response.getWriter();
  Page p = new Page(writer);
  p.html()
      .head().title("Moved")._()
      .body()
      .h1("Moved")
      .div()
        ._("Content has moved ")
        .a(location, "here")._()
      ._()._();
  writer.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:41,代码来源:ProxyUtils.java


示例3: testGetJob

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 *  Test method 'job'. Should print message about error or set JobPage class for rendering
 */
@Test
public void testGetJob() {
  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(false);

  appController.job();
  verify(appController.response()).setContentType(MimeType.TEXT);
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01",
      appController.getData());
  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(true);

  appController.getProperty().remove(AMParams.JOB_ID);
  appController.job();
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01Bad Request: Missing job ID",
      appController.getData());

  appController.getProperty().put(AMParams.JOB_ID, "job_01_01");
  appController.job();
  assertEquals(JobPage.class, appController.getClazz());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestAppController.java


示例4: testGetJobCounters

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 *  Test method 'jobCounters'. Should print message about error or set CountersPage class for rendering
 */
@Test
public void testGetJobCounters() {

  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(false);

  appController.jobCounters();
  verify(appController.response()).setContentType(MimeType.TEXT);
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01",
      appController.getData());
  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(true);

  appController.getProperty().remove(AMParams.JOB_ID);
  appController.jobCounters();
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01Bad Request: Missing job ID",
      appController.getData());

  appController.getProperty().put(AMParams.JOB_ID, "job_01_01");
  appController.jobCounters();
  assertEquals(CountersPage.class, appController.getClazz());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestAppController.java


示例5: testGetTaskCounters

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 *  Test method 'taskCounters'. Should print message about error or set CountersPage class for rendering
 */
@Test
public void testGetTaskCounters() {

  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(false);

  appController.taskCounters();
  verify(appController.response()).setContentType(MimeType.TEXT);
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01",
      appController.getData());

  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(true);

  appController.getProperty().remove(AMParams.TASK_ID);
  appController.taskCounters();
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01missing task ID",
      appController.getData());

  appController.getProperty().put(AMParams.TASK_ID, "task_01_01_m01_01");
  appController.taskCounters();
  assertEquals(CountersPage.class, appController.getClazz());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestAppController.java


示例6: testGetTaskCounters

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 *  Test method 'taskCounters'. Should print message about error or set CountersPage class for rendering
 */
@Test
public void testGetTaskCounters() {

  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(false);

  appController.taskCounters();
  verify(appController.response()).setContentType(MimeType.TEXT);
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01",
      appController.getData());

  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(true);

  appController.getProperty().remove(AMParams.TASK_ID);
  appController.taskCounters();
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01missing task ID",
      appController.getData());

  appController.getProperty().put(AMParams.TASK_ID, taskId);
  appController.taskCounters();
  assertEquals(CountersPage.class, appController.getClazz());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:29,代码来源:TestAppController.java


示例7: warnUserPage

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 * Warn the user that the link may not be safe!
 * @param resp the http response
 * @param link the link to point to
 * @param user the user that owns the link.
 * @throws IOException on any error.
 */
private static void warnUserPage(HttpServletResponse resp, String link, 
    String user, ApplicationId id) throws IOException {
  //Set the cookie when we warn which overrides the query parameter
  //This is so that if a user passes in the approved query parameter without
  //having first visited this page then this page will still be displayed 
  resp.addCookie(makeCheckCookie(id, false));
  resp.setContentType(MimeType.HTML);
  Page p = new Page(resp.getWriter());
  p.html().
    h1("WARNING: The following page may not be safe!").h3().
    _("click ").a(link, "here").
    _(" to continue to an Application Master web interface owned by ", user).
    _().
  _();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:23,代码来源:WebAppProxyServlet.java


示例8: render

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
@Override
public void render() {
  response().setContentType(MimeType.HTML);
  PrintWriter pw = writer();
  pw.write("<html>");
  pw.write("<head>");
  pw.write("<meta charset=\"utf-8\">");
  pw.write("<title>Redirecting to Tez UI</title>");
  pw.write("</head>");
  pw.write("<body>");
  if (historyUrl == null || historyUrl.isEmpty()) {
    pw.write("<h1>Tez UI Url is not defined.</h1>" +
        "<p>To enable tracking url pointing to Tez UI, set the config <b>" +
        TezConfiguration.TEZ_HISTORY_URL_BASE + "</b> in the tez-site.xml.</p>");
  } else {
    pw.write("<h1>Redirecting to Tez UI</h1>. <p>If you are not redirected shortly, click " +
        "<a href='" + historyUrl + "'><b>here</b></a></p>"
    );
    pw.write("<script type='text/javascript'>setTimeout(function() { " +
      "window.location.replace('" + historyUrl + "');" +
      "}, 0); </script>");
  }
  pw.write("</body>");
  pw.write("</html>");
  pw.flush();
}
 
开发者ID:apache,项目名称:tez,代码行数:27,代码来源:AMWebController.java


示例9: render

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
@Override
public void render() {
  puts(DOCTYPE);
  render(page().html().meta_http("X-UA-Compatible", "IE=8")
      .meta_http("Content-type", MimeType.HTML));
  if (page().nestLevel() != 0) {
    throw new WebAppException("Error rendering page: nestLevel="+
                              page().nestLevel());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:HtmlPage.java


示例10: testUsual

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
@Test public void testUsual() {
  Injector injector = WebAppTests.testPage(TestView.class);
  PrintWriter out = injector.getInstance(PrintWriter.class);

  // Verify the HTML page has correct meta tags in the header
  verify(out).print(" http-equiv=\"X-UA-Compatible\"");
  verify(out).print(" content=\"IE=8\"");
  verify(out).print(" http-equiv=\"Content-type\"");
  verify(out).print(String.format(" content=\"%s\"", MimeType.HTML));

  verify(out).print("test");
  verify(out).print(" id=\"testid\"");
  verify(out).print("test note");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestHtmlPage.java


示例11: notFound

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 * Output 404 with appropriate message.
 * @param resp the http response.
 * @param message the message to include on the page.
 * @throws IOException on any error.
 */
public static void notFound(HttpServletResponse resp, String message)
    throws IOException {
  resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
  resp.setContentType(MimeType.HTML);
  Page p = new Page(resp.getWriter());
  p.html().
      h1(message).
       _();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:ProxyUtils.java


示例12: testAttempts

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
/**
 *   Test method 'conf'. Should set AttemptsPage class for rendering or print information about error
 */
@Test
public void testAttempts() {

  appController.getProperty().remove(AMParams.TASK_TYPE);

  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(false);

  appController.attempts();
  verify(appController.response()).setContentType(MimeType.TEXT);
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01",
      appController.getData());

  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
      .thenReturn(true);

  appController.getProperty().remove(AMParams.TASK_ID);
  appController.attempts();
  assertEquals(
      "Access denied: User user does not have permission to view job job_01_01",
      appController.getData());

  appController.getProperty().put(AMParams.TASK_ID, "task_01_01_m01_01");
  appController.attempts();
  assertEquals("Bad request: missing task-type.", appController.getProperty()
      .get("title"));
  appController.getProperty().put(AMParams.TASK_TYPE, "m");

  appController.attempts();
  assertEquals("Bad request: missing attempt-state.", appController
      .getProperty().get("title"));
  appController.getProperty().put(AMParams.ATTEMPT_STATE, "State");

  appController.attempts();

  assertEquals(AttemptsPage.class, appController.getClazz());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:TestAppController.java


示例13: render

import org.apache.hadoop.yarn.webapp.MimeType; //导入依赖的package包/类
@Override
public void render() {
  putWithoutEscapeHtml(DOCTYPE);
  render(page().html().meta_http("X-UA-Compatible", "IE=8")
      .meta_http("Content-type", MimeType.HTML));
  if (page().nestLevel() != 0) {
    throw new WebAppException("Error rendering page: nestLevel="+
                              page().nestLevel());
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:11,代码来源:HtmlPage.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Logging类代码示例发布时间:2022-05-22
下一篇:
Java Registration类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap