Exemple #1
0
  /**
   * Builds the response to be shown.
   *
   * @param logMessageSetVO - Object of LogMessageSetVO containing errors/warnings to be shown.
   * @param isHTML - Whether response is in html format or not.
   * @return - The response string.
   */
  public static String buildResponse(LogMessageSetVO logMessageSetVO, boolean isHTML) {

    // Assume that eCodes contains a list of comma separated error/warning
    // codes
    // Get the Error message for each code and terminate it with <BR> in
    // case of HTML, else terminate with &

    StringBuffer err_buf = new StringBuffer();
    StringBuffer warn_buf = new StringBuffer();
    String errors = "";
    String notices = "";
    Set<LOGMESSAGE> errorSet = logMessageSetVO.getErrorsSet();
    Set<LOGMESSAGE> warningSet = logMessageSetVO.getWarningSet();

    for (Enum<LOGMESSAGE> error : errorSet) {
      // Error
      err_buf.append(error.toString());
    }
    for (Enum<LOGMESSAGE> warning : warningSet) {
      // Error
      err_buf.append(warning.toString());
    }

    if (err_buf.length() > 0)
      errors =
          (isHTML ? "<BR>" : "&")
              + "statusMessage="
              + err_buf.substring(0)
              + (isHTML ? "<BR>" : "&")
              + "statusCode="
              + Status.FAILURE.getCode();
    else errors = "statusMessage=" + Status.SUCCESS + "&statusCode=" + Status.SUCCESS.getCode();
    if (warn_buf.length() > 0)
      notices = (isHTML ? "<BR>" : "&") + "notice=" + warn_buf.substring(0);

    String otherMessages = logMessageSetVO.getOtherMessages();
    otherMessages = otherMessages == null ? "" : otherMessages;

    logger.info("Errors=" + errors);
    logger.info("Notices=" + notices);
    logger.info("Miscellaneous Messages=" + otherMessages);
    return errors + notices + otherMessages;
  }