Search in sources :

Example 56 with User

use of org.jivesoftware.openfire.user.User in project Openfire by igniterealtime.

the class UserServiceController method updateUser.

/**
	 * Update user.
	 *
	 * @param username
	 *            the username
	 * @param userEntity
	 *            the user entity
	 * @throws ServiceException
	 *             the service exception
	 */
public void updateUser(String username, UserEntity userEntity) throws ServiceException {
    if (userEntity != null && !username.isEmpty()) {
        // parameter
        if (userEntity.getUsername() != null) {
            if (!userEntity.getUsername().equals(username)) {
                JustMarriedController.changeName(username, userEntity.getUsername(), true, userEntity.getEmail(), userEntity.getName());
                addProperties(userEntity.getUsername(), userEntity.getProperties());
                return;
            }
        }
        User user = getAndCheckUser(username);
        if (userEntity.getPassword() != null) {
            user.setPassword(userEntity.getPassword());
        }
        if (userEntity.getName() != null) {
            user.setName(userEntity.getName());
        }
        if (userEntity.getEmail() != null) {
            user.setEmail(userEntity.getEmail());
        }
        addProperties(username, userEntity.getProperties());
    }
}
Also used : User(org.jivesoftware.openfire.user.User)

Example 57 with User

use of org.jivesoftware.openfire.user.User in project Openfire by igniterealtime.

the class UserServiceLegacyController method deleteUser.

/**
	 * Delete user.
	 *
	 * @param username the username
	 * @throws UserNotFoundException the user not found exception
	 * @throws SharedGroupException the shared group exception
	 */
public void deleteUser(String username) throws UserNotFoundException, SharedGroupException {
    User user = getUser(username);
    userManager.deleteUser(user);
    rosterManager.deleteRoster(server.createJID(username, null));
}
Also used : User(org.jivesoftware.openfire.user.User)

Example 58 with User

use of org.jivesoftware.openfire.user.User in project Openfire by igniterealtime.

the class UserServiceLegacyController method getUserGroups.

/**
	 * Returns all group names or an empty collection for specific user.
	 *
	 * @param username the username
	 * @return the user groups
	 * @throws UserNotFoundException the user not found exception
	 */
public Collection<String> getUserGroups(String username) throws UserNotFoundException {
    User user = getUser(username);
    Collection<Group> groups = GroupManager.getInstance().getGroups(user);
    Collection<String> groupNames = new ArrayList<String>();
    for (Group group : groups) {
        groupNames.add(group.getName());
    }
    return groupNames;
}
Also used : Group(org.jivesoftware.openfire.group.Group) User(org.jivesoftware.openfire.user.User) ArrayList(java.util.ArrayList)

Aggregations

User (org.jivesoftware.openfire.user.User)58 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)26 Element (org.dom4j.Element)17 JID (org.xmpp.packet.JID)17 UserManager (org.jivesoftware.openfire.user.UserManager)10 ArrayList (java.util.ArrayList)9 Group (org.jivesoftware.openfire.group.Group)9 IQ (org.xmpp.packet.IQ)7 List (java.util.List)6 UserAlreadyExistsException (org.jivesoftware.openfire.user.UserAlreadyExistsException)6 RosterItem (org.jivesoftware.openfire.roster.RosterItem)5 Date (java.util.Date)4 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)4 Message (org.xmpp.packet.Message)4 Presence (org.xmpp.packet.Presence)4 HashSet (java.util.HashSet)3 StringTokenizer (java.util.StringTokenizer)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileInputStream (java.io.FileInputStream)2