// This method returns the sender data structure private SocketInfo getSenderInfo(boolean senderIsMailUser) { SocketInfo sender = null; // Sender is a POS user if (!senderIsMailUser) { // Querying the info of the sender (a pos user) sender = SocketServer.getSocketInfo(from); // If sender doesn't exist, this operation is aborted if (sender == null) { String msg = "ERROR: El Colocador {" + from + "} no esta registrado en el sistema."; LogWriter.write(msg); sendAlarm("Error procesando mensaje de colocador", msg); return null; } } // Sender is a POP user else { // Querying users from the pop server (admin user) sender = getUserData(from, senderIsMailUser); if (LOTTERY_MODE) { if (sender == null) { sender = insertPopUser(from); if (sender == null) { return null; } } } } return sender; }
private SocketInfo getUserData(String login, boolean senderIsMailUser) { SocketInfo user = null; QueryRunner qRunner = null; ResultSet resultSet = null; if (!senderIsMailUser) { // Check is POS user is online user = SocketServer.getSocketInfo(login); if (user != null) { return user; } } // If user is POP or if is a POS user offline int i = 0; try { if (senderIsMailUser) { qRunner = new QueryRunner("SEL0036", new String[] {login}); } else { qRunner = new QueryRunner("SEL0026", new String[] {login}); } resultSet = qRunner.select(); if (resultSet.next()) { i++; user = SocketServer.getInstaceOfSocketInfo(); user.setUid(resultSet.getInt(1)); user.setLogin(resultSet.getString(2)); user.setNames(resultSet.getString(3)); user.setEmail(resultSet.getString(4)); user.setAdmin(resultSet.getBoolean(5)); user.setAudit(resultSet.getBoolean(6)); user.setGroupID(resultSet.getInt(7)); user.setWsName(resultSet.getString(9)); user.setGroupName(resultSet.getString(12)); } } catch (SQLNotFoundException e) { e.printStackTrace(); } catch (SQLBadArgumentsException e) { e.printStackTrace(); } catch (SQLException e) { LogWriter.write("ERROR: Falla mientras se consultaba la informacion del usuario: " + login); e.printStackTrace(); } finally { QueryClosingHandler.close(resultSet); qRunner.closeStatement(); } return user; }