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;
}
Aggregations