Source:
public List<QuotaUsageVO> getQuotaUsage(Long accountId, String accountName, Long domainId, Integer usageType, Date startDate, Date endDate) { final short opendb = TransactionLegacy.currentTxn().getDatabaseId(); TransactionLegacy.open(TransactionLegacy.CLOUD_DB).close(); if ((accountId == null) && (accountName != null) && (domainId != null)) { Account userAccount = null; Account caller = CallContext.current().getCallingAccount(); if (_domainDao.isChildDomain(caller.getDomainId(), domainId)) { Filter filter = new Filter(AccountVO.class, "id", Boolean.FALSE, null, null); List<AccountVO> accounts = _accountDao.listAccounts(accountName, domainId, filter); if (accounts.size() > 0) { userAccount = accounts.get(0); } if (userAccount != null) { accountId = userAccount.getId(); } else { throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId); } } else { throw new PermissionDeniedException("Invalid Domain Id or Account"); } } TransactionLegacy.open(opendb).close(); if (startDate.after(endDate)) { throw new InvalidParameterValueException("Incorrect Date Range. Start date: " + startDate + " is after end date:" + endDate); } if (endDate.after(_respBldr.startOfNextDay())) { throw new InvalidParameterValueException("Incorrect Date Range. End date:" + endDate + " should not be in future. "); } Date adjustedEndDate = computeAdjustedTime(endDate); Date adjustedStartDate = computeAdjustedTime(startDate); s_logger.debug("Getting quota records for account: " + accountId + ", domainId: " + domainId + ", between " + startDate + " and " + endDate); return _quotaUsageDao.findQuotaUsage(accountId, domainId, usageType, adjustedStartDate, adjustedEndDate); }

Target:
public List<QuotaUsageVO> getQuotaUsage(Long accountId, String accountName, Long domainId, Integer usageType, Date startDate, Date endDate) { if ((accountId == null) && (accountName != null) && (domainId != null)) { Account userAccount = null; Account caller = CallContext.current().getCallingAccount(); if (_domainDao.isChildDomain(caller.getDomainId(), domainId)) { Filter filter = new Filter(AccountVO.class, "id", Boolean.FALSE, null, null); List<AccountVO> accounts = _accountDao.listAccounts(accountName, domainId, filter); if (!accounts.isEmpty()) { userAccount = accounts.get(0); } if (userAccount != null) { accountId = userAccount.getId(); } else { throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId); } } else { throw new PermissionDeniedException("Invalid Domain Id or Account"); } } if (startDate.after(endDate)) { throw new InvalidParameterValueException("Incorrect Date Range. Start date: " + startDate + " is after end date:" + endDate); } if (endDate.after(_respBldr.startOfNextDay())) { throw new InvalidParameterValueException("Incorrect Date Range. End date:" + endDate + " should not be in future. "); } Date adjustedEndDate = computeAdjustedTime(endDate); Date adjustedStartDate = computeAdjustedTime(startDate); if (s_logger.isDebugEnabled()) { s_logger.debug("Getting quota records for account: " + accountId + ", domainId: " + domainId + ", between " + startDate + " and " + endDate); } return _quotaUsageDao.findQuotaUsage(accountId, domainId, usageType, adjustedStartDate, adjustedEndDate); }