public synchronized MeetmeRoom findAvailableRoom(RoomOwner newOwner)
    {
        int count = 0;
        for (final MeetmeRoom room : this.rooms)
        {
            if (MeetmeRoomControl.logger.isDebugEnabled())
            {
                MeetmeRoomControl.logger.debug("room " + room.getRoomNumber() + " count " + count);
            }
            if (room.getOwner() == null || !room.getOwner().isRoomStillRequired())
            {
                /*
                 * new code to attempt to recover uncleared meetme rooms safely
                 */
                try
                {
                    final Date lastUpdated = room.getLastUpdated();
                    final long now = new Date().getTime();
                    if (lastUpdated != null)
                    {
                        final long elapsedTime = now - lastUpdated.getTime();
                        MeetmeRoomControl.logger
                                .debug("room: " + room.getRoomNumber() + " count: " + count + " elapsed: " + elapsedTime);
                        if ((elapsedTime > 7200000) && (room.getChannelCount() == 1))
                        {
                            MeetmeRoomControl.logger.debug("clearing room"); //$NON-NLS-1$
                            room.setInactive();
                        }
                    }
                }
                catch (final Exception e)
                {
                    /*
                     * attempt to make this new change safe
                     */
                    MeetmeRoomControl.logger.error(e, e);
                }

                if (room.getChannelCount() == 0)
                {
                    room.setInactive();
                    room.setOwner(newOwner);
                    MeetmeRoomControl.logger.warn("Returning available room " + room.getRoomNumber());
                    return room;
                }

            }
            else
            {
                logger.warn("Meetme " + room.getRoomNumber() + " is still in use by " + room.getOwner());
            }
            count++;
        }
        MeetmeRoomControl.logger.error("no more available rooms");
        return null;

    }
public synchronized MeetmeRoom findAvailableRoom ( RoomOwner newOwner ) { int count = 0 ; for ( final MeetmeRoom room : this . rooms ) { if ( MeetmeRoomControl . logger . isDebugEnabled ( ) ) { MeetmeRoomControl . logger . debug ( "room " + room . getRoomNumber ( ) + " count " + count ) ; } if ( room . getOwner ( ) == null || ! room . getOwner ( ) . isRoomStillRequired ( ) ) { try { final Date lastUpdated = room . getLastUpdated ( ) ; final long now = new Date ( ) . getTime ( ) ; if ( lastUpdated != null ) { final long elapsedTime = now - lastUpdated . getTime ( ) ; MeetmeRoomControl . logger . debug ( "room: " + room . getRoomNumber ( ) + " count: " + count + " elapsed: " + elapsedTime ) ; if ( ( elapsedTime > 7200000 ) && ( room . getChannelCount ( ) == 1 ) ) { MeetmeRoomControl . logger . debug ( "clearing room" ) ; room . setInactive ( ) ; } } } catch ( final Exception e ) { MeetmeRoomControl . logger . error ( e , e ) ; } if ( room . getChannelCount ( ) == 0 ) { room . setInactive ( ) ; room . setOwner ( newOwner ) ; MeetmeRoomControl . logger . warn ( "Returning available room " + room . getRoomNumber ( ) ) ; return room ; } } else { logger . warn ( "Meetme " + room . getRoomNumber ( ) + " is still in use by " + room . getOwner ( ) ) ; } count ++ ; } MeetmeRoomControl . logger . error ( "no more available rooms" ) ; return null ; }
/*
returns the next available meetme room, or null if no rooms are
available.