Search in sources :

Example 1 with UserEntity

use of org.jivesoftware.openfire.entity.UserEntity in project Openfire by igniterealtime.

the class UserServicePluginNG method getUserEntitiesByProperty.

/**
	 * Gets the user entities by property key and or value.
	 *
	 * @param propertyKey
	 *            the property key
	 * @param propertyValue
	 *            the property value (can be null)
	 * @return the user entities by property
	 * @throws ServiceException
	 *             the service exception
	 */
public UserEntities getUserEntitiesByProperty(String propertyKey, String propertyValue) throws ServiceException {
    List<String> usernames = PropertyDAO.getUsernameByProperty(propertyKey, propertyValue);
    List<UserEntity> users = new ArrayList<UserEntity>();
    UserEntities userEntities = new UserEntities();
    for (String username : usernames) {
        users.add(getUserEntity(username));
    }
    userEntities.setUsers(users);
    return userEntities;
}
Also used : UserEntities(org.jivesoftware.openfire.entity.UserEntities) ArrayList(java.util.ArrayList) UserEntity(org.jivesoftware.openfire.entity.UserEntity)

Example 2 with UserEntity

use of org.jivesoftware.openfire.entity.UserEntity in project Openfire by igniterealtime.

the class UserUtils method convertUserToUserEntity.

/**
	 * Convert user to user entity.
	 *
	 * @param user
	 *            the user
	 * @return the user entity
	 */
public static UserEntity convertUserToUserEntity(User user) {
    UserEntity userEntity = new UserEntity(user.getUsername(), user.getName(), user.getEmail());
    List<UserProperty> userProperties = new ArrayList<UserProperty>();
    for (Entry<String, String> property : user.getProperties().entrySet()) {
        userProperties.add(new UserProperty(property.getKey(), property.getValue()));
    }
    userEntity.setProperties(userProperties);
    return userEntity;
}
Also used : UserProperty(org.jivesoftware.openfire.entity.UserProperty) ArrayList(java.util.ArrayList) UserEntity(org.jivesoftware.openfire.entity.UserEntity)

Aggregations

ArrayList (java.util.ArrayList)2 UserEntity (org.jivesoftware.openfire.entity.UserEntity)2 UserEntities (org.jivesoftware.openfire.entity.UserEntities)1 UserProperty (org.jivesoftware.openfire.entity.UserProperty)1