/** * Builds a special outcome processed by {@link RewriteNavigationHandler} */ private String buildRedirectOutcome() { AddressBuilderPath builderPath = AddressBuilder.begin().pathEncoded(viewId); for (Entry<String, List<String>> param : parameters.entrySet()) { String[] values = param.getValue().toArray(new String[param.getValue().size()]); builderPath.queryEncoded(param.getKey(), (Object[]) values); } String url = builderPath.toString(); return RewriteNavigationHandler.REDIRECT_PREFIX + url; }
/** * Builds a special outcome processed by {@link RewriteNavigationHandler} */ private String buildRedirectOutcome() { AddressBuilderPath builderPath = AddressBuilder.begin().pathEncoded(viewId); for (Entry<String, List<String>> param : parameters.entrySet()) { String[] values = param.getValue().toArray(new String[param.getValue().size()]); builderPath.queryEncoded(param.getKey(), (Object[]) values); } String url = builderPath.toString(); return RewriteNavigationHandler.REDIRECT_PREFIX + url; }
/** * Create a new {@link Address} from the given URL. Improperly formatted or encoded URLs are not parse-able and will * result in an exception. No builder parameterization is possible using this method. * * @see http://en.wikipedia.org/wiki/URI_scheme * @throws IllegalArgumentException when the input URL or URL fragment is not valid. */ public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } }
/** * Create a new {@link Address} from the given URL. Improperly formatted or encoded URLs are not parse-able and will * result in an exception. No builder parameterization is possible using this method. * * @see http://en.wikipedia.org/wiki/URI_scheme * @throws IllegalArgumentException when the input URL or URL fragment is not valid. */ public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } }
@Override public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context) { String url = null; if (event instanceof HttpOutboundServletRewrite) { url = ((HttpOutboundServletRewrite) event).getOutboundAddress().getPath(); if (url == null) // e.g an external url like http://ocpsoft.org (without trailing slash) or an anchor link have // a null path return false; } else url = AddressBuilder.begin().pathDecoded(event.getInboundAddress().getPath()).buildLiteral().toString(); String contextPath = event.getContextPath(); if (!contextPath.equals("/") && url.startsWith(contextPath)) url = url.substring(contextPath.length()); return expression.parse(url).submit(event, context); }
@Override public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context) { String url = null; if (event instanceof HttpOutboundServletRewrite) { url = ((HttpOutboundServletRewrite) event).getOutboundAddress().getPath(); if (url == null) // e.g an external url like http://ocpsoft.org (without trailing slash) or an anchor link have // a null path return false; } else url = AddressBuilder.begin().pathDecoded(event.getInboundAddress().getPath()).buildLiteral().toString(); String contextPath = event.getContextPath(); if (!contextPath.equals("/") && url.startsWith(contextPath)) url = url.substring(contextPath.length()); return expression.parse(url).submit(event, context); }
@Override public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context) { String url = null; if (event instanceof HttpOutboundServletRewrite) { url = ((HttpOutboundServletRewrite) event).getOutboundAddress().getPath(); if (url == null) // e.g an external url like http://ocpsoft.org (without trailing slash) or an anchor link have // a null path return false; } else url = AddressBuilder.begin().pathDecoded(event.getInboundAddress().getPath()).buildLiteral().toString(); String contextPath = event.getContextPath(); if (!contextPath.equals("/") && url.startsWith(contextPath)) url = url.substring(contextPath.length()); return expression.parse(url).submit(event, context); }
@Override public Address getInboundAddress() { if (this.address == null) { String requestURI = getRequest().getRequestURI(); Matcher sessionIdMatcher = JSESSIONID_PATTERN.matcher(requestURI); if (sessionIdMatcher.matches()) { requestURI = sessionIdMatcher.replaceFirst(JSESSIONID_REPLACEMENT); } // for forwards the requestURI isn't URL encoded as we expect it // see: https://github.com/ocpsoft/rewrite/issues/165 if (getRequest().getAttribute("javax.servlet.forward.request_uri") != null) { requestURI = Encoder.path(requestURI); } this.address = AddressBuilder.begin() .scheme(getRequest().getScheme()) .domain(getRequest().getServerName()) .port(getRequest().getServerPort()) .path(requestURI) .queryLiteral(getRequest().getQueryString()).buildLiteral(); } return this.address; }
@Override public Address getInboundAddress() { if (this.address == null) { String requestURI = getRequest().getRequestURI(); Matcher sessionIdMatcher = JSESSIONID_PATTERN.matcher(requestURI); if (sessionIdMatcher.matches()) { requestURI = sessionIdMatcher.replaceFirst(JSESSIONID_REPLACEMENT); } // for forwards the requestURI isn't URL encoded as we expect it // see: https://github.com/ocpsoft/rewrite/issues/165 if (getRequest().getAttribute("javax.servlet.forward.request_uri") != null) { requestURI = Encoder.path(requestURI); } this.address = AddressBuilder.begin() .scheme(getRequest().getScheme()) .domain(getRequest().getServerName()) .port(getRequest().getServerPort()) .path(requestURI) .queryLiteral(getRequest().getQueryString()).buildLiteral(); } return this.address; }
@Override public Address getInboundAddress() { if (this.address == null) { String requestURI = getRequest().getRequestURI(); Matcher sessionIdMatcher = JSESSIONID_PATTERN.matcher(requestURI); if (sessionIdMatcher.matches()) { requestURI = sessionIdMatcher.replaceFirst(JSESSIONID_REPLACEMENT); } // for forwards the requestURI isn't URL encoded as we expect it // see: https://github.com/ocpsoft/rewrite/issues/165 if (getRequest().getAttribute("javax.servlet.forward.request_uri") != null) { requestURI = Encoder.path(requestURI); } this.address = AddressBuilder.begin() .scheme(getRequest().getScheme()) .domain(getRequest().getServerName()) .port(getRequest().getServerPort()) .path(requestURI) .queryLiteral(getRequest().getQueryString()).buildLiteral(); } return this.address; }
@Override public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context) { String url = null; if (event instanceof HttpOutboundServletRewrite) { url = ((HttpOutboundServletRewrite) event).getOutboundAddress().getPathAndQuery(); if (url == null) /* * e.g an external url like http://ocpsoft.org (without trailing slash) or an anchor link have a null path */ return false; } else url = AddressBuilder.begin() .pathDecoded(event.getInboundAddress().getPath()) .queryLiteral(event.getInboundAddress().getQuery()) .build().toString(); String contextPath = event.getContextPath(); if (!contextPath.equals("/") && url.startsWith(contextPath)) url = url.substring(contextPath.length()); return (expression.parse(url).submit(event, context)); }
@Override public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context) { String url = null; if (event instanceof HttpOutboundServletRewrite) { url = ((HttpOutboundServletRewrite) event).getOutboundAddress().getPathAndQuery(); if (url == null) /* * e.g an external url like http://ocpsoft.org (without trailing slash) or an anchor link have a null path */ return false; } else url = AddressBuilder.begin() .pathDecoded(event.getInboundAddress().getPath()) .queryLiteral(event.getInboundAddress().getQuery()) .build().toString(); String contextPath = event.getContextPath(); if (!contextPath.equals("/") && url.startsWith(contextPath)) url = url.substring(contextPath.length()); return (expression.parse(url).submit(event, context)); }
@Override public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context) { String url = null; if (event instanceof HttpOutboundServletRewrite) { url = ((HttpOutboundServletRewrite) event).getOutboundAddress().getPathAndQuery(); if (url == null) /* * e.g an external url like http://ocpsoft.org (without trailing slash) or an anchor link have a null path */ return false; } else url = AddressBuilder.begin() .pathDecoded(event.getInboundAddress().getPath()) .queryLiteral(event.getInboundAddress().getQuery()) .build().toString(); String contextPath = event.getContextPath(); if (!contextPath.equals("/") && url.startsWith(contextPath)) url = url.substring(contextPath.length()); return (expression.parse(url).submit(event, context)); }
AddressBuilderBase queryBuilder = AddressBuilder.begin(); if (outboundAddress.isQuerySet())
AddressBuilderBase queryBuilder = AddressBuilder.begin(); if (outboundAddress.isQuerySet())
AddressBuilderBase queryBuilder = AddressBuilder.begin(); if (outboundAddress.isQuerySet())