protected void updateViewControlPanelPermission( Role role, long scopeGroupId, String portletId, int scope, String[] groupIds) throws Exception { PanelCategoryHelper panelCategoryHelper = new PanelCategoryHelper(_panelAppRegistry, _panelCategoryRegistry); String selResource = null; String actionId = null; if (panelCategoryHelper.containsPortlet(portletId, PanelCategoryKeys.CONTROL_PANEL) && (role.getType() == RoleConstants.TYPE_REGULAR)) { selResource = PortletKeys.PORTAL; actionId = ActionKeys.VIEW_CONTROL_PANEL; } else if (panelCategoryHelper.containsPortlet( portletId, PanelCategoryKeys.SITE_ADMINISTRATION)) { selResource = Group.class.getName(); actionId = ActionKeys.VIEW_SITE_ADMINISTRATION; } if (selResource != null) { updateAction(role, scopeGroupId, selResource, actionId, true, scope, groupIds); } }
/** * Deletes the role and its associated permissions. * * @param role the role * @return the deleted role * @throws PortalException if the role is a default system role or if the role's resource could * not be found * @throws SystemException if a system exception occurred */ @Override public Role deleteRole(Role role) throws PortalException, SystemException { if (PortalUtil.isSystemRole(role.getName())) { throw new RequiredRoleException(); } // Resources String className = role.getClassName(); long classNameId = role.getClassNameId(); if ((classNameId <= 0) || className.equals(Role.class.getName())) { resourceLocalService.deleteResource( role.getCompanyId(), Role.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, role.getRoleId()); } if ((role.getType() == RoleConstants.TYPE_ORGANIZATION) || (role.getType() == RoleConstants.TYPE_SITE)) { userGroupRoleLocalService.deleteUserGroupRolesByRoleId(role.getRoleId()); userGroupGroupRoleLocalService.deleteUserGroupGroupRolesByRoleId(role.getRoleId()); } // Role rolePersistence.remove(role); // Permission cache PermissionCacheUtil.clearCache(); return role; }
/** * Returns <code>true</code> if the user is associated with the named regular role. * * @param userId the primary key of the user * @param companyId the primary key of the company * @param name the name of the role * @param inherited whether to include the user's inherited roles in the search * @return <code>true</code> if the user is associated with the regular role; <code>false</code> * otherwise * @throws PortalException if a role with the name could not be found in the company or if a * default user for the company could not be found * @throws SystemException if a system exception occurred */ @ThreadLocalCachable public boolean hasUserRole(long userId, long companyId, String name, boolean inherited) throws PortalException, SystemException { Role role = rolePersistence.findByC_N(companyId, name); if (role.getType() != RoleConstants.TYPE_REGULAR) { throw new IllegalArgumentException(name + " is not a regular role"); } long defaultUserId = userLocalService.getDefaultUserId(companyId); if (userId == defaultUserId) { if (name.equals(RoleConstants.GUEST)) { return true; } else { return false; } } if (inherited) { if (userPersistence.containsRole(userId, role.getRoleId())) { return true; } ThreadLocalCache<Integer> threadLocalCache = ThreadLocalCacheManager.getThreadLocalCache( Lifecycle.REQUEST, RoleLocalServiceImpl.class.getName()); String key = String.valueOf(role.getRoleId()).concat(String.valueOf(userId)); Integer value = threadLocalCache.get(key); if (value == null) { value = roleFinder.countByR_U(role.getRoleId(), userId); threadLocalCache.put(key, value); } if (value > 0) { return true; } else { return false; } } else { return userPersistence.containsRole(userId, role.getRoleId()); } }
@Override public long[] getPooledActorsIds(long companyId, long workflowTaskInstanceId) throws WorkflowException { try { KaleoTaskInstanceToken kaleoTaskInstanceToken = KaleoTaskInstanceTokenLocalServiceUtil.getKaleoTaskInstanceToken(workflowTaskInstanceId); List<KaleoTaskAssignment> calculatedKaleoTaskAssignments = getCalculatedKaleoTaskAssignments(kaleoTaskInstanceToken); Map<String, Long> pooledActors = new TreeMap<>(new NaturalOrderStringComparator()); for (KaleoTaskAssignment calculatedKaleoTaskAssignment : calculatedKaleoTaskAssignments) { String assigneeClassName = calculatedKaleoTaskAssignment.getAssigneeClassName(); long assigneeClassPK = calculatedKaleoTaskAssignment.getAssigneeClassPK(); if (assigneeClassName.equals(User.class.getName())) { User user = UserLocalServiceUtil.fetchUser(assigneeClassPK); if (user != null) { pooledActors.put(user.getFullName(), user.getUserId()); } continue; } Role role = RoleLocalServiceUtil.getRole(calculatedKaleoTaskAssignment.getAssigneeClassPK()); if ((role.getType() == RoleConstants.TYPE_SITE) || (role.getType() == RoleConstants.TYPE_ORGANIZATION)) { List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole( kaleoTaskInstanceToken.getGroupId(), assigneeClassPK); for (UserGroupRole userGroupRole : userGroupRoles) { User user = userGroupRole.getUser(); pooledActors.put(user.getFullName(), user.getUserId()); } List<UserGroupGroupRole> userGroupGroupRoles = UserGroupGroupRoleLocalServiceUtil.getUserGroupGroupRolesByGroupAndRole( kaleoTaskInstanceToken.getGroupId(), assigneeClassPK); for (UserGroupGroupRole userGroupGroupRole : userGroupGroupRoles) { List<User> userGroupUsers = UserLocalServiceUtil.getUserGroupUsers(userGroupGroupRole.getUserGroupId()); for (User user : userGroupUsers) { pooledActors.put(user.getFullName(), user.getUserId()); } } } else { List<User> inheritedRoleUsers = UserLocalServiceUtil.getInheritedRoleUsers( assigneeClassPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); for (User user : inheritedRoleUsers) { pooledActors.put(user.getFullName(), user.getUserId()); } } } return ArrayUtil.toLongArray(pooledActors.values()); } catch (Exception e) { throw new WorkflowException(e); } }
public void addPermissions(String resourceName, long resourcePK) throws PortalException, SystemException { if (!MapUtil.getBoolean(_parameterMap, PortletDataHandlerKeys.PERMISSIONS)) { return; } List<KeyValuePair> permissions = new ArrayList<KeyValuePair>(); Group group = GroupLocalServiceUtil.getGroup(_groupId); List<Role> roles = RoleLocalServiceUtil.getRoles(_companyId); PrimitiveLongList roleIds = new PrimitiveLongList(roles.size()); Map<Long, String> roleIdsToNames = new HashMap<Long, String>(); for (Role role : roles) { int type = role.getType(); if ((type == RoleConstants.TYPE_REGULAR) || ((type == RoleConstants.TYPE_ORGANIZATION) && group.isOrganization()) || ((type == RoleConstants.TYPE_SITE) && (group.isLayoutSetPrototype() || group.isSite()))) { String name = role.getName(); roleIds.add(role.getRoleId()); roleIdsToNames.put(role.getRoleId(), name); } else if ((type == RoleConstants.TYPE_PROVIDER) && role.isTeam()) { Team team = TeamLocalServiceUtil.getTeam(role.getClassPK()); if (team.getGroupId() == _groupId) { String name = PermissionExporter.ROLE_TEAM_PREFIX + team.getName(); roleIds.add(role.getRoleId()); roleIdsToNames.put(role.getRoleId(), name); } } } List<String> actionIds = ResourceActionsUtil.getModelResourceActions(resourceName); Map<Long, Set<String>> roleIdsToActionIds = getActionIds(_companyId, roleIds.getArray(), resourceName, resourcePK, actionIds); for (Map.Entry<Long, String> entry : roleIdsToNames.entrySet()) { long roleId = entry.getKey(); String name = entry.getValue(); Set<String> availableActionIds = roleIdsToActionIds.get(roleId); if ((availableActionIds == null) || availableActionIds.isEmpty()) { continue; } KeyValuePair permission = new KeyValuePair(name, StringUtil.merge(availableActionIds)); permissions.add(permission); } _permissionsMap.put(getPrimaryKeyString(resourceName, resourcePK), permissions); }
public void updateActions(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long roleId = ParamUtil.getLong(actionRequest, "roleId"); Role role = RoleLocalServiceUtil.getRole(roleId); String roleName = role.getName(); if (roleName.equals(RoleConstants.ADMINISTRATOR) || roleName.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR) || roleName.equals(RoleConstants.ORGANIZATION_OWNER) || roleName.equals(RoleConstants.OWNER) || roleName.equals(RoleConstants.SITE_ADMINISTRATOR) || roleName.equals(RoleConstants.SITE_OWNER)) { throw new RolePermissionsException(roleName); } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); String[] relatedPortletResources = StringUtil.split(ParamUtil.getString(actionRequest, "relatedPortletResources")); String[] modelResources = StringUtil.split(ParamUtil.getString(actionRequest, "modelResources")); Map<String, List<String>> resourceActionsMap = new HashMap<>(); if (Validator.isNotNull(portletResource)) { resourceActionsMap.put( portletResource, ResourceActionsUtil.getResourceActions(portletResource, null)); } for (String relatedPortletResource : relatedPortletResources) { resourceActionsMap.put( relatedPortletResource, ResourceActionsUtil.getResourceActions(relatedPortletResource, null)); } for (String modelResource : modelResources) { resourceActionsMap.put( modelResource, ResourceActionsUtil.getResourceActions(null, modelResource)); } int rootResourceScope = ResourceConstants.SCOPE_COMPANY; String[] rootResourceGroupIds = null; String[] selectedTargets = StringUtil.split(ParamUtil.getString(actionRequest, "selectedTargets")); String[] unselectedTargets = StringUtil.split(ParamUtil.getString(actionRequest, "unselectedTargets")); for (Map.Entry<String, List<String>> entry : resourceActionsMap.entrySet()) { String selResource = entry.getKey(); List<String> actions = entry.getValue(); actions = ListUtil.sort(actions, new ActionComparator(themeDisplay.getLocale())); for (String actionId : actions) { String target = selResource + actionId; boolean selected = ArrayUtil.contains(selectedTargets, target); if (!selected && !ArrayUtil.contains(unselectedTargets, target)) { continue; } String[] groupIds = StringUtil.split(ParamUtil.getString(actionRequest, "groupIds" + target)); groupIds = ArrayUtil.distinct(groupIds); int scope = ResourceConstants.SCOPE_COMPANY; if ((role.getType() == RoleConstants.TYPE_ORGANIZATION) || (role.getType() == RoleConstants.TYPE_PROVIDER) || (role.getType() == RoleConstants.TYPE_SITE)) { scope = ResourceConstants.SCOPE_GROUP_TEMPLATE; } else { if (groupIds.length > 0) { scope = ResourceConstants.SCOPE_GROUP; } } if (ResourceBlockLocalServiceUtil.isSupported(selResource)) { updateActions_Blocks( role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); } else { updateAction( role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); } if (selected && actionId.equals(ActionKeys.ACCESS_IN_CONTROL_PANEL)) { updateViewControlPanelPermission( role, themeDisplay.getScopeGroupId(), selResource, scope, groupIds); rootResourceScope = scope; rootResourceGroupIds = groupIds; } } } // LPS-38031 if (rootResourceGroupIds != null) { updateViewRootResourcePermission( role, themeDisplay.getScopeGroupId(), portletResource, rootResourceScope, rootResourceGroupIds); } // Send redirect SessionMessages.add(actionRequest, "permissionsUpdated"); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } }
@Override protected void doImportStagedModel(PortletDataContext portletDataContext, Role role) throws Exception { long userId = portletDataContext.getUserId(role.getUserUuid()); ServiceContext serviceContext = portletDataContext.createServiceContext(role); Role existingRole = RoleLocalServiceUtil.fetchRoleByUuidAndCompanyId( role.getUuid(), portletDataContext.getCompanyId()); if (existingRole == null) { existingRole = RoleLocalServiceUtil.fetchRole(portletDataContext.getCompanyId(), role.getName()); } Role importedRole = null; if (existingRole == null) { serviceContext.setUuid(role.getUuid()); importedRole = RoleLocalServiceUtil.addRole( userId, null, 0, role.getName(), role.getTitleMap(), role.getDescriptionMap(), role.getType(), role.getSubtype(), serviceContext); } else { importedRole = RoleLocalServiceUtil.updateRole( existingRole.getRoleId(), role.getName(), role.getTitleMap(), role.getDescriptionMap(), role.getSubtype(), serviceContext); deleteRolePermissions(portletDataContext, importedRole); } String permissionsPath = ExportImportPathUtil.getModelPath(role, "permissions.xml"); List<Permission> permissions = (List<Permission>) portletDataContext.getZipEntryAsObject(permissionsPath); for (Permission permission : permissions) { if (ResourceBlockLocalServiceUtil.isSupported(permission.getName())) { importResourceBlock(portletDataContext, importedRole, permission); } else { importResourcePermissions(portletDataContext, importedRole, permission); } } portletDataContext.importClassedModel(role, importedRole); }
protected void updateActions(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long roleId = ParamUtil.getLong(actionRequest, "roleId"); Role role = RoleLocalServiceUtil.getRole(roleId); String roleName = role.getName(); if (roleName.equals(RoleConstants.ADMINISTRATOR) || roleName.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR) || roleName.equals(RoleConstants.ORGANIZATION_OWNER) || roleName.equals(RoleConstants.OWNER) || roleName.equals(RoleConstants.SITE_ADMINISTRATOR) || roleName.equals(RoleConstants.SITE_OWNER)) { throw new RolePermissionsException(roleName); } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); String[] modelResources = StringUtil.split(ParamUtil.getString(actionRequest, "modelResources")); boolean showModelResources = ParamUtil.getBoolean(actionRequest, "showModelResources"); Map<String, List<String>> resourceActionsMap = new HashMap<String, List<String>>(); if (showModelResources) { for (String modelResource : modelResources) { resourceActionsMap.put( modelResource, ResourceActionsUtil.getResourceActions(null, modelResource)); } } else if (Validator.isNotNull(portletResource)) { resourceActionsMap.put( portletResource, ResourceActionsUtil.getResourceActions(portletResource, null)); } String[] selectedTargets = StringUtil.split(ParamUtil.getString(actionRequest, "selectedTargets")); for (Map.Entry<String, List<String>> entry : resourceActionsMap.entrySet()) { String selResource = entry.getKey(); List<String> actions = entry.getValue(); actions = ListUtil.sort(actions, new ActionComparator(themeDisplay.getLocale())); for (String actionId : actions) { String target = selResource + actionId; boolean selected = ArrayUtil.contains(selectedTargets, target); String[] groupIds = StringUtil.split(ParamUtil.getString(actionRequest, "groupIds" + target)); groupIds = ArrayUtil.distinct(groupIds); int scope = ResourceConstants.SCOPE_COMPANY; if ((role.getType() == RoleConstants.TYPE_ORGANIZATION) || (role.getType() == RoleConstants.TYPE_PROVIDER) || (role.getType() == RoleConstants.TYPE_SITE)) { scope = ResourceConstants.SCOPE_GROUP_TEMPLATE; } else { if (groupIds.length > 0) { scope = ResourceConstants.SCOPE_GROUP; } } if (PropsValues.PERMISSIONS_USER_CHECK_ALGORITHM == 6) { if (ResourceBlockLocalServiceUtil.isSupported(selResource)) { updateActions_6Blocks( role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); } else { updateAction_6( role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); } } else { updateAction_1to5( role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); } } } // Send redirect SessionMessages.add(actionRequest, "permissionsUpdated"); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { redirect = redirect + "&" + Constants.CMD + "=" + Constants.VIEW; actionResponse.sendRedirect(redirect); } }
protected Query doGetPermissionQuery_6( long companyId, long[] groupIds, long userId, String className, Query query, SearchContext searchContext, AdvancedPermissionChecker advancedPermissionChecker, List<Group> groups, List<Role> roles, List<UserGroupRole> userGroupRoles, Map<Long, List<Role>> groupIdsToRoles) throws Exception { BooleanQuery permissionQuery = BooleanQueryFactoryUtil.create(searchContext); if (userId > 0) { permissionQuery.addTerm(Field.USER_ID, userId); } BooleanQuery groupsQuery = BooleanQueryFactoryUtil.create(searchContext); BooleanQuery rolesQuery = BooleanQueryFactoryUtil.create(searchContext); for (Role role : roles) { String roleName = role.getName(); if (roleName.equals(RoleConstants.ADMINISTRATOR)) { return query; } if (ResourcePermissionLocalServiceUtil.hasResourcePermission( companyId, className, ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId), role.getRoleId(), ActionKeys.VIEW)) { return query; } if ((role.getType() == RoleConstants.TYPE_REGULAR) && ResourcePermissionLocalServiceUtil.hasResourcePermission( companyId, className, ResourceConstants.SCOPE_GROUP_TEMPLATE, String.valueOf(GroupConstants.DEFAULT_PARENT_GROUP_ID), role.getRoleId(), ActionKeys.VIEW)) { return query; } for (Group group : groups) { if (ResourcePermissionLocalServiceUtil.hasResourcePermission( companyId, className, ResourceConstants.SCOPE_GROUP, String.valueOf(group.getGroupId()), role.getRoleId(), ActionKeys.VIEW)) { groupsQuery.addTerm(Field.GROUP_ID, group.getGroupId()); } if ((role.getType() != RoleConstants.TYPE_REGULAR) && ResourcePermissionLocalServiceUtil.hasResourcePermission( companyId, className, ResourceConstants.SCOPE_GROUP_TEMPLATE, String.valueOf(GroupConstants.DEFAULT_PARENT_GROUP_ID), role.getRoleId(), ActionKeys.VIEW)) { List<Role> groupRoles = groupIdsToRoles.get(group.getGroupId()); if (groupRoles.contains(role)) { groupsQuery.addTerm(Field.GROUP_ID, group.getGroupId()); } } if (group.isSite() && !roleName.equals(RoleConstants.SITE_MEMBER) && (role.getType() == RoleConstants.TYPE_SITE)) { rolesQuery.addTerm( Field.GROUP_ROLE_ID, group.getGroupId() + StringPool.DASH + role.getRoleId()); } } rolesQuery.addTerm(Field.ROLE_ID, role.getRoleId()); } for (Group group : groups) { addRequiredMemberRole(group, rolesQuery); } for (UserGroupRole userGroupRole : userGroupRoles) { rolesQuery.addTerm( Field.GROUP_ROLE_ID, userGroupRole.getGroupId() + StringPool.DASH + userGroupRole.getRoleId()); } if (groupsQuery.hasClauses()) { permissionQuery.add(groupsQuery, BooleanClauseOccur.SHOULD); } if (rolesQuery.hasClauses()) { permissionQuery.add(rolesQuery, BooleanClauseOccur.SHOULD); } BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext); fullQuery.add(query, BooleanClauseOccur.MUST); fullQuery.add(permissionQuery, BooleanClauseOccur.MUST); return fullQuery; }
protected void doAddPermissionFields_6( long companyId, long groupId, String className, String classPK, Document doc) throws Exception { Group group = null; if (groupId > 0) { group = GroupLocalServiceUtil.getGroup(groupId); } List<Role> roles = ListUtil.copy(ResourceActionsUtil.getRoles(companyId, group, className, null)); if (groupId > 0) { List<Role> teamRoles = RoleLocalServiceUtil.getTeamRoles(groupId); roles.addAll(teamRoles); } long[] roleIdsArray = new long[roles.size()]; for (int i = 0; i < roleIdsArray.length; i++) { Role role = roles.get(i); roleIdsArray[i] = role.getRoleId(); } boolean[] hasResourcePermissions = null; if (ResourceBlockLocalServiceUtil.isSupported(className)) { ResourceBlockIdsBag resourceBlockIdsBag = ResourceBlockLocalServiceUtil.getResourceBlockIdsBag( companyId, groupId, className, roleIdsArray); long actionId = ResourceBlockLocalServiceUtil.getActionId(className, ActionKeys.VIEW); List<Long> resourceBlockIds = resourceBlockIdsBag.getResourceBlockIds(actionId); hasResourcePermissions = new boolean[roleIdsArray.length]; for (long resourceBlockId : resourceBlockIds) { for (int i = 0; i < roleIdsArray.length; i++) { int count = ResourceBlockPermissionLocalServiceUtil.getResourceBlockPermissionsCount( resourceBlockId, roleIdsArray[i]); hasResourcePermissions[i] = (count > 0); } } } else { hasResourcePermissions = ResourcePermissionLocalServiceUtil.hasResourcePermissions( companyId, className, ResourceConstants.SCOPE_INDIVIDUAL, classPK, roleIdsArray, ActionKeys.VIEW); } List<Long> roleIds = new ArrayList<Long>(); List<String> groupRoleIds = new ArrayList<String>(); for (int i = 0; i < hasResourcePermissions.length; i++) { if (!hasResourcePermissions[i]) { continue; } Role role = roles.get(i); if ((role.getType() == RoleConstants.TYPE_ORGANIZATION) || (role.getType() == RoleConstants.TYPE_SITE)) { groupRoleIds.add(groupId + StringPool.DASH + role.getRoleId()); } else { roleIds.add(role.getRoleId()); } } doc.addKeyword(Field.ROLE_ID, roleIds.toArray(new Long[roleIds.size()])); doc.addKeyword(Field.GROUP_ROLE_ID, groupRoleIds.toArray(new String[groupRoleIds.size()])); }
protected void notifyUsers(AnnouncementsEntry entry) throws PortalException { Company company = companyPersistence.findByPrimaryKey(entry.getCompanyId()); String className = entry.getClassName(); long classPK = entry.getClassPK(); String toName = PropsValues.ANNOUNCEMENTS_EMAIL_TO_NAME; String toAddress = PropsValues.ANNOUNCEMENTS_EMAIL_TO_ADDRESS; long teamId = 0; LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put("announcementsDeliveryEmailOrSms", entry.getType()); if (classPK > 0) { if (className.equals(Group.class.getName())) { Group group = groupPersistence.findByPrimaryKey(classPK); toName = group.getDescriptiveName(); params.put("inherit", Boolean.TRUE); params.put("usersGroups", classPK); } else if (className.equals(Organization.class.getName())) { Organization organization = organizationPersistence.findByPrimaryKey(classPK); toName = organization.getName(); params.put("usersOrgsTree", ListUtil.fromArray(new Organization[] {organization})); } else if (className.equals(Role.class.getName())) { Role role = rolePersistence.findByPrimaryKey(classPK); toName = role.getName(); if (role.getType() == RoleConstants.TYPE_REGULAR) { params.put("inherit", Boolean.TRUE); params.put("usersRoles", classPK); } else if (role.isTeam()) { teamId = role.getClassPK(); } else { params.put("userGroupRole", new Long[] {Long.valueOf(0), classPK}); } } else if (className.equals(UserGroup.class.getName())) { UserGroup userGroup = userGroupPersistence.findByPrimaryKey(classPK); toName = userGroup.getName(); params.put("usersUserGroups", classPK); } } if (className.equals(User.class.getName())) { User user = userPersistence.findByPrimaryKey(classPK); if (Validator.isNull(user.getEmailAddress())) { return; } notifyUsers( ListUtil.fromArray(new User[] {user}), entry, company.getLocale(), user.getEmailAddress(), user.getFullName()); } else { int count = 0; if (teamId > 0) { count = userLocalService.getTeamUsersCount(teamId); } else { count = userLocalService.searchCount( company.getCompanyId(), null, WorkflowConstants.STATUS_APPROVED, params); } int pages = count / Indexer.DEFAULT_INTERVAL; for (int i = 0; i <= pages; i++) { int start = (i * Indexer.DEFAULT_INTERVAL); int end = start + Indexer.DEFAULT_INTERVAL; List<User> users = null; if (teamId > 0) { users = userLocalService.getTeamUsers(teamId, start, end); } else { users = userLocalService.search( company.getCompanyId(), null, WorkflowConstants.STATUS_APPROVED, params, start, end, (OrderByComparator<User>) null); } notifyUsers(users, entry, company.getLocale(), toAddress, toName); } } }