Example #1
0
  public void group(Map<String, List<String>> requestProperties) {
    UnitofInteraction talking = new UnitofInteraction(requestProperties);
    talking.startThread();

    Group _group = new Group();
    Map<String, String> result = null;

    try {
      result = _group.Run(GeneralStuff._getArguments(requestProperties));

    } catch (Exception ex) {
      StringWriter str = new StringWriter();
      PrintWriter writer = new PrintWriter(str);
      ex.printStackTrace(writer);
      System.out.println(str.getBuffer().toString());
      talking.notifyError();

    } finally {
      talking.stopThread();
    }

    talking.stopThread();
    String text = result.get("text");
    requestProperties.put("text", Arrays.asList(new String[] {text}));
    // System.out.println ("----\n " + requestProperties.get("text").get(0)+ "----\n ");

    try {
      GeneralStuff._sendMessage(GeneralStuff._forgeMessage(requestProperties));
    } catch (IOException ex) {
      Logger.getLogger(Commands.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Example #2
0
  public void compare(Map<String, List<String>> requestProperties) {
    Compare _compare = new Compare();
    UnitofInteraction talking = new UnitofInteraction(requestProperties);
    talking.startThread();

    Map<String, String> result = null;

    try {
      result = _compare.Run(GeneralStuff._getArguments(requestProperties));
    } catch (IOException ex) {
      talking.notifyError();
    } catch (SQLException ex) {
      talking.notifyError();
    } catch (ClassNotFoundException ex) {
      talking.notifyError();
    } finally {
      talking.stopThread();
    }

    String text = result.get("text");
    requestProperties.put("text", Arrays.asList(new String[] {text}));
    System.out.println(text);

    try {
      GeneralStuff._sendMessage(GeneralStuff._forgeMessage(requestProperties));
    } catch (IOException ex) {
      Logger.getLogger(Commands.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Example #3
0
  public void echo(Map<String, List<String>> requestProperties) {
    Echo _echo = new Echo();
    UnitofInteraction talking = new UnitofInteraction(requestProperties);
    talking.startThread();

    Map<String, String> result = _echo.Run(requestProperties);

    talking.stopThread();

    String text = result.get("text");
    requestProperties.put("text", Arrays.asList(new String[] {text}));

    try {
      GeneralStuff._sendMessage(GeneralStuff._forgeMessage(requestProperties));
    } catch (IOException ex) {
      Logger.getLogger(Commands.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Example #4
0
  public void recommendations(Map<String, List<String>> requestProperties) {
    Recommendations _recommendations = new Recommendations();
    UnitofInteraction talking = new UnitofInteraction(requestProperties);
    talking.startThread();

    // Add the "--groupname" preffix to the given command text so the
    // _getArguments method puts the groupname under the "--groupname" key.

    if (requestProperties.get("text") != null) {
      if (requestProperties.get("text").get(0) != null) {

        requestProperties.get("text").set(0, "--groupname " + requestProperties.get("text").get(0));
      }
    }

    Map<String, String> result = null;

    try {
      result = _recommendations.Run(GeneralStuff._getArguments(requestProperties));
    } catch (MessagingException ex) {
      result.put("text", result.get("text") + "`" + ex.getMessage() + "`");
      talking.notifyError();
    } catch (IOException ex) {
      Logger.getLogger(Commands.class.getName()).log(Level.SEVERE, null, ex);
      talking.notifyError();
    } catch (SQLException ex) {
      Logger.getLogger(Commands.class.getName()).log(Level.SEVERE, null, ex);
      talking.notifyError();
    } catch (ClassNotFoundException ex) {
      Logger.getLogger(Commands.class.getName()).log(Level.SEVERE, null, ex);
      talking.notifyError();
    } finally {
      talking.stopThread();
    }

    String text = result.get("text");
    requestProperties.put("text", Arrays.asList(new String[] {text}));
    System.out.println(text);
    try {
      GeneralStuff._sendMessage(GeneralStuff._forgeMessage(requestProperties));
    } catch (IOException ex) {
      Logger.getLogger(Commands.class.getName()).log(Level.SEVERE, null, ex);
    }
  }