From 61cb4ea0663a737e5a5cb27177c50907f9bad02e Mon Sep 17 00:00:00 2001 From: PrashantBhanage Date: Thu, 25 Jun 2026 13:54:18 +0530 Subject: [PATCH] Refactor: Modularize ApiResponseHelper#createUsageResponse Fixes #11635 - Extracted the 500+ line switch/if-else block into a main dispatcher method `populateUsageTypeSpecificDetails`. - Created 18 individual private helper methods for each specific `UsageType` to improve maintainability and readability. - Introduced a `UsageResourceDetails` container class to safely manage and return `resourceId` and `resourceType` state for tag lookups. - Verified zero business logic changes; strictly structural refactoring. --- .../java/com/cloud/api/ApiResponseHelper.java | 950 ++++++++++-------- 1 file changed, 530 insertions(+), 420 deletions(-) diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java index 8c51d9926841..f309196442ea 100644 --- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -4184,474 +4184,584 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord, Map