Ejemplo n.º 1
0
  protected String updateCloseRedirect(
      String closeRedirect,
      Group group,
      ThemeDisplay themeDisplay,
      String oldFriendlyURL,
      String oldStagingFriendlyURL)
      throws PortalException, SystemException {

    if (Validator.isNull(closeRedirect) || (group == null)) {
      return closeRedirect;
    }

    String oldPath = null;
    String newPath = null;

    if (Validator.isNotNull(oldFriendlyURL)) {
      oldPath = oldFriendlyURL;
      newPath = group.getFriendlyURL();

      if (closeRedirect.contains(oldPath)) {
        closeRedirect = PortalUtil.updateRedirect(closeRedirect, oldPath, newPath);
      } else {
        closeRedirect = PortalUtil.getGroupFriendlyURL(group, false, themeDisplay);
      }
    }

    if (Validator.isNotNull(oldStagingFriendlyURL)) {
      Group stagingGroup = group.getStagingGroup();

      if (GroupLocalServiceUtil.fetchGroup(stagingGroup.getGroupId()) == null) {

        oldPath = oldStagingFriendlyURL;
        newPath = group.getFriendlyURL();
      } else {
        oldPath = oldStagingFriendlyURL;
        newPath = stagingGroup.getFriendlyURL();
      }

      if (closeRedirect.contains(oldPath)) {
        closeRedirect = PortalUtil.updateRedirect(closeRedirect, oldPath, newPath);
      } else {
        closeRedirect = PortalUtil.getGroupFriendlyURL(group, false, themeDisplay);
      }
    }

    return closeRedirect;
  }