Method that computes the number of relevant items in the test set for a
user.

@param user a user
@return the number of relevant items the user has in the test set
432740
protected double getNumberOfRelevantItems(final U user) {
        int n = 0;
        if (getTest().getUserItems(user) != null) {
            for (I i : getTest().getUserItems(user)) {
                if (getTest().getUserItemPreference(user, i) >= relevanceThreshold) {
                    n++;
                }
            }
        }
        return n * 1.0;
    }
600455
public int countProtocolItems()
    throws MessageStoreException
  {
    if (tc.isEntryEnabled())  
      SibTr.entry(tc, "countProtocolItems");      

    int count = 0;
    
    NonLockingCursor cursor 
      = newNonLockingItemCursor(new ClassEqualsFilter(StreamSet.class));
           
    AbstractItem item = cursor.next();
    while (null != item)
    {
      //ProtocolItem protocolItem = (ProtocolItem)item;
      count++;
      item = cursor.next();
    }
 
    if (tc.isEntryEnabled())  
      SibTr.exit(tc, "countProtocolItems", new Integer(count));
            
    return count;
  }
9814
public T allowedUser(User allowedUser) {
        this.userPredicate = (user) -> user.getId() == allowedUser.getId();
        return instance();
    }
1346371
public User getUser(String userName) {
        User result = null;
        for (User item : getUsersList()) {
            if (item.getName().equals(userName)) {
                result = item;
            }
        }
        return result;
    }
1074979
@Override
    public Set<Node> getGroupsForUser(Node user) {
        Set<Node> groups = new TreeSet<>();
        try {
            String query = "(& (objectClass=" + groupObjectClass + ") (" + groupMemberAttribut + "=" + ((LdapUser) user).getDn() + "))";
            SearchResult searchResult;
            Attributes attributes;
            SearchControls controls = new SearchControls();
            controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
            NamingEnumeration<SearchResult> results = ctx.search("", query, controls);
            queryCount++;
            Node group;
            while (results.hasMore()) {
                searchResult = results.next();
                attributes = searchResult.getAttributes();
                group = getGroup(getAttributeOrNa(attributes, groupIdentifyer));
                group.setDn(searchResult.getNameInNamespace());
                groups.add(group);
            }
        } catch (NamingException ex) {
            handleNamingException(user, ex);
        }
        return groups;
    }
1327236
public void addUser(PrincipalUser user) {
        SystemAssert.requireArgument(user != null, "Null user can not be added.");
        users.add(user);
    }
304802
public OvhUser identity_user_user_GET(String user) throws IOException {
		String qPath = "/me/identity/user/{user}";
		StringBuilder sb = path(qPath, user);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhUser.class);
	}
816260
public static UserCredentialsDto fromUser(User user) {
    UserCredentialsDto result = new UserCredentialsDto();
    result.setPassword(user.getPassword());
    return result;
  }
584844
@Restricted(NoExternalUse.class)
    public List<User> getImpactedUserList() {
        return User.getAll().stream()
                .filter(user -> {
                    ApiTokenProperty apiTokenProperty = user.getProperty(ApiTokenProperty.class);
                    return (apiTokenProperty != null && apiTokenProperty.hasLegacyToken());
                })
                .collect(Collectors.toList());
    }
297052
public boolean hasUser(String userName) {
        boolean result = false;
        for (User item : getUsersList()) {
            if (item.getName().equals(userName)) {
                result = true;
            }
        }
        return result;
    }
14366
@Override
    public Double getUserItemPreference(U u, I i) {
        if (userItemPreferences.containsKey(u) && userItemPreferences.get(u).containsKey(i)) {
            return userItemPreferences.get(u).get(i);
        }
        return Double.NaN;
    }
106096
public void withUser(boolean user) {
    if (user) {
      addQueryParameter(Constants.WITH_PARAM, Constants.WITH_USER);
    } else {
      removeQueryParameter(Constants.WITH_PARAM);
    }
  }
611588
public boolean writeUser(User user) {
		// save user info to file
		if (resourcePath != null) {

			lock.writeLock().lock();
			try {
				File userDir = new File(resourcePath, "users");
				if (userDir.isDirectory()) {
					// get the file which corresponds to the user
					File userFile = new File(userDir.getAbsolutePath(), user.getName());
					Properties props = user.toProperties();
					try (FileOutputStream out = new FileOutputStream(userFile)) {
						props.store(out, "");
						return true;
					} catch (IOException ex) {
						log.error("Could not write users file", ex);
					}
				}
			} finally {
				lock.writeLock().unlock();
			}
		} // end if resourcePath not null
		return false;
	}
33939
protected void fillItem(Item item, CmsUser user) {

        item.getItemProperty(TableProperty.Name).setValue(user.getSimpleName());
        item.getItemProperty(TableProperty.FullName).setValue(user.getFullName());
        item.getItemProperty(TableProperty.SystemName).setValue(user.getName());
        boolean disabled = !user.isEnabled();
        item.getItemProperty(TableProperty.DISABLED).setValue(new Boolean(disabled));
        boolean newUser = user.getLastlogin() == 0L;
        item.getItemProperty(TableProperty.NEWUSER).setValue(new Boolean(newUser));
        try {
            item.getItemProperty(TableProperty.OU).setValue(
                OpenCms.getOrgUnitManager().readOrganizationalUnit(m_cms, user.getOuFqn()).getDisplayName(
                    A_CmsUI.get().getLocale()));
        } catch (CmsException e) {
            LOG.error("Can't read OU", e);
        }
        item.getItemProperty(TableProperty.LastLogin).setValue(new Long(user.getLastlogin()));
        item.getItemProperty(TableProperty.Created).setValue(new Long(user.getDateCreated()));
        item.getItemProperty(TableProperty.INDIRECT).setValue(new Boolean(m_indirects.contains(user)));
        item.getItemProperty(TableProperty.FROMOTHEROU).setValue(new Boolean(!user.getOuFqn().equals(m_ou)));
        item.getItemProperty(TableProperty.STATUS).setValue(getStatusInt(disabled, newUser));
    }
337177
private static int checkNumItems(final HttpServletRequest request,
			final ReadResponse response) {
		final String sNumItems = request
				.getParameter(ProtocolConstants.Parameters.Read.NUM_ITEMS);
		if (sNumItems != null) {
			int numItems;
			try {
				numItems = Integer.valueOf(sNumItems);
				if (numItems > 0) {
					return numItems;
				}

				response.numItemsInvalid("Please provide a number greater than zero.");
			} catch (final NumberFormatException e) {
				response.numItemsInvalid("\""
						+ sNumItems
						+ "\" is not a number. Please provide a number such as \"15\" to retrieve that number of items.");
			}
		} else {
			response.numItemsMissing();
		}

		return 0;
	}
1022221
public GenericUser getUserForUserReference(String userReference) {
    	GenericUser user = getReference(GenericUser.class, userReference);
        if (user == null) {
            fail("No user of type '" + userReference + "' is found. Available user references are: " + getObjectReferenceMap(GenericUser.class).keySet().toString());
        }
        return user;
    }
866563
private Set<String> getKeysForUser(CmsUser user) {

        Set<String> keysToRemove = new HashSet<String>();
        for (Map.Entry<String, CmsUserData> entry : m_storage.entrySet()) {
            String key = entry.getKey();
            int separatorPos = key.lastIndexOf(KEY_SEPARATOR);
            String prefix = key.substring(0, separatorPos);
            if (user.getName().equals(prefix)) {
                keysToRemove.add(key);
            }
        }
        return keysToRemove;
    }