@@ -205,11 +205,6 @@ public Pair<List<QuotaSummaryResponse>, Integer> createQuotaSummaryResponse(Quot
205205 }
206206
207207 protected Pair <List <QuotaSummaryResponse >, Integer > getQuotaSummaryResponseWithListAll (QuotaSummaryCmd cmd , Account caller ) {
208- Long accountId = cmd .getEntityOwnerId ();
209- if (accountId == -1 ) {
210- accountId = cmd .isListAll () ? null : caller .getAccountId ();
211- }
212-
213208 Long domainId = cmd .getDomainId ();
214209 if (domainId != null ) {
215210 DomainVO domain = domainDao .findByIdIncludingRemoved (domainId );
@@ -220,6 +215,12 @@ protected Pair<List<QuotaSummaryResponse>, Integer> getQuotaSummaryResponseWithL
220215
221216 String domainPath = getDomainPathByDomainIdForDomainAdmin (caller );
222217
218+ Long accountId = cmd .getEntityOwnerId ();
219+ if (accountId == -1 ) {
220+ // No specific account was provided
221+ accountId = cmd .isListAll () ? null : caller .getAccountId ();
222+ }
223+
223224 String keyword = null ;
224225 if (Account .Type .ADMIN .equals (caller .getType ())) {
225226 keyword = cmd .getKeyword ();
@@ -250,7 +251,8 @@ protected String getDomainPathByDomainIdForDomainAdmin(Account caller) {
250251 }
251252
252253 protected Pair <List <QuotaSummaryResponse >, Integer > getQuotaSummaryResponse (Long accountId , String accountName , Long domainId , String domainPath , QuotaSummaryCmd cmd ) {
253- if (accountId == -1 ) {
254+ if (accountId != null && accountId == -1 ) {
255+ // Either no specific account as provided, or list all is disabled
254256 accountId = CallContext .current ().getCallingAccountId ();
255257 }
256258
@@ -301,33 +303,6 @@ protected QuotaSummaryResponse getQuotaSummaryResponse(QuotaSummaryVO summary) {
301303 return response ;
302304 }
303305
304- protected QuotaSummaryResponse getQuotaSummaryResponse (final Account account ) {
305- Calendar [] period = quotaStatement .getCurrentStatementTime ();
306-
307- if (account != null ) {
308- QuotaSummaryResponse qr = new QuotaSummaryResponse ();
309- DomainVO domain = domainDao .findById (account .getDomainId ());
310- BigDecimal curBalance = _quotaBalanceDao .lastQuotaBalance (account .getAccountId (), account .getDomainId (), period [1 ].getTime ());
311- BigDecimal quotaUsage = quotaUsageDao .findTotalQuotaUsage (account .getAccountId (), account .getDomainId (), null , period [0 ].getTime (), period [1 ].getTime ());
312-
313- qr .setAccountId (account .getUuid ());
314- qr .setAccountName (account .getAccountName ());
315- qr .setDomainId (domain .getUuid ());
316- qr .setDomainPath (domain .getName ());
317- qr .setBalance (curBalance );
318- qr .setQuotaUsage (quotaUsage );
319- qr .setState (account .getState ());
320- qr .setStartDate (period [0 ].getTime ());
321- qr .setEndDate (period [1 ].getTime ());
322- qr .setCurrency (QuotaConfig .QuotaCurrencySymbol .value ());
323- qr .setQuotaEnabled (QuotaConfig .QuotaAccountEnabled .valueIn (account .getId ()));
324- qr .setObjectName ("summary" );
325- return qr ;
326- } else {
327- return new QuotaSummaryResponse ();
328- }
329- }
330-
331306 public boolean isUserAllowedToSeeActivationRules (User user ) {
332307 List <ApiDiscoveryResponse > apiList = (List <ApiDiscoveryResponse >) apiDiscoveryService .listApis (user , null ).getResponses ();
333308 return apiList .stream ().anyMatch (response -> StringUtils .equalsAny (response .getName (), "quotaTariffCreate" , "quotaTariffUpdate" ));
0 commit comments