/**
     * Takes the given message from Harvest, figures out its severity and reports it back to
     * CruiseControl.
     *
     * @param message The message to process.
     */
    public void handleMessage(String message) {
      int level = JCaHarvestLogStream.getSeverityLevel(message);

      // Convert Harvest level to log4j level
      switch (level) {
        case JCaHarvestLogStream.INFO:
          LOG.info(message);
          break;
        case JCaHarvestLogStream.WARNING:
          LOG.warn(message);
          break;
        case JCaHarvestLogStream.ERROR:
          LOG.error(message);
          break;
        case JCaHarvestLogStream.OK:
        default:
          LOG.debug(message);
          break;
      }
    }
  /** Internal method which connects to Harvest using the details provided. */
  protected boolean login() {
    if (loggedIn) {
      return true;
    }

    harvest = new JCaHarvest(broker);

    logstream = new JCaHarvestLogStream();
    logstream.addLogStreamListener(new MyLogStreamListener());

    harvest.setStaticLog(logstream);
    harvest.setLog(logstream);

    if (harvest.login(username, password) != 0) {
      LOG.error("Login failed: " + harvest.getLastMessage());
      return false;
    }

    loggedIn = true;
    return true;
  }