use of com.liferay.portal.model.Team in project liferay-ide by liferay.
the class UserLocalServiceImpl method unsetGroupTeamsUsers.
/**
* Removes the users from the teams of a group.
*
* @param groupId the primary key of the group
* @param userIds the primary keys of the users
* @throws PortalException if a portal exception occurred
* @throws SystemException if a system exception occurred
*/
@Override
public void unsetGroupTeamsUsers(long groupId, long[] userIds) throws PortalException, SystemException {
List<Team> teams = teamPersistence.findByGroupId(groupId);
for (Team team : teams) {
unsetTeamUsers(team.getTeamId(), userIds);
}
PermissionCacheUtil.clearCache();
}
use of com.liferay.portal.model.Team in project liferay-ide by liferay.
the class UserLocalServiceImpl method addDefaultRolesAndTeams.
protected void addDefaultRolesAndTeams(long groupId, long[] userIds) throws PortalException, SystemException {
List<Role> defaultSiteRoles = new ArrayList<Role>();
Group group = groupLocalService.getGroup(groupId);
UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties();
long[] defaultSiteRoleIds = StringUtil.split(typeSettingsProperties.getProperty("defaultSiteRoleIds"), 0L);
for (long defaultSiteRoleId : defaultSiteRoleIds) {
Role defaultSiteRole = rolePersistence.fetchByPrimaryKey(defaultSiteRoleId);
if (defaultSiteRole == null) {
if (_log.isWarnEnabled()) {
_log.warn("Unable to find role " + defaultSiteRoleId);
}
continue;
}
defaultSiteRoles.add(defaultSiteRole);
}
List<Team> defaultTeams = new ArrayList<Team>();
long[] defaultTeamIds = StringUtil.split(typeSettingsProperties.getProperty("defaultTeamIds"), 0L);
for (long defaultTeamId : defaultTeamIds) {
Team defaultTeam = teamPersistence.findByPrimaryKey(defaultTeamId);
if (defaultTeam == null) {
if (_log.isWarnEnabled()) {
_log.warn("Unable to find team " + defaultTeamId);
}
continue;
}
defaultTeams.add(defaultTeam);
}
for (long userId : userIds) {
Set<Long> userRoleIdsSet = new HashSet<Long>();
for (Role role : defaultSiteRoles) {
if (!userPersistence.containsRole(userId, role.getRoleId())) {
userRoleIdsSet.add(role.getRoleId());
}
}
long[] userRoleIds = ArrayUtil.toArray(userRoleIdsSet.toArray(new Long[userRoleIdsSet.size()]));
userGroupRoleLocalService.addUserGroupRoles(userId, groupId, userRoleIds);
Set<Long> userTeamIdsSet = new HashSet<Long>();
for (Team team : defaultTeams) {
if (!userPersistence.containsTeam(userId, team.getTeamId())) {
userTeamIdsSet.add(team.getTeamId());
}
}
long[] userTeamIds = ArrayUtil.toArray(userTeamIdsSet.toArray(new Long[userTeamIdsSet.size()]));
userPersistence.addTeams(userId, userTeamIds);
}
}
Aggregations