List of usage examples for com.liferay.portal.kernel.model UserGroupRole getUser
public User getUser() throws com.liferay.portal.kernel.exception.PortalException;
From source file:com.liferay.flags.internal.messaging.FlagsRequestMessageListener.java
License:Open Source License
protected Set<User> getRecipients(long companyId, long groupId) throws PortalException { Set<User> recipients = new LinkedHashSet<>(); List<String> roleNames = new ArrayList<>(); Group group = _groupLocalService.getGroup(groupId); if (group.isSite()) { roleNames.add(RoleConstants.SITE_ADMINISTRATOR); roleNames.add(RoleConstants.SITE_OWNER); }//from ww w . j a va 2 s.co m if (group.isCompany()) { roleNames.add(RoleConstants.ADMINISTRATOR); } else if (group.isOrganization()) { roleNames.add(RoleConstants.ORGANIZATION_ADMINISTRATOR); roleNames.add(RoleConstants.ORGANIZATION_OWNER); } for (String roleName : roleNames) { Role role = _roleLocalService.getRole(companyId, roleName); List<UserGroupRole> userGroupRoles = _userGroupRoleLocalService.getUserGroupRolesByGroupAndRole(groupId, role.getRoleId()); for (UserGroupRole userGroupRole : userGroupRoles) { recipients.add(userGroupRole.getUser()); } } if (recipients.isEmpty()) { Role role = _roleLocalService.getRole(companyId, RoleConstants.ADMINISTRATOR); recipients.addAll(_userLocalService.getRoleUsers(role.getRoleId())); } return recipients; }
From source file:se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.java
License:Open Source License
private LinkedList<String> getUserGroupRoleByRoleAndGroup(Idea idea, LinkedList<String> toEmail, String roleName) throws PortalException, SystemException { Role roleInnovationsslussen = roleLocalService.getRole(idea.getCompanyId(), roleName); List<UserGroupRole> roleUsersInnovationsslussen = userGroupRoleLocalService .getUserGroupRolesByGroupAndRole(idea.getGroupId(), roleInnovationsslussen.getRoleId()); for (UserGroupRole userGroupRole : roleUsersInnovationsslussen) { String email = userGroupRole.getUser().getEmailAddress(); if (!toEmail.contains(email)) { toEmail.add(email);/* www . j a va 2s .c o m*/ } } return toEmail; }