Search in sources :

Example 1 with UserProperty

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

Example 2 with UserProperty

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

the class UserServicePluginNG method addProperties.

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

Aggregations

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