Exemple #1
0
 public void addOccupants(MucRoom room, Set<MucOccupant> occupants) {
   Preconditions.checkArgument(room.getId() != null);
   for (MucOccupant occupant : occupants) {
     occupant.setRoom(room);
     occupant.setId(null);
     occupant.setReadSeq(room.getMaxSeq());
   }
   oDao.save(occupants);
 }
Exemple #2
0
 public Long incrMaxSeq(MucRoom room) {
   Lock lock = roomLockSet.getLock(room.getId());
   try {
     lock.lock();
     room.setMaxSeq(room.getMaxSeq() + 1);
     upadte(room);
     return room.getMaxSeq();
   } finally {
     lock.unlock();
   }
 }
Exemple #3
0
  public boolean changeOwner(MucRoom room, long ownerId) {
    if (room.getOwner().equals(ownerId)) {
      return false;
    }
    MucOccupant o = oDao.findByRoomIdAndUserId(room.getId(), ownerId);
    if (o == null) {
      return false;
    }
    o.setRole(Role.Moderator);
    oDao.save(o);

    MucOccupant o2 = oDao.findByRoomIdAndUserId(room.getId(), room.getOwner());
    if (o2 != null) {
      o2.setRole(Role.Participant);
      oDao.save(o2);
    }

    room.setOwner(ownerId);
    rDao.save(room);
    return true;
  }
Exemple #4
0
 public void upadte(MucRoom room) {
   Preconditions.checkArgument(room.getId() != null);
   rDao.save(room);
 }
Exemple #5
0
 public MucRoom add(MucRoom room, Set<MucOccupant> occupants) {
   Preconditions.checkArgument(room.getId() == null);
   rDao.save(room);
   addOccupants(room, occupants);
   return room;
 }