cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [04/14] Revamped UserContext
Date Fri, 31 May 2013 12:06:44 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java
index 9c95a9e..f252d30 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java
@@ -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();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 6dfc576..1d780ae 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java
index 1891365..8d4181d 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java
@@ -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();
     }
 

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

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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
index 85629d1..3966c42 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
@@ -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;

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

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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
index 20a29d4..5cc6247 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
@@ -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;

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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java
index 3546267..510f894 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java
@@ -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;
     }

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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
index 12ef712..fa57604 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
@@ -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");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java
index 5043ff3..d65241d 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java
@@ -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;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java
index 12ed65b..977651e 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java
@@ -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;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
index 19eff1c..35f4f3e 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
@@ -95,6 +95,8 @@ public interface AsyncJob extends Job {
     @Override
     Long getInstanceId();
 
+    String getShortUuid();
+
     SyncQueueItem getSyncSource();
     void setSyncSource(SyncQueueItem item);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
index b5f883c..9c9001a 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
----------------------------------------------------------------------
diff --git a/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java b/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
index 5de04f0..3bb04fd 100644
--- a/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
+++ b/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java
@@ -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");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java
----------------------------------------------------------------------
diff --git a/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java b/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java
index 7ec5316..bf4e91c 100644
--- a/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java
+++ b/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java
@@ -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();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java
----------------------------------------------------------------------
diff --git a/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java b/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java
index ba92e8b..319daec 100644
--- a/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java
+++ b/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java
@@ -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");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java b/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java
index 83cc123..32ff998 100644
--- a/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java
+++ b/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java
@@ -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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
index c749832..9c3398c 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
@@ -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() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
index 63e1147..e64e070 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
@@ -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() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
index 30f631d..f82ee12 100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
@@ -96,7 +96,7 @@ public class AddBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
index 9a7dc48..514d312 100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
@@ -86,7 +86,7 @@ public class DeleteBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoAsa1000vResourceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoAsa1000vResourceCmd.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoAsa1000vResourceCmd.java
index c880199..11ea00f 100755
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoAsa1000vResourceCmd.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoAsa1000vResourceCmd.java
@@ -111,6 +111,6 @@ public class AddCiscoAsa1000vResourceCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoVnmcResourceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoVnmcResourceCmd.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoVnmcResourceCmd.java
index bfd6db9..900e4ac 100644
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoVnmcResourceCmd.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/AddCiscoVnmcResourceCmd.java
@@ -110,6 +110,6 @@ public class AddCiscoVnmcResourceCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoAsa1000vResourceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoAsa1000vResourceCmd.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoAsa1000vResourceCmd.java
index d4f86fa..0894f2f1 100755
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoAsa1000vResourceCmd.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoAsa1000vResourceCmd.java
@@ -87,7 +87,7 @@ public class DeleteCiscoAsa1000vResourceCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoVnmcResourceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoVnmcResourceCmd.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoVnmcResourceCmd.java
index d2a3720..bdc00e8 100644
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoVnmcResourceCmd.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/api/commands/DeleteCiscoVnmcResourceCmd.java
@@ -87,7 +87,7 @@ public class DeleteCiscoVnmcResourceCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
index 799e449..75e1d34 100644
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
index 51567a8..dc3e134 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
@@ -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);
                     }
                 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java
