Esempio n. 1
0
  /**
   * Processes the request.
   *
   * @return <code>true</code> if the request resolved to a Wicket request, <code>false</code>
   *     otherwise.
   */
  public boolean processRequest() {
    try {
      set(this);
      listeners.onBeginRequest(this);
      onBeginRequest();
      IRequestHandler handler = resolveRequestHandler();
      if (handler != null) {
        execute(handler);
        return true;
      }

      // Did not find any suitable handler, thus not executing the request
      log.debug(
          "No suitable handler found for URL {}, falling back to container to process this request",
          request.getUrl());
    } catch (Exception e) {
      IRequestHandler handler = handleException(e);
      if (handler != null) {
        listeners.onExceptionRequestHandlerResolved(this, handler, e);
        executeExceptionRequestHandler(handler, getExceptionRetryCount());
        listeners.onRequestHandlerExecuted(this, handler);
      } else {
        log.error("Error during request processing. URL=" + request.getUrl(), e);
      }
      return true;
    } finally {
      set(null);
    }
    return false;
  }
  /**
   * @see
   *     org.apache.wicket.request.mapper.parameter.IPageParametersEncoder#decodePageParameters(org.apache.wicket.request.Request)
   */
  public PageParameters decodePageParameters(final Request request) {
    PageParameters parameters = new PageParameters();

    int i = 0;
    for (String s : request.getUrl().getSegments()) {
      parameters.set(i, s);
      ++i;
    }

    for (QueryParameter p : request.getUrl().getQueryParameters()) {
      parameters.add(p.getName(), p.getValue());
    }

    return parameters.isEmpty() ? null : parameters;
  }
 public IRequestHandler mapRequest(final Request request) {
   final Url url = this.decryptUrl(request, request.getUrl());
   if (url == null) {
     return this.wrappedMapper.mapRequest(request);
   }
   return this.wrappedMapper.mapRequest(request.cloneWithUrl(url));
 }
Esempio n. 4
0
  /**
   * @see
   *     org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper#parseRequest(org.apache.wicket.request.Request)
   */
  @Override
  protected UrlInfo parseRequest(Request request) {
    Url url = request.getUrl();
    if (url.getSegments().size() >= 1) {
      // try to extract page and component information from URL
      PageComponentInfo info = getPageComponentInfo(url);

      // load the page class
      String className = url.getSegments().get(0);

      if (isValidClassName(className) == false) {
        return null;
      }

      className = transformFromUrl(className);
      String fullyQualifiedClassName = packageName.getName() + '.' + className;
      Class<? extends IRequestablePage> pageClass = getPageClass(fullyQualifiedClassName);

      if (pageClass != null
          && Modifier.isAbstract(pageClass.getModifiers()) == false
          && IRequestablePage.class.isAssignableFrom(pageClass)) {
        // extract the PageParameters from URL if there are any
        PageParameters pageParameters = extractPageParameters(request, 1, pageParametersEncoder);

        return new UrlInfo(info, pageClass, pageParameters);
      }
    }
    return null;
  }
 @Override
 public int getCompatibilityScore(Request request) {
   if (request.getUrl().getPath().equals(path)) {
     return Integer.MAX_VALUE;
   }
   return 0;
 }
 @Override
 public IRequestHandler mapRequest(Request request) {
   if (request.getUrl().getPath().equals(path)) {
     return new RenderPageRequestHandler(new DummyPanelPageProvider(loader));
   }
   return null;
 }
 @Override
 public int getCompatibilityScore(Request request) {
   if (urlStartsWith(request.getUrl(), mountSegments)) {
     return mountSegments.length;
   } else {
     return 0;
   }
 }
Esempio n. 8
0
 @Override
 public int getCompatibilityScore(Request request) {
   if (isInternalWicket(request)) {
     return 0;
   }
   // bluff we can parse all segments - makes sure we run first
   return request.getUrl().getSegments().size();
 }
Esempio n. 9
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));
  }
Esempio n. 10
0
 private boolean isInternalWicket(Request request) {
   Url url = request.getUrl();
   if (url.getSegments().size() > 0) {
     if (url.getSegments().get(0).equals((Application.get().getMapperContext().getNamespace()))) {
       // starts with wicket namespace - is an internal wicket url
       return true;
     }
   }
   return false;
 }
Esempio n. 11
0
  @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;
  }