sureshanaparti commented on a change in pull request #5866:
URL: https://github.com/apache/cloudstack/pull/5866#discussion_r794313356
##########
File path: server/src/main/java/com/cloud/usage/UsageServiceImpl.java
##########
@@ -397,6 +363,56 @@ public boolean
generateUsageRecords(GenerateUsageRecordsCmd cmd) {
return new Pair<List<? extends Usage>, Integer>(usageRecords.first(),
usageRecords.second());
}
+ private Long getDomainScopeForQuery(ListUsageRecordsCmd cmd, Long
accountId, Long domainId, Account caller, boolean isDomainAdmin) {
+ if (isDomainAdmin) {
+ if (domainId != null) {
+ Account callerAccount =
_accountService.getAccount(caller.getId());
+ Domain domain = _domainDao.findById(domainId);
+ _accountService.checkAccess(callerAccount, domain);
+ } else {
+ domainId = caller.getDomainId();
+ }
+
+ if (cmd.getAccountId() != null) {
+ checkDomainAdminAccountAccess(accountId, domainId);
+ }
+ }
+ return domainId;
+ }
+
+ @NotNull
+ private Long getAccountIdFromDomainPlusName(Long domainId, String
accountName, Account caller) {
+ Long accountId;
+ Account userAccount = null;
+ if (! _domainDao.isChildDomain(caller.getDomainId(), domainId)) {
+ throw new PermissionDeniedException("Invalid Domain Id or
Account");
+ }
+ 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) {
+ throw new InvalidParameterValueException("Unable to find account "
+ accountName + " in domain " + domainId);
+ }
+ return userAccount.getId();
+ }
+
+ @NotNull
+ private Long GetAccountIdFromProject(Long projectId) {
Review comment:
```suggestion
private Long getAccountIdFromProject(Long projectId) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]