Source:
public QuotaCreditsResponse addQuotaCredits(final Long accountId, final Long domainId, final Double amount, final Long updatedBy, final Date despositedOn) { final short opendb = TransactionLegacy.currentTxn().getDatabaseId(); QuotaCreditsVO result = null; TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { QuotaCreditsVO credits = new QuotaCreditsVO(accountId, domainId, new BigDecimal(amount), updatedBy); s_logger.info("addQuotaCredits: Depositing " + amount + " on adjusted date " + despositedOn); credits.setUpdatedOn(despositedOn); result = _quotaCreditsDao.saveCredits(credits); } finally { txn.close(); } TransactionLegacy.open(TransactionLegacy.CLOUD_DB).close(); final AccountVO account = _accountDao.findById(accountId); final boolean lockAccountEnforcement = QuotaConfig.QuotaEnableEnforcement.value().equalsIgnoreCase("true"); final BigDecimal currentAccountBalance = _quotaBalanceDao.lastQuotaBalance(accountId, domainId, startOfNextDay(despositedOn)); if (lockAccountEnforcement && (currentAccountBalance.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())); } } } String creditor = String.valueOf(Account.ACCOUNT_ID_SYSTEM); User creditorUser = _userDao.getUser(updatedBy); if (creditorUser != null) { creditor = creditorUser.getUsername(); } TransactionLegacy.open(opendb).close(); QuotaCreditsResponse response = new QuotaCreditsResponse(result, creditor); response.setCurrency(QuotaConfig.QuotaCurrencySymbol.value()); return response; }

Target:
public QuotaCreditsResponse addQuotaCredits(final Long accountId, final Long domainId, final Double amount, final Long updatedBy, final Date despositedOn) { final short opendb = TransactionLegacy.currentTxn().getDatabaseId(); QuotaCreditsVO result = null; TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB); try { QuotaCreditsVO credits = new QuotaCreditsVO(accountId, domainId, new BigDecimal(amount), updatedBy); s_logger.info("addQuotaCredits: Depositing " + amount + " on adjusted date " + despositedOn); credits.setUpdatedOn(despositedOn); result = _quotaCreditsDao.saveCredits(credits); } finally { txn.close(); } TransactionLegacy.open(TransactionLegacy.CLOUD_DB).close(); final AccountVO account = _accountDao.findById(accountId); final boolean lockAccountEnforcement = "true".equalsIgnoreCase(QuotaConfig.QuotaEnableEnforcement.value()); final BigDecimal currentAccountBalance = _quotaBalanceDao.lastQuotaBalance(accountId, domainId, startOfNextDay(despositedOn)); if (lockAccountEnforcement && (currentAccountBalance.compareTo(new BigDecimal(0)) >= 0)) { if (account.getState() == Account.State.locked) { _regionMgr.enableAccount(account.getAccountName(), domainId, accountId); } } String creditor = String.valueOf(Account.ACCOUNT_ID_SYSTEM); User creditorUser = _userDao.getUser(updatedBy); if (creditorUser != null) { creditor = creditorUser.getUsername(); } TransactionLegacy.open(opendb).close(); QuotaCreditsResponse response = new QuotaCreditsResponse(result, creditor); response.setCurrency(QuotaConfig.QuotaCurrencySymbol.value()); return response; }