你可以使用
public List<Group> getGroups(long companyId, long parentGroupId, boolean site)
组的LocalServiceUtil(
https://docs.liferay.com/dxp/digital-enterprise/7.0-sp1/javadocs/portal-kernel/com/liferay/portal/kernel/service/GroupLocalServiceUtil.html#getGroups-long-long-boolean-
)。当您不在基于OSGi的portlet中时,应该可以调用它。如果您在OSGi组件中,可以注入GroupLocalService。
如果您不关心parent group,可以使用groupconstants.any_parent_group_id作为parent group id。