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);
        }
      }
    }
  }
Пример #2
0
 /**
  * Get the permalink of current wiki page <br>
  *
  * <ul>
  *   With the current page param:
  * </ul>
  *
  * <li>type = "group"
  * <li>owner = "spaces/test_space"
  * <li>pageId = "test_page" <br>
  *
  *     <ul>
  *       The permalink will be:
  * </ul>
  *
  * <li>http://int.exoplatform.org/portal/intranet/wiki/group/spaces/test_space/test_page <br>
  *
  * @return The permalink of current wiki page
  * @throws Exception
  */
 protected static String getPermanlink() throws Exception {
   WikiPageParams params = Utils.getCurrentWikiPageParams();
   return org.exoplatform.wiki.utils.Utils.getPermanlink(params, true);
 }