Skip to content

Commit 3d34473

Browse files
committed
Fix ControlledEntityResponse interface to remove IdentityProxy for
projectId and domainId. Signed-off-by: Min Chen <min.chen@citrix.com>
1 parent 57eda4e commit 3d34473

29 files changed

Lines changed: 234 additions & 225 deletions

api/src/com/cloud/network/as/AutoScalePolicy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public interface AutoScalePolicy extends ControlledEntity {
2323

2424
long getId();
2525

26+
String getUuid();
27+
2628
public int getDuration();
2729

2830
public int getQuietTime();

api/src/org/apache/cloudstack/api/command/user/user/AddVpnUserCmd.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,26 @@ public String getEventType() {
118118

119119
@Override
120120
public void execute(){
121-
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
122-
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
123-
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
124-
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
125-
}
126-
127-
VpnUsersResponse vpnResponse = new VpnUsersResponse();
128-
vpnResponse.setId(vpnUser.getId());
129-
vpnResponse.setUserName(vpnUser.getUsername());
130-
vpnResponse.setAccountName(account.getAccountName());
131-
132-
vpnResponse.setDomainId(account.getDomainId());
133-
vpnResponse.setDomainName(_entityMgr.findById(Domain.class, account.getDomainId()).getName());
134-
135-
vpnResponse.setResponseName(getCommandName());
136-
vpnResponse.setObjectName("vpnuser");
137-
this.setResponseObject(vpnResponse);
121+
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
122+
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
123+
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
124+
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
125+
}
126+
127+
VpnUsersResponse vpnResponse = new VpnUsersResponse();
128+
vpnResponse.setId(vpnUser.getId());
129+
vpnResponse.setUserName(vpnUser.getUsername());
130+
vpnResponse.setAccountName(account.getAccountName());
131+
132+
Domain domain = _entityMgr.findById(Domain.class, account.getDomainId());
133+
if (domain != null) {
134+
vpnResponse.setDomainId(domain.getUuid());
135+
vpnResponse.setDomainName(domain.getName());
136+
}
137+
138+
vpnResponse.setResponseName(getCommandName());
139+
vpnResponse.setObjectName("vpnuser");
140+
this.setResponseObject(vpnResponse);
138141
}
139142

140143
@Override

api/src/org/apache/cloudstack/api/response/AutoScalePolicyResponse.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.apache.cloudstack.api.response;
1818

1919
import org.apache.cloudstack.api.ApiConstants;
20-
import com.cloud.utils.IdentityProxy;
2120
import com.cloud.serializer.Param;
2221
import com.google.gson.annotations.SerializedName;
2322
import org.apache.cloudstack.api.BaseResponse;
@@ -28,7 +27,7 @@ public class AutoScalePolicyResponse extends BaseResponse implements ControlledE
2827

2928
@SerializedName(ApiConstants.ID)
3029
@Param(description = "the autoscale policy ID")
31-
private IdentityProxy id = new IdentityProxy("autoscale_policies");
30+
private String id;
3231

3332
@SerializedName(ApiConstants.ACTION)
3433
@Param(description = "the action to be executed if all the conditions evaluate to true for the specified duration.")
@@ -50,19 +49,19 @@ public class AutoScalePolicyResponse extends BaseResponse implements ControlledE
5049
private String accountName;
5150

5251
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id autoscale policy")
53-
private IdentityProxy projectId = new IdentityProxy("projects");
52+
private String projectId;
5453

5554
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the autoscale policy")
5655
private String projectName;
5756

5857
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID of the autoscale policy")
59-
private IdentityProxy domainId = new IdentityProxy("domain");
58+
private String domainId;
6059

6160
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the autoscale policy")
6261
private String domainName;
6362

