public void onStartRequest(final Application app, final WebuiRequestContext context)
      throws Exception {
    PortalRequestContext pcontext = (PortalRequestContext) context;
    String requestPath =
        pcontext.getControllerContext().getParameter(RequestNavigationData.REQUEST_PATH);
    if (pcontext.getSiteType().equals(SiteType.GROUP)
        && pcontext.getSiteName().startsWith("/spaces")
        && (requestPath != null)
        && (requestPath.length() > 0)) {

      // Check if user want to access to wiki application
      String currentUser = Utils.getCurrentUser();
      String[] params = requestPath.split("/");
      if ((params.length > 1) && params[1].equals(WIKI_PORTLET_NAME)) {
        String spaceId = params[0];
        String owner = "/spaces/" + spaceId;
        String pageId = "WikiHome";
        if (params.length > 2) {
          pageId = params[2];
        }

        // Get page
        WikiService wikiService = (WikiService) PortalContainer.getComponent(WikiService.class);

        // If user is not member of space but has view permission
        if (!wikiService.isHiddenSpace(owner) && !wikiService.isSpaceMember(spaceId, currentUser)) {
          WikiPageParams wikiPageParams =
              new WikiPageParams(PortalConfig.GROUP_TYPE, owner, pageId);
          String permalink = Utils.getPermanlink(wikiPageParams);
          redirect(permalink);
        }
      }
    }
  }