private BrixPageParameters createBrixPageParams(Url url, Path path) {
    BrixPageParameters parameters = new BrixPageParameters();
    Path nodePath = path;
    Path requestPath = new Path("/" + url.getPath());

    if (nodePath.isAncestorOf(requestPath)) {
      Path remaining = new Path(requestPath.toString(), false).toRelative(nodePath);
      int i = 0;
      for (String s : remaining) {
        parameters.set(i, BrixNodePageUrlMapper.urlDecode(s));
        ++i;
      }
    }
    for (QueryParameter parameter : url.getQueryParameters()) {
      String parameterName = parameter.getName();
      if (PageComponentInfo.parse(parameterName) == null) {
        parameters.add(parameterName, parameter.getValue());
      }
    }
    return parameters;
  }
  @Override
  public IRequestHandler mapRequest(Request request) {
    final Url url = request.getClientUrl();

    if (isInternalWicket(request)) {
      return null;
    }

    // TODO: This is just a quick fix
    if (url.getSegments().size() > 0) {
      if (url.getSegments().get(0).equals("webdav")
          || url.getSegments().get(0).equals("jcrwebdav")) {
        return null;
      }
    }

    Path path = new Path("/" + url.getPath());

    // root path handling
    if (path.isRoot()) {
      if (handleHomePage) {
        final BrixNode node = getNodeForUriPath(path);
        return SitePlugin.get()
            .getNodePluginForNode(node)
            .respond(
                new BrixNodeModel(node), new BrixPageParameters(request.getRequestParameters()));
      } else {
        return null;
      }
    }

    IRequestHandler handler = null;
    try {
      while (handler == null) {
        final BrixNode node = getNodeForUriPath(path);
        if (node != null) {
          SiteNodePlugin plugin = SitePlugin.get().getNodePluginForNode(node);
          if (plugin instanceof AbstractSitePagePlugin) {
            handler =
                SitePlugin.get()
                    .getNodePluginForNode(node)
                    .respond(new BrixNodeModel(node), createBrixPageParams(request.getUrl(), path));
          } else {
            handler =
                SitePlugin.get()
                    .getNodePluginForNode(node)
                    .respond(
                        new BrixNodeModel(node),
                        new BrixPageParameters(request.getRequestParameters()));
          }
        }
        if (handler != null || path.toString().equals(".")) {
          break;
        }
        path = path.parent();
        if (path.isRoot()) {
          break;
        }
      }
    } catch (JcrException e) {
      logger.warn("JcrException caught due to incorrect url", e);
    }

    final PageComponentInfo info = getPageComponentInfo(request.getUrl());
    if (info != null && info.getPageInfo().getPageId() != null) {
      Integer renderCount =
          info.getComponentInfo() != null ? info.getComponentInfo().getRenderCount() : null;

      if (info.getComponentInfo() == null) {
        PageProvider provider;
        if (handler instanceof BrixNodePageRequestHandler) {
          provider =
              new PageProvider(info.getPageInfo().getPageId(), BrixNodeWebPage.class, renderCount);
          BrixNodePageRequestHandler brixNodePageRequestHandler =
              (BrixNodePageRequestHandler) handler;
          final IPageProvider pageProviderAdapter = brixNodePageRequestHandler.getPageProvider();
          provider.setPageSource(
              new IPageSource() {
                @Override
                public IRequestablePage getPageInstance(int pageId) {
                  IRequestablePage page = null;
                  Integer existingPageId = pageProviderAdapter.getPageId();
                  if (existingPageId != null && pageId == existingPageId) {
                    page = pageProviderAdapter.getPageInstance();
                  }
                  return page;
                }

                @Override
                public IRequestablePage newPageInstance(
                    Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) {
                  IRequestablePage page = pageProviderAdapter.getPageInstance();
                  page.getPageParameters().set(info.toString(), "");
                  return page;
                }
              });
        } else {
          provider = new PageProvider(info.getPageInfo().getPageId(), renderCount);
          provider.setPageSource(getContext());
        }

        // render page
        return new RenderPageRequestHandler(provider);
      } else {
        ComponentInfo componentInfo = info.getComponentInfo();
        PageAndComponentProvider provider =
            new PageAndComponentProvider(
                info.getPageInfo().getPageId(), renderCount, componentInfo.getComponentPath());

        provider.setPageSource(getContext());
        // listener interface
        RequestListenerInterface listenerInterface =
            requestListenerInterfaceFromString(componentInfo.getListenerInterface());

        return new ListenerInterfaceRequestHandler(
            provider, listenerInterface, componentInfo.getBehaviorId());
      }
    }

    return handler;
  }