コード例 #1
0
  public LayoutSet updateVirtualHost(long groupId, boolean privateLayout, String virtualHost)
      throws PortalException, SystemException {

    GroupPermissionUtil.check(getPermissionChecker(), groupId, ActionKeys.UPDATE);

    return layoutSetLocalService.updateVirtualHost(groupId, privateLayout, virtualHost);
  }
コード例 #2
0
  /**
   * Updates the group's friendly URL.
   *
   * @param groupId the primary key of the group
   * @param friendlyURL the group's new friendlyURL (optionally <code>null</code>)
   * @return the group
   * @throws PortalException if a portal exception occurred
   */
  @Override
  public Group updateFriendlyURL(long groupId, String friendlyURL) throws PortalException {

    GroupPermissionUtil.check(getPermissionChecker(), groupId, ActionKeys.UPDATE);

    return groupLocalService.updateFriendlyURL(groupId, friendlyURL);
  }
コード例 #3
0
  /**
   * Updates the group's type settings.
   *
   * @param groupId the primary key of the group
   * @param typeSettings the group's new type settings (optionally <code>null</code>)
   * @return the group
   * @throws PortalException if a portal exception occurred
   */
  @Override
  public Group updateGroup(long groupId, String typeSettings) throws PortalException {

    Group group = groupPersistence.findByPrimaryKey(groupId);

    GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.UPDATE);

    if (group.isSite()) {
      Group oldGroup = group;

      UnicodeProperties oldTypeSettingsProperties = oldGroup.getTypeSettingsProperties();

      group = groupLocalService.updateGroup(groupId, typeSettings);

      RatingsDataTransformerUtil.transformGroupRatingsData(
          groupId, oldTypeSettingsProperties, group.getTypeSettingsProperties());

      SiteMembershipPolicyUtil.verifyPolicy(
          group, oldGroup, null, null, null, oldTypeSettingsProperties);

      return group;
    } else {
      return groupLocalService.updateGroup(groupId, typeSettings);
    }
  }
コード例 #4
0
  public void updateLogo(long groupId, boolean privateLayout, boolean logo, InputStream inputStream)
      throws PortalException, SystemException {

    GroupPermissionUtil.check(getPermissionChecker(), groupId, ActionKeys.UPDATE);

    layoutSetLocalService.updateLogo(groupId, privateLayout, logo, inputStream);
  }
コード例 #5
0
  /**
   * Returns the group with the primary key.
   *
   * @param groupId the primary key of the group
   * @return the group with the primary key
   * @throws PortalException if a portal exception occurred
   */
  @Override
  public Group getGroup(long groupId) throws PortalException {
    Group group = groupLocalService.getGroup(groupId);

    GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.VIEW);

    return group;
  }
コード例 #6
0
  @Override
  public void enableStaging(long groupId) throws PortalException {
    Group group = groupLocalService.getGroup(groupId);

    GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.UPDATE);

    groupLocalService.enableStaging(groupId);
  }
コード例 #7
0
  /**
   * Returns the group's display URL.
   *
   * @param groupId the primary key of the group
   * @param privateLayout whether the layout set is private to the group
   * @param secureConnection whether the generated URL uses a secure connection
   * @return the group's display URL
   * @throws PortalException if a group with the primary key could not be found or if a portal
   *     exception occurred
   */
  @Override
  public String getGroupDisplayURL(long groupId, boolean privateLayout, boolean secureConnection)
      throws PortalException {

    Group group = groupLocalService.getGroup(groupId);

    GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.VIEW);

    if (!privateLayout && (group.getPublicLayoutsPageCount() > 0)) {
      return PortalUtil.getLayoutSetDisplayURL(group.getPublicLayoutSet(), secureConnection);
    } else if (privateLayout && (group.getPrivateLayoutsPageCount() > 0)) {
      return PortalUtil.getLayoutSetDisplayURL(group.getPrivateLayoutSet(), secureConnection);
    }

    GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.UPDATE);

    return PortalUtil.getControlPanelFullURL(groupId, PortletKeys.LAYOUTS_ADMIN, null);
  }
