cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [05/14] git commit: updated refs/heads/vmsync to b8261b8
Date Fri, 31 May 2013 12:06:45 GMT
Revamped UserContext


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/54de6b48
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/54de6b48
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/54de6b48

Branch: refs/heads/vmsync
Commit: 54de6b486895a9a39d6bfbdb15d008e4e175d4c5
Parents: cd6aea1
Author: Alex Huang <alex.huang@gmail.com>
Authored: Fri May 31 04:44:37 2013 -0700
Committer: Alex Huang <alex.huang@gmail.com>
Committed: Fri May 31 04:44:37 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/user/UserContext.java            |  171 ++++++++++-----
 api/src/com/cloud/user/UserContextInitializer.java |   40 ----
 .../org/apache/cloudstack/api/BaseAsyncCmd.java    |    4 +-
 .../api/BaseListTemplateOrIsoPermissionsCmd.java   |    2 +-
 .../command/admin/account/DeleteAccountCmd.java    |    2 +-
 .../command/admin/host/CancelMaintenanceCmd.java   |    2 +-
 .../admin/host/PrepareForMaintenanceCmd.java       |    2 +-
 .../api/command/admin/host/ReconnectHostCmd.java   |    2 +-
 .../admin/host/ReleaseHostReservationCmd.java      |    2 +-
 .../admin/internallb/StartInternalLBVMCmd.java     |    2 +-
 .../admin/internallb/StopInternalLBVMCmd.java      |    2 +-
 .../api/command/admin/router/DestroyRouterCmd.java |    2 +-
 .../CancelPrimaryStorageMaintenanceCmd.java        |    2 +-
 .../PreparePrimaryStorageForMaintenanceCmd.java    |    2 +-
 .../command/admin/systemvm/DestroySystemVmCmd.java |    2 +-
 .../command/admin/systemvm/MigrateSystemVMCmd.java |    2 +-
 .../command/admin/systemvm/RebootSystemVmCmd.java  |    2 +-
 .../command/admin/systemvm/ScaleSystemVMCmd.java   |    2 +-
 .../command/admin/systemvm/StartSystemVMCmd.java   |    2 +-
 .../command/admin/systemvm/StopSystemVmCmd.java    |    2 +-
 .../command/admin/systemvm/UpgradeSystemVMCmd.java |    2 +-
 .../api/command/admin/user/CreateUserCmd.java      |    2 +-
 .../command/user/address/AssociateIPAddrCmd.java   |    6 +-
 .../user/affinitygroup/CreateAffinityGroupCmd.java |    2 +-
 .../user/affinitygroup/DeleteAffinityGroupCmd.java |    2 +-
 .../autoscale/CreateAutoScaleVmProfileCmd.java     |    4 +-
 .../command/user/autoscale/CreateConditionCmd.java |    6 +-
 .../api/command/user/event/ArchiveEventsCmd.java   |    2 +-
 .../api/command/user/event/DeleteEventsCmd.java    |    2 +-
 .../user/firewall/CreateEgressFirewallRuleCmd.java |    4 +-
 .../user/firewall/CreateFirewallRuleCmd.java       |    4 +-
 .../user/firewall/CreatePortForwardingRuleCmd.java |    6 +-
 .../api/command/user/iso/ListIsosCmd.java          |    2 +-
 .../api/command/user/iso/RegisterIsoCmd.java       |    2 +-
 .../loadbalancer/CreateLBHealthCheckPolicyCmd.java |    2 +-
 .../loadbalancer/CreateLBStickinessPolicyCmd.java  |    2 +-
 .../loadbalancer/CreateLoadBalancerRuleCmd.java    |    4 +-
 .../loadbalancer/DeleteLBHealthCheckPolicyCmd.java |    2 +-
 .../loadbalancer/DeleteLBStickinessPolicyCmd.java  |    2 +-
 .../loadbalancer/ListLBStickinessPoliciesCmd.java  |    2 +-
 .../user/nat/CreateIpForwardingRuleCmd.java        |    6 +-
 .../command/user/network/CreateNetworkACLCmd.java  |    2 +-
 .../api/command/user/network/CreateNetworkCmd.java |    2 +-
 .../command/user/network/DeleteNetworkACLCmd.java  |    2 +-
 .../user/network/DeleteNetworkACLListCmd.java      |    2 +-
 .../user/network/ReplaceNetworkACLListCmd.java     |    2 +-
 .../user/network/UpdateNetworkACLItemCmd.java      |    2 +-
 .../api/command/user/network/UpdateNetworkCmd.java |    2 +-
 .../api/command/user/project/CreateProjectCmd.java |    6 +-
 .../ha/gslb/CreateGlobalLoadBalancerRuleCmd.java   |    2 +-
 .../user/resource/UpdateResourceCountCmd.java      |    2 +-
 .../user/resource/UpdateResourceLimitCmd.java      |    2 +-
 .../AuthorizeSecurityGroupEgressCmd.java           |    2 +-
 .../AuthorizeSecurityGroupIngressCmd.java          |    2 +-
 .../user/securitygroup/CreateSecurityGroupCmd.java |    2 +-
 .../user/securitygroup/DeleteSecurityGroupCmd.java |    2 +-
 .../api/command/user/ssh/CreateSSHKeyPairCmd.java  |    2 +-
 .../api/command/user/ssh/DeleteSSHKeyPairCmd.java  |    2 +-
 .../command/user/ssh/RegisterSSHKeyPairCmd.java    |    2 +-
 .../command/user/template/ListTemplatesCmd.java    |    2 +-
 .../command/user/template/RegisterTemplateCmd.java |    2 +-
 .../api/command/user/vm/AddIpToVmNicCmd.java       |    6 +-
 .../api/command/user/vm/DeployVMCmd.java           |    6 +-
 .../api/command/user/vm/ListNicsCmd.java           |    6 +-
 .../api/command/user/vm/RemoveIpFromVmNicCmd.java  |    6 +-
 .../api/command/user/vmgroup/CreateVMGroupCmd.java |    2 +-
 .../api/command/user/volume/CreateVolumeCmd.java   |    2 +-
 .../api/command/user/volume/DeleteVolumeCmd.java   |    2 +-
 .../api/command/user/volume/UploadVolumeCmd.java   |    2 +-
 .../api/command/user/vpc/CreateVPCCmd.java         |    2 +-
 .../api/command/user/vpn/AddVpnUserCmd.java        |    2 +-
 .../user/vpn/CreateVpnCustomerGatewayCmd.java      |    2 +-
 .../command/user/vpn/DeleteRemoteAccessVpnCmd.java |    2 +-
 .../api/command/user/vpn/RemoveVpnUserCmd.java     |    4 +-
 .../command/user/vpn/ResetVpnConnectionCmd.java    |    2 +-
 .../user/vpn/UpdateVpnCustomerGatewayCmd.java      |    2 +-
 .../apache/cloudstack/framework/jobs/AsyncJob.java |    2 +
 .../cloudstack/framework/jobs/AsyncJobVO.java      |    6 +
 .../api/command/user/discovery/ListApisCmd.java    |    2 +-
 .../command/admin/ratelimit/ResetApiLimitCmd.java  |    2 +-
 .../api/command/user/ratelimit/GetApiLimitCmd.java |    4 +-
 .../implicitplanner/ImplicitPlannerTest.java       |    2 +-
 .../networkservice/AddBaremetalDhcpCmd.java        |    2 +-
 .../networkservice/AddBaremetalPxeCmd.java         |    2 +-
 .../api/commands/AddBigSwitchVnsDeviceCmd.java     |    2 +-
 .../api/commands/DeleteBigSwitchVnsDeviceCmd.java  |    2 +-
 .../api/commands/AddCiscoAsa1000vResourceCmd.java  |    2 +-
 .../api/commands/AddCiscoVnmcResourceCmd.java      |    2 +-
 .../commands/DeleteCiscoAsa1000vResourceCmd.java   |    2 +-
 .../api/commands/DeleteCiscoVnmcResourceCmd.java   |    2 +-
 .../cloud/network/element/CiscoVnmcElement.java    |    4 +-
 .../network/lb/ElasticLoadBalancerManagerImpl.java |    4 +-
 .../cloud/api/commands/AddF5LoadBalancerCmd.java   |    2 +-
 .../api/commands/ConfigureF5LoadBalancerCmd.java   |    2 +-
 .../api/commands/DeleteF5LoadBalancerCmd.java      |    2 +-
 .../internallbvmmgr/InternalLBVMServiceTest.java   |    2 +-
 .../com/cloud/api/commands/AddSrxFirewallCmd.java  |    2 +-
 .../api/commands/ConfigureSrxFirewallCmd.java      |    2 +-
 .../cloud/api/commands/DeleteSrxFirewallCmd.java   |    2 +-
 .../api/commands/AddNetscalerLoadBalancerCmd.java  |    2 +-
 .../ConfigureNetscalerLoadBalancerCmd.java         |    2 +-
 .../commands/DeleteNetscalerLoadBalancerCmd.java   |    2 +-
 .../cloud/api/commands/AddNiciraNvpDeviceCmd.java  |    2 +-
 .../api/commands/DeleteNiciraNvpDeviceCmd.java     |    2 +-
 .../cloud/network/guru/OvsGuestNetworkGuru.java    |    2 +-
 .../com/cloud/agent/manager/AgentManagerImpl.java  |    9 +-
 .../src/com/cloud/api/ApiAsyncJobDispatcher.java   |    4 +-
 server/src/com/cloud/api/ApiDispatcher.java        |    9 +-
 server/src/com/cloud/api/ApiResponseHelper.java    |   12 +-
 server/src/com/cloud/api/ApiSerializerHelper.java  |    3 +-
 server/src/com/cloud/api/ApiServer.java            |   30 +--
 server/src/com/cloud/api/ApiServlet.java           |   18 +-
 .../src/com/cloud/api/query/QueryManagerImpl.java  |   38 ++--
 .../com/cloud/api/query/ViewResponseHelper.java    |    6 +-
 .../cloud/api/query/dao/DataCenterJoinDaoImpl.java |    2 +-
 .../com/cloud/api/query/dao/VolumeJoinDaoImpl.java |    2 +-
 .../src/com/cloud/async/AsyncJobManagerImpl.java   |    2 +-
 .../configuration/ConfigurationManagerImpl.java    |   26 +-
 .../consoleproxy/ConsoleProxyManagerImpl.java      |    2 +-
 .../com/cloud/event/ActionEventInterceptor.java    |   12 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  |   22 +-
 .../src/com/cloud/network/NetworkServiceImpl.java  |   58 ++---
 .../com/cloud/network/NetworkUsageManagerImpl.java |    2 +-
 .../com/cloud/network/as/AutoScaleManagerImpl.java |   36 ++--
 .../network/firewall/FirewallManagerImpl.java      |   10 +-
 .../network/guru/ExternalGuestNetworkGuru.java     |    2 +-
 .../com/cloud/network/guru/GuestNetworkGuru.java   |    4 +-
 .../network/lb/LoadBalancingRulesManagerImpl.java  |   34 ++--
 .../router/VirtualNetworkApplianceManagerImpl.java |   97 +++++----
 .../com/cloud/network/rules/RulesManagerImpl.java  |   24 +-
 .../network/security/SecurityGroupManagerImpl.java |   10 +-
 .../cloud/network/vpc/NetworkACLServiceImpl.java   |   14 +-
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |   34 ++--
 .../network/vpn/RemoteAccessVpnManagerImpl.java    |   14 +-
 .../cloud/network/vpn/Site2SiteVpnManagerImpl.java |   22 +-
 .../src/com/cloud/projects/ProjectManagerImpl.java |   22 +-
 .../com/cloud/resource/ResourceManagerImpl.java    |   12 +-
 .../resourcelimit/ResourceLimitManagerImpl.java    |    6 +-
 .../src/com/cloud/server/ManagementServerImpl.java |   68 +++---
 .../src/com/cloud/storage/StorageManagerImpl.java  |   10 +-
 .../cloud/storage/StoragePoolAutomationImpl.java   |    8 +-
 .../src/com/cloud/storage/VolumeManagerImpl.java   |   12 +-
 .../secondary/SecondaryStorageManagerImpl.java     |    2 +-
 .../storage/snapshot/SnapshotManagerImpl.java      |   20 +-
 .../storage/snapshot/SnapshotSchedulerImpl.java    |   21 +-
 .../com/cloud/tags/TaggedResourceManagerImpl.java  |    4 +-
 .../com/cloud/template/TemplateAdapterBase.java    |   20 +-
 .../com/cloud/template/TemplateManagerImpl.java    |   34 ++--
 server/src/com/cloud/usage/UsageServiceImpl.java   |    2 +-
 server/src/com/cloud/user/AccountManagerImpl.java  |   36 ++--
 server/src/com/cloud/user/DomainManagerImpl.java   |   14 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   73 +++----
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |    1 +
 server/src/com/cloud/vm/VmWorkJobDispatcher.java   |   78 ++------
 .../com/cloud/vm/VmWorkJobWakeupDispatcher.java    |    4 +-
 .../cloud/vm/snapshot/VMSnapshotManagerImpl.java   |    4 +-
 .../affinity/AffinityGroupServiceImpl.java         |    8 +-
 .../lb/ApplicationLoadBalancerManagerImpl.java     |    4 +-
 .../gslb/GlobalLoadBalancingRulesServiceImpl.java  |    8 +-
 .../configuration/ConfigurationManagerTest.java    |    2 +-
 .../cloud/network/DedicateGuestVlanRangesTest.java |    2 +-
 server/test/com/cloud/vm/UserVmManagerTest.java    |    6 +-
 .../test/com/cloud/vpc/NetworkACLManagerTest.java  |    2 +-
 .../test/com/cloud/vpc/NetworkACLServiceTest.java  |    2 +-
 server/test/com/cloud/vpc/VpcTest.java             |    2 +-
 .../cloudstack/affinity/AffinityApiUnitTest.java   |    2 +-
 .../cloudstack/lb/ApplicationLoadBalancerTest.java |    2 +-
 .../networkoffering/ChildTestConfiguration.java    |   20 +-
 .../networkoffering/CreateNetworkOfferingTest.java |    2 +-
 .../GlobalLoadBalancingRulesServiceImplTest.java   |   16 +-
 170 files changed, 761 insertions(+), 801 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/com/cloud/user/UserContext.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/UserContext.java b/api/src/com/cloud/user/UserContext.java
