cloudstack-commits mailing list archives

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


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

Branch: refs/heads/vmsync
Commit: b8261b87058709c678bfc637365f9f7086d7faf2
Parents: 54de6b4
Author: Alex Huang <alex.huang@gmail.com>
Authored: Fri May 31 05:05:05 2013 -0700
Committer: Alex Huang <alex.huang@gmail.com>
Committed: Fri May 31 05:05:05 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/user/UserContext.java            |  200 --------------
 .../org/apache/cloudstack/api/BaseAsyncCmd.java    |    7 +-
 api/src/org/apache/cloudstack/api/BaseCmd.java     |  181 +-------------
 .../api/BaseListTemplateOrIsoPermissionsCmd.java   |    4 +-
 .../command/admin/account/CreateAccountCmd.java    |    4 +-
 .../command/admin/account/DeleteAccountCmd.java    |    6 +-
 .../command/admin/account/DisableAccountCmd.java   |    4 +-
 .../api/command/admin/domain/CreateDomainCmd.java  |    4 +-
 .../api/command/admin/domain/DeleteDomainCmd.java  |    4 +-
 .../api/command/admin/domain/UpdateDomainCmd.java  |    4 +-
 .../command/admin/host/CancelMaintenanceCmd.java   |    4 +-
 .../admin/host/PrepareForMaintenanceCmd.java       |    4 +-
 .../api/command/admin/host/ReconnectHostCmd.java   |    4 +-
 .../admin/host/ReleaseHostReservationCmd.java      |    4 +-
 .../ConfigureInternalLoadBalancerElementCmd.java   |    4 +-
 .../CreateInternalLoadBalancerElementCmd.java      |    4 +-
 .../admin/internallb/StartInternalLBVMCmd.java     |    6 +-
 .../admin/internallb/StopInternalLBVMCmd.java      |    6 +-
 .../network/AddNetworkServiceProviderCmd.java      |    4 +-
 .../admin/network/CreatePhysicalNetworkCmd.java    |    4 +-
 .../admin/network/DeletePhysicalNetworkCmd.java    |    4 +-
 .../network/ReleaseDedicatedGuestVlanRangeCmd.java |    4 +-
 .../router/ConfigureVirtualRouterElementCmd.java   |    4 +-
 .../router/CreateVirtualRouterElementCmd.java      |    4 +-
 .../api/command/admin/router/DestroyRouterCmd.java |    4 +-
 .../api/command/admin/router/RebootRouterCmd.java  |    4 +-
 .../api/command/admin/router/StartRouterCmd.java   |    4 +-
 .../api/command/admin/router/StopRouterCmd.java    |    4 +-
 .../CancelPrimaryStorageMaintenanceCmd.java        |    4 +-
 .../PreparePrimaryStorageForMaintenanceCmd.java    |    4 +-
 .../command/admin/systemvm/DestroySystemVmCmd.java |    6 +-
 .../command/admin/systemvm/MigrateSystemVMCmd.java |    6 +-
 .../command/admin/systemvm/RebootSystemVmCmd.java  |    6 +-
 .../command/admin/systemvm/ScaleSystemVMCmd.java   |    7 +-
 .../command/admin/systemvm/StartSystemVMCmd.java   |    6 +-
 .../command/admin/systemvm/StopSystemVmCmd.java    |    6 +-
 .../command/admin/systemvm/UpgradeSystemVMCmd.java |    6 +-
 .../api/command/admin/usage/AddTrafficTypeCmd.java |    4 +-
 .../api/command/admin/user/CreateUserCmd.java      |    6 +-
 .../api/command/admin/user/DeleteUserCmd.java      |    4 +-
 .../api/command/admin/user/DisableUserCmd.java     |    4 +-
 .../api/command/admin/user/EnableUserCmd.java      |    4 +-
 .../api/command/admin/user/UpdateUserCmd.java      |    4 +-
 .../api/command/admin/vm/MigrateVMCmd.java         |    6 +-
 .../command/admin/vpc/DeletePrivateGatewayCmd.java |    4 +-
 .../api/command/admin/zone/CreateZoneCmd.java      |    4 +-
 .../api/command/admin/zone/DeleteZoneCmd.java      |    4 +-
 .../api/command/admin/zone/UpdateZoneCmd.java      |    4 +-
 .../user/account/AddAccountToProjectCmd.java       |    4 +-
 .../user/account/DeleteAccountFromProjectCmd.java  |    4 +-
 .../command/user/address/AssociateIPAddrCmd.java   |   10 +-
 .../user/address/DisassociateIPAddrCmd.java        |    4 +-
 .../user/affinitygroup/CreateAffinityGroupCmd.java |    4 +-
 .../user/affinitygroup/DeleteAffinityGroupCmd.java |    4 +-
 .../affinitygroup/UpdateVMAffinityGroupCmd.java    |    4 +-
 .../autoscale/CreateAutoScaleVmProfileCmd.java     |    6 +-
 .../command/user/autoscale/CreateConditionCmd.java |    8 +-
 .../user/autoscale/DeleteAutoScalePolicyCmd.java   |    4 +-
 .../user/autoscale/DeleteAutoScaleVmGroupCmd.java  |    4 +-
 .../autoscale/DeleteAutoScaleVmProfileCmd.java     |    4 +-
 .../user/autoscale/UpdateAutoScalePolicyCmd.java   |    4 +-
 .../user/autoscale/UpdateAutoScaleVmGroupCmd.java  |    4 +-
 .../autoscale/UpdateAutoScaleVmProfileCmd.java     |    4 +-
 .../api/command/user/event/ArchiveEventsCmd.java   |    4 +-
 .../api/command/user/event/DeleteEventsCmd.java    |    4 +-
 .../user/firewall/CreateEgressFirewallRuleCmd.java |    8 +-
 .../user/firewall/CreateFirewallRuleCmd.java       |    8 +-
 .../user/firewall/CreatePortForwardingRuleCmd.java |    8 +-
 .../user/firewall/DeleteEgressFirewallRuleCmd.java |    4 +-
 .../user/firewall/DeleteFirewallRuleCmd.java       |    4 +-
 .../user/firewall/DeletePortForwardingRuleCmd.java |    4 +-
 .../api/command/user/iso/AttachIsoCmd.java         |    4 +-
 .../api/command/user/iso/DeleteIsoCmd.java         |    4 +-
 .../api/command/user/iso/ExtractIsoCmd.java        |    4 +-
 .../api/command/user/iso/ListIsosCmd.java          |    4 +-
 .../api/command/user/iso/RegisterIsoCmd.java       |    4 +-
 .../loadbalancer/AssignToLoadBalancerRuleCmd.java  |    4 +-
 .../CreateApplicationLoadBalancerCmd.java          |    4 +-
 .../loadbalancer/CreateLBHealthCheckPolicyCmd.java |    6 +-
 .../loadbalancer/CreateLBStickinessPolicyCmd.java  |    6 +-
 .../loadbalancer/CreateLoadBalancerRuleCmd.java    |    8 +-
 .../DeleteApplicationLoadBalancerCmd.java          |    4 +-
 .../loadbalancer/DeleteLBHealthCheckPolicyCmd.java |    6 +-
 .../loadbalancer/DeleteLBStickinessPolicyCmd.java  |    6 +-
 .../loadbalancer/DeleteLoadBalancerRuleCmd.java    |    4 +-
 .../loadbalancer/ListLBStickinessPoliciesCmd.java  |    4 +-
 .../RemoveFromLoadBalancerRuleCmd.java             |    4 +-
 .../loadbalancer/UpdateLoadBalancerRuleCmd.java    |    4 +-
 .../user/nat/CreateIpForwardingRuleCmd.java        |   10 +-
 .../user/nat/DeleteIpForwardingRuleCmd.java        |    4 +-
 .../command/user/network/CreateNetworkACLCmd.java  |    6 +-
 .../user/network/CreateNetworkACLListCmd.java      |    3 +-
 .../api/command/user/network/CreateNetworkCmd.java |    4 +-
 .../command/user/network/DeleteNetworkACLCmd.java  |    6 +-
 .../user/network/DeleteNetworkACLListCmd.java      |    6 +-
 .../api/command/user/network/DeleteNetworkCmd.java |    4 +-
 .../user/network/ReplaceNetworkACLListCmd.java     |    7 +-
 .../user/network/UpdateNetworkACLItemCmd.java      |    7 +-
 .../api/command/user/network/UpdateNetworkCmd.java |    4 +-
 .../command/user/project/ActivateProjectCmd.java   |    4 +-
 .../api/command/user/project/CreateProjectCmd.java |   10 +-
 .../api/command/user/project/DeleteProjectCmd.java |    4 +-
 .../user/project/DeleteProjectInvitationCmd.java   |    4 +-
 .../command/user/project/SuspendProjectCmd.java    |    4 +-
 .../api/command/user/project/UpdateProjectCmd.java |    4 +-
 .../user/project/UpdateProjectInvitationCmd.java   |    4 +-
 .../ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java |    4 +-
 .../ha/gslb/CreateGlobalLoadBalancerRuleCmd.java   |    8 +-
 .../ha/gslb/DeleteGlobalLoadBalancerRuleCmd.java   |    4 +-
 .../gslb/RemoveFromGlobalLoadBalancerRuleCmd.java  |    4 +-
 .../user/resource/UpdateResourceCountCmd.java      |    4 +-
 .../user/resource/UpdateResourceLimitCmd.java      |    4 +-
 .../AuthorizeSecurityGroupEgressCmd.java           |    4 +-
 .../AuthorizeSecurityGroupIngressCmd.java          |    4 +-
 .../user/securitygroup/CreateSecurityGroupCmd.java |    4 +-
 .../user/securitygroup/DeleteSecurityGroupCmd.java |    4 +-
 .../command/user/snapshot/CreateSnapshotCmd.java   |    4 +-
 .../command/user/snapshot/DeleteSnapshotCmd.java   |    4 +-
 .../api/command/user/ssh/CreateSSHKeyPairCmd.java  |    4 +-
 .../api/command/user/ssh/DeleteSSHKeyPairCmd.java  |    4 +-
 .../command/user/ssh/RegisterSSHKeyPairCmd.java    |    4 +-
 .../api/command/user/template/CopyTemplateCmd.java |    4 +-
 .../command/user/template/CreateTemplateCmd.java   |    4 +-
 .../command/user/template/DeleteTemplateCmd.java   |    4 +-
 .../command/user/template/ExtractTemplateCmd.java  |    4 +-
 .../command/user/template/ListTemplatesCmd.java    |    4 +-
 .../command/user/template/RegisterTemplateCmd.java |    4 +-
 .../api/command/user/vm/AddIpToVmNicCmd.java       |   10 +-
 .../api/command/user/vm/AddNicToVMCmd.java         |    4 +-
 .../api/command/user/vm/DeployVMCmd.java           |   10 +-
 .../api/command/user/vm/DestroyVMCmd.java          |    4 +-
 .../api/command/user/vm/ListNicsCmd.java           |    8 +-
 .../api/command/user/vm/RebootVMCmd.java           |    4 +-
 .../api/command/user/vm/RemoveIpFromVmNicCmd.java  |   10 +-
 .../api/command/user/vm/RemoveNicFromVMCmd.java    |    4 +-
 .../api/command/user/vm/ResetVMPasswordCmd.java    |    4 +-
 .../api/command/user/vm/ResetVMSSHKeyCmd.java      |    4 +-
 .../api/command/user/vm/RestoreVMCmd.java          |    4 +-
 .../cloudstack/api/command/user/vm/StartVMCmd.java |    4 +-
 .../cloudstack/api/command/user/vm/StopVMCmd.java  |    4 +-
 .../command/user/vm/UpdateDefaultNicForVMCmd.java  |    4 +-
 .../api/command/user/vm/UpdateVMCmd.java           |    4 +-
 .../api/command/user/vm/UpgradeVMCmd.java          |    4 +-
 .../api/command/user/vmgroup/CreateVMGroupCmd.java |    4 +-
 .../user/vmsnapshot/CreateVMSnapshotCmd.java       |    4 +-
 .../user/vmsnapshot/DeleteVMSnapshotCmd.java       |    4 +-
 .../user/vmsnapshot/RevertToVMSnapshotCmd.java     |    4 +-
 .../api/command/user/volume/AttachVolumeCmd.java   |    4 +-
 .../api/command/user/volume/CreateVolumeCmd.java   |    6 +-
 .../api/command/user/volume/DeleteVolumeCmd.java   |    6 +-
 .../api/command/user/volume/DetachVolumeCmd.java   |    4 +-
 .../api/command/user/volume/ExtractVolumeCmd.java  |    4 +-
 .../api/command/user/volume/ResizeVolumeCmd.java   |    4 +-
 .../api/command/user/volume/UpdateVolumeCmd.java   |    4 +-
 .../api/command/user/volume/UploadVolumeCmd.java   |    4 +-
 .../api/command/user/vpc/CreateStaticRouteCmd.java |    4 +-
 .../api/command/user/vpc/CreateVPCCmd.java         |    4 +-
 .../api/command/user/vpc/DeleteStaticRouteCmd.java |    4 +-
 .../api/command/user/vpn/AddVpnUserCmd.java        |    4 +-
 .../user/vpn/CreateVpnCustomerGatewayCmd.java      |    4 +-
 .../command/user/vpn/DeleteRemoteAccessVpnCmd.java |    4 +-
 .../api/command/user/vpn/RemoveVpnUserCmd.java     |    6 +-
 .../command/user/vpn/ResetVpnConnectionCmd.java    |    4 +-
 .../user/vpn/UpdateVpnCustomerGatewayCmd.java      |    4 +-
 .../org/apache/cloudstack/context/CallContext.java |  202 +++++++++++++++
 .../api/command/user/discovery/ListApisCmd.java    |    4 +-
 .../command/admin/ratelimit/ResetApiLimitCmd.java  |    4 +-
 .../api/command/user/ratelimit/GetApiLimitCmd.java |    6 +-
 .../implicitplanner/ImplicitPlannerTest.java       |    4 +-
 .../networkservice/AddBaremetalDhcpCmd.java        |    5 +-
 .../networkservice/AddBaremetalPxeCmd.java         |    5 +-
 .../api/commands/AddBigSwitchVnsDeviceCmd.java     |    4 +-
 .../api/commands/DeleteBigSwitchVnsDeviceCmd.java  |    4 +-
 .../api/commands/AddCiscoAsa1000vResourceCmd.java  |    5 +-
 .../api/commands/AddCiscoVnmcResourceCmd.java      |    5 +-
 .../commands/DeleteCiscoAsa1000vResourceCmd.java   |    5 +-
 .../api/commands/DeleteCiscoVnmcResourceCmd.java   |    5 +-
 .../cloud/network/element/CiscoVnmcElement.java    |    6 +-
 .../network/lb/ElasticLoadBalancerManagerImpl.java |    8 +-
 .../cloud/api/commands/AddF5LoadBalancerCmd.java   |    5 +-
 .../api/commands/ConfigureF5LoadBalancerCmd.java   |    5 +-
 .../api/commands/DeleteF5LoadBalancerCmd.java      |    5 +-
 .../internallbvmmgr/InternalLBVMServiceTest.java   |    4 +-
 .../com/cloud/api/commands/AddSrxFirewallCmd.java  |    5 +-
 .../api/commands/ConfigureSrxFirewallCmd.java      |    5 +-
 .../cloud/api/commands/DeleteSrxFirewallCmd.java   |    5 +-
 .../api/commands/AddNetscalerLoadBalancerCmd.java  |    5 +-
 .../ConfigureNetscalerLoadBalancerCmd.java         |    5 +-
 .../commands/DeleteNetscalerLoadBalancerCmd.java   |    5 +-
 .../cloud/api/commands/AddNiciraNvpDeviceCmd.java  |    5 +-
 .../api/commands/DeleteNiciraNvpDeviceCmd.java     |    5 +-
 .../cloud/network/guru/OvsGuestNetworkGuru.java    |    5 +-
 .../com/cloud/agent/manager/AgentManagerImpl.java  |    4 +-
 .../src/com/cloud/api/ApiAsyncJobDispatcher.java   |    6 +-
 server/src/com/cloud/api/ApiDispatcher.java        |    6 +-
 server/src/com/cloud/api/ApiResponseHelper.java    |   14 +-
 server/src/com/cloud/api/ApiServer.java            |   18 +-
 server/src/com/cloud/api/ApiServlet.java           |   10 +-
 .../src/com/cloud/api/query/QueryManagerImpl.java  |   40 ++--
 .../com/cloud/api/query/ViewResponseHelper.java    |    9 +-
 .../cloud/api/query/dao/DataCenterJoinDaoImpl.java |    4 +-
 .../com/cloud/api/query/dao/VolumeJoinDaoImpl.java |    5 +-
 .../src/com/cloud/async/AsyncJobManagerImpl.java   |    4 +-
 .../configuration/ConfigurationManagerImpl.java    |   52 ++--
 .../consoleproxy/ConsoleProxyManagerImpl.java      |    4 +-
 .../com/cloud/event/ActionEventInterceptor.java    |    9 +-
 .../metadata/ResourceMetaDataManagerImpl.java      |    3 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  |   28 +-
 .../src/com/cloud/network/NetworkServiceImpl.java  |   34 ++--
 .../com/cloud/network/NetworkUsageManagerImpl.java |    5 +-
 .../com/cloud/network/as/AutoScaleManagerImpl.java |   43 ++--
 .../network/firewall/FirewallManagerImpl.java      |   15 +-
 .../network/guru/ExternalGuestNetworkGuru.java     |    5 +-
 .../com/cloud/network/guru/GuestNetworkGuru.java   |    7 +-
 .../network/lb/LoadBalancingRulesManager.java      |    5 +-
 .../network/lb/LoadBalancingRulesManagerImpl.java  |   36 ++--
 .../router/VirtualNetworkApplianceManagerImpl.java |   26 +-
 .../com/cloud/network/rules/RulesManagerImpl.java  |   25 +-
 .../network/security/SecurityGroupManagerImpl.java |   13 +-
 .../cloud/network/vpc/NetworkACLManagerImpl.java   |    5 +-
 .../cloud/network/vpc/NetworkACLServiceImpl.java   |   17 +-
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |   43 ++--
 .../network/vpn/RemoteAccessVpnManagerImpl.java    |   26 +--
 .../cloud/network/vpn/Site2SiteVpnManagerImpl.java |   35 ++--
 .../src/com/cloud/projects/ProjectManagerImpl.java |   25 +-
 .../com/cloud/resource/ResourceManagerImpl.java    |   14 +-
 .../resourcelimit/ResourceLimitManagerImpl.java    |    9 +-
 .../src/com/cloud/server/ManagementServerImpl.java |   72 +++---
 .../src/com/cloud/storage/StorageManagerImpl.java  |   12 +-
 .../cloud/storage/StoragePoolAutomationImpl.java   |   10 +-
 .../src/com/cloud/storage/VolumeManagerImpl.java   |   18 +-
 .../secondary/SecondaryStorageManagerImpl.java     |    5 +-
 .../storage/snapshot/SnapshotManagerImpl.java      |   22 +-
 .../storage/snapshot/SnapshotSchedulerImpl.java    |    4 +-
 .../com/cloud/tags/TaggedResourceManagerImpl.java  |    7 +-
 .../com/cloud/template/TemplateAdapterBase.java    |   24 +-
 .../com/cloud/template/TemplateManagerImpl.java    |   38 ++--
 server/src/com/cloud/usage/UsageServiceImpl.java   |    4 +-
 server/src/com/cloud/user/AccountManagerImpl.java  |   29 +-
 server/src/com/cloud/user/DomainManagerImpl.java   |   15 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   74 +++---
 server/src/com/cloud/vm/VmWorkJobDispatcher.java   |    7 +-
 .../com/cloud/vm/VmWorkJobWakeupDispatcher.java    |    6 +-
 .../cloud/vm/snapshot/VMSnapshotManagerImpl.java   |    6 +-
 .../affinity/AffinityGroupServiceImpl.java         |   11 +-
 .../lb/ApplicationLoadBalancerManagerImpl.java     |    8 +-
 .../gslb/GlobalLoadBalancingRulesServiceImpl.java  |   10 +-
 .../configuration/ConfigurationManagerTest.java    |    5 +-
 .../cloud/network/DedicateGuestVlanRangesTest.java |    4 +-
 server/test/com/cloud/vm/UserVmManagerTest.java    |    8 +-
 .../test/com/cloud/vpc/NetworkACLManagerTest.java  |    5 +-
 .../test/com/cloud/vpc/NetworkACLServiceTest.java  |    4 +-
 server/test/com/cloud/vpc/VpcTest.java             |    4 +-
 .../cloudstack/affinity/AffinityApiUnitTest.java   |    4 +-
 .../cloudstack/lb/ApplicationLoadBalancerTest.java |    4 +-
 .../networkoffering/ChildTestConfiguration.java    |    6 +-
 .../networkoffering/CreateNetworkOfferingTest.java |    5 +-
 .../cloudstack/region/RegionManagerTest.java       |    2 +-
 .../GlobalLoadBalancingRulesServiceImplTest.java   |   18 +-
 utils/src/com/cloud/utils/UuidUtils.java           |   23 ++
 260 files changed, 1227 insertions(+), 1335 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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