コード例 #8
0
  /**
   * Returns the group directly associated with the user.
   *
   * @param companyId the primary key of the company
   * @param userId the primary key of the user
   * @return the group directly associated with the user
   * @throws PortalException if a portal exception occurred
   */
  @Override
  public Group getUserGroup(long companyId, long userId) throws PortalException {

    Group group = groupLocalService.getUserGroup(companyId, userId);

    GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.VIEW);

    return group;
  }
コード例 #9
0
  /**
   * Returns <code>true</code> if the user is associated with the group, including the user's
   * inherited organizations and user groups. System and staged groups are not included.
   *
   * @param userId the primary key of the user
   * @param groupId the primary key of the group
   * @return <code>true</code> if the user is associated with the group; <code>false</code>
   *     otherwise
   * @throws PortalException if a portal exception occurred
   */
  @Override
  public boolean hasUserGroup(long userId, long groupId) throws PortalException {

    try {
      UserPermissionUtil.check(getPermissionChecker(), userId, ActionKeys.VIEW);
    } catch (PrincipalException pe) {
      GroupPermissionUtil.check(getPermissionChecker(), groupId, ActionKeys.VIEW_MEMBERS);
    }

    return groupLocalService.hasUserGroup(userId, groupId);
  }
コード例 #10
0
  protected List<Group> filterGroups(List<Group> groups) throws PortalException {

    List<Group> filteredGroups = new ArrayList<>();

    for (Group group : groups) {
      if (GroupPermissionUtil.contains(getPermissionChecker(), group, ActionKeys.VIEW)) {

        filteredGroups.add(group);
      }
    }

    return filteredGroups;
  }
コード例 #11
0
  @Override
  public boolean isScopeIdSelectable(
      PermissionChecker permissionChecker, String scopeId, long companyGroupId, Layout layout)
      throws PortalException, SystemException {

    long groupId = getGroupIdFromScopeId(scopeId, layout.getGroupId(), layout.isPrivateLayout());

    if (scopeId.startsWith(SCOPE_ID_CHILD_GROUP_PREFIX)) {
      Group group = GroupLocalServiceUtil.getGroup(groupId);

      if (!group.hasAncestor(layout.getGroupId())) {
        return false;
      }
    } else if (scopeId.startsWith(SCOPE_ID_PARENT_GROUP_PREFIX)) {
      Group siteGroup = layout.getGroup();

      if (!siteGroup.hasAncestor(groupId)) {
        return false;
      }

      if (SitesUtil.isContentSharingWithChildrenEnabled(siteGroup)) {
        return true;
      }

      if (!PrefsPropsUtil.getBoolean(
          layout.getCompanyId(), PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) {

        return false;
      }

      return GroupPermissionUtil.contains(permissionChecker, groupId, ActionKeys.UPDATE);
    } else if (groupId != companyGroupId) {
      return GroupPermissionUtil.contains(permissionChecker, groupId, ActionKeys.UPDATE);
    }

    return true;
  }
コード例 #12
0
  public LayoutSet updateLookAndFeel(
      long groupId,
      boolean privateLayout,
      String themeId,
      String colorSchemeId,
      String css,
      boolean wapTheme)
      throws PortalException, SystemException {

    GroupPermissionUtil.check(getPermissionChecker(), groupId, ActionKeys.UPDATE);

    pluginSettingLocalService.checkPermission(getUserId(), themeId, Plugin.TYPE_THEME);

    return layoutSetLocalService.updateLookAndFeel(
        groupId, privateLayout, themeId, colorSchemeId, css, wapTheme);
  }
コード例 #13
0
  public void deleteArchivedPreferences(long portletItemId)
      throws PortalException, SystemException {

    PortletItem portletItem = portletItemLocalService.getPortletItem(portletItemId);

    GroupPermissionUtil.check(
        getPermissionChecker(), portletItem.getGroupId(), ActionKeys.MANAGE_ARCHIVED_SETUPS);

    long ownerId = portletItemId;
    int ownerType = PortletKeys.PREFS_OWNER_TYPE_ARCHIVED;
    long plid = 0;
    String portletId = portletItem.getPortletId();

    portletPreferencesLocalService.deletePortletPreferences(ownerId, ownerType, plid, portletId);

    portletItemLocalService.deletePortletItem(portletItemId);
  }
コード例 #14
0
  @Override
  public void updateStagedPortlets(long groupId, Map<String, String> stagedPortletIds)
      throws PortalException {

    Group group = groupPersistence.findByPrimaryKey(groupId);

    GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.UPDATE);

    UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties();

    for (String stagedPortletId : stagedPortletIds.keySet()) {
      typeSettingsProperties.setProperty(
          StagingUtil.getStagedPortletId(stagedPortletId), stagedPortletIds.get(stagedPortletId));
    }

    groupLocalService.updateGroup(group);
  }
