/**
     * Take all values from this object.
     *
     * @param user The user object to take values from.
     */
    protected void setAll(Digest digest) {
      m_id = digest.getId();

      m_properties = new BaseResourcePropertiesEdit();
      m_properties.addAll(digest.getProperties());

      m_ranges = new Hashtable();
      // %%% deep enough? -ggolden
      m_ranges.putAll(((BaseDigest) digest).m_ranges);
    }
  /**
   * If it's time, send out any digested messages. Send once daily, after a certiain time of day
   * (local time).
   */
  protected void sendDigests() {
    if (M_log.isDebugEnabled()) M_log.debug("checking for sending digests");

    // compute the current period
    String curPeriod = computeRange(timeService().newTime()).toString();

    // if we are in a new period, start sending again
    if (!curPeriod.equals(m_lastSendPeriod)) {
      m_sendDigests = true;

      // remember this period for next check
      m_lastSendPeriod = curPeriod;
    }

    // if we are not sending, early out
    if (!m_sendDigests) return;

    M_log.info("Preparing to send the mail digests for " + curPeriod);

    // count send candidate digests
    int count = 0;

    // process each digest
    List digests = getDigests();
    for (Iterator iDigests = digests.iterator(); iDigests.hasNext(); ) {
      Digest digest = (Digest) iDigests.next();

      // see if this one has any prior periods
      List periods = digest.getPeriods();
      if (periods.size() == 0) continue;

      boolean found = false;
      for (Iterator iPeriods = periods.iterator(); iPeriods.hasNext(); ) {
        String period = (String) iPeriods.next();
        if (!curPeriod.equals(period)) {
          found = true;
          break;
        }
      }
      if (!found) {
        continue;
      }

      // this digest is a send candidate
      count++;

      // get a lock
      DigestEdit edit = null;
      try {
        boolean changed = false;
        edit = edit(digest.getId());

        // process each non-current period
        for (Iterator iPeriods = edit.getPeriods().iterator(); iPeriods.hasNext(); ) {
          String period = (String) iPeriods.next();

          // process if it's not the current period
          if (!curPeriod.equals(period)) {
            TimeRange periodRange = timeService().newTimeRange(period);
            Time timeInPeriod = periodRange.firstTime();

            // any messages?
            List msgs = edit.getMessages(timeInPeriod);
            if (msgs.size() > 0) {
              // send this one
              send(edit.getId(), msgs, periodRange);
            }

            // clear this period
            edit.clear(timeInPeriod);

            changed = true;
          }
        }

        // commit, release the lock
        if (changed) {
          // delete it if empty
          if (edit.getPeriods().size() == 0) {
            remove(edit);
          } else {
            commit(edit);
          }
          edit = null;
        } else {
          cancel(edit);
          edit = null;
        }
      }
      // if in use, missing, whatever, skip on
      catch (Throwable any) {
      } finally {
        if (edit != null) {
          cancel(edit);
          edit = null;
        }
      }
    } // for (Iterator iDigests = digests.iterator(); iDigests.hasNext();)

    // if we didn't see any send candidates, we will stop sending till next period
    if (count == 0) {
      m_sendDigests = false;
    }
  }