index f14e6cd..ee519d2 100644
--- a/api/src/com/cloud/user/UserContext.java
+++ b/api/src/com/cloud/user/UserContext.java
@@ -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>();
+
+    private static EntityManager s_entityMgr;
 
-    @Inject private AccountService _accountMgr = null;
+    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 static UserContext current() {
+        return s_currentContext.get();
     }
 
-    public void setApiServer(boolean apiServer) {
-        this.apiServer = apiServer;
+    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 current() {
+    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";
+    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);
+    }
 
-        context.setCallerUserId(userId);
-        context.setCaller(accountObject);
-        context.setSessionKey(sessionId);
+    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 registerContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
-        s_currentContext.set(new UserContext(userId, accountObject, sessionId, apiServer));
+    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 void unregisterContext() {
-        s_currentContext.set(null);
+    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();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/com/cloud/user/UserContextInitializer.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/UserContextInitializer.java b/api/src/com/cloud/user/UserContextInitializer.java
deleted file mode 100644
index a545963..0000000
--- a/api/src/com/cloud/user/UserContextInitializer.java
+++ /dev/null
@@ -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);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
index 56e2ba1..b73a8bf 100644
--- a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
index 1c94e10..2da3a5e 100644
--- a/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java
index a283365..024e69c 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java
index b4023d9..2e725f1 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java
index e55680a..1534c79 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java
index f96d9b1..ca25b64 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java
index 5ace766..fe5a11e 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
index 5ca4f4f..7db6e6f 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
@@ -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){

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
index be1887e..67bce1d 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java
index 932becb..2407c4f 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java
@@ -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());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java
index c043311..fd194e3 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java
index 269b0ab..d84f641 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java
index 392d13f..8816d5a 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java
index 923e6fd..ec44e7a 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java
index dba34e1..b70e34b 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java
index a077e24..df86380 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java
index 9917747..2cc6956 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java
index 396360f..d891ca9 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java
index 4b5feb8..70e0dcb 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
index f9fc1ab..85a3ee2 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
index 21f8177..42215a7 100644
--- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
index a160892..3955da8 100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
index 0eb6a4c..4fa7f24 100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java
index 84a6182..485fc64 100644
--- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
index 293a054..9c07631 100644
--- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java
index cfff73b..1c641e8 100644
--- a/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java
index 324c7b2..4500b54 100644
--- a/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
index a1279a9..cece2d0 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
index c6cbe09..0388a48 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
index 43d7b8c..0e5a952 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
index d70375a..04d40bd 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
@@ -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.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
index ec08db0..719779d 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java
index 4a87652..c329781 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java
index 648983b..6bd3d83 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
index 46dd9b7..d50a797 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
@@ -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() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java
index 968dee9..4897a65 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java
index 32b1649..ecb9350 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java
index 19ac447..5443286 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
index cb9df7e..e165784 100644
--- a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
index 113e89c..60339e4 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
@@ -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();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
index 9ec436e..fd720c2 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
index 051e586..7ac90bd 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
@@ -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();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
index 22f7b3c..82bbab7 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
@@ -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();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java
index 67f40d1..e6ec517 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java
@@ -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();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
index 1ea815a..83bdc5b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java
@@ -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();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
index 63b5bb3..6fc99da 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java
index 789c0fe..7d77980 100644
--- a/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java
@@ -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");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
index e04bb33..595f4d9 100644
--- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
@@ -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;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java
index 791243a..b3255c4 100644
--- a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java
index 038d06d..9e5aa15 100644
--- a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
index bfbd97c..4f75724 100644
--- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
index 40e6620..5068699 100644
--- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
index fb7c2cc..1f970e4 100644
--- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
index bc30b76..2a4c4a9 100644
--- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java
index d87cf9e..1b948c2 100644
--- a/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java
index f40fa73..91f2f68 100644
--- a/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java
index feffda5..efc4e14 100644
--- a/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
index 2da3bf4..07f5d56 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
@@ -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.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
index a66acde..e3cc319 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
@@ -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;


Mime
View raw message