You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Noel J. Bergman" <no...@devtech.com> on 2002/10/23 21:30:25 UTC

RE: Re[2]: Mailbox quota

>>> how to set restriction at the mailbox size for file storage?
>> you can create a matcher to check the quota:
>> <mailet match="Quota[=max-size]" class="ToProcessor">
> Thanks! I'll do it.

Great.  :-)  Please submit it when you're done.  :-)

Here is a rough draft (not even tried to compile) for the key code:

    private long storageUsed(String user) {
        long size = 0;
        MailRepository userInbox = mailServer.getUserInbox(user);
        for (Iterator it = userInbox.list(); it.hasNext(); ) {
            String key = (String) it.next();
            MailImpl mc = userInbox.retrieve(key);
            // Retrieve can return null if the mail is no longer in the
store.
            if (mc != null) size += mc.getMessageSize();
        }
        return size;
    }

Hope that helps.  Actually, I think it should be added to the MailRepository
interface, but this should help you for now.

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>