Skip to content

Commit 8cdd7fd

Browse files
author
Julien Hervot de Mattos Vaz
committed
Fix projectid behavior
1 parent d9984c0 commit 8cdd7fd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
import com.cloud.domain.Domain;
4646
import com.cloud.exception.PermissionDeniedException;
47+
import com.cloud.projects.ProjectVO;
48+
import com.cloud.projects.dao.ProjectDao;
4749
import com.cloud.user.User;
4850
import com.cloud.user.UserVO;
4951
import com.cloud.utils.DateUtil;
@@ -139,6 +141,8 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
139141
@Inject
140142
private AccountDao _accountDao;
141143
@Inject
144+
private ProjectDao projectDao;
145+
@Inject
142146
private QuotaAccountDao quotaAccountDao;
143147
@Inject
144148
private DomainDao domainDao;
@@ -188,7 +192,13 @@ public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO tariff, boole
188192
public Pair<List<QuotaSummaryResponse>, Integer> createQuotaSummaryResponse(QuotaSummaryCmd cmd) {
189193
Account caller = CallContext.current().getCallingAccount();
190194

191-
if (cmd.getAccountId() != null && !cmd.isListAll() && accountTypesThatCanListAllQuotaSummaries.contains(caller.getType())) {
195+
if (cmd.getProjectId() != null && !cmd.isListAll() && accountTypesThatCanListAllQuotaSummaries.contains(caller.getType())) {
196+
ProjectVO projectVO = projectDao.findById(cmd.getProjectId());
197+
Long projectAccountId = projectVO.getProjectAccountId();
198+
return getQuotaSummaryResponse(projectAccountId, null, null, null, cmd);
199+
}
200+
201+
else if (cmd.getAccountId() != null && !cmd.isListAll() && accountTypesThatCanListAllQuotaSummaries.contains(caller.getType())) {
192202
return getQuotaSummaryResponse(cmd.getAccountId(), null, null, null, cmd);
193203
}
194204

0 commit comments

Comments
 (0)