use of com.liferay.portal.model.UserGroup in project liferay-ide by liferay.
the class UserLocalServiceImpl method getUserGroupUsersCount.
/**
* Returns the number of users with the status belonging to the user group.
*
* @param userGroupId the primary key of the user group
* @param status the workflow status
* @return the number of users with the status belonging to the user group
* @throws PortalException if a user group with the primary key could not be
* found
* @throws SystemException if a system exception occurred
*/
@Override
public int getUserGroupUsersCount(long userGroupId, int status) throws PortalException, SystemException {
UserGroup userGroup = userGroupPersistence.findByPrimaryKey(userGroupId);
LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();
params.put("usersUserGroups", new Long(userGroupId));
return searchCount(userGroup.getCompanyId(), null, status, params);
}
use of com.liferay.portal.model.UserGroup in project liferay-ide by liferay.
the class UserLocalServiceImpl method addDefaultUserGroups.
/**
* Adds the user to the default user groups, unless the user is already in
* these user groups. The default user groups can be specified in
* <code>portal.properties</code> with the property
* <code>admin.default.user.group.names</code>.
*
* @param userId the primary key of the user
* @throws PortalException if a user with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
@SuppressWarnings("deprecation")
public void addDefaultUserGroups(long userId) throws PortalException, SystemException {
User user = userPersistence.findByPrimaryKey(userId);
Set<Long> userGroupIdSet = new HashSet<Long>();
String[] defaultUserGroupNames = PrefsPropsUtil.getStringArray(user.getCompanyId(), PropsKeys.ADMIN_DEFAULT_USER_GROUP_NAMES, StringPool.NEW_LINE, PropsValues.ADMIN_DEFAULT_USER_GROUP_NAMES);
for (String defaultUserGroupName : defaultUserGroupNames) {
try {
UserGroup userGroup = userGroupPersistence.findByC_N(user.getCompanyId(), defaultUserGroupName);
if (!userPersistence.containsUserGroup(userId, userGroup.getUserGroupId())) {
userGroupIdSet.add(userGroup.getUserGroupId());
}
} catch (NoSuchUserGroupException nsuge) {
}
}
long[] userGroupIds = ArrayUtil.toArray(userGroupIdSet.toArray(new Long[userGroupIdSet.size()]));
if (PropsValues.USER_GROUPS_COPY_LAYOUTS_TO_USER_PERSONAL_SITE) {
for (long userGroupId : userGroupIds) {
userGroupLocalService.copyUserGroupLayouts(userGroupId, userId);
}
}
userPersistence.addUserGroups(userId, userGroupIds);
}
Aggregations