コード例 #15
0
  @Override
  public Group addGroup(
      long parentGroupId,
      long liveGroupId,
      Map<Locale, String> nameMap,
      Map<Locale, String> descriptionMap,
      int type,
      boolean manualMembership,
      int membershipRestriction,
      String friendlyURL,
      boolean site,
      boolean inheritContent,
      boolean active,
      ServiceContext serviceContext)
      throws PortalException {

    if (parentGroupId == GroupConstants.DEFAULT_PARENT_GROUP_ID) {
      PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_COMMUNITY);
    } else {
      GroupPermissionUtil.check(getPermissionChecker(), parentGroupId, ActionKeys.ADD_COMMUNITY);
    }

    Group group =
        groupLocalService.addGroup(
            getUserId(),
            parentGroupId,
            null,
            0,
            liveGroupId,
            nameMap,
            descriptionMap,
            type,
            manualMembership,
            membershipRestriction,
            friendlyURL,
            site,
            inheritContent,
            active,
            serviceContext);

    if (site) {
      SiteMembershipPolicyUtil.verifyPolicy(group);
    }

    return group;
  }
コード例 #16
0
  public void restoreArchivedPreferences(
      long groupId, String name, String portletId, javax.portlet.PortletPreferences preferences)
      throws PortalException, SystemException {

    GroupPermissionUtil.check(getPermissionChecker(), groupId, ActionKeys.MANAGE_ARCHIVED_SETUPS);

    PortletItem portletItem =
        portletItemLocalService.getPortletItem(
            groupId, name, portletId, PortletPreferences.class.getName());

    long ownerId = portletItem.getPortletItemId();
    int ownerType = PortletKeys.PREFS_OWNER_TYPE_ARCHIVED;
    long plid = 0;

    javax.portlet.PortletPreferences archivedPrefs =
        portletPreferencesLocalService.getPreferences(
            portletItem.getCompanyId(), ownerId, ownerType, plid, portletId);

    copyPreferences(archivedPrefs, preferences);
  }
