mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
server: consistent domainpath in api responses (#11589)
* 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 <abhishek.mrt22@gmail.com> * more changes Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com> --------- Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
6089c161a6
commit
a6ef24d167
@ -28,7 +28,6 @@ import org.apache.cloudstack.api.response.ProjectResponse;
|
|||||||
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
|
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.event.EventTypes;
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.network.VpnUser;
|
import com.cloud.network.VpnUser;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
@ -110,7 +109,6 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
|
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
|
||||||
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
|
|
||||||
try {
|
try {
|
||||||
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
|
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
|
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
|
||||||
@ -118,24 +116,10 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
|
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
VpnUsersResponse vpnResponse = new VpnUsersResponse();
|
|
||||||
vpnResponse.setId(vpnUser.getUuid());
|
|
||||||
vpnResponse.setUserName(vpnUser.getUsername());
|
|
||||||
vpnResponse.setAccountName(account.getAccountName());
|
|
||||||
// re-retrieve the vpnuser, as the call to `applyVpnUsers` might have changed the state
|
// re-retrieve the vpnuser, as the call to `applyVpnUsers` might have changed the state
|
||||||
vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
|
vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
|
||||||
vpnResponse.setState(vpnUser.getState().toString());
|
VpnUsersResponse vpnResponse = _responseGenerator.createVpnUserResponse(vpnUser);
|
||||||
|
|
||||||
Domain domain = _entityMgr.findById(Domain.class, account.getDomainId());
|
|
||||||
if (domain != null) {
|
|
||||||
vpnResponse.setDomainId(domain.getUuid());
|
|
||||||
vpnResponse.setDomainName(domain.getName());
|
|
||||||
vpnResponse.setDomainPath(domain.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
vpnResponse.setResponseName(getCommandName());
|
vpnResponse.setResponseName(getCommandName());
|
||||||
vpnResponse.setObjectName("vpnuser");
|
|
||||||
setResponseObject(vpnResponse);
|
setResponseObject(vpnResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@EntityReference(value = {VirtualMachine.class, UserVm.class, VirtualRouter.class})
|
@EntityReference(value = {VirtualMachine.class, UserVm.class, VirtualRouter.class})
|
||||||
public class UserVmResponse extends BaseResponseWithTagInformation implements ControlledEntityResponse, SetResourceIconResponse {
|
public class UserVmResponse extends BaseResponseWithTagInformation implements ControlledViewEntityResponse, SetResourceIconResponse {
|
||||||
@SerializedName(ApiConstants.ID)
|
@SerializedName(ApiConstants.ID)
|
||||||
@Param(description = "the ID of the virtual machine")
|
@Param(description = "the ID of the virtual machine")
|
||||||
private String id;
|
private String id;
|
||||||
|
|||||||
@ -118,6 +118,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.dao.NetworkOfferingJoinDao;
|
import com.cloud.api.query.dao.NetworkOfferingJoinDao;
|
||||||
import com.cloud.api.query.dao.TemplateJoinDao;
|
import com.cloud.api.query.dao.TemplateJoinDao;
|
||||||
import com.cloud.api.query.dao.UserVmJoinDao;
|
import com.cloud.api.query.dao.UserVmJoinDao;
|
||||||
@ -135,7 +136,6 @@ import com.cloud.dc.dao.ClusterDao;
|
|||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.DedicatedResourceDao;
|
import com.cloud.dc.dao.DedicatedResourceDao;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.event.ActionEvent;
|
import com.cloud.event.ActionEvent;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
@ -814,18 +814,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne
|
|||||||
response.setKubernetesVersionId(version.getUuid());
|
response.setKubernetesVersionId(version.getUuid());
|
||||||
response.setKubernetesVersionName(version.getName());
|
response.setKubernetesVersionName(version.getName());
|
||||||
}
|
}
|
||||||
Account account = ApiDBUtils.findAccountById(kubernetesCluster.getAccountId());
|
ApiResponseHelper.populateOwner(response, kubernetesCluster);
|
||||||
if (account.getType() == Account.Type.PROJECT) {
|
|
||||||
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
|
|
||||||
response.setProjectId(project.getUuid());
|
|
||||||
response.setProjectName(project.getName());
|
|
||||||
} else {
|
|
||||||
response.setAccountName(account.getAccountName());
|
|
||||||
}
|
|
||||||
Domain domain = ApiDBUtils.findDomainById(kubernetesCluster.getDomainId());
|
|
||||||
response.setDomainId(domain.getUuid());
|
|
||||||
response.setDomainName(domain.getName());
|
|
||||||
response.setDomainPath(domain.getPath());
|
|
||||||
response.setKeypair(kubernetesCluster.getKeyPair());
|
response.setKeypair(kubernetesCluster.getKeyPair());
|
||||||
response.setState(kubernetesCluster.getState().toString());
|
response.setState(kubernetesCluster.getState().toString());
|
||||||
response.setCores(String.valueOf(kubernetesCluster.getCores()));
|
response.setCores(String.valueOf(kubernetesCluster.getCores()));
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@EntityReference(value = {KubernetesCluster.class})
|
@EntityReference(value = {KubernetesCluster.class})
|
||||||
public class KubernetesClusterResponse extends BaseResponseWithAnnotations implements ControlledEntityResponse {
|
public class KubernetesClusterResponse extends BaseResponseWithAnnotations implements ControlledViewEntityResponse {
|
||||||
@SerializedName(ApiConstants.ID)
|
@SerializedName(ApiConstants.ID)
|
||||||
@Param(description = "the id of the Kubernetes cluster")
|
@Param(description = "the id of the Kubernetes cluster")
|
||||||
private String id;
|
private String id;
|
||||||
|
|||||||
@ -530,6 +530,15 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
@Inject
|
@Inject
|
||||||
ResourceIconManager resourceIconManager;
|
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
|
@Override
|
||||||
public UserResponse createUserResponse(User user) {
|
public UserResponse createUserResponse(User user) {
|
||||||
UserAccountJoinVO vUser = ApiDBUtils.newUserView(user);
|
UserAccountJoinVO vUser = ApiDBUtils.newUserView(user);
|
||||||
@ -567,9 +576,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
if (parentDomain != null) {
|
if (parentDomain != null) {
|
||||||
domainResponse.setParentDomainId(parentDomain.getUuid());
|
domainResponse.setParentDomainId(parentDomain.getUuid());
|
||||||
}
|
}
|
||||||
StringBuilder domainPath = new StringBuilder("ROOT");
|
domainResponse.setPath(getPrettyDomainPath(domain.getPath()));
|
||||||
(domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1);
|
|
||||||
domainResponse.setPath(domainPath.toString());
|
|
||||||
if (domain.getParent() != null) {
|
if (domain.getParent() != null) {
|
||||||
domainResponse.setParentDomainName(ApiDBUtils.findDomainById(domain.getParent()).getName());
|
domainResponse.setParentDomainName(ApiDBUtils.findDomainById(domain.getParent()).getName());
|
||||||
}
|
}
|
||||||
@ -822,21 +829,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
populateOwner(vmSnapshotResponse, 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<? extends ResourceTag> tags = _resourceTagDao.listBy(vmSnapshot.getId(), ResourceObjectType.VMSnapshot);
|
||||||
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
|
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
|
||||||
@ -2350,18 +2342,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
response.setName(securityGroup.getName());
|
response.setName(securityGroup.getName());
|
||||||
response.setDescription(securityGroup.getDescription());
|
response.setDescription(securityGroup.getDescription());
|
||||||
|
|
||||||
Account account = securiytGroupAccounts.get(securityGroup.getAccountId());
|
populateOwner(response, securityGroup);
|
||||||
|
|
||||||
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());
|
|
||||||
|
|
||||||
for (SecurityRule securityRule : securityRules) {
|
for (SecurityRule securityRule : securityRules) {
|
||||||
SecurityGroupRuleResponse securityGroupData = new SecurityGroupRuleResponse();
|
SecurityGroupRuleResponse securityGroupData = new SecurityGroupRuleResponse();
|
||||||
@ -2758,32 +2739,18 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
// get domain from network_domain table
|
// get domain from network_domain table
|
||||||
Pair<Long, Boolean> domainNetworkDetails = ApiDBUtils.getDomainNetworkDetails(network.getId());
|
Pair<Long, Boolean> domainNetworkDetails = ApiDBUtils.getDomainNetworkDetails(network.getId());
|
||||||
if (domainNetworkDetails.first() != null) {
|
if (domainNetworkDetails.first() != null) {
|
||||||
Domain domain = ApiDBUtils.findDomainById(domainNetworkDetails.first());
|
populateDomain(response, 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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
response.setSubdomainAccess(domainNetworkDetails.second());
|
response.setSubdomainAccess(domainNetworkDetails.second());
|
||||||
}
|
}
|
||||||
|
|
||||||
Long dedicatedDomainId = ApiDBUtils.getDedicatedNetworkDomain(network.getId());
|
Long dedicatedDomainId = ApiDBUtils.getDedicatedNetworkDomain(network.getId());
|
||||||
if (dedicatedDomainId != null) {
|
if (dedicatedDomainId != null) {
|
||||||
Domain domain = ApiDBUtils.findDomainById(dedicatedDomainId);
|
populateDomain(response, dedicatedDomainId);
|
||||||
if (domain != null) {
|
|
||||||
response.setDomainId(domain.getUuid());
|
|
||||||
response.setDomainName(domain.getName());
|
|
||||||
response.setDomainPath(domain.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setSpecifyIpRanges(network.getSpecifyIpRanges());
|
response.setSpecifyIpRanges(network.getSpecifyIpRanges());
|
||||||
|
|
||||||
|
|
||||||
setVpcIdInResponse(network.getVpcId(), response::setVpcId, response::setVpcName);
|
setVpcIdInResponse(network.getVpcId(), response::setVpcId, response::setVpcName);
|
||||||
|
|
||||||
setResponseAssociatedNetworkInformation(response, network.getId());
|
setResponseAssociatedNetworkInformation(response, network.getId());
|
||||||
@ -3045,14 +3012,10 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
} else {
|
} else {
|
||||||
response.setAccountName(account.getAccountName());
|
response.setAccountName(account.getAccountName());
|
||||||
}
|
}
|
||||||
|
populateDomain(response, object.getDomainId());
|
||||||
Domain domain = ApiDBUtils.findDomainById(object.getDomainId());
|
|
||||||
response.setDomainId(domain.getUuid());
|
|
||||||
response.setDomainName(domain.getName());
|
|
||||||
response.setDomainPath(domain.getPath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateOwner(ControlledViewEntityResponse response, ControlledEntity object) {
|
public static void populateOwner(ControlledViewEntityResponse response, ControlledEntity object) {
|
||||||
Account account = ApiDBUtils.findAccountById(object.getAccountId());
|
Account account = ApiDBUtils.findAccountById(object.getAccountId());
|
||||||
|
|
||||||
if (account.getType() == Account.Type.PROJECT) {
|
if (account.getType() == Account.Type.PROJECT) {
|
||||||
@ -3064,10 +3027,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
response.setAccountName(account.getAccountName());
|
response.setAccountName(account.getAccountName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Domain domain = ApiDBUtils.findDomainById(object.getDomainId());
|
populateDomain(response, object.getDomainId());
|
||||||
response.setDomainId(domain.getUuid());
|
|
||||||
response.setDomainName(domain.getName());
|
|
||||||
response.setDomainPath(domain.getPath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void populateOwner(ControlledViewEntityResponse response, ControlledViewEntity object) {
|
public static void populateOwner(ControlledViewEntityResponse response, ControlledViewEntity object) {
|
||||||
@ -3081,7 +3041,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
|
|
||||||
response.setDomainId(object.getDomainUuid());
|
response.setDomainId(object.getDomainUuid());
|
||||||
response.setDomainName(object.getDomainName());
|
response.setDomainName(object.getDomainName());
|
||||||
response.setDomainPath(object.getDomainPath());
|
response.setDomainPath(getPrettyDomainPath(object.getDomainPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateAccount(ControlledEntityResponse response, long accountId) {
|
private void populateAccount(ControlledEntityResponse response, long accountId) {
|
||||||
@ -3105,10 +3065,22 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
|
|
||||||
private void populateDomain(ControlledEntityResponse response, long domainId) {
|
private void populateDomain(ControlledEntityResponse response, long domainId) {
|
||||||
Domain domain = ApiDBUtils.findDomainById(domainId);
|
Domain domain = ApiDBUtils.findDomainById(domainId);
|
||||||
|
if (domain == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
response.setDomainId(domain.getUuid());
|
response.setDomainId(domain.getUuid());
|
||||||
response.setDomainName(domain.getName());
|
response.setDomainName(domain.getName());
|
||||||
response.setDomainPath(domain.getPath());
|
response.setDomainPath(getPrettyDomainPath(domain.getPath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void populateDomain(ControlledViewEntityResponse 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()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -4100,12 +4072,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
usageRecResponse.setAccountName(account.getAccountName());
|
usageRecResponse.setAccountName(account.getAccountName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Domain domain = ApiDBUtils.findDomainById(usageRecord.getDomainId());
|
populateDomain(usageRecResponse, account.getDomainId());
|
||||||
if (domain != null) {
|
|
||||||
usageRecResponse.setDomainId(domain.getUuid());
|
|
||||||
usageRecResponse.setDomainName(domain.getName());
|
|
||||||
usageRecResponse.setDomainPath(domain.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (usageRecord.getZoneId() != null) {
|
if (usageRecord.getZoneId() != null) {
|
||||||
DataCenter zone = ApiDBUtils.findZoneById(usageRecord.getZoneId());
|
DataCenter zone = ApiDBUtils.findZoneById(usageRecord.getZoneId());
|
||||||
@ -4892,18 +4859,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
|
|
||||||
AffinityGroupResponse response = new AffinityGroupResponse();
|
AffinityGroupResponse response = new AffinityGroupResponse();
|
||||||
|
|
||||||
Account account = ApiDBUtils.findAccountById(group.getAccountId());
|
|
||||||
response.setId(group.getUuid());
|
response.setId(group.getUuid());
|
||||||
response.setAccountName(account.getAccountName());
|
|
||||||
response.setName(group.getName());
|
response.setName(group.getName());
|
||||||
response.setType(group.getType());
|
response.setType(group.getType());
|
||||||
response.setDescription(group.getDescription());
|
response.setDescription(group.getDescription());
|
||||||
Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
|
populateOwner(response, group);
|
||||||
if (domain != null) {
|
|
||||||
response.setDomainId(domain.getUuid());
|
|
||||||
response.setDomainName(domain.getName());
|
|
||||||
response.setDomainPath(domain.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
response.setObjectName("affinitygroup");
|
response.setObjectName("affinitygroup");
|
||||||
return response;
|
return response;
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import org.apache.cloudstack.api.response.ResourceLimitAndCountResponse;
|
|||||||
import org.apache.cloudstack.api.response.UserResponse;
|
import org.apache.cloudstack.api.response.UserResponse;
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.ViewResponseHelper;
|
import com.cloud.api.query.ViewResponseHelper;
|
||||||
import com.cloud.api.query.vo.AccountJoinVO;
|
import com.cloud.api.query.vo.AccountJoinVO;
|
||||||
import com.cloud.api.query.vo.UserAccountJoinVO;
|
import com.cloud.api.query.vo.UserAccountJoinVO;
|
||||||
@ -74,9 +75,7 @@ public class AccountJoinDaoImpl extends GenericDaoBase<AccountJoinVO, Long> impl
|
|||||||
accountResponse.setAccountType(account.getType().ordinal());
|
accountResponse.setAccountType(account.getType().ordinal());
|
||||||
accountResponse.setDomainId(account.getDomainUuid());
|
accountResponse.setDomainId(account.getDomainUuid());
|
||||||
accountResponse.setDomainName(account.getDomainName());
|
accountResponse.setDomainName(account.getDomainName());
|
||||||
StringBuilder domainPath = new StringBuilder("ROOT");
|
accountResponse.setDomainPath(ApiResponseHelper.getPrettyDomainPath(account.getDomainPath()));
|
||||||
(domainPath.append(account.getDomainPath())).deleteCharAt(domainPath.length() - 1);
|
|
||||||
accountResponse.setDomainPath(domainPath.toString());
|
|
||||||
accountResponse.setState(account.getState().toString());
|
accountResponse.setState(account.getState().toString());
|
||||||
accountResponse.setCreated(account.getCreated());
|
accountResponse.setCreated(account.getCreated());
|
||||||
accountResponse.setNetworkDomain(account.getNetworkDomain());
|
accountResponse.setNetworkDomain(account.getNetworkDomain());
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import org.apache.cloudstack.api.ResponseObject;
|
|||||||
import org.apache.cloudstack.api.response.AsyncJobResponse;
|
import org.apache.cloudstack.api.response.AsyncJobResponse;
|
||||||
import org.apache.cloudstack.framework.jobs.AsyncJob;
|
import org.apache.cloudstack.framework.jobs.AsyncJob;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.ApiSerializerHelper;
|
import com.cloud.api.ApiSerializerHelper;
|
||||||
import com.cloud.api.SerializationContext;
|
import com.cloud.api.SerializationContext;
|
||||||
import com.cloud.api.query.vo.AsyncJobJoinVO;
|
import com.cloud.api.query.vo.AsyncJobJoinVO;
|
||||||
@ -60,9 +61,7 @@ public class AsyncJobJoinDaoImpl extends GenericDaoBase<AsyncJobJoinVO, Long> im
|
|||||||
jobResponse.setAccountId(job.getAccountUuid());
|
jobResponse.setAccountId(job.getAccountUuid());
|
||||||
jobResponse.setAccount(job.getAccountName());
|
jobResponse.setAccount(job.getAccountName());
|
||||||
jobResponse.setDomainId(job.getDomainUuid());
|
jobResponse.setDomainId(job.getDomainUuid());
|
||||||
StringBuilder domainPath = new StringBuilder("ROOT");
|
jobResponse.setDomainPath(ApiResponseHelper.getPrettyDomainPath(job.getDomainPath()));
|
||||||
(domainPath.append(job.getDomainPath())).deleteCharAt(domainPath.length() - 1);
|
|
||||||
jobResponse.setDomainPath(domainPath.toString());
|
|
||||||
jobResponse.setUserId(job.getUserUuid());
|
jobResponse.setUserId(job.getUserUuid());
|
||||||
jobResponse.setCmd(job.getCmd());
|
jobResponse.setCmd(job.getCmd());
|
||||||
jobResponse.setCreated(job.getCreated());
|
jobResponse.setCreated(job.getCreated());
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import java.util.EnumSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.configuration.Resource;
|
import com.cloud.configuration.Resource;
|
||||||
import com.cloud.user.AccountManager;
|
import com.cloud.user.AccountManager;
|
||||||
import org.apache.cloudstack.annotation.AnnotationService;
|
import org.apache.cloudstack.annotation.AnnotationService;
|
||||||
@ -79,9 +80,7 @@ public class DomainJoinDaoImpl extends GenericDaoBase<DomainJoinVO, Long> implem
|
|||||||
if (domain.getParentUuid() != null) {
|
if (domain.getParentUuid() != null) {
|
||||||
domainResponse.setParentDomainId(domain.getParentUuid());
|
domainResponse.setParentDomainId(domain.getParentUuid());
|
||||||
}
|
}
|
||||||
StringBuilder domainPath = new StringBuilder("ROOT");
|
domainResponse.setPath(ApiResponseHelper.getPrettyDomainPath(domain.getPath()));
|
||||||
(domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1);
|
|
||||||
domainResponse.setPath(domainPath.toString());
|
|
||||||
if (domain.getParent() != null) {
|
if (domain.getParent() != null) {
|
||||||
domainResponse.setParentDomainName(domain.getParentName());
|
domainResponse.setParentDomainName(domain.getParentName());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -207,10 +207,6 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
|
|||||||
// populate owner.
|
// populate owner.
|
||||||
ApiResponseHelper.populateOwner(routerResponse, router);
|
ApiResponseHelper.populateOwner(routerResponse, router);
|
||||||
|
|
||||||
routerResponse.setDomainId(router.getDomainUuid());
|
|
||||||
routerResponse.setDomainName(router.getDomainName());
|
|
||||||
routerResponse.setDomainPath(router.getDomainPath());
|
|
||||||
|
|
||||||
routerResponse.setZoneName(router.getDataCenterName());
|
routerResponse.setZoneName(router.getDataCenterName());
|
||||||
routerResponse.setDns1(router.getDns1());
|
routerResponse.setDns1(router.getDns1());
|
||||||
routerResponse.setDns2(router.getDns2());
|
routerResponse.setDns2(router.getDns2());
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||||
import com.cloud.projects.ProjectAccount;
|
import com.cloud.projects.ProjectAccount;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
@ -59,7 +60,7 @@ public class ProjectAccountJoinDaoImpl extends GenericDaoBase<ProjectAccountJoin
|
|||||||
projectAccountResponse.setRole(proj.getAccountRole().toString());
|
projectAccountResponse.setRole(proj.getAccountRole().toString());
|
||||||
projectAccountResponse.setDomainId(proj.getDomainUuid());
|
projectAccountResponse.setDomainId(proj.getDomainUuid());
|
||||||
projectAccountResponse.setDomainName(proj.getDomainName());
|
projectAccountResponse.setDomainName(proj.getDomainName());
|
||||||
projectAccountResponse.setDomainPath(proj.getDomainPath());
|
projectAccountResponse.setDomainPath(ApiResponseHelper.getPrettyDomainPath(proj.getDomainPath()));
|
||||||
|
|
||||||
projectAccountResponse.setObjectName("projectaccount");
|
projectAccountResponse.setObjectName("projectaccount");
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||||
import com.cloud.projects.ProjectInvitation;
|
import com.cloud.projects.ProjectInvitation;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
@ -65,7 +66,7 @@ public class ProjectInvitationJoinDaoImpl extends GenericDaoBase<ProjectInvitati
|
|||||||
|
|
||||||
response.setDomainId(invite.getDomainUuid());
|
response.setDomainId(invite.getDomainUuid());
|
||||||
response.setDomainName(invite.getDomainName());
|
response.setDomainName(invite.getDomainName());
|
||||||
response.setDomainPath(invite.getDomainPath());
|
response.setDomainPath(ApiResponseHelper.getPrettyDomainPath(invite.getDomainPath()));
|
||||||
|
|
||||||
response.setObjectName("projectinvitation");
|
response.setObjectName("projectinvitation");
|
||||||
return response;
|
return response;
|
||||||
|
|||||||
@ -78,10 +78,6 @@ public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Lo
|
|||||||
|
|
||||||
ApiResponseHelper.populateOwner(response, resourceTag);
|
ApiResponseHelper.populateOwner(response, resourceTag);
|
||||||
|
|
||||||
response.setDomainId(resourceTag.getDomainUuid());
|
|
||||||
response.setDomainName(resourceTag.getDomainName());
|
|
||||||
response.setDomainPath(resourceTag.getDomainPath());
|
|
||||||
|
|
||||||
response.setCustomer(resourceTag.getCustomer());
|
response.setCustomer(resourceTag.getCustomer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -266,11 +266,6 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||||||
// populate owner.
|
// populate owner.
|
||||||
ApiResponseHelper.populateOwner(templateResponse, template);
|
ApiResponseHelper.populateOwner(templateResponse, template);
|
||||||
|
|
||||||
// populate domain
|
|
||||||
templateResponse.setDomainId(template.getDomainUuid());
|
|
||||||
templateResponse.setDomainName(template.getDomainName());
|
|
||||||
templateResponse.setDomainPath(template.getDomainPath());
|
|
||||||
|
|
||||||
// If the user is an 'Admin' or 'the owner of template' or template belongs to a project, add the template download status
|
// If the user is an 'Admin' or 'the owner of template' or template belongs to a project, add the template download status
|
||||||
if (view == ResponseView.Full ||
|
if (view == ResponseView.Full ||
|
||||||
template.getAccountId() == CallContext.current().getCallingAccount().getId() ||
|
template.getAccountId() == CallContext.current().getCallingAccount().getId() ||
|
||||||
@ -415,11 +410,6 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||||||
// populate owner.
|
// populate owner.
|
||||||
ApiResponseHelper.populateOwner(response, result);
|
ApiResponseHelper.populateOwner(response, result);
|
||||||
|
|
||||||
// populate domain
|
|
||||||
response.setDomainId(result.getDomainUuid());
|
|
||||||
response.setDomainName(result.getDomainName());
|
|
||||||
response.setDomainPath(result.getDomainPath());
|
|
||||||
|
|
||||||
// set details map
|
// set details map
|
||||||
if (result.getDetailName() != null) {
|
if (result.getDetailName() != null) {
|
||||||
Map<String, String> details = new HashMap<>();
|
Map<String, String> details = new HashMap<>();
|
||||||
@ -504,11 +494,6 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||||||
// populate owner.
|
// populate owner.
|
||||||
ApiResponseHelper.populateOwner(isoResponse, iso);
|
ApiResponseHelper.populateOwner(isoResponse, iso);
|
||||||
|
|
||||||
// populate domain
|
|
||||||
isoResponse.setDomainId(iso.getDomainUuid());
|
|
||||||
isoResponse.setDomainName(iso.getDomainName());
|
|
||||||
isoResponse.setDomainPath(iso.getDomainPath());
|
|
||||||
|
|
||||||
Account caller = CallContext.current().getCallingAccount();
|
Account caller = CallContext.current().getCallingAccount();
|
||||||
boolean isAdmin = false;
|
boolean isAdmin = false;
|
||||||
if ((caller == null) || _accountService.isAdmin(caller.getId())) {
|
if ((caller == null) || _accountService.isAdmin(caller.getId())) {
|
||||||
|
|||||||
@ -194,21 +194,13 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
|
|||||||
userVmResponse.setDisplayName(userVm.getName());
|
userVmResponse.setDisplayName(userVm.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userVm.getAccountType() == Account.Type.PROJECT) {
|
ApiResponseHelper.populateOwner(userVmResponse, userVm);
|
||||||
userVmResponse.setProjectId(userVm.getProjectUuid());
|
|
||||||
userVmResponse.setProjectName(userVm.getProjectName());
|
|
||||||
} else {
|
|
||||||
userVmResponse.setAccountName(userVm.getAccountName());
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = _userDao.getUser(userVm.getUserId());
|
User user = _userDao.getUser(userVm.getUserId());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
userVmResponse.setUserId(user.getUuid());
|
userVmResponse.setUserId(user.getUuid());
|
||||||
userVmResponse.setUserName(user.getUsername());
|
userVmResponse.setUserName(user.getUsername());
|
||||||
}
|
}
|
||||||
userVmResponse.setDomainId(userVm.getDomainUuid());
|
|
||||||
userVmResponse.setDomainName(userVm.getDomainName());
|
|
||||||
userVmResponse.setDomainPath(userVm.getDomainPath());
|
|
||||||
|
|
||||||
userVmResponse.setCreated(userVm.getCreated());
|
userVmResponse.setCreated(userVm.getCreated());
|
||||||
userVmResponse.setLastUpdated(userVm.getLastUpdated());
|
userVmResponse.setLastUpdated(userVm.getLastUpdated());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user