*/
public UserData get(String sid) {
ArrayList<Window> windows = new ArrayList<Window>();
Collection<database.Window> dbwindows;
Converter convert = new Converter();
database.Configuration db = null;
village.webservice.user.ProfileAttribute profile[] = null;
Iterator i = null;
include.net.Server serv = new include.net.Server();
String server;
UserData result = null;
Validation val = new Validation();
Window windowArray[] = new Window[1];
String login = val.validate(sid);
System.out.println("[DataGetter] Executing function 'getUserData'. Parameters:");
System.out.println("[DataGetter] sid: '" + sid + "'");
try {
InitialContext ctx = new InitialContext();
db = (database.Configuration) ctx.lookup("ear3/CMPConfiguration/local");
} catch (NamingException e) {
e.printStackTrace();
}
server = sid.substring(sid.indexOf('@') + 1);
if (serv.isMyName(server)) {
System.out.println("[DataGetter] Local execution");
if (login != null) {
System.out.println("[DataGetter] Session is valid.");
System.out.println("[DataGetter] Gathering windows.");
if (login.indexOf('@') != -1)
login = login.substring(0, login.indexOf('@'));
dbwindows = db.getWindows(login);
if (dbwindows.isEmpty()) {
System.out.println("[DataGetter] No windows found.");
windowArray = null;
}
else {
i = dbwindows.iterator();
if (i == null)
System.out.println("[DataGetter] Error in generating iterator.");
else {
System.out.println("[DataGetter] Converting windows.");
while (i.hasNext())
windows.add(convert.windowToAPI((database.Window) i.next()));
windowArray = windows.toArray(windowArray);
}
}
System.out.println("[DataGetter] Constructing UserData.");