public static String getUserName(JID entity) throws UserNotFoundException {
        return getUserName(entity, entity.toString());
    }
Returns the name of the XMPP entity. If the entity is a local user then the User's name
will be returned. However, if the user is not a local user then check if there exists a
UserNameProvider that provides name for the specified domain. If none was found then
the vCard of the entity might be requested and if none was found then a string
representation of the entity's JID will be returned.

@param entity the JID of the entity to get its name.
@return the name of the XMPP entity.
@throws UserNotFoundException if the jid belongs to the local server but no user was
                              found for that jid.
xmppserver/src/main/java/org/jivesoftware/openfire/user/UserNameManager.java