/** * Get the absolute bookmarkable path of a page * * @param pageClass Page * @param pageParameters Optional page parameters * @return Bookmarkable path */ public static String absoluteMountPathForPage( Class<? extends Page> pageClass, PageParameters pageParameters) { HttpServletRequest req = getHttpServletRequest(); RequestCycle requestCycle = RequestCycle.get(); Url url = requestCycle.mapUrlFor(pageClass, pageParameters); String renderedUrl = url.toString(); renderedUrl = Strings.isEmpty(renderedUrl) ? "." : renderedUrl; return RequestUtils.toAbsolutePath( HttpUtils.getWebappContextUrl(req), requestCycle.getOriginalResponse().encodeURL(renderedUrl)); }
/** * Cache the requested protected resource pending successful authentication. * * @param pageClass */ public void cacheRequest(Class<? extends Page> pageClass) { // build absolute url with correctly encoded parameters?! Request req = WebRequestCycle.get().getRequest(); Map<String, ?> params = req.getRequestParameters().getParameters(); PageParameters pageParams = new PageParameters(params); String relativeUrl = WebRequestCycle.get().urlFor(pageClass, pageParams).toString(); requestUrl = RequestUtils.toAbsolutePath(relativeUrl); if (isTemporary()) { // we must bind the temporary session into the session store // so that we can re-use this session for reporting an error message // on the redirected page and continuing the request after // authentication. bind(); } }
public void error( String message, Throwable t, Class<? extends Page> toPage, PageParameters params) { if (t == null) { logger().error(message + " for " + GitBlitWebSession.get().getUsername()); } else { logger().error(message + " for " + GitBlitWebSession.get().getUsername(), t); } if (toPage != null) { GitBlitWebSession.get().cacheErrorMessage(message); String relativeUrl = urlFor(toPage, params).toString(); String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl); throw new RedirectToUrlException(absoluteUrl); } else { super.error(message); } }
public static String toAbsolutePath(final String relativePagePath) { HttpServletRequest req = getHttpServletRequest(); return RequestUtils.toAbsolutePath(req.getRequestURL().toString(), relativePagePath); }
/** * @param relativePagePath * @return * @see RequestUtils#toAbsolutePath(String, String) * @see URLHelper#removeJSessionId(String) */ public static final String toAbsolutePath( final String requestUrl, final String relativePagePath) { final String absoluteUrl = RequestUtils.toAbsolutePath(requestUrl, relativePagePath); return URLHelper.removeJSessionId(absoluteUrl); }
protected String getCanonicalUrl(Class<? extends BasePage> clazz, PageParameters params) { String relativeUrl = urlFor(clazz, params).toString(); String canonicalUrl = RequestUtils.toAbsolutePath(relativeUrl); return canonicalUrl; }