diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java index a7d28169b72..50d1cf60eef 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java @@ -282,22 +282,12 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder { TransactionLegacy.open(TransactionLegacy.CLOUD_DB).close(); final AccountVO account = _accountDao.findById(accountId); final boolean lockAccountEnforcement = QuotaConfig.QuotaEnableEnforcement.value().equalsIgnoreCase("true"); - if (lockAccountEnforcement) { - if (_quotaBalanceDao.lastQuotaBalance(accountId, domainId, new Date()).compareTo(new BigDecimal(0)) >= 0) { - if (account.getState() == Account.State.locked) { - try { - _regionMgr.enableAccount(account.getAccountName(), domainId, accountId); - } catch (Exception e) { - s_logger.error(String.format("Unable to unlock account %s after getting enough quota credits", account.getAccountName())); - } - } - } else { - if (account.getState() == Account.State.enabled) { - try { - _regionMgr.disableAccount(account.getAccountName(), domainId, accountId, true); - } catch (Exception e) { - s_logger.error(String.format("Unable to lock account %s due to low balance", account.getAccountName())); - } + if (lockAccountEnforcement && (_quotaBalanceDao.lastQuotaBalance(accountId, domainId, new Date()).compareTo(new BigDecimal(0)) >= 0)) { + if (account.getState() == Account.State.locked) { + try { + _regionMgr.enableAccount(account.getAccountName(), domainId, accountId); + } catch (Exception e) { + s_logger.error(String.format("Unable to unlock account %s after getting enough quota credits", account.getAccountName())); } } }