private Presence generateJoinStanza( @Nonnull MUCOccupant occupantData )
    {
        Log.debug( "(room: '{}'): Generating a stanza that represents the joining of local user '{}' (as '{}').", room.getJID(), occupantData.getUserAddress(), occupantData.getOccupantJID() );
        final Presence joinStanza = new Presence();
        joinStanza.getElement().addElement(QName.get("x", "http://jabber.org/protocol/muc"));
        final Element mucUser = joinStanza.getElement().addElement(QName.get("x", "http://jabber.org/protocol/muc#user"));
        final Element mucUserItem = mucUser.addElement("item");
        mucUserItem.addAttribute("affiliation", occupantData.getAffiliation().toString());
        mucUserItem.addAttribute("role", occupantData.getRole().toString());

        // Don't include the occupant's JID if the room is semi-anon and the new occupant is not a moderator
        if (!room.canAnyoneDiscoverJID()) {
            if (Role.moderator == occupantData.getRole()) {
                mucUserItem.addAttribute("jid", occupantData.getUserAddress().toString());
            }
            else {
                mucUserItem.addAttribute("jid", null);
            }
        }

        return joinStanza;
    }
Creates a stanza that represents a room 'join' in a MUC room.

@param occupantData Representation of the (local) user that caused the join to be initiated.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/spi/FMUCHandler.java