Search in sources :

Example 1 with UserProperty

use of org.jivesoftware.openfire.plugin.rest.entity.UserProperty 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.plugin.rest.entity.UserProperty) ArrayList(java.util.ArrayList) UserEntity(org.jivesoftware.openfire.plugin.rest.entity.UserEntity)

Example 2 with UserProperty

use of org.jivesoftware.openfire.plugin.rest.entity.UserProperty in project Openfire by igniterealtime.

the class UserServiceController method addProperties.

/**
	 * Adds the properties.
	 *
	 * @param userEntity
	 *            the user entity
	 * @throws ServiceException
	 *             the service exception
	 */
private void addProperties(String username, List<UserProperty> properties) throws ServiceException {
    User user = getAndCheckUser(username);
    user.getProperties().clear();
    if (properties != null) {
        for (UserProperty property : properties) {
            user.getProperties().put(property.getKey(), property.getValue());
        }
    }
}
Also used : User(org.jivesoftware.openfire.user.User) UserProperty(org.jivesoftware.openfire.plugin.rest.entity.UserProperty)

Aggregations

UserProperty (org.jivesoftware.openfire.plugin.rest.entity.UserProperty)2 ArrayList (java.util.ArrayList)1 UserEntity (org.jivesoftware.openfire.plugin.rest.entity.UserEntity)1 User (org.jivesoftware.openfire.user.User)1