Search in sources :

Example 1 with InvalidQuotaParametersException

use of org.ovirt.engine.core.bll.quota.InvalidQuotaParametersException in project ovirt-engine by oVirt.

the class CommandBase method internalValidateAndSetQuota.

private boolean internalValidateAndSetQuota() {
    // Quota accounting is done only in the most external Command.
    if (!isQuotaDependant()) {
        return true;
    }
    QuotaConsumptionParametersWrapper quotaConsumptionParametersWrapper = new QuotaConsumptionParametersWrapper(this, getReturnValue().getValidationMessages());
    quotaConsumptionParametersWrapper.setParameters(getQuotaConsumptionParameters());
    List<QuotaConsumptionParameter> quotaParams = quotaConsumptionParametersWrapper.getParameters();
    if (quotaParams == null) {
        throw new InvalidQuotaParametersException("Command: " + this.getClass().getName() + ". No Quota parameters available.");
    }
    // scenarios like this must set its QuotaConsumptionParameter to an empty list.
    if (quotaParams.isEmpty()) {
        return true;
    }
    if (getStoragePool() == null) {
        throw new InvalidQuotaParametersException("Command: " + this.getClass().getName() + ". Storage pool is not available for quota calculation. ");
    }
    boolean result = getQuotaManager().consume(quotaConsumptionParametersWrapper);
    setQuotaChanged(result);
    return result;
}
Also used : InvalidQuotaParametersException(org.ovirt.engine.core.bll.quota.InvalidQuotaParametersException) QuotaConsumptionParametersWrapper(org.ovirt.engine.core.bll.quota.QuotaConsumptionParametersWrapper) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)

Aggregations

InvalidQuotaParametersException (org.ovirt.engine.core.bll.quota.InvalidQuotaParametersException)1 QuotaConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)1 QuotaConsumptionParametersWrapper (org.ovirt.engine.core.bll.quota.QuotaConsumptionParametersWrapper)1