class QuotaChecker {

    void checkGroupQuota(ObjectStoreConnection con, String domainName, Group group, String caller) {

        // if quota check is disabled we have nothing to do

        if (!quotaCheckEnabled) {
            return;
        }

        // if our group is null then there is no quota check

        if (group == null) {
            return;
        }

        // first retrieve the domain quota

        final Quota quota = getDomainQuota(con, domainName);

        // first we're going to verify the elements that do not
        // require any further data from the object store

        int objectCount = getListSize(group.getGroupMembers());
        if (quota.getGroupMember() < objectCount) {
            throw ZMSUtils.quotaLimitError("group member quota exceeded - limit: "
                    + quota.getGroupMember() + " actual: " + objectCount, caller);
        }

        // now we're going to check if we'll be allowed
        // to create this group in the domain

        objectCount = con.countGroups(domainName) + 1;
        if (quota.getGroup() < objectCount) {
            throw ZMSUtils.quotaLimitError("group quota exceeded - limit: "
                    + quota.getGroup() + " actual: " + objectCount, caller);
        }
    }

    public  QuotaChecker();

}