-
Notifications
You must be signed in to change notification settings - Fork 1.2k
server: consistent domainpath in api responses #11589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server: consistent domainpath in api responses #11589
Conversation
Currently, some APIs return domainpath as 'ROOT/domain1/domain2' while other return it as '/domain1/domain2'. This PR makes the response consistent. Signed-off-by: Abhishek Kumar <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11589 +/- ##
============================================
+ Coverage 17.36% 17.56% +0.20%
- Complexity 15235 15491 +256
============================================
Files 5888 5897 +9
Lines 525740 528179 +2439
Branches 64164 64716 +552
============================================
+ Hits 91272 92801 +1529
- Misses 424168 424950 +782
- Partials 10300 10428 +128
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 14879 |
DaanHoogland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my preference would be to remove the word ‘ROOT’ but CLGTM (also potaeto/potahto)
Signed-off-by: Abhishek Kumar <[email protected]>
|
@harikrishna-patnala I've made changes to normalize domain path across code now. @blueorangutan package |
|
@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15338 |
|
@blueorangutan test |
|
@harikrishna-patnala a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR standardizes the format of domainpath fields in API responses across all endpoints. Previously, some APIs returned domainpath as 'ROOT/domain1/domain2' while others returned it as '/domain1/domain2'. The changes ensure all APIs consistently return the "ROOT/..." format.
- Centralized domain path formatting logic in a new utility method
getPrettyDomainPath() - Refactored multiple DAO implementations to use common helper methods for owner/domain population
- Updated response interfaces to support the consolidated approach
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ApiResponseHelper.java | Added getPrettyDomainPath() utility method and consolidated owner/domain population logic |
| Multiple DAO implementations | Removed duplicated domain path logic and switched to use centralized helper methods |
| Response classes | Updated interfaces to support unified response handling |
| AddVpnUserCmd.java | Refactored to use response generator instead of manual response construction |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| return null; | ||
| } | ||
| StringBuilder domainPath = new StringBuilder("ROOT"); | ||
| (domainPath.append(path)).deleteCharAt(domainPath.length() - 1); |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method assumes path always ends with a character that can be deleted, but if path is empty or doesn't end with a trailing character, deleteCharAt(domainPath.length() - 1) will throw a StringIndexOutOfBoundsException.
| (domainPath.append(path)).deleteCharAt(domainPath.length() - 1); | |
| if (path != null && !path.isEmpty()) { | |
| domainPath.append(path); | |
| // Remove trailing '/' if present | |
| if (domainPath.length() > 0 && domainPath.charAt(domainPath.length() - 1) == '/') { | |
| domainPath.deleteCharAt(domainPath.length() - 1); | |
| } | |
| } |
| response.setDomainPath(getPrettyDomainPath(domain.getPath())); | ||
| } | ||
|
|
||
| private static void populateDomain(ControlledViewEntityResponse response, long domainId) { |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is declared as private static but needs to be accessible from other classes. It should be public static to match the usage pattern of other helper methods in this class.
| private static void populateDomain(ControlledViewEntityResponse response, long domainId) { | |
| public static void populateDomain(ControlledViewEntityResponse response, long domainId) { |
|
@shwstppr I prefer "/" but am not going to make a big issue about it. what do you think @harikrishna-patnala ? |
|
[SF] Trillian test result (tid-14576)
|
Both are fine, but ROOT/ seems better to me as it implies directly and we are showing the domain as ROOT in UI as well. |
* server: consistent domainpath in api responses Currently, some APIs return domainpath as 'ROOT/domain1/domain2' while other return it as '/domain1/domain2'. This PR makes the response consistent like "ROOT/domain1/domain2" Signed-off-by: Abhishek Kumar <[email protected]> * more changes Signed-off-by: Abhishek Kumar <[email protected]> --------- Signed-off-by: Abhishek Kumar <[email protected]>
Description
Currently, some APIs return domainpath as 'ROOT/domain1/domain2' while other return it as '/domain1/domain2'. This PR makes the response consistent.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Before:
After:
How did you try to break this feature and the system with this change?