@Override public Presence addVisitor(JID jid, MUCRole senderRole) throws NotAllowedException, ForbiddenException { if (MUCRole.Role.moderator != senderRole.getRole()) { throw new ForbiddenException(); } return changeOccupantRole(jid, MUCRole.Role.visitor); }
@Override public void lock(MUCRole senderRole) throws ForbiddenException { if (MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); } if (isLocked()) { // Do nothing if the room was already locked return; } setLocked(true); }
@Override public void unlock(MUCRole senderRole) throws ForbiddenException { if (MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); } if (!isLocked()) { // Do nothing if the room was already unlocked return; } setLocked(false); }
@Override public Presence addParticipant(JID jid, String reason, MUCRole senderRole) throws NotAllowedException, ForbiddenException { if (MUCRole.Role.moderator != senderRole.getRole()) { throw new ForbiddenException(); } // Update the presence with the new role and inform all occupants Presence updatedPresence = changeOccupantRole(jid, MUCRole.Role.participant); if (updatedPresence != null) { Element frag = updatedPresence.getChildElement( "x", "http://jabber.org/protocol/muc#user"); // Add the reason why the user was granted voice if (reason != null && reason.trim().length() > 0) { frag.element("item").addElement("reason").setText(reason); } } return updatedPresence; }
@Override public Presence addModerator(JID jid, MUCRole senderRole) throws ForbiddenException { if (MUCRole.Affiliation.admin != senderRole.getAffiliation() && MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); } // Update the presence with the new role and inform all occupants try { return changeOccupantRole(jid, MUCRole.Role.moderator); } catch (NotAllowedException e) { // We should never receive this exception....in theory return null; } }
@Override public void sendPrivatePacket(Packet packet, MUCRole senderRole) throws NotFoundException, ForbiddenException { switch (senderRole.getRole()) { // intended fall-through case none: throw new ForbiddenException(); default: case visitor: if (canSendPrivateMessage().equals( "participants" )) throw new ForbiddenException(); case participant: if (canSendPrivateMessage().equals( "moderators" )) throw new ForbiddenException(); case moderator: if (canSendPrivateMessage().equals( "none" )) throw new ForbiddenException(); } String resource = packet.getTo().getResource(); List<MUCRole> occupants = occupantsByNickname.get(resource.toLowerCase()); if (occupants == null || occupants.size() == 0) { throw new NotFoundException(); } for (MUCRole occupant : occupants) { packet.setFrom(senderRole.getRoleAddress()); occupant.send(packet); if(packet instanceof Message) { Message message = (Message) packet; MUCEventDispatcher.privateMessageRecieved(occupant.getUserAddress(), senderRole.getUserAddress(), message); } } }
MUCRole.Affiliation oldAffiliation = MUCRole.Affiliation.none; if (MUCRole.Affiliation.owner != sendRole.getAffiliation()) { throw new ForbiddenException();
if (MUCRole.Affiliation.admin != sendRole.getAffiliation() && MUCRole.Affiliation.owner != sendRole.getAffiliation()) { throw new ForbiddenException(); if (MUCRole.Affiliation.admin != sendRole.getAffiliation() && MUCRole.Affiliation.owner != sendRole.getAffiliation()) { throw new ForbiddenException();
if (MUCRole.Affiliation.admin != senderRole.getAffiliation() && MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException();
MUCRole.Affiliation oldAffiliation = MUCRole.Affiliation.none; if (MUCRole.Affiliation.owner != sendRole.getAffiliation()) { throw new ForbiddenException();
if (MUCRole.Affiliation.admin != senderRole.getAffiliation() && MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException();
throw new ForbiddenException(); && MUCRole.Affiliation.admin != senderRole.getAffiliation() && MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); throw new ForbiddenException(); throw new ForbiddenException(); throw new ForbiddenException();
throw new ForbiddenException(); throw new ForbiddenException();
@Override public void sendPublicMessage(Message message, MUCRole senderRole) throws ForbiddenException { // Check that if the room is moderated then the sender of the message has to have voice if (isModerated() && senderRole.getRole().compareTo(MUCRole.Role.participant) > 0) { throw new ForbiddenException(); } // Send the message to all occupants message.setFrom(senderRole.getRoleAddress()); send(message); // Fire event that message was received by the room MUCEventDispatcher.messageReceived(getRole().getRoleAddress(), senderRole.getUserAddress(), senderRole.getNickname(), message); }
throw new ForbiddenException(); if (!((MultiUserChatServiceImpl)room.getMUCService()).getMUCDelegate().destroyingRoom(room.getName(), role.getUserAddress())) { throw new ForbiddenException();
@Override public void changeSubject(Message packet, MUCRole role) throws ForbiddenException { if ((canOccupantsChangeSubject() && role.getRole().compareTo(MUCRole.Role.visitor) < 0) || MUCRole.Role.moderator == role.getRole()) { // Set the new subject to the room subject = packet.getSubject(); MUCPersistenceManager.updateRoomSubject(this); // Notify all the occupants that the subject has changed packet.setFrom(role.getRoleAddress()); send(packet); // Fire event signifying that the room's subject has changed. MUCEventDispatcher.roomSubjectChanged(getJID(), role.getUserAddress(), subject); // Let other cluster nodes that the room has been updated CacheFactory.doClusterTask(new RoomUpdatedEvent(this)); } else { throw new ForbiddenException(); } }
throw new ForbiddenException();
@Override public Presence addVisitor(JID jid, MUCRole senderRole) throws NotAllowedException, ForbiddenException { if (MUCRole.Role.moderator != senderRole.getRole()) { throw new ForbiddenException(); } return changeOccupantRole(jid, MUCRole.Role.visitor); }
@Override public void lock(MUCRole senderRole) throws ForbiddenException { if (MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); } if (isLocked()) { // Do nothing if the room was already locked return; } setLocked(true); }
@Override public void unlock(MUCRole senderRole) throws ForbiddenException { if (MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); } if (!isLocked()) { // Do nothing if the room was already unlocked return; } setLocked(false); }