* @param windows array of windows
* @return true if desktop was updated correctly
*/
public Boolean updateDesktop(String sid, Window windows[]) {
Configuration conf = null;
boolean result = false;
include.net.Server serv = new include.net.Server();
String server = null;
String rid = null;
Integer dbSid = null;
Validation val = new Validation();
String login = val.validate(sid);
System.out.println("[DesktopUpdater] Executing function 'updateDesktop'.");
try {
InitialContext ctx = new InitialContext();
conf = (Configuration) ctx.lookup("ear3/CMPConfiguration/local");
} catch (NamingException e) {
e.printStackTrace();
}
server = sid.substring(sid.indexOf('@') + 1);
if (serv.isMyName(server)) {
System.out.println("[DesktopUpdater] Local execution.");
if (login != null) {
System.out.println("[DesktopUpdater] Session is valid.");
result = true;
if (login.indexOf('@') != -1)
login = login.substring(0, login.indexOf('@'));
for (Integer i = 0; i < windows.length; i++) {
rid = windows[i].getRid();
dbSid = Integer.parseInt(sid.substring(0, sid.indexOf('@')));
int tmpId = conf.getId(rid, login);
result = result && conf.move(tmpId, windows[i].getX(), windows[i].getY());
result = result && conf.resize(tmpId, windows[i].getW(), windows[i].getH());
if (!windows[i].getBar().equals(conf.getWindow(tmpId).isMinimized()))
result = result && conf.reminimize(tmpId);
if (!windows[i].getFullscreen().equals(conf.getWindow(tmpId).isMaximized()))
result = result && conf.remaximize(tmpId);
}
} else
System.out.println("[DesktopUpdater] Session is invalid.");