@Override public UserGroup findByName(String userGroupName, long companyId) { try { return userGroupLocalService.getUserGroup(companyId, userGroupName); } catch (Exception e) { String msg = String.format("Unable to find UserGroup [%s] for companyId [%s]", userGroupName, companyId); log(msg, e); } return null; }
internalAccess = userExpandoHelper.get("isInternalAccess", user); int cnt = userGroupLocalService.getUserGroupsCount(); List<UserGroup> allUserGroups = userGroupLocalService.getUserGroups(0, cnt); List<UserGroup> allInternalUserGroups = internalOnlyGroups(allUserGroups); List<UserGroup> userGroups = user.getUserGroups();
@Override public void delete(UserGroup userGroup) { try { List<User> users = userLocalService.getUserGroupUsers(userGroup.getUserGroupId()); long[] userIds = toIdArray(users.toArray(new User[]{})); userLocalService.unsetUserGroupUsers(userGroup.getUserGroupId(), userIds); userGroupLocalService.deleteUserGroup(userGroup); } catch (Exception e) { String msg = String.format("Failed to delete UserGroup [%s]", userGroup.getName()); log(msg, e); throw new RuntimeException(msg, e); } }
@Override public void createIfNeeded(String userGroupName, long companyId) { try { if (findByName(userGroupName, companyId) != null) return; User systemUser = liferayAutomation.lookupSysadmin(companyId); String description = liferayAutomation.autoCreateDescription(); userGroupLocalService.addUserGroup(systemUser.getUserId(), systemUser.getCompanyId(), userGroupName, description); } catch (Exception e) { String msg = String.format("Failed to create UserGroup [%s]", userGroupName); log(msg, e); throw new RuntimeException(msg, e); } }
@Override public void rename(String newUserGroupName, UserGroup userGroup) { try { String description = liferayAutomation.autoRenameDescription(userGroup.getName(), newUserGroupName); userGroup.setName(newUserGroupName); userGroup.setDescription(userGroup.getDescription() + description); userGroupLocalService.updateUserGroup(userGroup); } catch (Exception e) { String msg = String.format("Failed to rename UserGroup from [%s] to [%s]", userGroup.getName(), newUserGroupName); log(msg, e); throw new RuntimeException(msg, e); } }
externalSithsAccess = externalSithsAccess != null ? externalSithsAccess : false; int cnt = userGroupLocalService.getUserGroupsCount(); List<UserGroup> allUserGroups = userGroupLocalService.getUserGroups(0, cnt); List<UserGroup> allExternallySithsOnlyGroups = externallySithsOnlyGroups(allUserGroups); List<UserGroup> userGroups = user.getUserGroups();