shwstppr commented on code in PR #12336:
URL: https://github.com/apache/cloudstack/pull/12336#discussion_r3534173359
##########
api/src/main/java/org/apache/cloudstack/context/CallContext.java:
##########
@@ -135,6 +141,25 @@ public Account getCallingAccount() {
return account;
}
+ public boolean isCallingAccountRootAdmin() {
+ if (isAccountRootAdmin != null) {
+ return isAccountRootAdmin;
+ }
+ if (account == null && s_entityMgr == null) {
+ return false;
+ }
+ Account caller = getCallingAccount();
+ AccountService accountService;
+ try {
+ accountService =
ComponentContext.getDelegateComponentOfType(AccountService.class);
+ } catch (NoSuchBeanDefinitionException e) {
+ LOGGER.warn("Falling back to account type check for isRootAdmin
for account ID: {} as no AccountService bean found: {}", accountId,
e.getMessage());
+ return caller != null && caller.getType() == Account.Type.ADMIN;
+ }
Review Comment:
We want to cache only when the result is from accountService
--
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]