Esempio n. 1
0
  public static void outputMessages(Map<String, ImportMessageBean> messageMap) {
    for (ImportMessageBean message : messageMap.values()) {
      ArrayList<String> msgList = message.getMessageList();
      boolean doneWithMessage = false;

      for (int k = 0; k < msgList.size() && !doneWithMessage; ++k) {
        String msgToShow = (String) msgList.get(k);
        if (k == message.getMaxNumToDisplay() - 1) {
          int numberNotShown = message.getMessageList().size() - message.getMaxNumToDisplay();
          msgToShow = msgToShow + " [ " + numberNotShown + " SIMILAR ERRORS NOT SHOWN ]";
          doneWithMessage = true;
        }

        switch (message.getSeverity()) {
          case Error:
            MessageHandler.sendErrorMessage(msgToShow);
            break;
          case Warn:
            MessageHandler.sendWarnMessage(msgToShow);
            break;
          default:
            MessageHandler.sendInfoMessage(msgToShow);
            break;
        }
      }
    }
  }
Esempio n. 2
0
  public static void addMessage(
      Map<String, ImportMessageBean> messageMap, String messageId, String message) {

    ImportMessageBean messageBean = messageMap.get(messageId);
    if (messageBean == null) {
      for (ImportMessageBean current : messageMap.values()) {
        if (current.pattern != null && current.pattern.matcher(message).find()) {
          LOG.fine("Pattern matched: " + current.getMessageId());
          messageBean = current;
        }
      }

      if (messageBean == null)
        // just use the message itself as the id for a new one to ensure it doesn't get stomped on
        // later.
        messageMap.put(
            message,
            messageBean =
                new ImportMessageBean(message, message, Integer.MAX_VALUE, Severity.Error));
    }

    messageBean.messageList.add(message);
  }