if (t instanceof LoginFailedException) {
throw (LoginFailedException) t;
} else if (t instanceof DBDirtyException) {
throw (DBDirtyException) t;
} else {
throw new LoginFailedException("Login response undefined!");
}
} else if (response instanceof DataResponse) {
DataResponse dataResponse = (DataResponse) response;
if (dataResponse.getObjects().size() != 1) {
fireEvent(NetworkEvent.NEType.loginError);
throw new LoginFailedException("Login response undefined!");
}
Object obj = dataResponse.getObjects().get(0);
if (!(obj instanceof Employee)) {
fireEvent(NetworkEvent.NEType.loginError);
throw new LoginFailedException("Login response undefined!");
}
Employee employee = (Employee) obj;
{
final List<ClientLogRecord> list = SerializingReportHandler.getInstance().read();
for (ClientLogRecord clientLogRecord : list) {
final Response o1 = synchroneousRequest(clientLogRecord);
if (!(o1 instanceof VoidResponse)) {
fireEvent(NetworkEvent.NEType.loginError);
throw new LoginFailedException("Problem sending exception to the server.");
}
}
SerializingReportHandler.getInstance().clear();
if (!list.isEmpty()) {
logger.info(String.format("Sent %d exceptions to the server.", list.size()));
}
}
setStreams();
fireEvent(NetworkEvent.NEType.loggedIn, employee.getEmail());
return employee;
} else {
fireEvent(NetworkEvent.NEType.loginError);
throw new LoginFailedException("Login response undefined!");
}
}