Exemplo n.º 1
0
  @Override
  public String getPortalURL(long groupId) throws PortalException, SystemException {

    String portalURL = PortalUtil.getPortalURL(getVirtualHostname(), Http.HTTP_PORT, false);

    if (groupId <= 0) {
      return portalURL;
    }

    Group group = GroupLocalServiceUtil.getGroup(groupId);

    if (group.hasPublicLayouts()) {
      LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, false);

      if (Validator.isNotNull(layoutSet.getVirtualHostname())) {
        portalURL = PortalUtil.getPortalURL(layoutSet.getVirtualHostname(), Http.HTTP_PORT, false);
      }
    } else if (group.hasPrivateLayouts()) {
      LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, true);

      if (Validator.isNotNull(layoutSet.getVirtualHostname())) {
        portalURL = PortalUtil.getPortalURL(layoutSet.getVirtualHostname(), Http.HTTP_PORT, false);
      }
    }

    return portalURL;
  }
Exemplo n.º 2
0
  /**
   * Derive default permissions based on the logic found in
   * portal-web/docroot/html/taglib/ui/input_permissions/page.jsp. Do not update this logic updating
   * the logic in the JSP.
   */
  public void deriveDefaultPermissions(long repositoryId, String modelName) throws PortalException {

    long siteGroupId = PortalUtil.getSiteGroupId(repositoryId);

    Group siteGroup = GroupLocalServiceUtil.getGroup(siteGroupId);

    Role defaultGroupRole = RoleLocalServiceUtil.getDefaultGroupRole(siteGroupId);

    List<String> groupPermissions = new ArrayList<String>();
    List<String> guestPermissions = new ArrayList<String>();

    String[] roleNames = {RoleConstants.GUEST, defaultGroupRole.getName()};

    List<String> supportedActions = ResourceActionsUtil.getModelResourceActions(modelName);
    List<String> groupDefaultActions =
        ResourceActionsUtil.getModelResourceGroupDefaultActions(modelName);
    List<String> guestDefaultActions =
        ResourceActionsUtil.getModelResourceGuestDefaultActions(modelName);
    List<String> guestUnsupportedActions =
        ResourceActionsUtil.getModelResourceGuestUnsupportedActions(modelName);

    for (String roleName : roleNames) {
      for (String action : supportedActions) {
        if (roleName.equals(RoleConstants.GUEST)
            && !guestUnsupportedActions.contains(action)
            && guestDefaultActions.contains(action)
            && siteGroup.hasPublicLayouts()) {

          guestPermissions.add(action);
        } else if (roleName.equals(defaultGroupRole.getName())
            && groupDefaultActions.contains(action)) {

          groupPermissions.add(action);
        }
      }
    }

    setGroupPermissions(groupPermissions.toArray(new String[groupPermissions.size()]));
    setGuestPermissions(guestPermissions.toArray(new String[guestPermissions.size()]));
  }
Exemplo n.º 3
0
  /** @deprecated As of 6.2.0, replaced by {@link #getGroupName(long, ServiceContext)} */
  protected String getGroupName(long groupId, ThemeDisplay themeDisplay) {
    try {
      if (groupId <= 0) {
        return StringPool.BLANK;
      }

      Group group = GroupLocalServiceUtil.getGroup(groupId);

      String groupName = group.getDescriptiveName();

      if (group.getGroupId() == themeDisplay.getScopeGroupId()) {
        return HtmlUtil.escape(groupName);
      }

      String groupDisplayURL =
          themeDisplay.getPortalURL()
              + themeDisplay.getPathMain()
              + "/my_sites/view?groupId="
              + group.getGroupId();

      if (group.hasPublicLayouts()) {
        groupDisplayURL = groupDisplayURL + "&privateLayout=0";
      } else if (group.hasPrivateLayouts()) {
        groupDisplayURL = groupDisplayURL + "&privateLayout=1";
      } else {
        return HtmlUtil.escape(groupName);
      }

      groupName =
          "<a class=\"group\" href=\""
              + groupDisplayURL
              + "\">"
              + HtmlUtil.escape(groupName)
              + "</a>";

      return groupName;
    } catch (Exception e) {
      return StringPool.BLANK;
    }
  }