コード例 #17
0
  protected Organization updateOrganization(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long organizationId = ParamUtil.getLong(actionRequest, "organizationId");

    long parentOrganizationId =
        ParamUtil.getLong(
            actionRequest,
            "parentOrganizationSearchContainerPrimaryKeys",
            OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID);
    String name = ParamUtil.getString(actionRequest, "name");
    int statusId = ParamUtil.getInteger(actionRequest, "statusId");
    String type = ParamUtil.getString(actionRequest, "type");
    long regionId = ParamUtil.getLong(actionRequest, "regionId");
    long countryId = ParamUtil.getLong(actionRequest, "countryId");
    String comments = ParamUtil.getString(actionRequest, "comments");
    boolean deleteLogo = ParamUtil.getBoolean(actionRequest, "deleteLogo");

    byte[] logoBytes = null;

    long fileEntryId = ParamUtil.getLong(actionRequest, "fileEntryId");

    if (fileEntryId > 0) {
      FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);

      logoBytes = FileUtil.getBytes(fileEntry.getContentStream());
    }

    boolean site = ParamUtil.getBoolean(actionRequest, "site");
    List<Address> addresses = UsersAdminUtil.getAddresses(actionRequest);
    List<EmailAddress> emailAddresses = UsersAdminUtil.getEmailAddresses(actionRequest);
    List<OrgLabor> orgLabors = UsersAdminUtil.getOrgLabors(actionRequest);
    List<Phone> phones = UsersAdminUtil.getPhones(actionRequest);
    List<Website> websites = UsersAdminUtil.getWebsites(actionRequest);

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(Organization.class.getName(), actionRequest);

    Organization organization = null;

    if (organizationId <= 0) {

      // Add organization

      organization =
          OrganizationServiceUtil.addOrganization(
              parentOrganizationId,
              name,
              type,
              regionId,
              countryId,
              statusId,
              comments,
              site,
              addresses,
              emailAddresses,
              orgLabors,
              phones,
              websites,
              serviceContext);
    } else {

      // Update organization

      organization =
          OrganizationServiceUtil.updateOrganization(
              organizationId,
              parentOrganizationId,
              name,
              type,
              regionId,
              countryId,
              statusId,
              comments,
              !deleteLogo,
              logoBytes,
              site,
              addresses,
              emailAddresses,
              orgLabors,
              phones,
              websites,
              serviceContext);
    }

    // Layout set prototypes

    long publicLayoutSetPrototypeId =
        ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId");
    long privateLayoutSetPrototypeId =
        ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId");
    boolean publicLayoutSetPrototypeLinkEnabled =
        ParamUtil.getBoolean(
            actionRequest, "publicLayoutSetPrototypeLinkEnabled", (publicLayoutSetPrototypeId > 0));
    boolean privateLayoutSetPrototypeLinkEnabled =
        ParamUtil.getBoolean(
            actionRequest,
            "privateLayoutSetPrototypeLinkEnabled",
            (privateLayoutSetPrototypeId > 0));

    Group organizationGroup = organization.getGroup();

    if (GroupPermissionUtil.contains(
        themeDisplay.getPermissionChecker(), organizationGroup, ActionKeys.UPDATE)) {

      SitesUtil.updateLayoutSetPrototypesLinks(
          organizationGroup,
          publicLayoutSetPrototypeId,
          privateLayoutSetPrototypeId,
          publicLayoutSetPrototypeLinkEnabled,
          privateLayoutSetPrototypeLinkEnabled);
    }

    // Reminder queries

    String reminderQueries = actionRequest.getParameter("reminderQueries");

    PortletPreferences portletPreferences = organization.getPreferences();

    LocalizationUtil.setLocalizedPreferencesValues(
        actionRequest, portletPreferences, "reminderQueries");

    portletPreferences.setValue("reminderQueries", reminderQueries);

    portletPreferences.store();

    return organization;
  }
