winterhazel commented on code in PR #13449:
URL: https://github.com/apache/cloudstack/pull/13449#discussion_r3508841626


##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaCreditsCmd.java:
##########
@@ -100,42 +112,28 @@ public void setValue(Double value) {
         this.value = value;
     }
 
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public Long getProjectId() {
+        return projectId;
+    }
+
     public QuotaCreditsCmd() {
         super();
     }
 
     @Override
     public void execute() {
-        Long accountId = null;
-        Account account = _accountService.getActiveAccountByName(accountName, 
domainId);
-        if (account != null) {
-            accountId = account.getAccountId();
-        }
-        if (accountId == null) {
-            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "The 
Account does not exists or has been removed/disabled");
-        }
-        if (getValue() == null) {
-            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Please 
send a valid non-empty quota value");
-        }
-        if (getQuotaEnforce() != null) {
-            _quotaService.setLockAccount(accountId, getQuotaEnforce());
-        }
-        if (getMinBalance() != null) {
-            _quotaService.setMinBalance(accountId, getMinBalance());
-        }
-
-        final QuotaCreditsResponse response = 
_responseBuilder.addQuotaCredits(accountId, getDomainId(), getValue(), 
CallContext.current().getCallingUserId(), getQuotaEnforce());
+        QuotaCreditsResponse response = _responseBuilder.addQuotaCredits(this);
         response.setResponseName(getCommandName());
         response.setObjectName("quotacredits");
         setResponseObject(response);
     }
 
     @Override
     public long getEntityOwnerId() {
-        Account account = _accountService.getActiveAccountByName(accountName, 
domainId);
-        if (account != null) {
-            return account.getAccountId();
-        }
         return Account.ACCOUNT_ID_SYSTEM;
     }

Review Comment:
   This is intended. Only root admins should be able to add credits.



-- 
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]

Reply via email to