private void setMoreParams(RequestContext rc, String pathInfo, Dest dest) { checkState(pathInfo.startsWith(dest.prefix), "prefix should match"); if (dest.pathParams.size() == 0 || dest.prefix.length() == pathInfo.length()) { return; } String[] parts = Iterables.toArray(WebApp.pathSplitter.split( pathInfo.substring(dest.prefix.length())), String.class); LOG.debug("parts={}, params={}", parts, dest.pathParams); for (int i = 0; i < dest.pathParams.size() && i < parts.length; ++i) { String key = dest.pathParams.get(i); if (key.charAt(0) == ':') { rc.moreParams().put(key.substring(1), parts[i]); } } }
injector.getInstance(Controller.RequestContext.class); if (setCookieParams(rc, req) > 0) { Cookie ec = rc.cookies().get(ERROR_COOKIE); if (ec != null) { rc.setStatus(Integer.parseInt(rc.cookies(). get(STATUS_COOKIE).getValue())); removeErrorCookies(res, uri); rc.set(Params.ERROR_DETAILS, ec.getValue()); render(ErrorPage.class); return; rc.error = e; if (!e.getMessage().contains("not found")) { rc.setStatus(res.SC_INTERNAL_SERVER_ERROR); render(ErrorPage.class); return; rc.setStatus(res.SC_NOT_FOUND); render(ErrorPage.class); return;
rc.setStatus(HttpServletResponse.SC_FOUND); render(RobotsTextPage.class); return; Cookie ec = rc.cookies().get(ERROR_COOKIE); if (ec != null) { rc.setStatus(Integer.parseInt(rc.cookies(). get(STATUS_COOKIE).getValue())); removeErrorCookies(res, uri); rc.set(Params.ERROR_DETAILS, ec.getValue()); render(ErrorPage.class); return; rc.error = e; if (!e.getMessage().contains("not found")) { rc.setStatus(res.SC_INTERNAL_SERVER_ERROR); render(ErrorPage.class); return; rc.setStatus(res.SC_NOT_FOUND); render(ErrorPage.class); return;
injector.getInstance(Controller.RequestContext.class); if (setCookieParams(rc, req) > 0) { Cookie ec = rc.cookies().get(ERROR_COOKIE); if (ec != null) { rc.setStatus(Integer.parseInt(rc.cookies(). get(STATUS_COOKIE).getValue())); removeErrorCookies(res, uri); rc.set(Params.ERROR_DETAILS, ec.getValue()); render(ErrorPage.class); return; rc.error = e; if (!e.getMessage().contains("not found")) { rc.setStatus(res.SC_INTERNAL_SERVER_ERROR); render(ErrorPage.class); return; rc.setStatus(res.SC_NOT_FOUND); render(ErrorPage.class); return;
WebAppUtils.appendQueryParams(request, sb.toString()); } else { injector.getInstance(RequestContext.class).set( ContainerLogsPage.REDIRECT_URL, "false");
WebAppUtils.appendQueryParams(request, sb.toString()); } else { injector.getInstance(RequestContext.class).set( ContainerLogsPage.REDIRECT_URL, "false");
@Test public void testView() { Injector injector = WebAppTests.createMockInjector(RMContext.class, mockRMContext(15, 1, 2, 8*GiB), new Module() { @Override public void configure(Binder binder) { try { ResourceManager mockRm = mockRm(3, 1, 2, 8*GiB); binder.bind(ResourceManager.class).toInstance(mockRm); } catch (IOException e) { throw new IllegalStateException(e); } } }); RmView rmViewInstance = injector.getInstance(RmView.class); rmViewInstance.set(YarnWebParams.APP_STATE, YarnApplicationState.RUNNING.toString()); rmViewInstance.render(); WebAppTests.flushOutput(injector); rmViewInstance.set(YarnWebParams.APP_STATE, StringHelper.cjoin( YarnApplicationState.ACCEPTED.toString(), YarnApplicationState.RUNNING.toString())); rmViewInstance.render(); WebAppTests.flushOutput(injector); Map<String, String> moreParams = rmViewInstance.context().requestContext().moreParams(); String appsTableColumnsMeta = moreParams.get("ui.dataTables.apps.init"); Assert.assertTrue(appsTableColumnsMeta.indexOf("natural") != -1); }
WebAppTests.flushOutput(injector); Map<String, String> moreParams = rmViewInstance.context().requestContext().moreParams(); String appsTableColumnsMeta = moreParams.get("ui.dataTables.apps.init"); Assert.assertTrue(appsTableColumnsMeta.indexOf("natural") != -1);
@Inject ErrorsAndWarningsBlock(ViewContext ctx, Configuration conf) { super(ctx); // default is to show all errors and warnings cutoffPeriodSeconds = Time.now() / 1000; String value = ctx.requestContext().get("cutoff", ""); try { cutoffPeriodSeconds = Integer.parseInt(value); if (cutoffPeriodSeconds <= 0) { cutoffPeriodSeconds = Time.now() / 1000; } } catch (NumberFormatException ne) { cutoffPeriodSeconds = Time.now() / 1000; } adminAclsManager = new AdminACLsManager(conf); }
private void setMoreParams(RequestContext rc, String pathInfo, Dest dest) { checkState(pathInfo.startsWith(dest.prefix), "prefix should match"); if (dest.pathParams.size() == 0 || dest.prefix.length() == pathInfo.length()) { return; } String[] parts = Iterables.toArray(WebApp.pathSplitter.split( pathInfo.substring(dest.prefix.length())), String.class); LOG.debug("parts={}, params={}", parts, dest.pathParams); for (int i = 0; i < dest.pathParams.size() && i < parts.length; ++i) { String key = dest.pathParams.get(i); if (key.charAt(0) == ':') { rc.moreParams().put(key.substring(1), parts[i]); } } }
private void setMoreParams(RequestContext rc, String pathInfo, Dest dest) { checkState(pathInfo.startsWith(dest.prefix), "prefix should match"); if (dest.pathParams.size() == 0 || dest.prefix.length() == pathInfo.length()) { return; } String[] parts = Iterables.toArray(WebApp.pathSplitter.split( pathInfo.substring(dest.prefix.length())), String.class); LOG.debug("parts={}, params={}", parts, dest.pathParams); for (int i = 0; i < dest.pathParams.size() && i < parts.length; ++i) { String key = dest.pathParams.get(i); if (key.charAt(0) == ':') { rc.moreParams().put(key.substring(1), parts[i]); } } }
public void set(String key, String value) { moreParams().put(key, value); }
public void set(String key, String value) { moreParams().put(key, value); }
public void set(String key, String value) { context().set(key, value); }
public String get(String key, String defaultValue) { return context().get(key, defaultValue); }
public Map<String, String> moreParams() { return context().rc.moreParams(); }
public Map<String, String> moreParams() { return context().rc.moreParams(); }
@Test public void testAppAttemptPageNaturalSortType() throws Exception { Injector injector = WebAppTests.createMockInjector(ApplicationBaseProtocol.class, mockApplicationHistoryClientService(1, 1, 5)); AppAttemptPage appAttemptPageInstance = injector.getInstance(AppAttemptPage.class); appAttemptPageInstance.render(); WebAppTests.flushOutput(injector); Map<String, String> moreParams = appAttemptPageInstance.context().requestContext().moreParams(); String tableColumnsMeta = moreParams.get("ui.dataTables.containers.init"); Assert.assertTrue(tableColumnsMeta.indexOf("natural") != -1); }
public void set(String key, String value) { context().set(key, value); }
public void setStatus(int status) { context().setStatus(status); }