Revamped UserContext

This commit is contained in:
Alex Huang 2013-05-31 04:44:37 -07:00
parent cd6aea1015
commit 54de6b4868
170 changed files with 765 additions and 805 deletions

View File

@ -16,103 +16,150 @@
// under the License.
package com.cloud.user;
import javax.inject.Inject;
import java.util.HashMap;
import java.util.Map;
import com.cloud.utils.component.ComponentContext;
import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
import com.cloud.dao.EntityManager;
import com.cloud.exception.CloudAuthenticationException;
import com.cloud.utils.exception.CloudRuntimeException;
/**
* Calling Context records information about who is making this call. This
* class must be always be available in all CloudStack code. Every thread
* entry point must set the context and remove it when the thread finishes.
*/
public class UserContext {
private static final Logger s_logger = Logger.getLogger(UserContext.class);
private static ThreadLocal<UserContext> s_currentContext = new ThreadLocal<UserContext>();
private long userId;
private String sessionId;
private Account account;
private long startEventId = 0;
private long accountId;
private String eventDetails;
private boolean apiServer;
private User user;
private final Map<String, Object> context = new HashMap<String, Object>();
@Inject private AccountService _accountMgr = null;
private static EntityManager s_entityMgr;
public static void init(EntityManager entityMgr) {
s_entityMgr = entityMgr;
}
public UserContext() {
}
public UserContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
this.userId = userId;
this.account = accountObject;
protected UserContext(User user, Account account, String sessionId) {
this.user = user;
this.account = account;
this.sessionId = sessionId;
this.apiServer = apiServer;
}
public void putContextParameter(String key, Object value) {
context.put(key, value);
}
public long getCallerUserId() {
return userId;
public Object getContextParameter(String key) {
return context.get(key);
}
public User getCallerUser() {
if (_accountMgr == null) {
_accountMgr = ComponentContext.getComponent(AccountService.class);
}
return _accountMgr.getActiveUser(userId);
public long getCallingUserId() {
return user.getId();
}
public void setCallerUserId(long userId) {
this.userId = userId;
public User getCallingUser() {
return user;
}
public String getSessionId() {
return sessionId;
}
public Account getCaller() {
public Account getCallingAccount() {
return account;
}
public void setCaller(Account accountObject) {
this.account = accountObject;
}
public void setSessionKey(String sessionId) {
this.sessionId = sessionId;
}
public boolean isApiServer() {
return apiServer;
}
public void setApiServer(boolean apiServer) {
this.apiServer = apiServer;
}
public static UserContext current() {
return s_currentContext.get();
}
public static UserContext register(User callingUser, Account callingAccount, String sessionId) {
assert s_currentContext.get() == null : "There's a context already so what does this new register context mean? " + s_currentContext.get().toString();
if (s_currentContext.get() != null) { // FIXME: This should be removed soon. I added this check only to surface all the places that have this problem.
throw new CloudRuntimeException("There's a context already so what does this new register context mean? " + s_currentContext.get().toString());
}
UserContext callingContext = new UserContext(callingUser, callingAccount, sessionId);
s_currentContext.set(callingContext);
if (sessionId != null) {
NDC.push(sessionId);
}
s_logger.debug("Setting calling context: " + s_currentContext.get());
return callingContext;
}
public static UserContext registerOnceOnly() {
UserContext context = s_currentContext.get();
if (context == null) {
//
// TODO: we should enforce explicit UserContext setup at major entry-points for security concerns,
// however, there are many places that run background jobs assume the system context.
//
// If there is a security concern, all entry points from user (including the front end that takes HTTP
// request in and
// the core async-job manager that runs commands from user) have explicitly setup the UserContext.
//
return UserContextInitializer.getInstance().getAdminContext();
return register(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, null);
}
assert context.getCallingUserId() == User.UID_SYSTEM : "You are calling a very specific method that registers a one time system context. This method is meant for background threads that does processing.";
return context;
}
public static void updateContext(long userId, Account accountObject, String sessionId) {
UserContext context = current();
assert (context != null) : "Context should be already setup before you can call this one";
context.setCallerUserId(userId);
context.setCaller(accountObject);
context.setSessionKey(sessionId);
public static UserContext register(String callingUserUuid, String callingAccountUuid, String sessionId) {
Account account = s_entityMgr.findByUuid(Account.class, callingAccountUuid);
if (account == null) {
throw new CloudAuthenticationException("The account is no longer current.").add(Account.class, callingAccountUuid);
}
User user = s_entityMgr.findByUuid(User.class, callingUserUuid);
if (user == null) {
throw new CloudAuthenticationException("The user is no longer current.").add(User.class, callingUserUuid);
}
return register(user, account, sessionId);
}
public static void registerContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
s_currentContext.set(new UserContext(userId, accountObject, sessionId, apiServer));
public static UserContext register(long callingUserId, long callingAccountId, String sessionId) throws CloudAuthenticationException {
Account account = s_entityMgr.findById(Account.class, callingAccountId);
if (account == null) {
throw new CloudAuthenticationException("The account is no longer current.").add(Account.class, Long.toString(callingAccountId));
}
User user = s_entityMgr.findById(User.class, callingUserId);
if (user == null) {
throw new CloudAuthenticationException("The user is no longer current.").add(User.class, Long.toString(callingUserId));
}
return register(user, account, sessionId);
}
public static void unregisterContext() {
s_currentContext.set(null);
public static UserContext register(long callingUserId, Account callingAccount, String sessionId, boolean apiServer) {
User user = s_entityMgr.findById(User.class, callingUserId);
if (user == null) {
throw new CloudAuthenticationException("The user is no longer current.").add(User.class, Long.toString(callingUserId));
}
return register(user, callingAccount, sessionId);
}
public static UserContext unregister() {
assert s_currentContext.get() != null : "Removing the context when we don't need to " + s_currentContext.get().toString();
UserContext context = s_currentContext.get();
if (context == null) {
s_logger.trace("No context to remove");
return null;
}
s_currentContext.remove();
s_logger.debug("Context removed " + context);
String sessionId = context.getSessionId();
if (sessionId != null) {
while ((sessionId = NDC.pop()) != null) {
if (context.getSessionId().equals(sessionId)) {
break;
}
}
}
return context;
}
public void setStartEventId(long startEventId) {
@ -123,12 +170,16 @@ public class UserContext {
return startEventId;
}
public long getAccountId() {
return accountId;
public long getCallingAccountId() {
return account.getId();
}
public void setAccountId(long accountId) {
this.accountId = accountId;
public String getCallingAccountUuid() {
return account.getUuid();
}
public String getCallingUserUuid() {
return user.getUuid();
}
public void setEventDetails(String eventDetails) {
@ -138,4 +189,12 @@ public class UserContext {
public String getEventDetails() {
return eventDetails;
}
@Override
public String toString() {
return new StringBuffer("CallContext[acct=").append(account.getId())
.append("; user=").append(user.getId())
.append("; session=").append(sessionId)
.append("]").toString();
}
}

View File

@ -1,40 +0,0 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.user;
import javax.inject.Inject;
import org.springframework.stereotype.Component;
@Component
public class UserContextInitializer {
@Inject private AccountService _accountMgr;
private static UserContextInitializer s_instance;
public UserContextInitializer() {
s_instance = this;
}
public static UserContextInitializer getInstance() {
return s_instance;
}
public UserContext getAdminContext() {
return new UserContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, false);
}
}

View File

@ -98,7 +98,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
protected long saveStartedEvent(String eventType, String description, Long startEventId) {
UserContext ctx = UserContext.current();
Long userId = ctx.getCallerUserId();
Long userId = ctx.getCallingUserId();
userId = (userId == null) ? User.UID_SYSTEM : userId;
Long startEvent = startEventId;
if (startEvent == null) {
@ -113,7 +113,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId) {
UserContext ctx = UserContext.current();
Long userId = ctx.getCallerUserId();
Long userId = ctx.getCallingUserId();
userId = (userId == null) ? User.UID_SYSTEM : userId;
Long startEvent = startEventId;
if (startEvent == null) {

View File

@ -80,7 +80,7 @@ public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd {
public void execute(){
List<String> accountNames = _templateService.listTemplatePermissions(this);
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
boolean isAdmin = (isAdmin(account.getType()));
TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(accountNames, id, isAdmin);

View File

@ -75,7 +75,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();// Let's give the caller here for event logging.
Account account = UserContext.current().getCallingAccount();// Let's give the caller here for event logging.
if (account != null) {
return account.getAccountId();
}

View File

@ -69,7 +69,7 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -69,7 +69,7 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -69,7 +69,7 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -65,7 +65,7 @@ public class ReleaseHostReservationCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -109,7 +109,7 @@ public class StartInternalLBVMCmd extends BaseAsyncCmd {
if (router == null || router.getRole() != Role.INTERNAL_LB_VM) {
throw new InvalidParameterValueException("Can't find internal lb vm by id");
} else {
result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCallingAccount(), UserContext.current().getCallingUserId());
}
if (result != null){

View File

@ -110,7 +110,7 @@ public class StopInternalLBVMCmd extends BaseAsyncCmd {
if (vm == null || vm.getRole() != Role.INTERNAL_LB_VM) {
throw new InvalidParameterValueException("Can't find internal lb vm by id");
} else {
result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCallingAccount(), UserContext.current().getCallingUserId());
}
if (result != null) {

View File

@ -99,7 +99,7 @@ public class DestroyRouterCmd extends BaseAsyncCmd {
UserContext ctx = UserContext.current();
ctx.setEventDetails("Router Id: "+getId());
VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCaller(), ctx.getCallerUserId());
VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCallingAccount(), ctx.getCallingUserId());
if (result != null) {
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName(getCommandName());

View File

@ -82,7 +82,7 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -80,7 +80,7 @@ public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -57,7 +57,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -82,7 +82,7 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -65,7 +65,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -71,7 +71,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -69,7 +69,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -70,7 +70,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -76,7 +76,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -120,7 +120,7 @@ public class CreateUserCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);

View File

@ -103,14 +103,14 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
if (accountName != null) {
return accountName;
}
return UserContext.current().getCaller().getAccountName();
return UserContext.current().getCallingAccount().getAccountName();
}
public long getDomainId() {
if (domainId != null) {
return domainId;
}
return UserContext.current().getCaller().getDomainId();
return UserContext.current().getCallingAccount().getDomainId();
}
private long getZoneId() {
@ -191,7 +191,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
if (accountName != null && domainId != null) {
Account account = _accountService.finalizeOwner(caller, accountName, domainId, projectId);
return account.getId();

View File

@ -95,7 +95,7 @@ public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);

View File

@ -102,7 +102,7 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);

View File

@ -120,7 +120,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
if (autoscaleUserId != null) {
return autoscaleUserId;
} else {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}
@ -137,7 +137,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
User user = _entityMgr.findById(User.class, autoscaleUserId);
account = _entityMgr.findById(Account.class, user.getAccountId());
} else {
account = UserContext.current().getCaller();
account = UserContext.current().getCallingAccount();
}
accountId = account.getAccountId();
domainId = account.getDomainId();

View File

@ -106,7 +106,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
public String getAccountName() {
if (accountName == null) {
return UserContext.current().getCaller().getAccountName();
return UserContext.current().getCallingAccount().getAccountName();
}
return accountName;
@ -114,7 +114,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
public Long getDomainId() {
if (domainId == null) {
return UserContext.current().getCaller().getDomainId();
return UserContext.current().getCallingAccount().getDomainId();
}
return domainId;
}
@ -142,7 +142,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -82,7 +82,7 @@ public class ArchiveEventsCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -82,7 +82,7 @@ public class DeleteEventsCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -133,7 +133,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
FirewallRule rule = _entityMgr.findById(FirewallRule.class, getEntityId());
try {
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
success = _firewallService.applyEgressFirewallRules (rule, callerContext.getCaller());
success = _firewallService.applyEgressFirewallRules (rule, callerContext.getCallingAccount());
// State is different after the rule is applied, so get new object here
rule = _entityMgr.findById(FirewallRule.class, getEntityId());
FirewallResponse fwResponse = new FirewallResponse();
@ -204,7 +204,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();

View File

@ -122,7 +122,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
FirewallRule rule = _entityMgr.findById(FirewallRule.class, getEntityId());
try {
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
success = _firewallService.applyIngressFirewallRules(rule.getSourceIpAddressId(), callerContext.getCaller());
success = _firewallService.applyIngressFirewallRules(rule.getSourceIpAddressId(), callerContext.getCallingAccount());
// State is different after the rule is applied, so get new object here
rule = _entityMgr.findById(FirewallRule.class, getEntityId());
@ -212,7 +212,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();

View File

@ -179,10 +179,10 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
if (getOpenFirewall()) {
success = success && _firewallService.applyIngressFirewallRules(ipAddressId, callerContext.getCaller());
success = success && _firewallService.applyIngressFirewallRules(ipAddressId, callerContext.getCallingAccount());
}
success = success && _rulesService.applyPortForwardingRules(ipAddressId, callerContext.getCaller());
success = success && _rulesService.applyPortForwardingRules(ipAddressId, callerContext.getCallingAccount());
// State is different after the rule is applied, so get new object here
rule = _entityMgr.findById(PortForwardingRule.class, getEntityId());
@ -272,7 +272,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();

View File

@ -124,7 +124,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
}
public boolean listInReadyState() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
// It is account specific if account is admin type and domainId and accountName are not null
boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
// Show only those that are downloaded.

View File

@ -163,7 +163,7 @@ public class RegisterIsoCmd extends BaseCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -98,7 +98,7 @@ public class CreateLBHealthCheckPolicyCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -104,7 +104,7 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -245,7 +245,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
if (getOpenFirewall()) {
success = success && _firewallService.applyIngressFirewallRules(getSourceIpAddressId(), callerContext.getCaller());
success = success && _firewallService.applyIngressFirewallRules(getSourceIpAddressId(), callerContext.getCallingAccount());
}
// State might be different after the rule is applied, so get new object here
@ -328,7 +328,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
if (domainId != null) {
return domainId;
}
return UserContext.current().getCaller().getDomainId();
return UserContext.current().getCallingAccount().getDomainId();
}
public int getDefaultPortStart() {

View File

@ -65,7 +65,7 @@ public class DeleteLBHealthCheckPolicyCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -65,7 +65,7 @@ public class DeleteLBStickinessPolicyCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -72,7 +72,7 @@ public class ListLBStickinessPoliciesCmd extends BaseListCmd {
if (lb != null) {
//check permissions
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
_accountService.checkAccess(caller, null, true, lb);
List<? extends StickinessPolicy> stickinessPolicies = _lbService.searchForLBStickinessPolicies(this);
LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies, lb);

View File

@ -115,10 +115,10 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
UserContext.current().setEventDetails("Rule Id: "+ getEntityId());
if (getOpenFirewall()) {
result = result && _firewallService.applyIngressFirewallRules(ipAddressId, UserContext.current().getCaller());
result = result && _firewallService.applyIngressFirewallRules(ipAddressId, UserContext.current().getCallingAccount());
}
result = result && _rulesService.applyStaticNatRules(ipAddressId, UserContext.current().getCaller());
result = result && _rulesService.applyStaticNatRules(ipAddressId, UserContext.current().getCallingAccount());
rule = _entityMgr.findById(FirewallRule.class, getEntityId());
StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false);
IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule);
@ -158,7 +158,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();

View File

@ -166,7 +166,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
return caller.getAccountId();
}

View File

@ -282,7 +282,7 @@ public class CreateNetworkCmd extends BaseCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -73,7 +73,7 @@ public class DeleteNetworkACLCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
return caller.getAccountId();
}

View File

@ -74,7 +74,7 @@ public class DeleteNetworkACLListCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
return caller.getAccountId();
}

View File

@ -87,7 +87,7 @@ public class ReplaceNetworkACLListCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
return caller.getAccountId();
}

View File

@ -134,7 +134,7 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
return caller.getAccountId();
}

View File

@ -130,7 +130,7 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException{
User callerUser = _accountService.getActiveUser(UserContext.current().getCallerUserId());
User callerUser = _accountService.getActiveUser(UserContext.current().getCallingUserId());
Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId());
Network network = _networkService.getNetwork(id);
if (network == null) {

View File

@ -66,7 +66,7 @@ public class CreateProjectCmd extends BaseAsyncCreateCmd {
if (accountName != null) {
return accountName;
} else {
return UserContext.current().getCaller().getAccountName();
return UserContext.current().getCallingAccount().getAccountName();
}
}
@ -74,7 +74,7 @@ public class CreateProjectCmd extends BaseAsyncCreateCmd {
if (domainId != null) {
return domainId;
} else {
return UserContext.current().getCaller().getDomainId();
return UserContext.current().getCallingAccount().getDomainId();
}
}
@ -94,7 +94,7 @@ public class CreateProjectCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
if ((accountName != null && domainId == null) || (domainId != null && accountName == null)) {
throw new InvalidParameterValueException("Account name and domain id must be specified together");

View File

@ -182,7 +182,7 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;
}

View File

@ -100,7 +100,7 @@ public class UpdateResourceCountCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);

View File

@ -97,7 +97,7 @@ public class UpdateResourceLimitCmd extends BaseCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -165,7 +165,7 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -166,7 +166,7 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -92,7 +92,7 @@ public class CreateSecurityGroupCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);

View File

@ -108,7 +108,7 @@ public class DeleteSecurityGroupCmd extends BaseCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -82,7 +82,7 @@ public class CreateSSHKeyPairCmd extends BaseCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -91,7 +91,7 @@ public class DeleteSSHKeyPairCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);

View File

@ -88,7 +88,7 @@ public class RegisterSSHKeyPairCmd extends BaseCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -103,7 +103,7 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
public boolean listInReadyState() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
// It is account specific if account is admin type and domainId and accountName are not null
boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
// Show only those that are downloaded.

View File

@ -226,7 +226,7 @@ public class RegisterTemplateCmd extends BaseCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -69,11 +69,11 @@ public class AddIpToVmNicCmd extends BaseAsyncCmd {
}
public String getAccountName() {
return UserContext.current().getCaller().getAccountName();
return UserContext.current().getCallingAccount().getAccountName();
}
public long getDomainId() {
return UserContext.current().getCaller().getDomainId();
return UserContext.current().getCallingAccount().getDomainId();
}
private long getZoneId() {
@ -113,7 +113,7 @@ public class AddIpToVmNicCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
return caller.getAccountId();
}

View File

@ -195,7 +195,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
public String getAccountName() {
if (accountName == null) {
return UserContext.current().getCaller().getAccountName();
return UserContext.current().getCallingAccount().getAccountName();
}
return accountName;
}
@ -210,7 +210,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
public Long getDomainId() {
if (domainId == null) {
return UserContext.current().getCaller().getDomainId();
return UserContext.current().getCallingAccount().getDomainId();
}
return domainId;
}
@ -380,7 +380,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -66,11 +66,11 @@ public class ListNicsCmd extends BaseListCmd {
}
public String getAccountName() {
return UserContext.current().getCaller().getAccountName();
return UserContext.current().getCallingAccount().getAccountName();
}
public long getDomainId() {
return UserContext.current().getCaller().getDomainId();
return UserContext.current().getCallingAccount().getDomainId();
}
public Long getNicId() {
@ -83,7 +83,7 @@ public class ListNicsCmd extends BaseListCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
return caller.getAccountId();
}

View File

@ -67,16 +67,16 @@ public class RemoveIpFromVmNicCmd extends BaseAsyncCmd {
}
public String getAccountName() {
return UserContext.current().getCaller().getAccountName();
return UserContext.current().getCallingAccount().getAccountName();
}
public long getDomainId() {
return UserContext.current().getCaller().getDomainId();
return UserContext.current().getCallingAccount().getDomainId();
}
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
return caller.getAccountId();
}

View File

@ -89,7 +89,7 @@ public class CreateVMGroupCmd extends BaseCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -141,7 +141,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -81,7 +81,7 @@ public class DeleteVolumeCmd extends BaseCmd {
@Override
public void execute() throws ConcurrentOperationException {
UserContext.current().setEventDetails("Volume Id: "+getId());
boolean result = this._volumeService.deleteVolume(id, UserContext.current().getCaller());
boolean result = this._volumeService.deleteVolume(id, UserContext.current().getCallingAccount());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);

View File

@ -144,7 +144,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -180,7 +180,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -98,7 +98,7 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;

View File

@ -138,7 +138,7 @@ public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
accountId = UserContext.current().getCaller().getId();
accountId = UserContext.current().getCallingAccount().getId();
}
return accountId;
}

View File

@ -85,7 +85,7 @@ public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd {
@Override
public void execute() throws ResourceUnavailableException {
_ravService.destroyRemoteAccessVpnForIp(publicIpId, UserContext.current().getCaller());
_ravService.destroyRemoteAccessVpnForIp(publicIpId, UserContext.current().getCallingAccount());
}
@Override

View File

@ -90,7 +90,7 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return accountId;
@ -109,7 +109,7 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
@Override
public void execute(){
Account owner = _accountService.getAccount(getEntityOwnerId());
boolean result = _ravService.removeVpnUser(owner.getId(), userName, UserContext.current().getCaller());
boolean result = _ravService.removeVpnUser(owner.getId(), userName, UserContext.current().getCallingAccount());
if (!result) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn user");
}

View File

@ -85,7 +85,7 @@ public class ResetVpnConnectionCmd extends BaseAsyncCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
return Account.ACCOUNT_ID_SYSTEM;
}

View File

@ -137,7 +137,7 @@ public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd {
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
accountId = UserContext.current().getCaller().getId();
accountId = UserContext.current().getCallingAccount().getId();
}
return accountId;
}

View File

@ -95,6 +95,8 @@ public interface AsyncJob extends Job {
@Override
Long getInstanceId();
String getShortUuid();
SyncQueueItem getSyncSource();
void setSyncSource(SyncQueueItem item);
}

View File

@ -35,6 +35,7 @@ import javax.persistence.Transient;
import org.apache.cloudstack.jobs.Job;
import com.cloud.utils.UuidUtils;
import com.cloud.utils.db.GenericDao;
@Entity
@ -142,6 +143,11 @@ public class AsyncJobVO implements AsyncJob, Job {
this.id = id;
}
@Override
public String getShortUuid() {
return UuidUtils.first(uuid);
}
@Override
public String getType() {
return type;

View File

@ -47,7 +47,7 @@ public class ListApisCmd extends BaseCmd {
@Override
public void execute() throws ServerApiException {
if (_apiDiscoveryService != null) {
User user = UserContext.current().getCallerUser();
User user = UserContext.current().getCallingUser();
ListResponse<ApiDiscoveryResponse> response = (ListResponse<ApiDiscoveryResponse>) _apiDiscoveryService.listApis(user, name);
if (response == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Api Discovery plugin was unable to find an api by that name or process any apis");

View File

@ -84,7 +84,7 @@ public class ResetApiLimitCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}

View File

@ -73,7 +73,7 @@ public class GetApiLimitCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCallingAccount();
if (account != null) {
return account.getId();
}
@ -87,7 +87,7 @@ public class GetApiLimitCmd extends BaseCmd {
if ( !apiLimitEnabled ){
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "This api is only available when api.throttling.enabled = true.");
}
Account caller = UserContext.current().getCaller();
Account caller = UserContext.current().getCallingAccount();
ApiLimitResponse response = _apiLimitService.searchApiLimit(caller);
response.setResponseName(getCommandName());
response.setObjectName("apilimit");

View File

@ -165,7 +165,7 @@ public class ImplicitPlannerTest {
acct.setDomainId(domainId);
acct.setId(accountId);
UserContext.registerContext(1, acct, null, true);
UserContext.register(1, acct, null, true);
}
@Test

View File

@ -100,7 +100,7 @@ public class AddBaremetalDhcpCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
public Long getPodId() {

View File

@ -94,7 +94,7 @@ public class AddBaremetalPxeCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
public Long getPhysicalNetworkId() {

View File

@ -96,7 +96,7 @@ public class AddBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
@Override

View File

@ -86,7 +86,7 @@ public class DeleteBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
@Override

View File

@ -111,6 +111,6 @@ public class AddCiscoAsa1000vResourceCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -110,6 +110,6 @@ public class AddCiscoVnmcResourceCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -87,7 +87,7 @@ public class DeleteCiscoAsa1000vResourceCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -87,7 +87,7 @@ public class DeleteCiscoVnmcResourceCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -359,8 +359,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
}
if (outsideIp == null) { // none available, acquire one
try {
Account caller = UserContext.current().getCaller();
long callerUserId = UserContext.current().getCallerUserId();
Account caller = UserContext.current().getCallingAccount();
long callerUserId = UserContext.current().getCallingUserId();
outsideIp = _networkMgr.allocateIp(owner, false, caller, callerUserId, zone);
} catch (ResourceAllocationException e) {
s_logger.error("Unable to allocate additional public Ip address. Exception details " + e);

View File

@ -667,7 +667,7 @@ public class ElasticLoadBalancerManagerImpl extends ManagerBase implements
} catch (NetworkRuleConflictException e) {
s_logger.warn("Failed to create LB rule, not continuing with ELB deployment");
if (newIp) {
releaseIp(ipId, UserContext.current().getCallerUserId(), account);
releaseIp(ipId, UserContext.current().getCallingUserId(), account);
}
throw e;
}
@ -681,7 +681,7 @@ public class ElasticLoadBalancerManagerImpl extends ManagerBase implements
if (elbVm == null) {
s_logger.warn("Failed to deploy a new ELB vm for ip " + ipAddr + " in network " + network + "lb name=" + lb.getName());
if (newIp)
releaseIp(ipId, UserContext.current().getCallerUserId(), account);
releaseIp(ipId, UserContext.current().getCallingUserId(), account);
}
}

View File

@ -127,6 +127,6 @@ public class AddF5LoadBalancerCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -105,6 +105,6 @@ public class ConfigureF5LoadBalancerCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -102,6 +102,6 @@ public class DeleteF5LoadBalancerCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -91,7 +91,7 @@ public class InternalLBVMServiceTest extends TestCase {
Mockito.when(_accountMgr.getSystemUser()).thenReturn(new UserVO(1));
Mockito.when(_accountMgr.getSystemAccount()).thenReturn(new AccountVO(2));
Mockito.when(_accountDao.findByIdIncludingRemoved(Mockito.anyLong())).thenReturn(new AccountVO(2));
UserContext.registerContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, false);
UserContext.register(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, false);
DomainRouterVO validVm = new DomainRouterVO(validVmId,off.getId(),1,"alena",1,HypervisorType.XenServer,1,1,1,

View File

@ -130,6 +130,6 @@ public class AddSrxFirewallCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -109,6 +109,6 @@ public class ConfigureSrxFirewallCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -100,6 +100,6 @@ public class DeleteSrxFirewallCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

View File

@ -143,6 +143,6 @@ public class AddNetscalerLoadBalancerCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
return UserContext.current().getCaller().getId();
return UserContext.current().getCallingAccount().getId();
}
}

Some files were not shown because too many files have changed in this diff Show More