Example #1
0
 /**
  * Bind each path parameter to the corresponding request parameter by name. By default, matching
  * values are bound only to the {@link org.ocpsoft.rewrite.context.EvaluationContext}.
  *
  * <p>See also {@link #where(String)}
  */
 @Override
 public IPath withRequestBinding() {
   for (PatternParameter capture : expression.getParameterMap().values()) {
     where(capture.getName()).bindsTo(Request.parameter(capture.getName()));
   }
   return this;
 }
Example #2
0
  @Override
  public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context) {
    String requestURL = null;

    if (event instanceof HttpOutboundServletRewrite) {
      requestURL = ((HttpOutboundServletRewrite) event).getOutboundURL().split("\\?")[0];
      if (requestURL.startsWith(event.getContextPath())) {
        requestURL = requestURL.substring(event.getContextPath().length());
      }
    } else requestURL = event.getRequestPath();

    if (expression.matches(event, context, requestURL)) {
      Map<PatternParameter, String[]> parameters = expression.parse(event, context, requestURL);

      for (PatternParameter capture : parameters.keySet()) {
        if (!Bindings.enqueueSubmission(
            event, context, where(capture.getName()), parameters.get(capture))) return false;
      }
      return true;
    }
    return false;
  }
Example #3
0
 @Override
 public PathParameter where(String param) {
   return parameters.where(param, new PathParameter(this, expression.getParameter(param)));
 }
Example #4
0
 @Override
 public String toString() {
   return expression.toString();
 }