index 1670351..2ec641f 100644
--- a/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java
+++ b/plugins/network-elements/f5/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java
@@ -127,6 +127,6 @@ public class AddF5LoadBalancerCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java
index 209a258..ec4c809 100644
--- a/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java
+++ b/plugins/network-elements/f5/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java
@@ -105,6 +105,6 @@ public class ConfigureF5LoadBalancerCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java
index 691643d..d43e24f 100644
--- a/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java
+++ b/plugins/network-elements/f5/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java
@@ -102,6 +102,6 @@ public class DeleteF5LoadBalancerCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
index 1afb008..d3fd686 100644
--- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
+++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
@@ -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,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/AddSrxFirewallCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/AddSrxFirewallCmd.java b/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/AddSrxFirewallCmd.java
index f5bb037..ff01899 100644
--- a/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/AddSrxFirewallCmd.java
+++ b/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/AddSrxFirewallCmd.java
@@ -130,6 +130,6 @@ public class AddSrxFirewallCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/ConfigureSrxFirewallCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/ConfigureSrxFirewallCmd.java b/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/ConfigureSrxFirewallCmd.java
index 9bffee1..f61c3e8 100644
--- a/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/ConfigureSrxFirewallCmd.java
+++ b/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/ConfigureSrxFirewallCmd.java
@@ -109,6 +109,6 @@ public class ConfigureSrxFirewallCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/DeleteSrxFirewallCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/DeleteSrxFirewallCmd.java b/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/DeleteSrxFirewallCmd.java
index ce804a7..5134730 100644
--- a/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/DeleteSrxFirewallCmd.java
+++ b/plugins/network-elements/juniper-srx/src/com/cloud/api/commands/DeleteSrxFirewallCmd.java
@@ -100,6 +100,6 @@ public class DeleteSrxFirewallCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java
index e4327b4..8f1da5a 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java
@@ -143,6 +143,6 @@ public class AddNetscalerLoadBalancerCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java
index a04a48d..3f36ec8 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java
@@ -129,6 +129,6 @@ public class ConfigureNetscalerLoadBalancerCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java
index 76f0273..51b8f66 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/DeleteNetscalerLoadBalancerCmd.java
@@ -100,6 +100,6 @@ public class DeleteNetscalerLoadBalancerCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
index 5b2dacf..bb8e1e1 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
@@ -122,7 +122,7 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 
 	@Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
index 9ba1c83..bc20d8e 100755
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
@@ -90,7 +90,7 @@ public class DeleteNiciraNvpDeviceCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return UserContext.current().getCallingAccount().getId();
     }
 
 	@Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
index 781b4b9..8df8cd2 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
@@ -99,7 +99,7 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
                 throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a part of network " + network + " implement ", DataCenter.class, dcId);
             }
             implemented.setBroadcastUri(BroadcastDomainType.Vswitch.toUri(vnet));
