* @return array with information about rooms
*/
public RoomInfo[] getRoomsInfo (String sid, String server) {
RoomInfo result[] = new RoomInfo[1];
ArrayList<RoomInfo> rooms = new ArrayList<RoomInfo>();
Collection<database.Room> dbRooms;
database.Configuration db = null;
Iterator i = null;
include.net.Server serv = new include.net.Server();
Validation val = new Validation();
RoomInfo tmpRi = null;
database.Room tmpDb = null;
System.out.println("[RoomInfoGetter] Executing function 'getRoomsInfo'. Parameters:");
System.out.println("[RoomInfoGetter] sid: '" + sid + "'");
System.out.println("[RoomInfoGetter] server: '" + server + "'");
try {
InitialContext ctx = new InitialContext();
db = (database.Configuration) ctx.lookup("ear3/CMPConfiguration/local");
} catch (NamingException e) {
e.printStackTrace();
}
if (serv.isMyName(server)) {
System.out.println("[RoomInfoGetter] Local execution");
if (val.validate(sid) != null) {
System.out.println("[RoomInfoGetter] Session is valid.");
System.out.println("[RoomInfoGetter] Gathering rooms.");
dbRooms = db.getRooms();
if (dbRooms == null)
System.out.println("[RoomInfoGetter] No windows found.");
else {
i = dbRooms.iterator();
if (i == null)
System.out.println("[RoomInfoGetter] Error in generating iterator.");
else {
System.out.println("[RoomInfoGetter] Converting rooms.");
while (i.hasNext()) {
tmpDb = (database.Room) i.next();
tmpRi = new RoomInfo(tmpDb.getName() + '@' + serv.giveName(), tmpDb.getDescription());
rooms.add(tmpRi);
}
}
}