-
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
Merged
harikrishna-patnala
merged 2 commits into
apache:main
from
shwstppr:fix-api-consistentdomainpath
Oct 9, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -530,6 +530,15 @@ public class ApiResponseHelper implements ResponseGenerator { | |||||
| @Inject | ||||||
| ResourceIconManager resourceIconManager; | ||||||
|
|
||||||
| public static String getPrettyDomainPath(String path) { | ||||||
| if (path == null) { | ||||||
| return null; | ||||||
| } | ||||||
| StringBuilder domainPath = new StringBuilder("ROOT"); | ||||||
| (domainPath.append(path)).deleteCharAt(domainPath.length() - 1); | ||||||
| return domainPath.toString(); | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public UserResponse createUserResponse(User user) { | ||||||
| UserAccountJoinVO vUser = ApiDBUtils.newUserView(user); | ||||||
|
|
@@ -567,9 +576,7 @@ public DomainResponse createDomainResponse(Domain domain) { | |||||
| if (parentDomain != null) { | ||||||
| domainResponse.setParentDomainId(parentDomain.getUuid()); | ||||||
| } | ||||||
| StringBuilder domainPath = new StringBuilder("ROOT"); | ||||||
| (domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1); | ||||||
| domainResponse.setPath(domainPath.toString()); | ||||||
| domainResponse.setPath(getPrettyDomainPath(domain.getPath())); | ||||||
| if (domain.getParent() != null) { | ||||||
| domainResponse.setParentDomainName(ApiDBUtils.findDomainById(domain.getParent()).getName()); | ||||||
| } | ||||||
|
|
@@ -822,21 +829,6 @@ public VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot) { | |||||
| } | ||||||
| } | ||||||
| populateOwner(vmSnapshotResponse, vmSnapshot); | ||||||
| Project project = ApiDBUtils.findProjectByProjectAccountId(vmSnapshot.getAccountId()); | ||||||
| if (project != null) { | ||||||
| vmSnapshotResponse.setProjectId(project.getUuid()); | ||||||
| vmSnapshotResponse.setProjectName(project.getName()); | ||||||
| } | ||||||
| Account account = ApiDBUtils.findAccountById(vmSnapshot.getAccountId()); | ||||||
| if (account != null) { | ||||||
| vmSnapshotResponse.setAccountName(account.getAccountName()); | ||||||
| } | ||||||
| DomainVO domain = ApiDBUtils.findDomainById(vmSnapshot.getDomainId()); | ||||||
| if (domain != null) { | ||||||
| vmSnapshotResponse.setDomainId(domain.getUuid()); | ||||||
| vmSnapshotResponse.setDomainName(domain.getName()); | ||||||
| vmSnapshotResponse.setDomainPath(domain.getPath()); | ||||||
| } | ||||||
|
|
||||||
| List<? extends ResourceTag> tags = _resourceTagDao.listBy(vmSnapshot.getId(), ResourceObjectType.VMSnapshot); | ||||||
| List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>(); | ||||||
|
|
@@ -2350,18 +2342,7 @@ public SecurityGroupResponse createSecurityGroupResponseFromSecurityGroupRule(Li | |||||
| response.setName(securityGroup.getName()); | ||||||
| response.setDescription(securityGroup.getDescription()); | ||||||
|
|
||||||
| Account account = securiytGroupAccounts.get(securityGroup.getAccountId()); | ||||||
|
|
||||||
| if (securityGroup.getAccountType() == Account.Type.PROJECT) { | ||||||
| response.setProjectId(securityGroup.getProjectUuid()); | ||||||
| response.setProjectName(securityGroup.getProjectName()); | ||||||
| } else { | ||||||
| response.setAccountName(securityGroup.getAccountName()); | ||||||
| } | ||||||
|
|
||||||
| response.setDomainId(securityGroup.getDomainUuid()); | ||||||
| response.setDomainName(securityGroup.getDomainName()); | ||||||
| response.setDomainPath(securityGroup.getDomainPath()); | ||||||
| populateOwner(response, securityGroup); | ||||||
|
|
||||||
| for (SecurityRule securityRule : securityRules) { | ||||||
| SecurityGroupRuleResponse securityGroupData = new SecurityGroupRuleResponse(); | ||||||
|
|
@@ -2758,32 +2739,18 @@ public NetworkResponse createNetworkResponse(ResponseView view, Network network) | |||||
| // get domain from network_domain table | ||||||
| Pair<Long, Boolean> domainNetworkDetails = ApiDBUtils.getDomainNetworkDetails(network.getId()); | ||||||
| if (domainNetworkDetails.first() != null) { | ||||||
| Domain domain = ApiDBUtils.findDomainById(domainNetworkDetails.first()); | ||||||
| if (domain != null) { | ||||||
| response.setDomainId(domain.getUuid()); | ||||||
|
|
||||||
| StringBuilder domainPath = new StringBuilder("ROOT"); | ||||||
| (domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1); | ||||||
| response.setDomainPath(domainPath.toString()); | ||||||
| } | ||||||
| populateDomain(response, domainNetworkDetails.first()); | ||||||
| } | ||||||
| response.setSubdomainAccess(domainNetworkDetails.second()); | ||||||
| } | ||||||
|
|
||||||
| Long dedicatedDomainId = ApiDBUtils.getDedicatedNetworkDomain(network.getId()); | ||||||
| if (dedicatedDomainId != null) { | ||||||
| Domain domain = ApiDBUtils.findDomainById(dedicatedDomainId); | ||||||
| if (domain != null) { | ||||||
| response.setDomainId(domain.getUuid()); | ||||||
| response.setDomainName(domain.getName()); | ||||||
| response.setDomainPath(domain.getPath()); | ||||||
| } | ||||||
|
|
||||||
| populateDomain(response, dedicatedDomainId); | ||||||
| } | ||||||
|
|
||||||
| response.setSpecifyIpRanges(network.getSpecifyIpRanges()); | ||||||
|
|
||||||
|
|
||||||
| setVpcIdInResponse(network.getVpcId(), response::setVpcId, response::setVpcName); | ||||||
|
|
||||||
| setResponseAssociatedNetworkInformation(response, network.getId()); | ||||||
|
|
@@ -3045,14 +3012,10 @@ private void populateOwner(ControlledEntityResponse response, ControlledEntity o | |||||
| } else { | ||||||
| response.setAccountName(account.getAccountName()); | ||||||
| } | ||||||
|
|
||||||
| Domain domain = ApiDBUtils.findDomainById(object.getDomainId()); | ||||||
| response.setDomainId(domain.getUuid()); | ||||||
| response.setDomainName(domain.getName()); | ||||||
| response.setDomainPath(domain.getPath()); | ||||||
| populateDomain(response, object.getDomainId()); | ||||||
| } | ||||||
|
|
||||||
| private void populateOwner(ControlledViewEntityResponse response, ControlledEntity object) { | ||||||
| public static void populateOwner(ControlledViewEntityResponse response, ControlledEntity object) { | ||||||
| Account account = ApiDBUtils.findAccountById(object.getAccountId()); | ||||||
|
|
||||||
| if (account.getType() == Account.Type.PROJECT) { | ||||||
|
|
@@ -3064,10 +3027,7 @@ private void populateOwner(ControlledViewEntityResponse response, ControlledEnti | |||||
| response.setAccountName(account.getAccountName()); | ||||||
| } | ||||||
|
|
||||||
| Domain domain = ApiDBUtils.findDomainById(object.getDomainId()); | ||||||
| response.setDomainId(domain.getUuid()); | ||||||
| response.setDomainName(domain.getName()); | ||||||
| response.setDomainPath(domain.getPath()); | ||||||
| populateDomain(response, object.getDomainId()); | ||||||
| } | ||||||
|
|
||||||
| public static void populateOwner(ControlledViewEntityResponse response, ControlledViewEntity object) { | ||||||
|
|
@@ -3081,7 +3041,7 @@ public static void populateOwner(ControlledViewEntityResponse response, Controll | |||||
|
|
||||||
| response.setDomainId(object.getDomainUuid()); | ||||||
| response.setDomainName(object.getDomainName()); | ||||||
| response.setDomainPath(object.getDomainPath()); | ||||||
| response.setDomainPath(getPrettyDomainPath(object.getDomainPath())); | ||||||
| } | ||||||
|
|
||||||
| private void populateAccount(ControlledEntityResponse response, long accountId) { | ||||||
|
|
@@ -3105,10 +3065,22 @@ private void populateAccount(ControlledEntityResponse response, long accountId) | |||||
|
|
||||||
| private void populateDomain(ControlledEntityResponse response, long domainId) { | ||||||
| Domain domain = ApiDBUtils.findDomainById(domainId); | ||||||
| if (domain == null) { | ||||||
| return; | ||||||
| } | ||||||
| response.setDomainId(domain.getUuid()); | ||||||
| response.setDomainName(domain.getName()); | ||||||
| response.setDomainPath(getPrettyDomainPath(domain.getPath())); | ||||||
| } | ||||||
|
|
||||||
| private static void populateDomain(ControlledViewEntityResponse response, long domainId) { | ||||||
|
||||||
| private static void populateDomain(ControlledViewEntityResponse response, long domainId) { | |
| public static void populateDomain(ControlledViewEntityResponse response, long domainId) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
pathalways ends with a character that can be deleted, but ifpathis empty or doesn't end with a trailing character,deleteCharAt(domainPath.length() - 1)will throw a StringIndexOutOfBoundsException.