Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api/src/main/java/com/cloud/server/ResourceTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
// under the License.
package com.cloud.server;

import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;

public interface ResourceTag extends ControlledEntity, Identity, InternalIdentity {

// FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
Expand Down Expand Up @@ -70,7 +70,7 @@ public enum ResourceObjectType {
GuestOs(false, true),
NetworkOffering(false, true),
VpcOffering(true, false),
Domain(false, false, true),
Domain(true, false, true),
ObjectStore(false, false, true);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
// under the License.
package org.apache.cloudstack.api.response;

import com.google.gson.annotations.SerializedName;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponseWithAnnotations;
import org.apache.cloudstack.api.BaseResponseWithTagInformation;
import org.apache.cloudstack.api.EntityReference;

import com.cloud.domain.Domain;
import com.cloud.serializer.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;
import com.google.gson.annotations.SerializedName;

@EntityReference(value = Domain.class)
public class DomainResponse extends BaseResponseWithAnnotations implements ResourceLimitAndCountResponse, SetResourceIconResponse {
public class DomainResponse extends BaseResponseWithTagInformation implements ResourceLimitAndCountResponse, SetResourceIconResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "the ID of the domain")
private String id;
Expand Down Expand Up @@ -589,4 +589,8 @@ public void setDetails(Map<String, String> details) {
public void setTaggedResourceLimitsAndCounts(List<TaggedResourceLimitAndCountResponse> taggedResourceLimitsAndCounts) {
this.taggedResources = taggedResourceLimitsAndCounts;
}

public void setTags(Set<ResourceTagResponse> tags) {
this.tags = tags;
}
}
34 changes: 22 additions & 12 deletions server/src/main/java/com/cloud/api/ApiResponseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@

import javax.inject.Inject;

import com.cloud.bgp.ASNumber;
import com.cloud.bgp.ASNumberRange;
import com.cloud.configuration.ConfigurationService;
import com.cloud.dc.ASNumberRangeVO;
import com.cloud.dc.ASNumberVO;
import com.cloud.dc.VlanDetailsVO;
import com.cloud.dc.dao.ASNumberDao;
import com.cloud.dc.dao.ASNumberRangeDao;
import com.cloud.dc.dao.VlanDetailsDao;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.network.vpc.VpcGateway;
import com.cloud.storage.BucketVO;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroup;
Expand Down Expand Up @@ -276,14 +264,19 @@
import com.cloud.api.query.vo.VolumeJoinVO;
import com.cloud.api.query.vo.VpcOfferingJoinVO;
import com.cloud.api.response.ApiResponseSerializer;
import com.cloud.bgp.ASNumber;
import com.cloud.bgp.ASNumberRange;
import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.ConfigurationService;
import com.cloud.configuration.Resource.ResourceOwnerType;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.configuration.ResourceCount;
import com.cloud.configuration.ResourceLimit;
import com.cloud.dc.ASNumberRangeVO;
import com.cloud.dc.ASNumberVO;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenter;
Expand All @@ -294,7 +287,11 @@
import com.cloud.dc.StorageNetworkIpRange;
import com.cloud.dc.Vlan;
import com.cloud.dc.Vlan.VlanType;
import com.cloud.dc.VlanDetailsVO;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.ASNumberDao;
import com.cloud.dc.dao.ASNumberRangeDao;
import com.cloud.dc.dao.VlanDetailsDao;
import com.cloud.domain.Domain;
import com.cloud.domain.DomainVO;
import com.cloud.event.Event;
Expand All @@ -303,6 +300,7 @@
import com.cloud.host.ControlState;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.HypervisorCapabilities;
import com.cloud.network.GuestVlan;
import com.cloud.network.GuestVlanRange;
Expand Down Expand Up @@ -366,6 +364,7 @@
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcGateway;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.network.vpc.VpcVO;
import com.cloud.network.vpc.dao.VpcOfferingDao;
Expand All @@ -387,6 +386,7 @@
import com.cloud.server.ResourceTag;
import com.cloud.server.ResourceTag.ResourceObjectType;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.BucketVO;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.GuestOS;
Expand Down Expand Up @@ -583,6 +583,16 @@ public DomainResponse createDomainResponse(Domain domain) {
if (domain.getChildCount() > 0) {
domainResponse.setHasChild(true);
}
List<ResourceTagJoinVO> tags = ApiDBUtils.listResourceTagViewByResourceUUID(domain.getUuid(),
ResourceTag.ResourceObjectType.Domain);
if (CollectionUtils.isNotEmpty(tags)) {
Set<ResourceTagResponse> tagResponses = new HashSet<>();
for (ResourceTagJoinVO tag : tags) {
ResourceTagResponse tagResponse = ApiDBUtils.newResourceTagResponse(tag, true);
tagResponses.add(tagResponse);
}
domainResponse.setTags(tagResponses);
}
domainResponse.setObjectName("domain");
return domainResponse;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,37 @@

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.inject.Inject;

import com.cloud.api.ApiResponseHelper;
import com.cloud.configuration.Resource;
import com.cloud.user.AccountManager;
import org.apache.cloudstack.annotation.AnnotationService;
import org.apache.cloudstack.annotation.dao.AnnotationDao;
import org.apache.cloudstack.api.ApiConstants.DomainDetails;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ResourceLimitAndCountResponse;
import org.apache.cloudstack.api.response.ResourceTagResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Component;

import com.cloud.api.ApiDBUtils;
import com.cloud.api.ApiResponseHelper;
import com.cloud.api.query.vo.DomainJoinVO;
import com.cloud.api.query.vo.ResourceTagJoinVO;
import com.cloud.configuration.Resource;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.domain.Domain;
import com.cloud.server.ResourceTag;
import com.cloud.user.AccountManager;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;

import javax.inject.Inject;

@Component
public class DomainJoinDaoImpl extends GenericDaoBase<DomainJoinVO, Long> implements DomainJoinDao {

Expand Down Expand Up @@ -110,6 +115,16 @@ public DomainResponse newDomainResponse(ResponseView view, EnumSet<DomainDetails
}

domainResponse.setDetails(ApiDBUtils.getDomainDetails(domain.getId()));
List<ResourceTagJoinVO> tags = ApiDBUtils.listResourceTagViewByResourceUUID(domain.getUuid(),
ResourceTag.ResourceObjectType.Domain);
if (CollectionUtils.isNotEmpty(tags)) {
Set<ResourceTagResponse> tagResponses = new HashSet<>();
for (ResourceTagJoinVO tag : tags) {
ResourceTagResponse tagResponse = ApiDBUtils.newResourceTagResponse(tag, true);
tagResponses.add(tagResponse);
}
domainResponse.setTags(tagResponses);
}
Comment on lines +118 to +127
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tag retrieval and population logic is duplicated in ApiResponseHelper.createDomainResponse(). Consider extracting this into a shared helper method to avoid code duplication and maintain consistency.

Suggested change
List<ResourceTagJoinVO> tags = ApiDBUtils.listResourceTagViewByResourceUUID(domain.getUuid(),
ResourceTag.ResourceObjectType.Domain);
if (CollectionUtils.isNotEmpty(tags)) {
Set<ResourceTagResponse> tagResponses = new HashSet<>();
for (ResourceTagJoinVO tag : tags) {
ResourceTagResponse tagResponse = ApiDBUtils.newResourceTagResponse(tag, true);
tagResponses.add(tagResponse);
}
domainResponse.setTags(tagResponses);
}
ApiResponseHelper.populateDomainTags(domain.getUuid(), domainResponse);

Copilot uses AI. Check for mistakes.
domainResponse.setObjectName("domain");

return domainResponse;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/view/InfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ export default {
return ['UserVm', 'Template', 'ISO', 'Volume', 'Snapshot', 'Backup', 'Network',
'LoadBalancer', 'PortForwardingRule', 'FirewallRule', 'SecurityGroup', 'SecurityGroupRule',
'PublicIpAddress', 'Project', 'Account', 'Vpc', 'NetworkACL', 'StaticRoute', 'VMSnapshot',
'RemoteAccessVpn', 'User', 'SnapshotPolicy', 'VpcOffering']
'RemoteAccessVpn', 'User', 'SnapshotPolicy', 'VpcOffering', 'Domain']
},
name () {
return this.resource.displayname || this.resource.name || this.resource.displaytext || this.resource.username ||
Expand Down
Loading