}
// if the new occupant is a server admin, he will be for the room, too
final ServerAdministrationService adhocCommandsService = (ServerAdministrationService)serverRuntimeContext.getServerRuntimeContextService(ServerAdministrationService.SERVICE_ID);
if (adhocCommandsService != null && adhocCommandsService.isAdmin(newOccupantJid.getBareJID())) {
final Affiliations roomAffiliations = room.getAffiliations();
// make new occupant an Admin, but do not downgrade from Owner
// Admin affilitation implies Moderator role (see XEP-0045 5.1.2)
if (roomAffiliations.getAffiliation(newOccupantJid) != Affiliation.Owner) {
roomAffiliations.add(newOccupantJid, Affiliation.Admin);
newOccupant.setRole(Role.Moderator);
}
}
// relay presence of all existing room occupants to the now joined occupant