Проверям сообщение на соответствие роботу @param message @return
(FtnMessage message)
| 831 | * @return |
| 832 | */ |
| 833 | public static boolean checkRobot(FtnMessage message) { |
| 834 | boolean isRobot = false; |
| 835 | String robotname = ""; |
| 836 | if (message.isNetmail()) { |
| 837 | if (MainHandler.getCurrentInstance().getInfo().getAddressList() |
| 838 | .contains(message.getToAddr())) { |
| 839 | // TODO: optiomize |
| 840 | IRobot oRobot = robotMaps |
| 841 | .get(message.getToName().toLowerCase()); |
| 842 | if (oRobot == null) { |
| 843 | try { |
| 844 | Robot robot = ORMManager.get(Robot.class).getById( |
| 845 | message.getToName().toLowerCase()); |
| 846 | if (robot != null) { |
| 847 | robotname = robot.getRobot(); |
| 848 | Class<?> clazz = Class |
| 849 | .forName(robot.getClassName()); |
| 850 | oRobot = (IRobot) clazz.newInstance(); |
| 851 | robotMaps.put(robotname, oRobot); |
| 852 | logger.l4("Message " + message.getMsgid() |
| 853 | + " sent to robot " + robotname); |
| 854 | } |
| 855 | } catch (ClassNotFoundException e) { |
| 856 | logger.l2("Robot class not found (INIT) " + robotname, |
| 857 | e); |
| 858 | } catch (Exception e) { |
| 859 | logger.l2( |
| 860 | "Robot excception " + robotname + " (INIT) ", |
| 861 | e); |
| 862 | } |
| 863 | } |
| 864 | if (oRobot != null) { |
| 865 | isRobot = true; |
| 866 | try { |
| 867 | oRobot.execute(message); |
| 868 | } catch (Exception e) { |
| 869 | logger.l2("Robot excception " + robotname |
| 870 | + " (PROCCESS) ", e); |
| 871 | } |
| 872 | } |
| 873 | } |
| 874 | } |
| 875 | return isRobot; |
| 876 | } |
| 877 | |
| 878 | /** |
| 879 | * Получаем роутинг для нетмейла |
no test coverage detected