protected void addAllUsersToSite(long companyId, long groupId) throws Exception { List<User> users = UserLocalServiceUtil.getUsers(QueryUtil.ALL_POS, QueryUtil.ALL_POS); ArrayList<Long> userIdList = new ArrayList<Long>(); for (User user : users) { if (!user.isDefaultUser()) { userIdList.add(user.getUserId()); } } long[] userIds = new long[userIdList.size()]; for (int i = 0; i < userIds.length; i++) { userIds[i] = userIdList.get(i); } UserLocalServiceUtil.addGroupUsers(groupId, userIds); }