-            ActionEventUtils.onCompletedActionEvent(UserContext.current().getCallerUserId(), network.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + network.getId(), 0);
+            ActionEventUtils.onCompletedActionEvent(UserContext.current().getCallingUserId(), network.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + network.getId(), 0);
         } else {
             implemented.setBroadcastUri(network.getBroadcastUri());
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
index 71ca88d..ddaf1b3 100755
--- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -105,6 +105,7 @@ import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.resource.DummySecondaryStorageResource;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
 import com.cloud.user.AccountManager;
+import com.cloud.user.UserContext;
 import com.cloud.utils.ActionDelegate;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
@@ -1175,10 +1176,16 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
 
         @Override
         public void run() {
+            try {
+                UserContext.registerOnceOnly();
+            } catch (Exception e) {
+                s_logger.error("Unable to register context", e);
+                return;
+            }
             _request.logD("Processing the first command ");
             StartupCommand[] startups = new StartupCommand[_cmds.length];
             for (int i = 0; i < _cmds.length; i++) {
-                startups[i] = (StartupCommand) _cmds[i];
+                startups[i] = (StartupCommand)_cmds[i];
             }
 
             AgentAttache attache = handleConnectedAgent(_link, startups, _request);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiAsyncJobDispatcher.java b/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
index 15f245c..1705e86 100644
--- a/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
+++ b/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
@@ -87,7 +87,7 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
                 accountObject = _accountDao.findById(Long.parseLong(acctIdStr));
             }
 
-            UserContext.registerContext(userId, accountObject, null, false);
+            UserContext.register(userId, accountObject, "job-" + job.getShortUuid(), false);
             try {
                 // dispatch could ultimately queue the job
                 _dispatcher.dispatch(cmdObj, params);
@@ -95,7 +95,7 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
                 // serialize this to the async job table
                 _asyncJobMgr.completeAsyncJob(job.getId(), AsyncJobConstants.STATUS_SUCCEEDED, 0, cmdObj.getResponseObject());
             } finally {
-                UserContext.unregisterContext();
+                UserContext.unregister();
             }
         } catch(Throwable e) {
             String errorMsg = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java
index 68a7481..7df17d3 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -96,15 +96,11 @@ public class ApiDispatcher {
 
     public void dispatchCreateCmd(BaseAsyncCreateCmd cmd, Map<String, String> params) throws Exception {
         processParameters(cmd, params);
-
-            UserContext ctx = UserContext.current();
-            ctx.setAccountId(cmd.getEntityOwnerId());
-            cmd.create();
-
+        cmd.create();
     }
 
     private void doAccessChecks(BaseCmd cmd, Map<Object, AccessType> entitiesToAccess) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = _accountMgr.getActiveAccountById(cmd.getEntityOwnerId());
 
         if(cmd instanceof BaseAsyncCreateCmd) {
@@ -129,7 +125,6 @@ public class ApiDispatcher {
     public void dispatch(BaseCmd cmd, Map<String, String> params) throws Exception {
         processParameters(cmd, params);
         UserContext ctx = UserContext.current();
-        ctx.setAccountId(cmd.getEntityOwnerId());
         
         if (cmd instanceof BaseAsyncCmd) {
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index b83b343..5d594d4 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -711,7 +711,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         }
 
         // show this info to admin only
-        Account account = UserContext.current().getCaller();
+        Account account = UserContext.current().getCallingAccount();
         if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
             VlanVO vl = ApiDBUtils.findVlanById(ipAddr.getVlanId());
             if (vl != null) {
@@ -1287,7 +1287,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             response.setOsTypeName(os.getDisplayName());
         }
         response.setDetails(result.getDetails());
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         if (result.getFormat() == ImageFormat.ISO) { // Templates are always bootable
             response.setBootable(result.isBootable());
@@ -1380,7 +1380,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         populateAccount(templateResponse, account.getId());
         populateDomain(templateResponse, account.getDomainId());
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         boolean isAdmin = false;
         if (BaseCmd.isAdmin(caller.getType())) {
             isAdmin = true;
@@ -1472,7 +1472,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         }
 
         boolean isAdmin = false;
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         if ((caller == null) || BaseCmd.isAdmin(caller.getType())) {
             isAdmin = true;
         }
@@ -1747,7 +1747,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         populateAccount(isoResponse, account.getId());
         populateDomain(isoResponse, account.getDomainId());
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         boolean isAdmin = false;
         if ((caller == null) || BaseCmd.isAdmin(caller.getType())) {
             isAdmin = true;
@@ -2360,7 +2360,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setReservedIpRange(reservation);
 
         //return vlan information only to Root admin
-        if (network.getBroadcastUri() != null && UserContext.current().getCaller().getType() == Account.ACCOUNT_TYPE_ADMIN) {
+        if (network.getBroadcastUri() != null && UserContext.current().getCallingAccount().getType() == Account.ACCOUNT_TYPE_ADMIN) {
             String broadcastUri = network.getBroadcastUri().toString();
             response.setBroadcastUri(broadcastUri);
             String vlan="N/A";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/ApiSerializerHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiSerializerHelper.java b/server/src/com/cloud/api/ApiSerializerHelper.java
index 97faa19..e65d5e7 100644
--- a/server/src/com/cloud/api/ApiSerializerHelper.java
+++ b/server/src/com/cloud/api/ApiSerializerHelper.java
@@ -16,11 +16,12 @@
 // under the License.
 package com.cloud.api;
 
-import org.apache.cloudstack.api.ResponseObject;
 import org.apache.log4j.Logger;
 
 import com.google.gson.Gson;
 
+import org.apache.cloudstack.api.ResponseObject;
+
 public class ApiSerializerHelper {
     public static final Logger s_logger = Logger.getLogger(ApiSerializerHelper.class.getName());
     public static String token = "/";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index 28d79f0..b4adf74 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -176,7 +176,6 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     @Inject private final RegionManager _regionMgr = null;
 
     private static int _workerCount = 0;
-    private static ApiServer s_instance = null;
     private static final DateFormat _dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
     private static Map<String, Class<?>> _apiNameCmdClassMap = new HashMap<String, Class<?>>();
 
@@ -187,16 +186,11 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
     @PostConstruct
     void initComponent() {
-        s_instance = this;
-    }
-
-    public static ApiServer getInstance() {
-        return s_instance;
+        UserContext.init(_entityMgr);
     }
 
 	@Override
-	public boolean configure(String name, Map<String, Object> params)
-			throws ConfigurationException {
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
 		init();
 		return true;
 	}
@@ -302,7 +296,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
             try {
                 // always trust commands from API port, user context will always be UID_SYSTEM/ACCOUNT_ID_SYSTEM
-                UserContext.registerContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, true);
+                UserContext.register(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, true);
                 sb.insert(0, "(userId=" + User.UID_SYSTEM + " accountId=" + Account.ACCOUNT_ID_SYSTEM + " sessionId=" + null + ") ");
                 String responseText = handleRequest(parameterMap, responseType, sb);
                 sb.append(" 200 " + ((responseText == null) ? 0 : responseText.length()));
@@ -319,7 +313,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             }
         } finally {
             s_accessLogger.info(sb.toString());
-            UserContext.unregisterContext();
+            UserContext.unregister();
         }
     }
 
@@ -416,7 +410,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         catch (InsufficientCapacityException ex){
             s_logger.info(ex.getMessage());
             String errorMsg = ex.getMessage();
-            if (UserContext.current().getCaller().getType() != Account.ACCOUNT_TYPE_ADMIN){
+            if (UserContext.current().getCallingAccount().getType() != Account.ACCOUNT_TYPE_ADMIN){
                 // hide internal details to non-admin user for security reason
                 errorMsg = BaseCmd.USER_ERROR_MESSAGE;
 
@@ -426,7 +420,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         catch (ResourceAllocationException ex){
             s_logger.info(ex.getMessage());
             String errorMsg = ex.getMessage();
-            if (UserContext.current().getCaller().getType() != Account.ACCOUNT_TYPE_ADMIN){
+            if (UserContext.current().getCallingAccount().getType() != Account.ACCOUNT_TYPE_ADMIN){
                 // hide internal details to non-admin user for security reason
                 errorMsg = BaseCmd.USER_ERROR_MESSAGE;
             }
@@ -435,7 +429,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         catch (ResourceUnavailableException ex){
             s_logger.info(ex.getMessage());
             String errorMsg = ex.getMessage();
-            if (UserContext.current().getCaller().getType() != Account.ACCOUNT_TYPE_ADMIN){
+            if (UserContext.current().getCallingAccount().getType() != Account.ACCOUNT_TYPE_ADMIN){
                 // hide internal details to non-admin user for security reason
                 errorMsg = BaseCmd.USER_ERROR_MESSAGE;
             }
@@ -448,7 +442,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         catch (Exception ex){
             s_logger.error("unhandled exception executing api command: " + ((command == null) ? "null" : command[0]), ex);
             String errorMsg = ex.getMessage();
-            if (UserContext.current().getCaller().getType() != Account.ACCOUNT_TYPE_ADMIN){
+            if (UserContext.current().getCallingAccount().getType() != Account.ACCOUNT_TYPE_ADMIN){
                 // hide internal details to non-admin user for security reason
                 errorMsg = BaseCmd.USER_ERROR_MESSAGE;
             }
@@ -478,8 +472,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
     private String queueCommand(BaseCmd cmdObj, Map<String, String> params) throws Exception {
         UserContext ctx = UserContext.current();
-        Long callerUserId = ctx.getCallerUserId();
-        Account caller = ctx.getCaller();
+        Long callerUserId = ctx.getCallingUserId();
+        Account caller = ctx.getCallingAccount();
 
 
         // Queue command based on Cmd super class:
@@ -522,8 +516,6 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
             params.put("ctxStartEventId", String.valueOf(startEventId));
 
-            ctx.setAccountId(asyncCmd.getEntityOwnerId());
-
             Long instanceId = (objectId == null) ? asyncCmd.getInstanceId() : objectId;
             AsyncJobVO job = new AsyncJobVO(callerUserId, caller.getId(), cmdObj.getClass().getName(),
                     ApiGsonHelper.getBuilder().create().toJson(params), instanceId,
@@ -747,8 +739,6 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 return false;
             }
 
-            UserContext.updateContext(user.getId(), account, null);
-
             try{
                 checkCommandAvailable(user, commandName);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java
index 7525b61..038a0a1 100755
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -31,13 +31,14 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
-import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.ServerApiException;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.support.SpringBeanAutowiringSupport;
 
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.ServerApiException;
+
 import com.cloud.exception.CloudAuthenticationException;
 import com.cloud.user.Account;
 import com.cloud.user.AccountService;
@@ -58,7 +59,7 @@ public class ApiServlet extends HttpServlet {
 
     @Override
     public void init(ServletConfig config) throws ServletException {
-    	SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext());       	
+    	SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext());
     }
     
     @Override
@@ -235,7 +236,6 @@ public class ApiServlet extends HttpServlet {
             // Initialize an empty context and we will update it after we have verified the request below,
             // we no longer rely on web-session here, verifyRequest will populate user/account information
             // if a API key exists
-            UserContext.registerContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, false);
             Long userId = null;
 
             if (!isNew) {
@@ -266,7 +266,7 @@ public class ApiServlet extends HttpServlet {
                         writeResponse(resp, serializedResponse, HttpServletResponse.SC_BAD_REQUEST, responseType);
                         return;
                     }
-                    UserContext.updateContext(userId, (Account) accountObj, session.getId());
+                    UserContext.register(userId, ((Account)accountObj).getId(), session.getId());
                 } else {
                     // Invalidate the session to ensure we won't allow a request across management server
                     // restarts if the userId was serialized to the stored session
@@ -296,8 +296,8 @@ public class ApiServlet extends HttpServlet {
                  * key mechanism updateUserContext(params, session != null ? session.getId() : null);
                  */
 
-                auditTrailSb.insert(0, "(userId=" + UserContext.current().getCallerUserId() + " accountId="
-                        + UserContext.current().getCaller().getId() + " sessionId=" + (session != null ? session.getId() : null) + ")");
+                auditTrailSb.insert(0, "(userId=" + UserContext.current().getCallingUserId() + " accountId="
+                        + UserContext.current().getCallingAccount().getId() + " sessionId=" + (session != null ? session.getId() : null) + ")");
 
                 // Add the HTTP method (GET/POST/PUT/DELETE) as well into the params map.
                 params.put("httpmethod", new String[] { req.getMethod() });
@@ -330,7 +330,7 @@ public class ApiServlet extends HttpServlet {
                 s_logger.debug("===END=== " + StringUtils.cleanString(reqStr));
             }
             // cleanup user context to prevent from being peeked in other request context
-            UserContext.unregisterContext();
+            UserContext.unregister();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 5a25732..6d65ec0 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -268,7 +268,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
     }
 
     private Pair<List<UserAccountJoinVO>, Integer> searchForUsersInternal(ListUsersCmd cmd) throws PermissionDeniedException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         //TODO: Integrate with ACL checkAccess refactoring
         Long domainId = cmd.getDomainId();
@@ -372,7 +372,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
     }
 
     private Pair<List<EventJoinVO>, Integer> searchForEventsInternal(ListEventsCmd cmd) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         Long id = cmd.getId();
@@ -482,7 +482,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
     }
 
     private Pair<List<ResourceTagJoinVO>, Integer> listTagsInternal(ListTagsCmd cmd) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
         String key = cmd.getKey();
         String value = cmd.getValue();
@@ -561,7 +561,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         String name = cmd.getGroupName();
         String keyword = cmd.getKeyword();
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
@@ -613,7 +613,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
     }
 
     private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cmd) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
         String hypervisor = cmd.getHypervisor();
         boolean listAll = cmd.listAll();
@@ -877,7 +877,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
     }
 
     private Pair<List<SecurityGroupJoinVO>, Integer> searchForSecurityGroupsInternal(ListSecurityGroupsCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long instanceId = cmd.getVirtualMachineId();
         String securityGroup = cmd.getSecurityGroupName();
         Long id = cmd.getId();
@@ -1010,7 +1010,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
             String name, String state, Long zoneId, Long podId, Long hostId, String keyword, Long networkId, Long vpcId, Boolean forVpc, String role, String zoneType) {
        
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
@@ -1149,7 +1149,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         boolean isRecursive = cmd.isRecursive();
         Map<String, String> tags = cmd.getTags();
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long accountId = null;
         String path = null;
 
@@ -1302,7 +1302,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         boolean isRecursive = cmd.isRecursive();
         boolean listAll = cmd.listAll();
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive, null);
@@ -1364,7 +1364,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         Long pageSizeVal = cmd.getPageSizeVal();
 
         //long projectId, String accountName, String role, Long startIndex, Long pageSizeVal) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         //check that the project exists
         Project project = _projectDao.findById(projectId);
@@ -1418,7 +1418,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
 
     public Pair<List<HostJoinVO>, Integer> searchForServersInternal(ListHostsCmd cmd) {
 
-        Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());
+        Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), cmd.getZoneId());
         String zoneType = cmd.getZoneType();
         Object name = cmd.getHostName();
         Object type = cmd.getType();
@@ -1535,7 +1535,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
 
     private Pair<List<VolumeJoinVO>, Integer> searchForVolumesInternal(ListVolumesCmd cmd) {
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         Long id = cmd.getId();
@@ -1675,7 +1675,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
 
 
     private Pair<List<AccountJoinVO>, Integer> searchForAccountsInternal(ListAccountsCmd cmd) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long domainId = cmd.getDomainId();
         Long accountId = cmd.getId();
         String accountName = cmd.getSearchName();
@@ -1803,7 +1803,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
 
     private Pair<List<AsyncJobJoinVO>, Integer> searchForAsyncJobsInternal(ListAsyncJobsCmd cmd) {
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         List<Long> permittedAccounts = new ArrayList<Long>();
 
@@ -1882,7 +1882,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
 
     private Pair<List<StoragePoolJoinVO>, Integer> searchForStoragePoolsInternal(ListStoragePoolsCmd cmd) {
 
-        Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId());
+        Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), cmd.getZoneId());
         String zoneType = cmd.getZoneType();
         Object id = cmd.getId();
         Object name = cmd.getStoragePoolName();
@@ -1991,7 +1991,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         SearchCriteria<DiskOfferingJoinVO> sc = _diskOfferingJoinDao.createSearchCriteria();
 
 
-        Account account = UserContext.current().getCaller();
+        Account account = UserContext.current().getCallingAccount();
         Object name = cmd.getDiskOfferingName();
         Object id = cmd.getId();
         Object keyword = cmd.getKeyword();
@@ -2105,7 +2105,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         Filter searchFilter = new Filter(ServiceOfferingJoinVO.class, "sortKey", isAscending, cmd.getStartIndex(), cmd.getPageSizeVal());
         SearchCriteria<ServiceOfferingJoinVO> sc = _srvOfferingJoinDao.createSearchCriteria();
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Object name = cmd.getServiceOfferingName();
         Object id = cmd.getId();
         Object keyword = cmd.getKeyword();
@@ -2227,7 +2227,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
 
 
     private Pair<List<DataCenterJoinVO>, Integer> listDataCentersInternal(ListZonesByCmd cmd) {
-        Account account = UserContext.current().getCaller();
+        Account account = UserContext.current().getCallingAccount();
         Long domainId = cmd.getDomainId();
         Long id = cmd.getId();
         String keyword = cmd.getKeyword();
@@ -2385,7 +2385,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
     public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long affinityGroupId,
             String affinityGroupName, String affinityGroupType, Long vmId, Long startIndex, Long pageSize) {
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         Long accountId = caller.getAccountId();
         Long domainId = caller.getDomainId();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/query/ViewResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/ViewResponseHelper.java b/server/src/com/cloud/api/query/ViewResponseHelper.java
index 827ae7b..b94dccf 100644
--- a/server/src/com/cloud/api/query/ViewResponseHelper.java
+++ b/server/src/com/cloud/api/query/ViewResponseHelper.java
@@ -115,7 +115,7 @@ public class ViewResponseHelper {
     }
 
     public static List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVmJoinVO... userVms) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         Hashtable<Long, UserVmResponse> vmDataList = new Hashtable<Long, UserVmResponse>();
         // Initialise the vmdatalist with the input data
@@ -136,7 +136,7 @@ public class ViewResponseHelper {
     }
 
     public static List<DomainRouterResponse> createDomainRouterResponse(DomainRouterJoinVO... routers) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<Long, DomainRouterResponse>();
         // Initialise the vrdatalist with the input data
         for (DomainRouterJoinVO vr : routers) {
@@ -156,7 +156,7 @@ public class ViewResponseHelper {
 
 
     public static List<SecurityGroupResponse> createSecurityGroupResponses(List<SecurityGroupJoinVO> securityGroups) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Hashtable<Long, SecurityGroupResponse> vrDataList = new Hashtable<Long, SecurityGroupResponse>();
         // Initialise the vrdatalist with the input data
         for (SecurityGroupJoinVO vr : securityGroups) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
index 4c8b545..5256c2a 100644
--- a/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
@@ -56,7 +56,7 @@ public class DataCenterJoinDaoImpl extends GenericDaoBase<DataCenterJoinVO, Long
     @Override
     public ZoneResponse newDataCenterResponse(DataCenterJoinVO dataCenter, Boolean showCapacities) {
 
-        Account account = UserContext.current().getCaller();
+        Account account = UserContext.current().getCallingAccount();
         ZoneResponse zoneResponse = new ZoneResponse();
         zoneResponse.setId(dataCenter.getUuid());
         zoneResponse.setName(dataCenter.getName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
index e27e2d9..0ce85f6 100644
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
@@ -73,7 +73,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
 
     @Override
     public VolumeResponse newVolumeResponse(VolumeJoinVO volume) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         VolumeResponse volResponse = new VolumeResponse();
         volResponse.setId(volume.getUuid());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/async/AsyncJobManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/async/AsyncJobManagerImpl.java b/server/src/com/cloud/async/AsyncJobManagerImpl.java
index cf5cc70..f17df5d 100644
--- a/server/src/com/cloud/async/AsyncJobManagerImpl.java
+++ b/server/src/com/cloud/async/AsyncJobManagerImpl.java
@@ -400,7 +400,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
 
     @Override
     public AsyncJob queryAsyncJobResult(QueryAsyncJobResultCmd cmd) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         AsyncJobVO job = _jobDao.findById(cmd.getId());
         if (job == null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 779ef48..07c43de 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -564,7 +564,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, eventDescription = "updating configuration")
     public Configuration updateConfiguration(UpdateCfgCmd cmd) throws InvalidParameterValueException {
-        Long userId = UserContext.current().getCallerUserId();
+        Long userId = UserContext.current().getCallingUserId();
         String name = cmd.getCfgName();
         String value = cmd.getValue();
         Long zoneId = cmd.getZoneId();
@@ -1112,7 +1112,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     @Override
     public Pod createPod(long zoneId, String name, String startIp, String endIp, String gateway, String netmask, String allocationState) {
         String cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
-        Long userId = UserContext.current().getCallerUserId();
+        Long userId = UserContext.current().getCallingUserId();
 
         if (allocationState == null) {
             allocationState = Grouping.AllocationState.Enabled.toString();
@@ -1131,7 +1131,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
         // Check if zone is disabled
         DataCenterVO zone = _zoneDao.findById(zoneId);
-        Account account = UserContext.current().getCaller();
+        Account account = UserContext.current().getCallingAccount();
         if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(account.getType())) {
             throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zoneId);
         }
@@ -1387,7 +1387,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         Transaction txn = Transaction.currentTxn();
         boolean success = false;
 
-        Long userId = UserContext.current().getCallerUserId();
+        Long userId = UserContext.current().getCallingUserId();
         Long zoneId = cmd.getId();
 
         if (userId == null) {
@@ -1874,7 +1874,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     @ActionEvent(eventType = EventTypes.EVENT_ZONE_CREATE, eventDescription = "creating zone", async = false)
     public DataCenter createZone(CreateZoneCmd cmd) {
         // grab parameters from the command
-        Long userId = UserContext.current().getCallerUserId();
+        Long userId = UserContext.current().getCallingUserId();
         String zoneName = cmd.getZoneName();
         String dns1 = cmd.getDns1();
         String dns2 = cmd.getDns2();
@@ -1928,7 +1928,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
     @Override
     public ServiceOffering createServiceOffering(CreateServiceOfferingCmd cmd) {
-        Long userId = UserContext.current().getCallerUserId();
+        Long userId = UserContext.current().getCallingUserId();
 
         String name = cmd.getServiceOfferingName();
         if ((name == null) || (name.length() == 0)) {
@@ -2046,7 +2046,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         Long id = cmd.getId();
         String name = cmd.getServiceOfferingName();
         Integer sortKey = cmd.getSortKey();
-        Long userId = UserContext.current().getCallerUserId();
+        Long userId = UserContext.current().getCallingUserId();
 
         if (userId == null) {
             userId = Long.valueOf(User.UID_SYSTEM);
@@ -2267,7 +2267,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     public boolean deleteServiceOffering(DeleteServiceOfferingCmd cmd) {
 
         Long offeringId = cmd.getId();
-        Long userId = UserContext.current().getCallerUserId();
+        Long userId = UserContext.current().getCallingUserId();
 
         if (userId == null) {
             userId = Long.valueOf(User.UID_SYSTEM);
@@ -2421,7 +2421,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         
         
         // Check if zone is enabled
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
             throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zoneId);
         }
@@ -2610,7 +2610,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         }
         
         // ACL check
-        checkZoneAccess(UserContext.current().getCaller(), zone);
+        checkZoneAccess(UserContext.current().getCallingAccount(), zone);
         
         //Validate the physical network
         if (_physicalNetworkDao.findById(physicalNetworkId) == null) {
@@ -3136,7 +3136,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             throw new InvalidParameterValueException("Please specify a valid IP range id.");
         }
 
-        return releasePublicIpRange(vlanDbId, UserContext.current().getCallerUserId(), UserContext.current().getCaller());
+        return releasePublicIpRange(vlanDbId, UserContext.current().getCallingUserId(), UserContext.current().getCallingAccount());
     }
 
 
@@ -3475,7 +3475,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             throw new InvalidParameterValueException("Please specify a valid IP range id.");
         }
 
-        return deleteVlanAndPublicIpRange(UserContext.current().getCallerUserId(), vlanDbId, UserContext.current().getCaller());
+        return deleteVlanAndPublicIpRange(UserContext.current().getCallingUserId(), vlanDbId, UserContext.current().getCallingAccount());
     }
 
     @Override
@@ -4049,7 +4049,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
         isAscending = (isAscending == null ? true : isAscending);
         Filter searchFilter = new Filter(NetworkOfferingVO.class, "sortKey", isAscending, cmd.getStartIndex(), cmd.getPageSizeVal());
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         SearchCriteria<NetworkOfferingVO> sc = _networkOfferingDao.createSearchCriteria();
 
         Long id = cmd.getId();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index e05780e..6bd1304 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -1513,7 +1513,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
         if (ip != null && ip.getSystem()) {
             UserContext ctx = UserContext.current();
             try {
-                _rulesMgr.disableStaticNat(ip.getId(), ctx.getCaller(), ctx.getCallerUserId(), true);
+                _rulesMgr.disableStaticNat(ip.getId(), ctx.getCallingAccount(), ctx.getCallingUserId(), true);
             } catch (Exception ex) {
                 s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex);
             }


Mime
View raw message