Class GroupServiceUtil

Object
com.liferay.portal.kernel.service.GroupServiceUtil

public class GroupServiceUtil extends Object
Provides the remote service utility for Group. This utility wraps com.liferay.portal.service.impl.GroupServiceImpl and is an access point for service operations in application layer code running on a remote server. Methods of this service are expected to have security checks based on the propagated JAAS credentials because this service can be accessed remotely.
Author:
Brian Wing Shun Chan
See Also:
{$generated.description}
  • Constructor Details

    • GroupServiceUtil

      public GroupServiceUtil()
  • Method Details

    • addGroup

      public static 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
      Throws:
      PortalException
    • addGroup

      public static 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 active, ServiceContext serviceContext) throws PortalException
      Throws:
      PortalException
    • addOrUpdateGroup

      public static Group addOrUpdateGroup(String externalReferenceCode, 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 Exception
      Throws:
      Exception
    • addRoleGroups

      public static void addRoleGroups(long roleId, long[] groupIds) throws PortalException
      Adds the groups to the role.
      Parameters:
      roleId - the primary key of the role
      groupIds - the primary keys of the groups
      Throws:
      PortalException - if a portal exception occurred
    • checkRemoteStagingGroup

      public static void checkRemoteStagingGroup(long groupId) throws PortalException
      Checks that the current user is permitted to use the group for Remote Staging.
      Parameters:
      groupId - the primary key of the group
      Throws:
      PortalException - if a portal exception occurred
    • deleteGroup

      public static void deleteGroup(long groupId) throws PortalException
      Deletes the group.

      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, and wikis are also deleted.

      Parameters:
      groupId - the primary key of the group
      Throws:
      PortalException - if a portal exception occurred
    • disableStaging

      public static void disableStaging(long groupId) throws PortalException
      Throws:
      PortalException
    • enableStaging

      public static void enableStaging(long groupId) throws PortalException
      Throws:
      PortalException
    • fetchGroupByExternalReferenceCode

      public static Group fetchGroupByExternalReferenceCode(String externalReferenceCode, long companyId) throws PortalException
      Throws:
      PortalException
    • getCompanyGroup

      public static Group getCompanyGroup(long companyId) throws PortalException
      Returns the company group.
      Parameters:
      companyId - the primary key of the company
      Returns:
      the group associated with the company
      Throws:
      PortalException - if a portal exception occurred
    • getGroup

      public static Group getGroup(long groupId) throws PortalException
      Returns the group with the primary key.
      Parameters:
      groupId - the primary key of the group
      Returns:
      the group with the primary key
      Throws:
      PortalException - if a portal exception occurred
    • getGroup

      public static Group getGroup(long companyId, String groupKey) throws PortalException
      Returns the group with the name.
      Parameters:
      companyId - the primary key of the company
      groupKey - the group key
      Returns:
      the group with the group key
      Throws:
      PortalException - if a portal exception occurred
    • getGroupDisplayURL

      public static String getGroupDisplayURL(long groupId, boolean privateLayout, boolean secureConnection) throws PortalException
      Returns the group's display URL.
      Parameters:
      groupId - the primary key of the group
      privateLayout - whether the layout set is private to the group
      secureConnection - whether the generated URL uses a secure connection
      Returns:
      the group's display URL
      Throws:
      PortalException - if a group with the primary key could not be found or if a portal exception occurred
    • getGroups

      public static List<Group> getGroups(long companyId, long parentGroupId, boolean site) throws PortalException
      Returns all the groups that are direct children of the parent group.
      Parameters:
      companyId - the primary key of the company
      parentGroupId - the primary key of the parent group
      site - whether the group is to be associated with a main site
      Returns:
      the matching groups, or null if no matches were found
      Throws:
      PortalException - if a portal exception occurred
    • getGroups

      public static List<Group> getGroups(long companyId, long parentGroupId, boolean site, int start, int end) throws PortalException
      Returns all the groups that are direct children of the parent group.
      Parameters:
      companyId - the primary key of the company
      parentGroupId - the primary key of the parent group
      site - whether the group is to be associated with a main site
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the matching groups, or null if no matches were found
      Throws:
      PortalException - if a portal exception occurred
    • getGroups

      public static List<Group> getGroups(long companyId, long parentGroupId, String name, boolean site, int start, int end) throws PortalException
      Throws:
      PortalException
    • getGroupsCount

      public static int getGroupsCount(long companyId, long parentGroupId, boolean site) throws PortalException
      Returns the number of groups that are direct children of the parent group.
      Parameters:
      companyId - the primary key of the company
      parentGroupId - the primary key of the parent group
      site - whether the group is to be associated with a main site
      Returns:
      the number of matching groups
      Throws:
      PortalException
    • getGroupsCount

      public static int getGroupsCount(long companyId, long parentGroupId, String name, boolean site) throws PortalException
      Throws:
      PortalException
    • getGroupsCount

      public static int getGroupsCount(long companyId, String className, long parentGroupId) throws PortalException
      Returns the number of groups that are direct children of the parent group with the matching className.
      Parameters:
      companyId - the primary key of the company
      className - the class name of the group
      parentGroupId - the primary key of the parent group
      Returns:
      the number of matching groups
      Throws:
      PortalException
    • getGtGroups

      public static List<Group> getGtGroups(long gtGroupId, long companyId, long parentGroupId, boolean site, int size) throws PortalException
      Throws:
      PortalException
    • getManageableSiteGroups

      public static List<Group> getManageableSiteGroups(Collection<Portlet> portlets, int max) throws PortalException
      Returns a range of all the site groups for which the user has control panel access.
      Parameters:
      portlets - the portlets to manage
      max - the upper bound of the range of groups to consider (not inclusive)
      Returns:
      the range of site groups for which the user has Control Panel access
      Throws:
      PortalException - if a portal exception occurred
    • getOrganizationsGroups

      public static List<Group> getOrganizationsGroups(List<Organization> organizations) throws PortalException
      Returns the groups associated with the organizations.
      Parameters:
      organizations - the organizations
      Returns:
      the groups associated with the organizations
      Throws:
      PortalException - if a portal exception occurred
    • getOSGiServiceIdentifier

      public static String getOSGiServiceIdentifier()
      Returns the OSGi service identifier.
      Returns:
      the OSGi service identifier
    • getUserGroup

      public static Group getUserGroup(long companyId, long userId) throws PortalException
      Returns the group directly associated with the user.
      Parameters:
      companyId - the primary key of the company
      userId - the primary key of the user
      Returns:
      the group directly associated with the user
      Throws:
      PortalException - if a portal exception occurred
    • getUserGroupsGroups

      public static List<Group> getUserGroupsGroups(List<UserGroup> userGroups) throws PortalException
      Returns the groups associated with the user groups.
      Parameters:
      userGroups - the user groups
      Returns:
      the groups associated with the user groups
      Throws:
      PortalException - if a portal exception occurred
    • getUserOrganizationsGroups

      public static List<Group> getUserOrganizationsGroups(long userId, int start, int end) throws PortalException
      Returns the range of all groups associated with the user's organization groups, including the ancestors of the organization groups, unless portal property organizations.membership.strict is set to true.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set.

      Parameters:
      userId - the primary key of the user
      start - the lower bound of the range of groups to consider
      end - the upper bound of the range of groups to consider (not inclusive)
      Returns:
      the range of groups associated with the user's organizations
      Throws:
      PortalException - if a portal exception occurred
    • getUserSitesGroups

      public static List<Group> getUserSitesGroups() throws PortalException
      Throws:
      PortalException
    • getUserSitesGroups

      public static List<Group> getUserSitesGroups(long userId, int start, int end) throws PortalException
      Throws:
      PortalException
    • getUserSitesGroups

      public static List<Group> getUserSitesGroups(long userId, String[] classNames, int max) throws PortalException
      Returns the user's groups "sites" associated with the group entity class names, including the Control Panel group if the user is permitted to view the Control Panel.
      • Class name "User" includes the user's layout set group.
      • Class name "Organization" includes the user's immediate organization groups and inherited organization groups.
      • Class name "Group" includes the user's immediate organization groups and site groups.
      • A classNames value of null includes the user's layout set group, organization groups, inherited organization groups, and site groups.
      Parameters:
      userId - the primary key of the user
      classNames - the group entity class names (optionally null). For more information see getUserSitesGroups(long, String[], int).
      max - the maximum number of groups to return
      Returns:
      the user's groups "sites"
      Throws:
      PortalException - if a portal exception occurred
    • getUserSitesGroups

      public static List<Group> getUserSitesGroups(String[] classNames, int max) throws PortalException
      Returns the guest or current user's groups "sites" associated with the group entity class names, including the Control Panel group if the user is permitted to view the Control Panel.
      • Class name "User" includes the user's layout set group.
      • Class name "Organization" includes the user's immediate organization groups and inherited organization groups.
      • Class name "Group" includes the user's immediate organization groups and site groups.
      • A classNames value of null includes the user's layout set group, organization groups, inherited organization groups, and site groups.
      Parameters:
      classNames - the group entity class names (optionally null). For more information see getUserSitesGroups(long, String[], int).
      max - the maximum number of groups to return
      Returns:
      the user's groups "sites"
      Throws:
      PortalException - if a portal exception occurred
    • getUserSitesGroupsCount

      public static int getUserSitesGroupsCount() throws PortalException
      Returns the number of the guest or current user's groups "sites" associated with the group entity class names, including the Control Panel group if the user is permitted to view the Control Panel.
      Returns:
      the number of user's groups "sites"
      Throws:
      PortalException - if a portal exception occurred
    • hasUserGroup

      public static boolean hasUserGroup(long userId, long groupId) throws PortalException
      Returns true if the user is associated with the group, including the user's inherited organizations and user groups. System and staged groups are not included.
      Parameters:
      userId - the primary key of the user
      groupId - the primary key of the group
      Returns:
      true if the user is associated with the group; false otherwise
      Throws:
      PortalException - if a portal exception occurred
    • search

      public static List<Group> search(long companyId, long[] classNameIds, String keywords, LinkedHashMap<String,Object> params, int start, int end, OrderByComparator<Group> orderByComparator) throws PortalException
      Throws:
      PortalException
    • search

      public static List<Group> search(long companyId, long[] classNameIds, String name, String description, LinkedHashMap<String,Object> params, boolean andOperator, int start, int end, OrderByComparator<Group> orderByComparator) throws PortalException
      Throws:
      PortalException
    • search

      public static List<Group> search(long companyId, String name, String description, String[] params, int start, int end) throws PortalException
      Returns an ordered range of all the site groups and organization groups that match the name and description, optionally including the user's inherited organization groups and user groups. System and staged groups are not included.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set.

      Parameters:
      companyId - the primary key of the company
      name - the group's name (optionally null)
      description - the group's description (optionally null)
      params - the finder params (optionally null). To include the user's inherited organizations and user groups in the search, add entries having "usersGroups" and "inherit" as keys mapped to the the user's ID. For more information see GroupFinder.
      start - the lower bound of the range of groups to return
      end - the upper bound of the range of groups to return (not inclusive)
      Returns:
      the matching groups ordered by name
      Throws:
      PortalException - if a portal exception occurred
    • searchCount

      public static int searchCount(long companyId, long[] classNameIds, String keywords, LinkedHashMap<String,Object> params)
    • searchCount

      public static int searchCount(long companyId, String name, String description, String[] params)
      Returns the number of groups and organization groups that match the name and description, optionally including the user's inherited organizations and user groups. System and staged groups are not included.
      Parameters:
      companyId - the primary key of the company
      name - the group's name (optionally null)
      description - the group's description (optionally null)
      params - the finder params (optionally null). To include the user's inherited organizations and user groups in the search, add entries having "usersGroups" and "inherit" as keys mapped to the the user's ID. For more information see GroupFinder.
      Returns:
      the number of matching groups
    • setRoleGroups

      public static void setRoleGroups(long roleId, long[] groupIds) throws PortalException
      Sets the groups associated with the role, removing and adding associations as necessary.
      Parameters:
      roleId - the primary key of the role
      groupIds - the primary keys of the groups
      Throws:
      PortalException - if a portal exception occurred
    • unsetRoleGroups

      public static void unsetRoleGroups(long roleId, long[] groupIds) throws PortalException
      Removes the groups from the role.
      Parameters:
      roleId - the primary key of the role
      groupIds - the primary keys of the groups
      Throws:
      PortalException - if a portal exception occurred
    • updateFriendlyURL

      public static Group updateFriendlyURL(long groupId, String friendlyURL) throws PortalException
      Updates the group's friendly URL.
      Parameters:
      groupId - the primary key of the group
      friendlyURL - the group's new friendlyURL (optionally null)
      Returns:
      the group
      Throws:
      PortalException - if a portal exception occurred
    • updateGroup

      public static 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
      Throws:
      PortalException
    • updateGroup

      public static Group updateGroup(long groupId, String typeSettings) throws PortalException
      Updates the group's type settings.
      Parameters:
      groupId - the primary key of the group
      typeSettings - the group's new type settings (optionally null)
      Returns:
      the group
      Throws:
      PortalException - if a portal exception occurred
    • updateStagedPortlets

      public static void updateStagedPortlets(long groupId, Map<String,String> stagedPortletIds) throws PortalException
      Throws:
      PortalException
    • getService

      public static GroupService getService()
    • setService

      public static void setService(GroupService service)