Beispiel #1
0
  @Override
  public IRequestHandler mapRequest(final Request request) {
    Url url = decryptUrl(request, request.getUrl());

    if (url == null) {
      return null;
    }

    return wrappedMapper.mapRequest(request.cloneWithUrl(url));
  }
Beispiel #2
0
  @Override
  public Url mapHandler(final IRequestHandler requestHandler) {
    final Url url = wrappedMapper.mapHandler(requestHandler);

    if (url == null) {
      return null;
    }

    return encryptUrl(url);
  }
Beispiel #3
0
  /**
   * Creates a url for the handler. Modifies it with the correct {@link Scheme} if necessary.
   *
   * @param handler
   * @param request
   * @return url
   */
  final Url mapHandler(IRequestHandler handler, Request request) {
    Url url = delegate.mapHandler(handler);

    Scheme desired = getDesiredSchemeFor(handler);
    Scheme current = getSchemeOf(request);
    if (!desired.isCompatibleWith(current)) {
      // the generated url does not have the correct scheme, set it (which in turn will cause
      // the url to be rendered in its full representation)
      url.setProtocol(desired.urlName());
      if (url.getPort() != null || !desired.usesStandardPort(config)) {
        url.setPort(desired.getPort(config));
      }
    }
    return url;
  }
Beispiel #4
0
  @Override
  public IRequestHandler mapRequest(Request request) {
    IRequestHandler handler = delegate.mapRequest(request);

    Scheme desired = getDesiredSchemeFor(handler);
    Scheme current = getSchemeOf(request);
    if (!desired.isCompatibleWith(current)) {
      // we are currently on the wrong scheme for this handler

      // construct a url for the handler on the correct scheme
      String url = createRedirectUrl(handler, request, desired);

      // replace handler with one that will redirect to the created url
      handler = createRedirectHandler(url);
    }
    return handler;
  }
Beispiel #5
0
 /**
  * Returns URL for the request handler or <code>null</code> if the handler couldn't have been
  * encoded.
  *
  * @param handler
  * @return Url instance or <code>null</code>
  */
 public Url mapUrlFor(IRequestHandler handler) {
   final Url url = requestMapper.mapHandler(handler);
   listeners.onUrlMapped(this, handler, url);
   return url;
 }
Beispiel #6
0
 /**
  * Resolves current request to a {@link IRequestHandler}.
  *
  * @return RequestHandler instance
  */
 protected IRequestHandler resolveRequestHandler() {
   return requestMapper.mapRequest(request);
 }
Beispiel #7
0
 @Override
 public int getCompatibilityScore(Request request) {
   return delegate.getCompatibilityScore(request);
 }