コード例 #18
0
  @Override
  public Group updateGroup(
      long groupId,
      long parentGroupId,
      Map<Locale, String> nameMap,
      Map<Locale, String> descriptionMap,
      int type,
      boolean manualMembership,
      int membershipRestriction,
      String friendlyURL,
      boolean inheritContent,
      boolean active,
      ServiceContext serviceContext)
      throws PortalException {

    Group group = groupPersistence.findByPrimaryKey(groupId);

    GroupPermissionUtil.check(getPermissionChecker(), group, ActionKeys.UPDATE);

    if (group.getParentGroupId() != parentGroupId) {
      if (parentGroupId == GroupConstants.DEFAULT_PARENT_GROUP_ID) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_COMMUNITY);
      } else {
        GroupPermissionUtil.check(getPermissionChecker(), parentGroupId, ActionKeys.ADD_COMMUNITY);
      }
    }

    if (group.isSite()) {
      Group oldGroup = group;

      List<AssetCategory> oldAssetCategories =
          assetCategoryLocalService.getCategories(Group.class.getName(), groupId);

      List<AssetTag> oldAssetTags = assetTagLocalService.getTags(Group.class.getName(), groupId);

      ExpandoBridge oldExpandoBridge = oldGroup.getExpandoBridge();

      Map<String, Serializable> oldExpandoAttributes = oldExpandoBridge.getAttributes();

      group =
          groupLocalService.updateGroup(
              groupId,
              parentGroupId,
              nameMap,
              descriptionMap,
              type,
              manualMembership,
              membershipRestriction,
              friendlyURL,
              inheritContent,
              active,
              serviceContext);

      SiteMembershipPolicyUtil.verifyPolicy(
          group, oldGroup, oldAssetCategories, oldAssetTags, oldExpandoAttributes, null);

      return group;
    } else {
      return groupLocalService.updateGroup(
          groupId,
          parentGroupId,
          nameMap,
          descriptionMap,
          type,
          manualMembership,
          membershipRestriction,
          friendlyURL,
          inheritContent,
          active,
          serviceContext);
    }
  }
コード例 #19
0
  /**
   * Deletes the group.
   *
   * <p>The group is unstaged and its assets and resources including layouts, membership requests,
   * subscriptions, teams, blogs, bookmarks, calendar events, image gallery, journals, message
   * boards, polls, shopping related entities, and wikis are also deleted.
   *
   * @param groupId the primary key of the group
   * @throws PortalException if a portal exception occurred
   */
  @Override
  public void deleteGroup(long groupId) throws PortalException {
    GroupPermissionUtil.check(getPermissionChecker(), groupId, ActionKeys.DELETE);

    groupLocalService.deleteGroup(groupId);
  }
コード例 #20
0
ファイル: ActionUtil.java プロジェクト: hu437/liferay-portal
  public static void getRole(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    long roleId = ParamUtil.getLong(request, "roleId");

    Role role = null;

    Group group = (Group) request.getAttribute(WebKeys.GROUP);

    if ((group != null) && group.isOrganization()) {
      long organizationId = group.getOrganizationId();

      while (organizationId != OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID) {

        Organization organization = OrganizationLocalServiceUtil.getOrganization(organizationId);

        long organizationGroupId = organization.getGroupId();

        if (GroupPermissionUtil.contains(
                permissionChecker, organizationGroupId, ActionKeys.ASSIGN_USER_ROLES)
            || OrganizationPermissionUtil.contains(
                permissionChecker, organizationId, ActionKeys.ASSIGN_USER_ROLES)
            || UserGroupRoleLocalServiceUtil.hasUserGroupRole(
                themeDisplay.getUserId(),
                organizationGroupId,
                RoleConstants.ORGANIZATION_ADMINISTRATOR,
                true)
            || UserGroupRoleLocalServiceUtil.hasUserGroupRole(
                themeDisplay.getUserId(),
                organizationGroupId,
                RoleConstants.ORGANIZATION_OWNER,
                true)) {

          if (roleId > 0) {
            role = RoleLocalServiceUtil.getRole(roleId);
          }

          break;
        }

        organizationId = organization.getParentOrganizationId();
      }

      if ((roleId > 0) && (role == null)) {
        role = RoleServiceUtil.getRole(roleId);
      }
    } else if ((group != null) && group.isRegularSite()) {
      if (GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.ASSIGN_USER_ROLES)
          || UserGroupRoleLocalServiceUtil.hasUserGroupRole(
              themeDisplay.getUserId(), group.getGroupId(), RoleConstants.SITE_ADMINISTRATOR, true)
          || UserGroupRoleLocalServiceUtil.hasUserGroupRole(
              themeDisplay.getUserId(), group.getGroupId(), RoleConstants.SITE_OWNER, true)) {

        if (roleId > 0) {
          role = RoleLocalServiceUtil.getRole(roleId);
        }
      } else {
        if (roleId > 0) {
          role = RoleServiceUtil.getRole(roleId);
        }
      }
    } else {
      if (roleId > 0) {
        role = RoleServiceUtil.getRole(roleId);
      }
    }

    request.setAttribute(WebKeys.ROLE, role);
  }
