*/
public Room[] getRooms (String sid, RoomRequest[] rids) {
database.Configuration db = null;
ArrayList<Room> rooms = new ArrayList<Room>();
Room tmpRoom = null;
// database.Window dbWindow = null;
database.Room dbRoom = null;
// include.auth.Validation valid = new include.auth.Validation();
Room[] result = new Room[1];
RoomRequest remoteCall[] = new RoomRequest[1];
Room[] remoteResult = null;
include.net.Server serv = new include.net.Server();
Collection<database.Room> roomColl = null;
utils.Utils u = new utils.Utils();
String server = null;
String rid = null;
String code = null;
String body = null;
Integer i = 0;
System.out.println("[RoomsGetter] Executing function 'getRooms'. Parameters:");
System.out.println("[RoomsGetter] sid: '" + sid + "'");
System.out.println("[RoomsGetter] rid[0]: '" + rids[0].getRid() + "'");
try {
InitialContext ctx = new InitialContext();
db = (database.Configuration) ctx.lookup("ear3/CMPConfiguration/local");
} catch (NamingException e) {
e.printStackTrace();
}
for (i = 0; i < rids.length; i++) {
rid = rids[i].getRid();
if (rid.indexOf('@') == -1){
System.out.println("[RoomsGetter] Local room, rid = "+rid+".");
// dbWindow = db.getWindow(rid, valid.validate(sid));
// dbRoom = dbWindow.getRoom();
roomColl = db.getRooms();
Boolean found = false;
Iterator j = roomColl.iterator();
while ((j.hasNext()) && (!found)) {
dbRoom = (database.Room) j.next();
if ((dbRoom.getName() + '@' + serv.giveName()).equals(rid))
found = true;
}
rid = dbRoom.getName()+"@"+serv.giveName();
tmpRoom = new Room();
tmpRoom.setRid(rid);
tmpRoom.setVersion(dbRoom.getVersion());
body = dbRoom.getBody();
body = body.replace("%safePortletName%", u.getSafeName(rid));
body = body.replace("%portletName%", rid);
tmpRoom.setBody(body);
code = dbRoom.getCode();
code = code.replace("%safePortletName%", u.getSafeName(rid));
code = code.replace("%portletName%", rid);
tmpRoom.setCode(code);
rooms.add(tmpRoom);
} else {
server = rid.substring(rid.indexOf('@') + 1);
if (serv.isMyName(server)) {
System.out.println("[RoomsGetter] Local room, rid = "+rid+".");
// dbWindow = db.getWindow(rid.substring(0, rid.indexOf('@')),
// valid.validate(sid));
// dbRoom = dbWindow.getRoom();
roomColl = db.getRooms();
Boolean found = false;
Iterator j = roomColl.iterator();
while ((j.hasNext()) && (!found)) {
dbRoom = (database.Room) j.next();
if ((dbRoom.getName() + '@' + serv.giveName()).equals(rid))
found = true;
}
rid = dbRoom.getName()+"@"+server;
tmpRoom = new Room();
tmpRoom.setRid(rid);
tmpRoom.setVersion(dbRoom.getVersion());
body = dbRoom.getBody();
body = body.replace("%safePortletName%", u.getSafeName(rid));
body = body.replace("%portletName%", rid);
tmpRoom.setBody(body);
code = dbRoom.getCode();
code = code.replace("%safePortletName%", u.getSafeName(rid));
code = code.replace("%portletName%", rid);
tmpRoom.setCode(code);
rooms.add(tmpRoom);
} else {