64-
public void setId(Long id) {
65-
this.id.setValue(id);
63+
public void setId(String id) {
64+
this.id = id;
6665
}
6766

6867
public void setDuration(Integer duration) {
@@ -86,9 +85,11 @@ public void setAccountName(String accountName) {
8685
this.accountName = accountName;
8786
}
8887

88+
89+
8990
@Override
90-
public void setDomainId(Long domainId) {
91-
this.domainId.setValue(domainId);
91+
public void setDomainId(String domainId) {
92+
this.domainId = domainId;
9293
}
9394

9495
@Override
@@ -97,8 +98,8 @@ public void setDomainName(String domainName) {
9798
}
9899

99100
@Override
100-
public void setProjectId(Long projectId) {
101-
this.projectId.setValue(projectId);
101+
public void setProjectId(String projectId) {
102+
this.projectId = projectId;
102103
}
103104

104105
@Override

api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled
6666
private String accountName;
6767

6868
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id vm profile")
69-
private IdentityProxy projectId = new IdentityProxy("projects");
69+
private String projectId;
7070

7171
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vm profile")
7272
private String projectName;
7373

7474
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID of the vm profile")
75-
private IdentityProxy domainId = new IdentityProxy("domain");
75+
private String domainId;
7676

7777
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the vm profile")
7878
private String domainName;
@@ -122,9 +122,10 @@ public void setAccountName(String accountName) {
122122
this.accountName = accountName;
123123
}
124124

125+
125126
@Override
126-
public void setDomainId(Long domainId) {
127-
this.domainId.setValue(domainId);
127+
public void setDomainId(String domainId) {
128+
this.domainId = domainId;
128129
}
129130

130131
@Override
@@ -133,8 +134,8 @@ public void setDomainName(String domainName) {
133134
}
134135

135136
@Override
136-
public void setProjectId(Long projectId) {
137-
this.projectId.setValue(projectId);
137+
public void setProjectId(String projectId) {
138+
this.projectId = projectId;
138139
}
139140

140141
@Override

api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
7575

7676
@SerializedName(ApiConstants.PROJECT_ID)
7777
@Param(description = "the project id vm profile")
78-
private IdentityProxy projectId = new IdentityProxy("projects");
78+
private String projectId;
7979

8080
@SerializedName(ApiConstants.PROJECT)
8181
@Param(description = "the project name of the vm profile")
8282
private String projectName;
8383

8484
@SerializedName(ApiConstants.DOMAIN_ID)
8585
@Param(description = "the domain ID of the vm profile")
86-
private IdentityProxy domainId = new IdentityProxy("domain");
86+
private String domainId;
8787

8888
@SerializedName(ApiConstants.DOMAIN)
8989
@Param(description = "the domain name of the vm profile")
@@ -128,8 +128,8 @@ public void setAccountName(String accountName) {
128128
}
129129

130130
@Override
131-
public void setDomainId(Long domainId) {
132-
this.domainId.setValue(domainId);
131+
public void setDomainId(String domainId) {
132+
this.domainId = domainId;
133133
}
134134

135135
@Override
@@ -138,8 +138,8 @@ public void setDomainName(String domainName) {
138138
}
139139

140140
@Override
141-
public void setProjectId(Long projectId) {
142-
this.projectId.setValue(projectId);
141+
public void setProjectId(String projectId) {
142+
this.projectId = projectId;
143143
}
144144

145145
@Override

api/src/org/apache/cloudstack/api/response/ConditionResponse.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class ConditionResponse extends BaseResponse implements ControlledEntityR
4545

4646
@SerializedName(ApiConstants.DOMAIN_ID)
4747
@Param(description = "the domain id of the Condition owner")
48-
private final IdentityProxy domainId = new IdentityProxy("domain");
48+
private String domainId;
4949

5050
@SerializedName(ApiConstants.DOMAIN)
5151
@Param(description = "the domain name of the owner.")
@@ -57,7 +57,7 @@ public class ConditionResponse extends BaseResponse implements ControlledEntityR
5757

5858
@SerializedName(ApiConstants.PROJECT_ID)
5959
@Param(description = "the project id of the Condition.")
60-
private final IdentityProxy projectId = new IdentityProxy("projects");
60+
private String projectId;
6161

6262
@SerializedName(ApiConstants.PROJECT)
6363
@Param(description = "the project name of the Condition")
@@ -93,8 +93,8 @@ public void setAccountName(String accountName) {
9393
}
9494

9595
@Override
96-
public void setProjectId(Long projectId) {
97-
this.projectId.setValue(projectId);
96+
public void setProjectId(String projectId) {
97+
this.projectId = projectId;
9898
}
9999

100100
public void setZoneId(Long zoneId) {
@@ -107,8 +107,8 @@ public void setProjectName(String projectName) {
107107
}
108108

109109
@Override
110-
public void setDomainId(Long domainId) {
111-
this.domainId.setValue(domainId);
110+
public void setDomainId(String domainId) {
111+
this.domainId = domainId;
112112
}
113113

114114
@Override

api/src/org/apache/cloudstack/api/response/ControlledEntityResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public interface ControlledEntityResponse {
2020

2121
public void setAccountName(String accountName);
2222

23-
public void setProjectId(Long projectId);
23+
public void setProjectId(String projectId);
2424

2525
public void setProjectName(String projectName);
2626

27-
public void setDomainId(Long domainId);
27+
public void setDomainId(String domainId);
2828

2929
public void setDomainName(String domainName);
3030
}

api/src/org/apache/cloudstack/api/response/IPAddressResponse.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
4949
private String accountName;
5050

5151
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the ipaddress")
52-
private IdentityProxy projectId = new IdentityProxy("projects");
52+
private String projectId;
5353

5454
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the address")
5555
private String projectName;
5656

5757
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID the public IP address is associated with")
58-
private IdentityProxy domainId = new IdentityProxy("domain");
58+
private String domainId;
5959

6060
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain the public IP address is associated with")
6161
private String domainName;
@@ -140,8 +140,8 @@ public void setAccountName(String accountName) {
140140
}
141141

142142
@Override
143-
public void setDomainId(Long domainId) {
144-
this.domainId.setValue(domainId);
143+
public void setDomainId(String domainId) {
144+
this.domainId = domainId;
145145
}
146146

147147
@Override
@@ -203,8 +203,8 @@ public Long getObjectId() {
203203
}
204204

205205
@Override
206-
public void setProjectId(Long projectId) {
207-
this.projectId.setValue(projectId);
206+
public void setProjectId(String projectId) {
207+
this.projectId = projectId;
208208
}
209209

210210
@Override

api/src/org/apache/cloudstack/api/response/LoadBalancerResponse.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ public class LoadBalancerResponse extends BaseResponse implements ControlledEnti
6666
private String accountName;
6767

6868
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the load balancer")
69-
private IdentityProxy projectId = new IdentityProxy("projects");
69+
private String projectId;
7070

7171
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the load balancer")
7272
private String projectName;
7373

7474
@SerializedName(ApiConstants.DOMAIN_ID)
7575
@Param(description = "the domain ID of the load balancer rule")
76-
private IdentityProxy domainId = new IdentityProxy("domain");
76+
private String domainId;
7777

7878
@SerializedName(ApiConstants.DOMAIN)
7979
@Param(description = "the domain of the load balancer rule")
@@ -126,8 +126,9 @@ public void setAccountName(String accountName) {
126126
this.accountName = accountName;
127127
}
128128

129-
public void setDomainId(Long domainId) {
130-
this.domainId.setValue(domainId);
129+
@Override
130+
public void setDomainId(String domainId) {
131+
this.domainId = domainId;
131132
}
132133

133134
public void setDomainName(String domainName) {
@@ -147,8 +148,8 @@ public void setZoneId(Long zoneId) {
147148
}
148149

149150
@Override
150-
public void setProjectId(Long projectId) {
151-
this.projectId.setValue(projectId);
151+
public void setProjectId(String projectId) {
152+
this.projectId = projectId;
152153
}
153154

154155
@Override

api/src/org/apache/cloudstack/api/response/NetworkResponse.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
106106
private String accountName;
107107

108108
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the ipaddress")
109-
private IdentityProxy projectId = new IdentityProxy("projects");
109+
private String projectId;
110110

111111
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the address")
112112
private String projectName;
113113

114114
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the network owner")
115-
private IdentityProxy domainId = new IdentityProxy("domain");
115+
private String domainId;
116116

117117
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the network owner")
118118
private String domain;
@@ -204,8 +204,9 @@ public void setAccountName(String accountName) {
204204
this.accountName = accountName;
205205
}
206206

207-
public void setDomainId(Long domainId) {
208-
this.domainId.setValue(domainId);
207+
@Override
208+
public void setDomainId(String domainId) {
209+
this.domainId = domainId;
209210
}
210211

211212
public void setNetworkOfferingName(String networkOfferingName) {
@@ -249,8 +250,8 @@ public void setNetworkDomain(String networkDomain) {
249250
}
250251

251252
@Override
252-
public void setProjectId(Long projectId) {
253-
this.projectId.setValue(projectId);
253+
public void setProjectId(String projectId) {
254+
this.projectId = projectId;
254255
}
255256

256257
@Override

0 commit comments

Comments
 (0)