ApiServer: Get rid of finding system account and user at init() time

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
This commit is contained in:
Rohit Yadav 2013-02-16 17:09:37 +05:30
parent 295b327281
commit 8094e933b0
1 changed files with 1 additions and 6 deletions

View File

@ -157,8 +157,6 @@ public class ApiServer implements HttpRequestHandler {
@Inject List<PluggableService> _pluggableServices;
@Inject List<APIChecker> _apiAccessCheckers;
private Account _systemAccount = null;
private User _systemUser = null;
@Inject private RegionManager _regionMgr = null;
private static int _workerCount = 0;
@ -182,9 +180,6 @@ public class ApiServer implements HttpRequestHandler {
}
public void init() {
_systemAccount = _accountMgr.getSystemAccount();
_systemUser = _accountMgr.getSystemUser();
Integer apiPort = null; // api port, null by default
SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
sc.addAnd("name", SearchCriteria.Op.EQ, "integration.api.port");
@ -278,7 +273,7 @@ public class ApiServer implements HttpRequestHandler {
try {
// always trust commands from API port, user context will always be UID_SYSTEM/ACCOUNT_ID_SYSTEM
UserContext.registerContext(_systemUser.getId(), _systemAccount, null, true);
UserContext.registerContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, true);
sb.insert(0, "(userId=" + User.UID_SYSTEM + " accountId=" + Account.ACCOUNT_ID_SYSTEM + " sessionId=" + null + ") ");
String responseText = handleRequest(parameterMap, responseType, sb);
sb.append(" 200 " + ((responseText == null) ? 0 : responseText.length()));