Skip to content

Commit 97cb169

Browse files
committed
Merge branch 'master' into api_limit
2 parents 3698d64 + 939acb0 commit 97cb169

22 files changed

Lines changed: 182 additions & 263 deletions

File tree

api/src/com/cloud/exception/CloudAuthenticationException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
package com.cloud.exception;
1818

1919
import com.cloud.utils.SerialVersionUID;
20-
import com.cloud.utils.exception.RuntimeCloudException;
20+
import com.cloud.utils.exception.CloudRuntimeException;
2121

22-
public class CloudAuthenticationException extends RuntimeCloudException {
22+
public class CloudAuthenticationException extends CloudRuntimeException {
2323
private static final long serialVersionUID = SerialVersionUID.CloudAuthenticationException;
2424

2525
public CloudAuthenticationException(String message) {

api/src/com/cloud/exception/CloudExecutionException.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

api/src/com/cloud/exception/ErrorCode.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

api/src/com/cloud/user/UserContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public long getCallerUserId() {
5050
return userId;
5151
}
5252

53+
public User getCallerUser() {
54+
return _accountMgr.getActiveUser(userId);
55+
}
56+
5357
public void setCallerUserId(long userId) {
5458
this.userId = userId;
5559
}

api/src/org/apache/cloudstack/api/ServerApiException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717
package org.apache.cloudstack.api;
18-
import com.cloud.utils.exception.RuntimeCloudException;
18+
import com.cloud.utils.exception.CloudRuntimeException;
1919

2020
@SuppressWarnings("serial")
21-
public class ServerApiException extends RuntimeCloudException {
21+
public class ServerApiException extends CloudRuntimeException {
2222
private int _errorCode;
2323
private String _description;
2424

plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.discovery;
1818

19-
import com.cloud.user.AccountService;
2019
import com.cloud.user.User;
2120
import com.cloud.user.UserContext;
22-
import com.cloud.utils.component.Inject;
23-
import org.apache.cloudstack.acl.RoleType;
2421
import org.apache.cloudstack.api.APICommand;
2522
import org.apache.cloudstack.api.ApiConstants;
2623
import org.apache.cloudstack.api.BaseCmd;
@@ -42,16 +39,13 @@ public class ListApisCmd extends BaseCmd {
4239
@PlugService
4340
ApiDiscoveryService _apiDiscoveryService;
4441

45-
@Inject
46-
private AccountService _accountService;
47-
4842
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="API name")
4943
private String name;
5044

5145
@Override
5246
public void execute() throws ServerApiException {
5347
if (_apiDiscoveryService != null) {
54-
User user = _accountService.getActiveUser(UserContext.current().getCallerUserId());
48+
User user = UserContext.current().getCallerUser();
5549
ListResponse<ApiDiscoveryResponse> response = (ListResponse<ApiDiscoveryResponse>) _apiDiscoveryService.listApis(user, name);
5650
if (response == null) {
5751
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Api Discovery plugin was unable to find an api by that name or process any apis");

plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717
package org.apache.cloudstack.discovery;
1818

1919
import com.cloud.serializer.Param;
20-
import com.cloud.server.ManagementServer;
2120
import com.cloud.user.User;
2221
import com.cloud.utils.ReflectUtil;
2322
import com.cloud.utils.StringUtils;
2423
import com.cloud.utils.component.Adapters;
2524
import com.cloud.utils.component.ComponentLocator;
26-
import com.cloud.utils.component.Inject;
27-
import com.cloud.utils.component.PluggableService;
2825
import com.google.gson.annotations.SerializedName;
2926
import org.apache.cloudstack.acl.APIChecker;
30-
import org.apache.cloudstack.acl.RoleType;
3127
import org.apache.cloudstack.api.APICommand;
3228
import org.apache.cloudstack.api.BaseCmd;
3329
import org.apache.cloudstack.api.BaseAsyncCmd;
@@ -54,16 +50,14 @@
5450
public class ApiDiscoveryServiceImpl implements ApiDiscoveryService {
5551
private static final Logger s_logger = Logger.getLogger(ApiDiscoveryServiceImpl.class);
5652

57-
@Inject(adapter = APIChecker.class)
58-
protected Adapters<APIChecker> _apiAccessCheckers;
59-
60-
private static Map<String, ApiDiscoveryResponse> _apiNameDiscoveryResponseMap = null;
53+
protected static Adapters<APIChecker> s_apiAccessCheckers = null;
54+
private static Map<String, ApiDiscoveryResponse> s_apiNameDiscoveryResponseMap = null;
6155

6256
protected ApiDiscoveryServiceImpl() {
6357
super();
64-
if (_apiNameDiscoveryResponseMap == null) {
58+
if (s_apiNameDiscoveryResponseMap == null) {
6559
long startTime = System.nanoTime();
66-
_apiNameDiscoveryResponseMap = new HashMap<String, ApiDiscoveryResponse>();
60+
s_apiNameDiscoveryResponseMap = new HashMap<String, ApiDiscoveryResponse>();
6761
cacheResponseMap();
6862
long endTime = System.nanoTime();
6963
s_logger.info("Api Discovery Service: Annotation, docstrings, api relation graph processed in " + (endTime - startTime) / 1000000.0 + " ms");
@@ -142,11 +136,11 @@ private void cacheResponseMap() {
142136
}
143137
}
144138
response.setObjectName("api");
145-
_apiNameDiscoveryResponseMap.put(apiName, response);
139+
s_apiNameDiscoveryResponseMap.put(apiName, response);
146140
}
147141

148-
for (String apiName : _apiNameDiscoveryResponseMap.keySet()) {
149-
ApiDiscoveryResponse response = _apiNameDiscoveryResponseMap.get(apiName);
142+
for (String apiName : s_apiNameDiscoveryResponseMap.keySet()) {
143+
ApiDiscoveryResponse response = s_apiNameDiscoveryResponseMap.get(apiName);
150144
Set<ApiParameterResponse> processedParams = new HashSet<ApiParameterResponse>();
151145
for (ApiParameterResponse param : response.getParams()) {
152146
if (responseApiNameListMap.containsKey(param.getRelated())) {
@@ -166,7 +160,7 @@ private void cacheResponseMap() {
166160
} else {
167161
response.setRelated(null);
168162
}
169-
_apiNameDiscoveryResponseMap.put(apiName, response);
163+
s_apiNameDiscoveryResponseMap.put(apiName, response);
170164
}
171165
}
172166

@@ -175,34 +169,39 @@ public ListResponse<? extends BaseResponse> listApis(User user, String name) {
175169
ListResponse<ApiDiscoveryResponse> response = new ListResponse<ApiDiscoveryResponse>();
176170
List<ApiDiscoveryResponse> responseList = new ArrayList<ApiDiscoveryResponse>();
177171

172+
if (s_apiAccessCheckers == null) {
173+
ComponentLocator locator = ComponentLocator.getCurrentLocator();
174+
s_apiAccessCheckers = locator.getAdapters(APIChecker.class);
175+
}
176+
178177
if (user == null)
179178
return null;
180179

181180
if (name != null) {
182-
if (!_apiNameDiscoveryResponseMap.containsKey(name))
181+
if (!s_apiNameDiscoveryResponseMap.containsKey(name))
183182
return null;
184183

185-
for (APIChecker apiChecker : _apiAccessCheckers) {
184+
for (APIChecker apiChecker : s_apiAccessCheckers) {
186185
try {
187186
apiChecker.checkAccess(user, name);
188187
} catch (Exception ex) {
189188
return null;
190189
}
191190
}
192-
responseList.add(_apiNameDiscoveryResponseMap.get(name));
191+
responseList.add(s_apiNameDiscoveryResponseMap.get(name));
193192

194193
} else {
195-
for (String apiName : _apiNameDiscoveryResponseMap.keySet()) {
194+
for (String apiName : s_apiNameDiscoveryResponseMap.keySet()) {
196195
boolean isAllowed = true;
197-
for (APIChecker apiChecker : _apiAccessCheckers) {
196+
for (APIChecker apiChecker : s_apiAccessCheckers) {
198197
try {
199-
apiChecker.checkAccess(user, name);
198+
apiChecker.checkAccess(user, apiName);
200199
} catch (Exception ex) {
201200
isAllowed = false;
202201
}
203202
}
204203
if (isAllowed)
205-
responseList.add(_apiNameDiscoveryResponseMap.get(apiName));
204+
responseList.add(s_apiNameDiscoveryResponseMap.get(apiName));
206205
}
207206
}
208207
response.setResponses(responseList);

plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
package com.cloud.simulator;
1919

2020
import com.cloud.utils.SerialVersionUID;
21-
import com.cloud.utils.exception.RuntimeCloudException;
21+
import com.cloud.utils.exception.CloudRuntimeException;
2222

2323
/**
2424
* wrap exceptions that you know there's no point in dealing with.
2525
*/
26-
public class SimulatorRuntimeException extends RuntimeCloudException {
26+
public class SimulatorRuntimeException extends CloudRuntimeException {
2727

2828
private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException;
2929

pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,6 @@
244244
<exclude>dist/console-proxy/js/jquery.js</exclude>
245245
<exclude>scripts/vm/systemvm/id_rsa.cloud</exclude>
246246
<exclude>tools/devcloud/basebuild/puppet-devcloudinitial/files/network.conf</exclude>
247-
<exclude>tools/devcloud/devcloud.cfg</exclude>
248-
<exclude>tools/devcloud/devcloud-advanced.cfg</exclude>
249-
<exclude>tools/devcloud-kvm/devcloud-kvm.cfg</exclude>
250-
<exclude>tools/devcloud-kvm/devcloud-kvm-advanced.cfg</exclude>
251247
<exclude>ui/lib/flot/jquery.colorhelpers.js</exclude>
252248
<exclude>ui/lib/flot/jquery.flot.crosshair.js</exclude>
253249
<exclude>ui/lib/flot/jquery.flot.fillbetween.js</exclude>

server/src/com/cloud/async/AsyncCommandQueued.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
package com.cloud.async;
1818

1919
import com.cloud.utils.SerialVersionUID;
20-
import com.cloud.utils.exception.RuntimeCloudException;
20+
import com.cloud.utils.exception.CloudRuntimeException;
2121

22-
public class AsyncCommandQueued extends RuntimeCloudException {
22+
public class AsyncCommandQueued extends CloudRuntimeException {
2323
private static final long serialVersionUID = SerialVersionUID.AsyncCommandQueued;
2424

2525
private SyncQueueVO _queue = null;

0 commit comments

Comments
 (0)