class QuotaChecker {

    void checkEntityQuota(ObjectStoreConnection con, String domainName, Entity entity,
            String caller) {
        
        // if quota check is disabled we have nothing to do
        
        if (!quotaCheckEnabled) {
            return;
        }
        
        // if our entity is null then there is no quota check
        
        if (entity == null) {
            return;
        }
        
        // first retrieve the domain quota
        
        final Quota quota = getDomainQuota(con, domainName);
        
        // we're going to check if we'll be allowed
        // to create this entity in the domain
        
        int objectCount = con.countEntities(domainName) + 1;
        if (quota.getEntity() < objectCount) {
            throw ZMSUtils.quotaLimitError("entity quota exceeded - limit: "
                    + quota.getEntity() + " actual: " + objectCount, caller);
        }
    }

    public  QuotaChecker();

}