use of com.ableneo.liferay.portal.setup.domain.UserGroupAsMember in project liferay-db-setup-core by ableneo.
the class SetupSites method assignMemberGroups.
private static void assignMemberGroups(List<UserGroupAsMember> memberGroups, long companyId, long groupId) {
if (Objects.isNull(memberGroups) || memberGroups.isEmpty()) {
return;
}
for (UserGroupAsMember memberGroup : memberGroups) {
try {
UserGroup liferayUserGroup = UserGroupLocalServiceUtil.getUserGroup(companyId, memberGroup.getUserGroupName());
Group liferayGroup = GroupLocalServiceUtil.getGroup(groupId);
GroupLocalServiceUtil.addUserGroupGroup(liferayUserGroup.getUserGroupId(), liferayGroup);
LOG.info(String.format("UserGroup %1$s was assigned as site member to %2$s", liferayUserGroup.getName(), liferayGroup.getDescriptiveName()));
assignGroupMemberRoles(memberGroup.getRole(), companyId, liferayGroup, liferayUserGroup);
} catch (PortalException e) {
LOG.error(String.format("Cannot find UserGroup with name: %1$s. Group won't be assigned to site.", memberGroup.getUserGroupName()), e);
}
}
}
Aggregations