deleted file mode 100644
index ee519d2..0000000
--- a/api/src/com/cloud/user/UserContext.java
+++ /dev/null
@@ -1,200 +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 java.util.HashMap;
-import java.util.Map;
-
-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 String sessionId;
-    private Account account;
-    private long startEventId = 0;
-    private String eventDetails;
-    private User user;
-    private final Map<String, Object> context = new HashMap<String, Object>();
-
-    private static EntityManager s_entityMgr;
-
-    public static void init(EntityManager entityMgr) {
-        s_entityMgr = entityMgr;
-    }
-
-    public UserContext() {
-    }
-
-    protected UserContext(User user, Account account, String sessionId) {
-        this.user = user;
-        this.account = account;
-        this.sessionId = sessionId;
-    }
-    
-    public void putContextParameter(String key, Object value) {
-        context.put(key, value);
-    }
-
-    public Object getContextParameter(String key) {
-        return context.get(key);
-    }
-
-    public long getCallingUserId() {
-        return user.getId();
-    }
-
-    public User getCallingUser() {
-        return user;
-    }
-
-    public String getSessionId() {
-        return sessionId;
-    }
-
-    public Account getCallingAccount() {
-        return account;
-    }
-
-    public static UserContext current() {
-        return s_currentContext.get();
-    }
-
-    public static UserContext register(User callingUser, Account callingAccount, String sessionId) {
-        assert s_currentContext.get() == null : "There's a context already so what does this new register context mean? " + s_currentContext.get().toString();
-        if (s_currentContext.get() != null) { // FIXME: This should be removed soon.  I added this check only to surface all the places that have this problem.
-            throw new CloudRuntimeException("There's a context already so what does this new register context mean? " + s_currentContext.get().toString());
-        }
-        UserContext callingContext = new UserContext(callingUser, callingAccount, sessionId);
-        s_currentContext.set(callingContext);
-        if (sessionId != null) {
-            NDC.push(sessionId);
-        }
-        s_logger.debug("Setting calling context: " + s_currentContext.get());
-        return callingContext;
-    }
-
-    public static UserContext registerOnceOnly() {
-        UserContext context = s_currentContext.get();
-        if (context == null) {
-            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 UserContext register(String callingUserUuid, String callingAccountUuid, String sessionId) {
-        Account account = s_entityMgr.findByUuid(Account.class, callingAccountUuid);
-        if (account == null) {
-            throw new CloudAuthenticationException("The account is no longer current.").add(Account.class, callingAccountUuid);
-        }
-        
-        User user = s_entityMgr.findByUuid(User.class, callingUserUuid);
-        if (user == null) {
-            throw new CloudAuthenticationException("The user is no longer current.").add(User.class, callingUserUuid);
-        }
-        return register(user, account, sessionId);
-    }
-
-    public static 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 UserContext register(long callingUserId, Account callingAccount, String sessionId, boolean apiServer) {
-        User user = s_entityMgr.findById(User.class, callingUserId);
-        if (user == null) {
-            throw new CloudAuthenticationException("The user is no longer current.").add(User.class, Long.toString(callingUserId));
-        }
-        return register(user, callingAccount, sessionId);
-    }
-
-    public static UserContext unregister() {
-        assert s_currentContext.get() != null : "Removing the context when we don't need to " + s_currentContext.get().toString();
-        UserContext context = s_currentContext.get();
-        if (context == null) {
-            s_logger.trace("No context to remove");
-            return null;
-        }
-        s_currentContext.remove();
-        s_logger.debug("Context removed " + context);
-        String sessionId = context.getSessionId();
-        if (sessionId != null) {
-            while ((sessionId = NDC.pop()) != null) {
-                if (context.getSessionId().equals(sessionId)) {
-                    break;
-                }
-            }
-        }
-        return context;
-    }
-
-    public void setStartEventId(long startEventId) {
-        this.startEventId = startEventId;
-    }
-
-    public long getStartEventId() {
-        return startEventId;
-    }
-
-    public long getCallingAccountId() {
-        return account.getId();
-    }
-
-    public String getCallingAccountUuid() {
-        return account.getUuid();
-    }
-
-    public String getCallingUserUuid() {
-        return user.getUuid();
-    }
-
-    public void setEventDetails(String eventDetails) {
-        this.eventDetails = eventDetails;
-    }
-
-    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/b8261b87/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 b73a8bf..ae0f5d7 100644
--- a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
@@ -16,8 +16,9 @@
 // under the License.
 package org.apache.cloudstack.api;
 
+import org.apache.cloudstack.context.CallContext;
+
 import com.cloud.user.User;
-import com.cloud.user.UserContext;
 
 /**
  * queryAsyncJobResult API command.
@@ -97,7 +98,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
     }
 
     protected long saveStartedEvent(String eventType, String description, Long startEventId) {
-        UserContext ctx = UserContext.current();
+        CallContext ctx = CallContext.current();
         Long userId = ctx.getCallingUserId();
         userId = (userId == null) ? User.UID_SYSTEM : userId;
         Long startEvent = startEventId;
@@ -112,7 +113,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
     }
 
     protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId) {
-        UserContext ctx = UserContext.current();
+        CallContext ctx = CallContext.current();
         Long userId = ctx.getCallingUserId();
         userId = (userId == null) ? User.UID_SYSTEM : userId;
         Long startEvent = startEventId;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index 1450e5d..f0e4f8c 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -21,7 +21,6 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 
@@ -30,7 +29,6 @@ import javax.inject.Inject;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.affinity.AffinityGroupService;
-import com.cloud.server.ResourceMetaDataService;
 import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
 import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
 import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
@@ -54,10 +52,10 @@ import com.cloud.network.StorageNetworkService;
 import com.cloud.network.VpcVirtualNetworkApplianceService;
 import com.cloud.network.as.AutoScaleService;
 import com.cloud.network.firewall.FirewallService;
-import com.cloud.network.vpc.NetworkACLService;
 import com.cloud.network.lb.LoadBalancingRulesService;
 import com.cloud.network.rules.RulesService;
 import com.cloud.network.security.SecurityGroupService;
+import com.cloud.network.vpc.NetworkACLService;
 import com.cloud.network.vpc.VpcProvisioningService;
 import com.cloud.network.vpc.VpcService;
 import com.cloud.network.vpn.RemoteAccessVpnService;
@@ -66,6 +64,7 @@ import com.cloud.projects.Project;
 import com.cloud.projects.ProjectService;
 import com.cloud.resource.ResourceService;
 import com.cloud.server.ManagementService;
+import com.cloud.server.ResourceMetaDataService;
 import com.cloud.server.TaggedResourceService;
 import com.cloud.storage.DataStoreProviderApiService;
 import com.cloud.storage.StorageService;
@@ -76,7 +75,6 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountService;
 import com.cloud.user.DomainService;
 import com.cloud.user.ResourceLimitService;
-import com.cloud.utils.Pair;
 import com.cloud.vm.UserVmService;
 import com.cloud.vm.snapshot.VMSnapshotService;
 
@@ -300,177 +298,6 @@ public abstract class BaseCmd {
         return lowercaseParams;
     }
 
-    public String buildResponse(ServerApiException apiException, String responseType) {
-        StringBuffer sb = new StringBuffer();
-        if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-            // JSON response
-            sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},");
-            sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }");
-        } else {
-            sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
-            sb.append("<" + getCommandName() + ">");
-            sb.append("<errorcode>" + apiException.getErrorCode() + "</errorcode>");
-            sb.append("<description>" + escapeXml(apiException.getDescription()) + "</description>");
-            sb.append("</" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
-        }
-        return sb.toString();
-    }
-
-    public String buildResponse(List<Pair<String, Object>> tagList, String responseType) {
-        StringBuffer prefixSb = new StringBuffer();
-        StringBuffer suffixSb = new StringBuffer();
-
-        // set up the return value with the name of the response
-        if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-            prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},");
-        } else {
-            prefixSb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
-            prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
-        }
-
-        int i = 0;
-        for (Pair<String, Object> tagData : tagList) {
-            String tagName = tagData.first();
-            Object tagValue = tagData.second();
-            if (tagValue instanceof Object[]) {
-                Object[] subObjects = (Object[]) tagValue;
-                if (subObjects.length < 1) {
-                    continue;
-                }
-                writeObjectArray(responseType, suffixSb, i++, tagName, subObjects);
-            } else {
-                writeNameValuePair(suffixSb, tagName, tagValue, responseType, i++);
-            }
-        }
-
-        if (suffixSb.length() > 0) {
-            if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { // append comma only if we have some suffix else
-                // not as per strict Json syntax.
-                prefixSb.append(",");
-            }
-            prefixSb.append(suffixSb);
-        }
-        // close the response
-        if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-            prefixSb.append("} }");
-        } else {
-            prefixSb.append("</" + getCommandName() + ">");
-        }
-        return prefixSb.toString();
-    }
-
-    private void writeNameValuePair(StringBuffer sb, String tagName, Object tagValue, String responseType, int propertyCount) {
-        if (tagValue == null) {
-            return;
-        }
-
-        if (tagValue instanceof Object[]) {
-            Object[] subObjects = (Object[]) tagValue;
-            if (subObjects.length < 1) {
-                return;
-            }
-            writeObjectArray(responseType, sb, propertyCount, tagName, subObjects);
-        } else {
-            if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-                String seperator = ((propertyCount > 0) ? ", " : "");
-                sb.append(seperator + "\"" + tagName + "\" : \"" + escapeJSON(tagValue.toString()) + "\"");
-            } else {
-                sb.append("<" + tagName + ">" + escapeXml(tagValue.toString()) + "</" + tagName + ">");
-            }
-        }
-    }
-
-    @SuppressWarnings("rawtypes")
-    private void writeObjectArray(String responseType, StringBuffer sb, int propertyCount, String tagName, Object[] subObjects) {
-        if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-            String separator = ((propertyCount > 0) ? ", " : "");
-            sb.append(separator);
-        }
-        int j = 0;
-        for (Object subObject : subObjects) {
-            if (subObject instanceof List) {
-                List subObjList = (List) subObject;
-                writeSubObject(sb, tagName, subObjList, responseType, j++);
-            }
-        }
-
-        if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-            sb.append("]");
-        }
-    }
-
-    @SuppressWarnings("rawtypes")
-    private void writeSubObject(StringBuffer sb, String tagName, List tagList, String responseType, int objectCount) {
-        if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-            sb.append(((objectCount == 0) ? "\"" + tagName + "\" : [  { " : ", { "));
-        } else {
-            sb.append("<" + tagName + ">");
-        }
-
-        int i = 0;
-        for (Object tag : tagList) {
-            if (tag instanceof Pair) {
-                Pair nameValuePair = (Pair) tag;
-                writeNameValuePair(sb, (String) nameValuePair.first(), nameValuePair.second(), responseType, i++);
-            }
-        }
-
-        if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-            sb.append("}");
-        } else {
-            sb.append("</" + tagName + ">");
-        }
-    }
-
-    /**
-     * Escape xml response set to false by default. API commands to override this method to allow escaping
-     */
-    public boolean requireXmlEscape() {
-        return true;
-    }
-
-    private String escapeXml(String xml) {
-        if (!requireXmlEscape()) {
-            return xml;
-        }
-        int iLen = xml.length();
-        if (iLen == 0) {
-            return xml;
-        }
-        StringBuffer sOUT = new StringBuffer(iLen + 256);
-        int i = 0;
-        for (; i < iLen; i++) {
-            char c = xml.charAt(i);
-            if (c == '<') {
-                sOUT.append("&lt;");
-            } else if (c == '>') {
-                sOUT.append("&gt;");
-            } else if (c == '&') {
-                sOUT.append("&amp;");
-            } else if (c == '"') {
-                sOUT.append("&quot;");
-            } else if (c == '\'') {
-                sOUT.append("&apos;");
-            } else {
-                sOUT.append(c);
-            }
-        }
-        return sOUT.toString();
-    }
-
-    private static String escapeJSON(String str) {
-        if (str == null) {
-            return str;
-        }
-
-        return str.replace("\"", "\\\"");
-    }
-
-    protected long getInstanceIdFromJobSuccessResult(String result) {
-        s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName());
-        return 0;
-    }
-
     public static boolean isAdmin(short accountType) {
         return ((accountType == Account.ACCOUNT_TYPE_ADMIN) ||
                 (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) ||
@@ -482,11 +309,11 @@ public abstract class BaseCmd {
     }
 
     public void setFullUrlParams(Map<String, String> map) {
-        this.fullUrlParams = map;
+        fullUrlParams = map;
     }
 
     public Map<String, String> getFullUrlParams() {
-        return this.fullUrlParams;
+        return fullUrlParams;
     }
 
     public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 2da3a5e..3b45ed6 100644
--- a/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
@@ -21,10 +21,10 @@ import java.util.List;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd {
     public Logger s_logger = getLogger();
@@ -80,7 +80,7 @@ public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd {
     public void execute(){
         List<String> accountNames = _templateService.listTemplatePermissions(this);
 
-        Account account = UserContext.current().getCallingAccount();
+        Account account = CallContext.current().getCallingAccount();
         boolean isAdmin = (isAdmin(account.getType()));
 
         TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(accountNames, id, isAdmin);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java
index 9f3624b..26626bf 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java
@@ -29,10 +29,10 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.user.Account;
 import com.cloud.user.UserAccount;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "createAccount", description="Creates an account", responseObject=AccountResponse.class)
 public class CreateAccountCmd extends BaseCmd {
@@ -162,7 +162,7 @@ public class CreateAccountCmd extends BaseCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
+        CallContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
         UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(),
                 getDomainId(), getNetworkDomain(), getDetails(), getAccountUUID(), getUserUUID());
         if (userAccount != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 024e69c..0aa1e41 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
@@ -29,12 +29,12 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.region.RegionService;
 
 import com.cloud.event.EventTypes;
 import com.cloud.user.Account;
 import com.cloud.user.User;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "deleteAccount", description="Deletes a account, and all users associated with this account", responseObject=SuccessResponse.class)
 public class DeleteAccountCmd extends BaseAsyncCmd {
@@ -75,7 +75,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Account account = UserContext.current().getCallingAccount();// Let's give the caller here for event logging.
+        Account account = CallContext.current().getCallingAccount();// Let's give the caller here for event logging.
         if (account != null) {
             return account.getAccountId();
         }
@@ -96,7 +96,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Account Id: "+getId());
+        CallContext.current().setEventDetails("Account Id: "+getId());
 
         boolean	result = _regionService.deleteUserAccount(this);
         if (result) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java
index c01433e..1f77195 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java
@@ -29,13 +29,13 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.region.RegionService;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "disableAccount", description="Disables an account", responseObject=AccountResponse.class)
 public class DisableAccountCmd extends BaseAsyncCmd {
@@ -117,7 +117,7 @@ public class DisableAccountCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
-        UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
+        CallContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
         Account result = _regionService.disableAccount(this);
         if (result != null){
             AccountResponse response = _responseGenerator.createAccountResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
index bf3be09..fca7f07 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
@@ -25,10 +25,10 @@ import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.domain.Domain;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "createDomain", description="Creates a domain", responseObject=DomainResponse.class)
 public class CreateDomainCmd extends BaseCmd {
@@ -89,7 +89,7 @@ public class CreateDomainCmd extends BaseCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
+        CallContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
         Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID());
         if (domain != null) {
             DomainResponse response = _responseGenerator.createDomainResponse(domain);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
index e6c9d88..22531ad 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
@@ -28,12 +28,12 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.region.RegionService;
 
 import com.cloud.domain.Domain;
 import com.cloud.event.EventTypes;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "deleteDomain", description="Deletes a specified domain", responseObject=SuccessResponse.class)
 public class DeleteDomainCmd extends BaseAsyncCmd {
@@ -96,7 +96,7 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Domain Id: "+getId());
+        CallContext.current().setEventDetails("Domain Id: "+getId());
         boolean result = _regionService.deleteDomain(this);
         if (result) {
             SuccessResponse response = new SuccessResponse(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
index 65d833c..7cb5dab 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
@@ -27,11 +27,11 @@ import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.region.RegionService;
 
 import com.cloud.domain.Domain;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "updateDomain", description="Updates a domain with a new name", responseObject=DomainResponse.class)
 public class UpdateDomainCmd extends BaseCmd {
@@ -86,7 +86,7 @@ public class UpdateDomainCmd extends BaseCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Domain Id: "+getId());
+        CallContext.current().setEventDetails("Domain Id: "+getId());
         Domain domain =  _regionService.updateDomain(this);
 
         if (domain != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 2e725f1..3d79c53 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
@@ -26,11 +26,11 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.host.Host;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "cancelHostMaintenance", description="Cancels host maintenance.", responseObject=HostResponse.class)
 public class CancelMaintenanceCmd extends BaseAsyncCmd  {
@@ -69,7 +69,7 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd  {
 
     @Override
     public long getEntityOwnerId() {
-        Account account = UserContext.current().getCallingAccount();
+        Account account = CallContext.current().getCallingAccount();
         if (account != null) {
             return account.getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 1534c79..83d6cf1 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
@@ -26,11 +26,11 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.host.Host;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "prepareHostForMaintenance", description="Prepares a host for maintenance.", responseObject=HostResponse.class)
 public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
@@ -69,7 +69,7 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Account account = UserContext.current().getCallingAccount();
+        Account account = CallContext.current().getCallingAccount();
         if (account != null) {
             return account.getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 ca25b64..cebd375 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
@@ -26,11 +26,11 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.host.Host;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "reconnectHost", description="Reconnects a host.", responseObject=HostResponse.class)
 public class ReconnectHostCmd extends BaseAsyncCmd {
@@ -69,7 +69,7 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Account account = UserContext.current().getCallingAccount();
+        Account account = CallContext.current().getCallingAccount();
         if (account != null) {
             return account.getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 fe5a11e..af805c5 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
@@ -27,10 +27,10 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.HostResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "releaseHostReservation", description = "Releases host reservation.", responseObject = SuccessResponse.class)
 public class ReleaseHostReservationCmd extends BaseAsyncCmd {
@@ -65,7 +65,7 @@ public class ReleaseHostReservationCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Account account = UserContext.current().getCallingAccount();
+        Account account = CallContext.current().getCallingAccount();
         if (account != null) {
             return account.getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java
index d8bdcc4..3feecc6 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java
@@ -30,6 +30,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
 
 import com.cloud.event.EventTypes;
@@ -38,7 +39,6 @@ import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.VirtualRouterProvider;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "configureInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class,
             description="Configures an Internal Load Balancer element.", since="4.2.0")
@@ -100,7 +100,7 @@ public class ConfigureInternalLoadBalancerElementCmd extends BaseAsyncCmd {
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
         s_logger.debug("hello alena");
-        UserContext.current().setEventDetails("Internal load balancer element: " + id);
+        CallContext.current().setEventDetails("Internal load balancer element: " + id);
         s_logger.debug("hello alena");
         VirtualRouterProvider result = _service.get(0).configureInternalLoadBalancerElement(getId(), getEnabled());
         s_logger.debug("hello alena");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java
index 53a193b..0e9fef6 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java
@@ -30,13 +30,13 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
 import org.apache.cloudstack.api.response.ProviderResponse;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.network.VirtualRouterProvider;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "createInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class, description="Create an Internal Load Balancer element.",since="4.2.0")
 public class CreateInternalLoadBalancerElementCmd extends BaseAsyncCreateCmd {
@@ -83,7 +83,7 @@ public class CreateInternalLoadBalancerElementCmd extends BaseAsyncCreateCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
+        CallContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
         VirtualRouterProvider result = _service.get(0).getInternalLoadBalancerElement(getEntityId());
         if (result != null) {
             InternalLoadBalancerElementResponse response = _responseGenerator.createInternalLbElementResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 7db6e6f..6448f88 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
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -34,7 +35,6 @@ import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.router.VirtualRouter.Role;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "startInternalLoadBalancerVM", responseObject=DomainRouterResponse.class, description="Starts an existing internal lb vm.")
 public class StartInternalLBVMCmd extends BaseAsyncCmd {
@@ -103,13 +103,13 @@ public class StartInternalLBVMCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
-        UserContext.current().setEventDetails("Internal Lb Vm Id: "+getId());
+        CallContext.current().setEventDetails("Internal Lb Vm Id: "+getId());
         VirtualRouter result = null;
         VirtualRouter router = _routerService.findRouter(getId());
         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().getCallingAccount(), UserContext.current().getCallingUserId());
+            result = _internalLbSvc.startInternalLbVm(getId(), CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId());
         }
         
         if (result != null){

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 67bce1d..2047164 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
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -33,7 +34,6 @@ import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.router.VirtualRouter.Role;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "stopInternalLoadBalancerVM", description = "Stops an Internal LB vm.", responseObject = DomainRouterResponse.class)
 public class StopInternalLBVMCmd extends BaseAsyncCmd {
@@ -104,13 +104,13 @@ public class StopInternalLBVMCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
-        UserContext.current().setEventDetails("Internal lb vm Id: "+getId());
+        CallContext.current().setEventDetails("Internal lb vm Id: "+getId());
         VirtualRouter result = null;
         VirtualRouter vm = _routerService.findRouter(getId());
         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().getCallingAccount(), UserContext.current().getCallingUserId());
+            result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId());
         }
         
         if (result != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.java
index c4cf96c..7f6d886 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.java
@@ -29,12 +29,12 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 import org.apache.cloudstack.api.response.ProviderResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "addNetworkServiceProvider", description="Adds a network serviceProvider to a physical network", responseObject=ProviderResponse.class, since="3.0.0")
 public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
@@ -97,7 +97,7 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Network ServiceProvider Id: "+getEntityId());
+        CallContext.current().setEventDetails("Network ServiceProvider Id: "+getEntityId());
         PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
         if (result != null) {
             ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.java
index 103a8f4..6f4f153 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.java
@@ -30,12 +30,12 @@ import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.network.PhysicalNetwork;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "createPhysicalNetwork", description="Creates a physical network", responseObject=PhysicalNetworkResponse.class, since="3.0.0")
 public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
@@ -145,7 +145,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Physical Network Id: "+getEntityId());
+        CallContext.current().setEventDetails("Physical Network Id: "+getEntityId());
         PhysicalNetwork result = _networkService.getCreatedPhysicalNetwork(getEntityId());
         if (result != null) {
             PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/network/DeletePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/DeletePhysicalNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/DeletePhysicalNetworkCmd.java
index 9307abb..8501345 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/DeletePhysicalNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/DeletePhysicalNetworkCmd.java
@@ -27,10 +27,10 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "deletePhysicalNetwork", description="Deletes a Physical Network.", responseObject=SuccessResponse.class, since="3.0.0")
 public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
@@ -69,7 +69,7 @@ public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Physical Network Id: " + id);
+        CallContext.current().setEventDetails("Physical Network Id: " + id);
         boolean result = _networkService.deletePhysicalNetwork(getId());
         if (result) {
             SuccessResponse response = new SuccessResponse(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
index c06bd51..68b4b08 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java
@@ -28,10 +28,10 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "releaseDedicatedGuestVlanRange", description = "Releases a dedicated guest vlan range to the system", responseObject = SuccessResponse.class)
 public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd {
@@ -86,7 +86,7 @@ public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Dedicated guest vlan range Id: " + id);
+        CallContext.current().setEventDetails("Dedicated guest vlan range Id: " + id);
         boolean result = _networkService.releaseDedicatedGuestVlanRange(getId());
         if (result) {
             SuccessResponse response = new SuccessResponse(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
index 4ad6aa6..318bd38 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
@@ -30,6 +30,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -38,7 +39,6 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.VirtualRouterProvider;
 import com.cloud.network.element.VirtualRouterElementService;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "configureVirtualRouterElement", responseObject=VirtualRouterProviderResponse.class, description="Configures a virtual router element.")
 public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
@@ -117,7 +117,7 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
-        UserContext.current().setEventDetails("Virtual router element: " + id);
+        CallContext.current().setEventDetails("Virtual router element: " + id);
         VirtualRouterProvider result = _service.get(0).configure(this);
         if (result != null){
             VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
index d77fc53..4854a05 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
@@ -30,6 +30,7 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.ProviderResponse;
 import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -38,7 +39,6 @@ import com.cloud.network.VirtualRouterProvider;
 import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
 import com.cloud.network.element.VirtualRouterElementService;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "createVirtualRouterElement", responseObject=VirtualRouterProviderResponse.class, description="Create a virtual router element.")
 public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
@@ -99,7 +99,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
+        CallContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
         VirtualRouterProvider result = _service.get(0).getCreatedElement(getEntityId());
         if (result != null) {
             VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 2407c4f..636866c 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
@@ -26,13 +26,13 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "destroyRouter", description = "Destroys a router.", responseObject = DomainRouterResponse.class)
 public class DestroyRouterCmd extends BaseAsyncCmd {
@@ -96,7 +96,7 @@ public class DestroyRouterCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
-        UserContext ctx = UserContext.current();
+        CallContext ctx = CallContext.current();
         ctx.setEventDetails("Router Id: "+getId());
 
         VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCallingAccount(), ctx.getCallingUserId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java
index bcb0068..8d4fb28 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -33,7 +34,6 @@ import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "rebootRouter", description="Starts a router.", responseObject=DomainRouterResponse.class)
 public class RebootRouterCmd extends BaseAsyncCmd {
@@ -96,7 +96,7 @@ public class RebootRouterCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
-        UserContext.current().setEventDetails("Router Id: "+getId());
+        CallContext.current().setEventDetails("Router Id: "+getId());
         VirtualRouter result = _routerService.rebootRouter(this.getId(), true);
         if (result != null){
             DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
index bdbb79e..8c21fc0 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -35,7 +36,6 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "startRouter", responseObject=DomainRouterResponse.class, description="Starts a router.")
 public class StartRouterCmd extends BaseAsyncCmd {
@@ -102,7 +102,7 @@ public class StartRouterCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
-        UserContext.current().setEventDetails("Router Id: "+getId());
+        CallContext.current().setEventDetails("Router Id: "+getId());
         VirtualRouter result = null;
         VirtualRouter router = _routerService.findRouter(getId());
         if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
index 503e73a..67e0810 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -34,7 +35,6 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "stopRouter", description = "Stops a router.", responseObject = DomainRouterResponse.class)
 public class StopRouterCmd extends BaseAsyncCmd {
@@ -105,7 +105,7 @@ public class StopRouterCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
-        UserContext.current().setEventDetails("Router Id: "+getId());
+        CallContext.current().setEventDetails("Router Id: "+getId());
         VirtualRouter result = null;
         VirtualRouter router = _routerService.findRouter(getId());
         if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 fd194e3..701ab0d 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
@@ -26,12 +26,12 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.StoragePoolResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.storage.StoragePool;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "cancelStorageMaintenance", description="Cancels maintenance for primary storage", responseObject=StoragePoolResponse.class)
 public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
@@ -82,7 +82,7 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Account account = UserContext.current().getCallingAccount();
+        Account account = CallContext.current().getCallingAccount();
         if (account != null) {
             return account.getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 d84f641..750cf9c 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
@@ -26,13 +26,13 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.StoragePoolResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.storage.StoragePool;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "enableStorageMaintenance", description="Puts storage pool into maintenance state", responseObject=StoragePoolResponse.class)
 public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
@@ -80,7 +80,7 @@ public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Account account = UserContext.current().getCallingAccount();
+        Account account = CallContext.current().getCallingAccount();
         if (account != null) {
             return account.getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/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 8816d5a..3cedd0e 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
@@ -26,10 +26,10 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.SystemVmResponse;
+import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.event.EventTypes;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 import com.cloud.vm.VirtualMachine;
 
 @APICommand(name = "destroySystemVm", responseObject=SystemVmResponse.class, description="Destroyes a system virtual machine.")
@@ -57,7 +57,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Account account = UserContext.current().getCallingAccount();
+        Account account = CallContext.current().getCallingAccount();
         if (account != null) {
             return account.getId();
         }
@@ -93,7 +93,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
 
     @Override
     public void execute(){
-        UserContext.current().setEventDetails("Vm Id: "+getId());
+        CallContext.current().setEventDetails("Vm Id: "+getId());
         VirtualMachine instance = _mgr.destroySystemVM(this);
         if (instance != null) {
             SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);


Mime
View raw message