コード例 #21
0
  @Override
  protected boolean hasPermissionImplicitlyGranted(
      PermissionChecker permissionChecker, Group group, Portlet portlet) throws Exception {

    return GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.MANAGE_LAYOUTS);
  }
コード例 #22
0
  /**
   * Returns the user's groups &quot;sites&quot; associated with the group entity class names,
   * including the Control Panel group if the user is permitted to view the Control Panel.
   *
   * <ul>
   *   <li>Class name &quot;User&quot; includes the user's layout set group.
   *   <li>Class name &quot;Organization&quot; includes the user's immediate organization groups and
   *       inherited organization groups.
   *   <li>Class name &quot;Group&quot; includes the user's immediate organization groups and site
   *       groups.
   *   <li>A <code>classNames</code> value of <code>null</code> includes the user's layout set
   *       group, organization groups, inherited organization groups, and site groups.
   * </ul>
   *
   * @param userId the primary key of the user
   * @param classNames the group entity class names (optionally <code>null</code>). For more
   *     information see {@link #getUserSitesGroups(long, String[], int)}.
   * @param max the maximum number of groups to return
   * @return the user's groups &quot;sites&quot;
   * @throws PortalException if a portal exception occurred
   */
  @Override
  public List<Group> getUserSitesGroups(long userId, String[] classNames, int max)
      throws PortalException {

    User user = userPersistence.findByPrimaryKey(userId);

    if (user.isDefaultUser()) {
      return Collections.emptyList();
    }

    Set<Group> userSiteGroups = new LinkedHashSet<>();

    if (classNames == null) {
      classNames =
          new String[] {
            Company.class.getName(), Group.class.getName(),
            Organization.class.getName(), User.class.getName()
          };
    }

    if (ArrayUtil.contains(classNames, User.class.getName())) {
      if (PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_ENABLED
          || PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_ENABLED) {

        userSiteGroups.add(user.getGroup());

        if (userSiteGroups.size() == max) {
          return new ArrayList<>(userSiteGroups);
        }
      }
    }

    if (ArrayUtil.contains(classNames, Company.class.getName())) {
      Group companyGroup = groupLocalService.getCompanyGroup(user.getCompanyId());

      if (GroupPermissionUtil.contains(
          getPermissionChecker(), companyGroup, ActionKeys.VIEW_SITE_ADMINISTRATION)) {

        userSiteGroups.add(companyGroup);

        if (userSiteGroups.size() == max) {
          return new ArrayList<>(userSiteGroups);
        }
      }
    }

    if (ArrayUtil.contains(classNames, Group.class.getName())
        || ArrayUtil.contains(classNames, Organization.class.getName())) {

      UserBag userBag = UserBagFactoryUtil.create(userId);

      if (ArrayUtil.contains(classNames, Group.class.getName())) {
        for (Group group : userBag.getUserGroups()) {
          if (group.isActive() && group.isSite()) {
            if (userSiteGroups.add(group) && (userSiteGroups.size() == max)) {

              return new ArrayList<>(userSiteGroups);
            }
          }
        }
      }

      if (ArrayUtil.contains(classNames, Organization.class.getName())) {
        for (Group group : userBag.getUserOrgGroups()) {
          if (group.isActive() && group.isSite()) {
            if (userSiteGroups.add(group) && (userSiteGroups.size() == max)) {

              return new ArrayList<>(userSiteGroups);
            }
          }
        }
      }
    }

    return new ArrayList<>(userSiteGroups);
  }