You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/05/31 14:06:48 UTC
[08/14] Moved UserContext to its proper place as CallContext
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
index 1cc6f8d..c8b1de8 100755
--- a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
+++ b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
@@ -75,7 +75,6 @@ import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.DomainManager;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.uservm.UserVm;
import com.cloud.utils.NumbersUtil;
@@ -99,6 +98,8 @@ import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
import edu.emory.mathcs.backport.java.util.Collections;
import org.apache.cloudstack.api.command.user.securitygroup.*;
+import org.apache.cloudstack.context.CallContext;
+
import java.util.*;
@Local(value = { SecurityGroupManager.class, SecurityGroupService.class })
@@ -585,7 +586,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
throw new InvalidParameterValueException("At least one cidr or at least one security group needs to be specified");
}
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountMgr.getAccount(securityGroup.getAccountId());
if (owner == null) {
@@ -762,7 +763,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
private boolean revokeSecurityGroupRule(Long id, SecurityRuleType type) {
// input validation
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
SecurityGroupRuleVO rule = _securityGroupRuleDao.findById(id);
if (rule == null) {
@@ -816,7 +817,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
@ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_CREATE, eventDescription = "creating security group")
public SecurityGroupVO createSecurityGroup(CreateSecurityGroupCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
String name = cmd.getSecurityGroupName();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountMgr.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
if (_securityGroupDao.isNameInUse(owner.getId(), owner.getDomainId(), cmd.getSecurityGroupName())) {
@@ -1055,7 +1056,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
@ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_DELETE, eventDescription = "deleting security group")
public boolean deleteSecurityGroup(DeleteSecurityGroupCmd cmd) throws ResourceInUseException {
Long groupId = cmd.getId();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
SecurityGroupVO group = _securityGroupDao.findById(groupId);
if (group == null) {
@@ -1307,7 +1308,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
return true;
}
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
for (SecurityGroupVO securityGroup: vmSgGrps) {
Account owner = _accountMgr.getAccount(securityGroup.getAccountId());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
index e26dad9..cdb3018 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
@@ -32,7 +32,6 @@ import com.cloud.network.vpc.dao.VpcGatewayDao;
import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
-import com.cloud.user.UserContext;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
@@ -40,6 +39,8 @@ import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
+import org.apache.cloudstack.context.CallContext;
+
import javax.ejb.Local;
import javax.inject.Inject;
import java.util.ArrayList;
@@ -166,7 +167,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
if (!_networkACLItemDao.setStateToAdd(newRule)) {
throw new CloudRuntimeException("Unable to update the state to add for " + newRule);
}
- UserContext.current().setEventDetails("ACL Item Id: " + newRule.getId());
+ CallContext.current().setEventDetails("ACL Item Id: " + newRule.getId());
txn.commit();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
index c228326..a89b414 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
@@ -31,7 +31,6 @@ import com.cloud.tags.ResourceTagVO;
import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
-import com.cloud.user.UserContext;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ManagerBase;
@@ -45,6 +44,8 @@ import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd;
+import org.apache.cloudstack.context.CallContext;
+
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -84,7 +85,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
@Override
public NetworkACL createNetworkACL(String name, String description, long vpcId) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Vpc vpc = _vpcMgr.getVpc(vpcId);
if(vpc == null){
throw new InvalidParameterValueException("Unable to find VPC");
@@ -135,7 +136,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
@Override
public boolean deleteNetworkACL(long id) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
NetworkACL acl = _networkACLDao.findById(id);
if(acl == null) {
throw new InvalidParameterValueException("Unable to find specified ACL");
@@ -155,7 +156,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
}
@Override
public boolean replaceNetworkACLonPrivateGw(long aclId, long privateGatewayId) throws ResourceUnavailableException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
VpcGateway gateway = _vpcGatewayDao.findById(privateGatewayId);
if (gateway == null) {
throw new InvalidParameterValueException("Unable to find specified private gateway");
@@ -196,7 +197,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
@Override
public boolean replaceNetworkACL(long aclId, long networkId) throws ResourceUnavailableException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
NetworkVO network = _networkDao.findById(networkId);
if(network == null){
@@ -235,7 +236,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
@Override
public NetworkACLItem createNetworkACLItem(CreateNetworkACLCmd aclItemCmd){
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Long aclId = aclItemCmd.getACLId();
if(aclId == null){
//ACL id is not specified. Get the ACL details from network
@@ -368,7 +369,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
String action = cmd.getAction();
Map<String, String> tags = cmd.getTags();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject =
@@ -471,7 +472,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
_accountMgr.checkAccess(caller, null, true, vpc);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 379980e..869054d 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -34,6 +34,8 @@ import javax.naming.ConfigurationException;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.api.command.user.vpc.ListPrivateGatewaysCmd;
import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd;
+import org.apache.cloudstack.context.CallContext;
+
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -102,7 +104,6 @@ import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.ResourceLimitService;
import com.cloud.user.User;
-import com.cloud.user.UserContext;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
@@ -352,7 +353,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
}
VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false, null);
- UserContext.current().setEventDetails(" Id: " + offering.getId() + " Name: " + name);
+ CallContext.current().setEventDetails(" Id: " + offering.getId() + " Name: " + name);
return offering;
}
@@ -500,7 +501,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_DELETE, eventDescription = "deleting vpc offering")
public boolean deleteVpcOffering(long offId) {
- UserContext.current().setEventDetails(" Id: " + offId);
+ CallContext.current().setEventDetails(" Id: " + offId);
// Verify vpc offering id
VpcOfferingVO offering = _vpcOffDao.findById(offId);
@@ -530,7 +531,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_UPDATE, eventDescription = "updating vpc offering")
public VpcOffering updateVpcOffering(long vpcOffId, String vpcOfferingName, String displayText, String state) {
- UserContext.current().setEventDetails(" Id: " + vpcOffId);
+ CallContext.current().setEventDetails(" Id: " + vpcOffId);
// Verify input parameters
VpcOfferingVO offeringToUpdate = _vpcOffDao.findById(vpcOffId);
@@ -573,7 +574,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", create=true)
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr,
String networkDomain) throws ResourceAllocationException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountMgr.getAccount(vpcOwnerId);
//Verify that caller can perform actions in behalf of vpc owner
@@ -695,8 +696,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_DELETE, eventDescription = "deleting VPC")
public boolean deleteVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException {
- UserContext.current().setEventDetails(" Id: " + vpcId);
- UserContext ctx = UserContext.current();
+ CallContext.current().setEventDetails(" Id: " + vpcId);
+ CallContext ctx = CallContext.current();
// Verify vpc id
Vpc vpc = getVpc(vpcId);
@@ -762,8 +763,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_UPDATE, eventDescription = "updating vpc")
public Vpc updateVpc(long vpcId, String vpcName, String displayText) {
- UserContext.current().setEventDetails(" Id: " + vpcId);
- Account caller = UserContext.current().getCallingAccount();
+ CallContext.current().setEventDetails(" Id: " + vpcId);
+ Account caller = CallContext.current().getCallingAccount();
// Verify input parameters
VpcVO vpcToUpdate = _vpcDao.findById(vpcId);
@@ -796,7 +797,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText, List<String> supportedServicesStr,
String cidr, Long vpcOffId, String state, String accountName, Long domainId, String keyword,
Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired, Map<String, String> tags, Long projectId) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
@@ -939,7 +940,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
public boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException {
- UserContext ctx = UserContext.current();
+ CallContext ctx = CallContext.current();
Account caller = ctx.getCallingAccount();
User callerUser = _accountMgr.getActiveUser(ctx.getCallingUserId());
@@ -1003,7 +1004,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
public boolean shutdownVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException {
- UserContext ctx = UserContext.current();
+ CallContext ctx = CallContext.current();
Account caller = ctx.getCallingAccount();
//check if vpc exists
@@ -1273,7 +1274,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@ActionEvent(eventType = EventTypes.EVENT_VPC_RESTART, eventDescription = "restarting vpc")
public boolean restartVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
// Verify input parameters
Vpc vpc = getActiveVpc(vpcId);
@@ -1508,7 +1509,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
}
if (deleteNetwork) {
- User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallingUserId());
+ User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
Account owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
ReservationContext context = new ReservationContextImpl(null, null, callerUser, owner);
_ntwkMgr.destroyNetwork(networkId, context);
@@ -1532,7 +1533,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
Boolean listAll = cmd.listAll();
Long domainId = cmd.getDomainId();
String accountName = cmd.getAccountName();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
String state = cmd.getState();
Long projectId = cmd.getProjectId();
@@ -1594,7 +1595,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
public boolean applyStaticRoutes(long vpcId) throws ResourceUnavailableException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<? extends StaticRoute> routes = _staticRouteDao.listByVpcId(vpcId);
return applyStaticRoutes(routes, caller, true);
}
@@ -1662,7 +1663,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
@ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_DELETE, eventDescription = "deleting static route")
public boolean revokeStaticRoute(long routeId) throws ResourceUnavailableException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
StaticRouteVO route = _staticRouteDao.findById(routeId);
if (route == null) {
@@ -1699,7 +1700,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@DB
@ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_CREATE, eventDescription = "creating static route", create=true)
public StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
//parameters validation
VpcGateway gateway = _vpcGatewayDao.findById(gatewayId);
@@ -1749,7 +1750,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
if (!_staticRouteDao.setStateToAdd(newRoute)) {
throw new CloudRuntimeException("Unable to update the state to add for " + newRoute);
}
- UserContext.current().setEventDetails("Static route Id: " + newRoute.getId());
+ CallContext.current().setEventDetails("Static route Id: " + newRoute.getId());
txn.commit();
@@ -1782,7 +1783,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
Boolean isRecursive = cmd.isRecursive();
Boolean listAll = cmd.listAll();
String accountName = cmd.getAccountName();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
Map<String, String> tags = cmd.getTags();
Long projectId = cmd.getProjectId();
@@ -1924,7 +1925,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "associating Ip", async = true)
public IpAddress associateIPToVpc(long ipId, long vpcId) throws ResourceAllocationException, ResourceUnavailableException,
InsufficientAddressCapacityException, ConcurrentOperationException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = null;
IpAddress ipToAssoc = _ntwkModel.getIp(ipId);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
index 472281b..401b9f4 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -27,6 +27,8 @@ import javax.naming.ConfigurationException;
import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd;
import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd;
+import org.apache.cloudstack.context.CallContext;
+
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -43,10 +45,6 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.Network.Service;
-import com.cloud.network.NetworkModel;
-import com.cloud.network.PublicIpAddress;
-import com.cloud.network.RemoteAccessVpn;
-import com.cloud.network.VpnUser;
import com.cloud.network.*;
import com.cloud.network.VpnUser.State;
import com.cloud.network.dao.FirewallRulesDao;
@@ -66,18 +64,12 @@ import com.cloud.server.ConfigurationServer;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.DomainManager;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.PasswordGenerator;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ManagerBase;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.JoinBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.*;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.net.NetUtils;
@@ -113,7 +105,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@DB
public RemoteAccessVpn createRemoteAccessVpn(long publicIpId, String ipRange, boolean openFirewall, long networkId)
throws NetworkRuleConflictException {
- UserContext ctx = UserContext.current();
+ CallContext ctx = CallContext.current();
Account caller = ctx.getCallingAccount();
// make sure ip address exists
@@ -312,7 +304,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@Override
@DB
public VpnUser addVpnUser(long vpnOwnerId, String username, String password) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
if (!username.matches("^[a-zA-Z0-9][a-zA-Z0-9@._-]{2,63}$")) {
throw new InvalidParameterValueException(
@@ -366,7 +358,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@Override
public List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountDao.findById(vpnOwnerId);
_accountMgr.checkAccess(caller, null, true, owner);
return _vpnUsersDao.listByAccount(vpnOwnerId);
@@ -374,7 +366,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@Override @DB
public RemoteAccessVpnVO startRemoteAccessVpn(long ipAddressId, boolean openFirewall) throws ResourceUnavailableException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
RemoteAccessVpnVO vpn = _remoteAccessVpnDao.findByPublicIpAddress(ipAddressId);
if (vpn == null) {
@@ -425,7 +417,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@DB
@Override
public boolean applyVpnUsers(long vpnOwnerId, String userName) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountDao.findById(vpnOwnerId);
_accountMgr.checkAccess(caller, null, true, owner);
@@ -504,7 +496,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
public Pair<List<? extends VpnUser>, Integer> searchForVpnUsers(ListVpnUsersCmd cmd) {
String username = cmd.getUsername();
Long id = cmd.getId();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
@@ -542,7 +534,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@Override
public Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd) {
// do some parameter validation
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Long ipAddressId = cmd.getPublicIpId();
List<Long> permittedAccounts = new ArrayList<Long>();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
index 360b46d..292b73e 100644
--- a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
@@ -35,6 +35,8 @@ import org.apache.cloudstack.api.command.user.vpn.ListVpnCustomerGatewaysCmd;
import org.apache.cloudstack.api.command.user.vpn.ListVpnGatewaysCmd;
import org.apache.cloudstack.api.command.user.vpn.ResetVpnConnectionCmd;
import org.apache.cloudstack.api.command.user.vpn.UpdateVpnCustomerGatewayCmd;
+import org.apache.cloudstack.context.CallContext;
+
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -64,7 +66,6 @@ import com.cloud.network.vpc.dao.VpcDao;
import com.cloud.projects.Project.ListProjectResourcesCriteria;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
@@ -112,7 +113,7 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_GATEWAY_CREATE, eventDescription = "creating s2s vpn gateway", create=true)
public Site2SiteVpnGateway createVpnGateway(CreateVpnGatewayCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
//Verify that caller can perform actions in behalf of vpc owner
@@ -157,7 +158,7 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_CUSTOMER_GATEWAY_CREATE, eventDescription = "creating s2s customer gateway", create=true)
public Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
//Verify that caller can perform actions in behalf of vpc owner
@@ -225,7 +226,7 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_CONNECTION_CREATE, eventDescription = "creating s2s vpn connection", create=true)
public Site2SiteVpnConnection createVpnConnection(CreateVpnConnectionCmd cmd) throws NetworkRuleConflictException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
//Verify that caller can perform actions in behalf of vpc owner
@@ -337,8 +338,8 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_CUSTOMER_GATEWAY_DELETE, eventDescription = "deleting s2s vpn customer gateway", create=true)
public boolean deleteCustomerGateway(DeleteVpnCustomerGatewayCmd cmd) {
- UserContext.current().setEventDetails(" Id: " + cmd.getId());
- Account caller = UserContext.current().getCallingAccount();
+ CallContext.current().setEventDetails(" Id: " + cmd.getId());
+ Account caller = CallContext.current().getCallingAccount();
Long id = cmd.getId();
Site2SiteCustomerGateway customerGateway = _customerGatewayDao.findById(id);
@@ -371,8 +372,8 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_GATEWAY_DELETE, eventDescription = "deleting s2s vpn gateway", create=true)
public boolean deleteVpnGateway(DeleteVpnGatewayCmd cmd) {
- UserContext.current().setEventDetails(" Id: " + cmd.getId());
- Account caller = UserContext.current().getCallingAccount();
+ CallContext.current().setEventDetails(" Id: " + cmd.getId());
+ Account caller = CallContext.current().getCallingAccount();
Long id = cmd.getId();
Site2SiteVpnGateway vpnGateway = _vpnGatewayDao.findById(id);
@@ -389,8 +390,8 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_CUSTOMER_GATEWAY_UPDATE, eventDescription = "update s2s vpn customer gateway", create=true)
public Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCmd cmd) {
- UserContext.current().setEventDetails(" Id: " + cmd.getId());
- Account caller = UserContext.current().getCallingAccount();
+ CallContext.current().setEventDetails(" Id: " + cmd.getId());
+ Account caller = CallContext.current().getCallingAccount();
Long id = cmd.getId();
Site2SiteCustomerGatewayVO gw = _customerGatewayDao.findById(id);
@@ -478,8 +479,8 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_CONNECTION_DELETE, eventDescription = "deleting s2s vpn connection", create=true)
public boolean deleteVpnConnection(DeleteVpnConnectionCmd cmd) throws ResourceUnavailableException {
- UserContext.current().setEventDetails(" Id: " + cmd.getId());
- Account caller = UserContext.current().getCallingAccount();
+ CallContext.current().setEventDetails(" Id: " + cmd.getId());
+ Account caller = CallContext.current().getCallingAccount();
Long id = cmd.getId();
Site2SiteVpnConnectionVO conn = _vpnConnectionDao.findById(id);
@@ -528,8 +529,8 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
@Override
@ActionEvent(eventType = EventTypes.EVENT_S2S_VPN_CONNECTION_RESET, eventDescription = "reseting s2s vpn connection", create=true)
public Site2SiteVpnConnection resetVpnConnection(ResetVpnConnectionCmd cmd) throws ResourceUnavailableException {
- UserContext.current().setEventDetails(" Id: " + cmd.getId());
- Account caller = UserContext.current().getCallingAccount();
+ CallContext.current().setEventDetails(" Id: " + cmd.getId());
+ Account caller = CallContext.current().getCallingAccount();
Long id = cmd.getId();
Site2SiteVpnConnectionVO conn = _vpnConnectionDao.findById(id);
@@ -559,7 +560,7 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
long startIndex = cmd.getStartIndex();
long pageSizeVal = cmd.getPageSizeVal();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
@@ -598,7 +599,7 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
long startIndex = cmd.getStartIndex();
long pageSizeVal = cmd.getPageSizeVal();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
@@ -642,7 +643,7 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
long startIndex = cmd.getStartIndex();
long pageSizeVal = cmd.getPageSizeVal();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/projects/ProjectManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/ProjectManagerImpl.java b/server/src/com/cloud/projects/ProjectManagerImpl.java
index 7b48209..1c83930 100755
--- a/server/src/com/cloud/projects/ProjectManagerImpl.java
+++ b/server/src/com/cloud/projects/ProjectManagerImpl.java
@@ -40,6 +40,8 @@ import javax.mail.internet.InternetAddress;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.context.CallContext;
+
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -72,7 +74,6 @@ import com.cloud.user.AccountVO;
import com.cloud.user.DomainManager;
import com.cloud.user.ResourceLimitService;
import com.cloud.user.User;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
@@ -175,7 +176,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_CREATE, eventDescription = "creating project", create=true)
@DB
public Project createProject(String name, String displayText, String accountName, Long domainId) throws ResourceAllocationException{
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = caller;
//check if the user authorized to create the project
@@ -215,7 +216,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
assignAccountToProject(project, owner.getId(), ProjectAccount.Role.Admin);
if (project != null) {
- UserContext.current().setEventDetails("Project id=" + project.getId());
+ CallContext.current().setEventDetails("Project id=" + project.getId());
}
//Increment resource count
@@ -231,7 +232,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_CREATE, eventDescription = "creating project", async=true)
@DB
public Project enableProject(long projectId){
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
ProjectVO project= getProject(projectId);
//verify input parameters
@@ -252,7 +253,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@Override
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_DELETE, eventDescription = "deleting project", async = true)
public boolean deleteProject(long projectId) {
- UserContext ctx = UserContext.current();
+ CallContext ctx = CallContext.current();
ProjectVO project= getProject(projectId);
//verify input parameters
@@ -442,7 +443,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@Override @DB
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_UPDATE, eventDescription = "updating project", async=true)
public Project updateProject(long projectId, String displayText, String newOwnerName) throws ResourceAllocationException{
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
//check that the project exists
ProjectVO project = getProject(projectId);
@@ -503,7 +504,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@Override
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_ACCOUNT_ADD, eventDescription = "adding account to project", async=true)
public boolean addAccountToProject(long projectId, String accountName, String email) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
//check that the project exists
Project project = getProject(projectId);
@@ -589,7 +590,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@Override
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_ACCOUNT_REMOVE, eventDescription = "removing account from project", async=true)
public boolean deleteAccountFromProject(long projectId, String accountName) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
//check that the project exists
Project project = getProject(projectId);
@@ -710,7 +711,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@Override @DB
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_INVITATION_UPDATE, eventDescription = "updating project invitation", async=true)
public boolean updateInvitation(long projectId, String accountName, String token, boolean accept) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Long accountId = null;
boolean result = true;
@@ -794,7 +795,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_ACTIVATE, eventDescription = "activating project")
@DB
public Project activateProject(long projectId) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
//check that the project exists
ProjectVO project = getProject(projectId);
@@ -837,7 +838,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@Override
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_SUSPEND, eventDescription = "suspending project", async = true)
public Project suspendProject (long projectId) throws ConcurrentOperationException, ResourceUnavailableException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
ProjectVO project= getProject(projectId);
//verify input parameters
@@ -979,7 +980,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
@Override @DB
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_INVITATION_REMOVE, eventDescription = "removing project invitation", async=true)
public boolean deleteProjectInvitation(long id) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
ProjectInvitation invitation = _projectInvitationDao.findById(id);
if (invitation == null) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 54b883a..afc2609 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -47,6 +47,7 @@ import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
+import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
@@ -139,7 +140,6 @@ import com.cloud.template.VirtualMachineTemplate;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.User;
-import com.cloud.user.UserContext;
import com.cloud.utils.Pair;
import com.cloud.utils.StringUtils;
import com.cloud.utils.UriUtils;
@@ -400,7 +400,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
throw ex;
}
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
if (Grouping.AllocationState.Disabled == zone.getAllocationState()
&& !_accountMgr.isRootAdmin(account.getType())) {
PermissionDeniedException ex = new PermissionDeniedException(
@@ -632,7 +632,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
String password = cmd.getPassword();
List<String> hostTags = cmd.getHostTags();
- dcId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current()
+ dcId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current()
.getCallingAccount(), dcId);
// this is for standalone option
@@ -704,7 +704,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
+ dcId);
}
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
if (Grouping.AllocationState.Disabled == zone.getAllocationState()
&& !_accountMgr.isRootAdmin(account.getType())) {
PermissionDeniedException ex = new PermissionDeniedException(
@@ -926,7 +926,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
@DB
protected boolean doDeleteHost(long hostId, boolean isForced,
boolean isForceDeleteStorage) {
- User caller = _accountMgr.getActiveUser(UserContext.current()
+ User caller = _accountMgr.getActiveUser(CallContext.current()
.getCallingUserId());
// Verify that host exists
HostVO host = _hostDao.findById(hostId);
@@ -934,7 +934,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
throw new InvalidParameterValueException("Host with id " + hostId
+ " doesn't exist");
}
- _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current()
+ _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current()
.getCallingAccount(), host.getDataCenterId());
/*
@@ -2295,7 +2295,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
+ host.getGuid());
}
- User caller = _accountMgr.getActiveUser(UserContext.current()
+ User caller = _accountMgr.getActiveUser(CallContext.current()
.getCallingUserId());
if (forceDestroyStorage) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
index 9b65b8a..edf14fc 100755
--- a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
+++ b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
@@ -30,6 +30,8 @@ import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.context.CallContext;
+
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -76,7 +78,6 @@ import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO;
import com.cloud.user.ResourceLimitService;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.ManagerBase;
@@ -421,7 +422,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
@Override
public List<ResourceLimitVO> searchForLimits(Long id, Long accountId, Long domainId, Integer type, Long startIndex, Long pageSizeVal) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<ResourceLimitVO> limits = new ArrayList<ResourceLimitVO>();
boolean isAccount = true;
@@ -565,7 +566,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
@Override
public ResourceLimitVO updateResourceLimit(Long accountId, Long domainId, Integer typeId, Long max) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
if (max == null) {
max = new Long(Resource.RESOURCE_UNLIMITED);
@@ -663,7 +664,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
@Override
public List<ResourceCountVO> recalculateResourceCount(Long accountId, Long domainId, Integer typeId) throws InvalidParameterValueException, CloudRuntimeException, PermissionDeniedException {
- Account callerAccount = UserContext.current().getCallingAccount();
+ Account callerAccount = CallContext.current().getCallingAccount();
long count = 0;
List<ResourceCountVO> counts = new ArrayList<ResourceCountVO>();
List<ResourceType> resourceTypes = new ArrayList<ResourceType>();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 6c07675..ffa2779 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -555,7 +555,6 @@ import com.cloud.user.AccountManager;
import com.cloud.user.SSHKeyPair;
import com.cloud.user.SSHKeyPairVO;
import com.cloud.user.User;
-import com.cloud.user.UserContext;
import com.cloud.user.UserVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.SSHKeyPairDao;
@@ -674,6 +673,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.api.command.admin.config.ListDeploymentPlannersCmd;
+import org.apache.cloudstack.context.CallContext;
public class ManagementServerImpl extends ManagerBase implements ManagementServer {
public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName());
@@ -983,7 +983,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public boolean archiveEvents(ArchiveEventsCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> ids = cmd.getIds();
boolean result =true;
List<Long> permittedAccountIds = new ArrayList<Long>();
@@ -998,7 +998,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), permittedAccountIds);
ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
- _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, sameOwnerEvents);
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, sameOwnerEvents);
if (ids != null && events.size() < ids.size()) {
result = false;
@@ -1010,7 +1010,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public boolean deleteEvents(DeleteEventsCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> ids = cmd.getIds();
boolean result =true;
List<Long> permittedAccountIds = new ArrayList<Long>();
@@ -1025,7 +1025,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), permittedAccountIds);
ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
- _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, sameOwnerEvents);
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, sameOwnerEvents);
if (ids != null && events.size() < ids.size()) {
result = false;
@@ -1052,7 +1052,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
Filter searchFilter = new Filter(ClusterVO.class, "id", true, startIndex, pageSizeVal);
SearchCriteria<ClusterVO> sc = _clusterDao.createSearchCriteria();
- zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), zoneId);
+ zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisorType);
@@ -1071,7 +1071,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
Object allocationState = cmd.getAllocationState();
String zoneType = cmd.getZoneType();
String keyword = cmd.getKeyword();
- zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), zoneId);
+ zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
@@ -1139,7 +1139,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public Pair<List<? extends Host>, Integer> searchForServers(ListHostsCmd cmd) {
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), cmd.getZoneId());
+ Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), cmd.getZoneId());
Object name = cmd.getHostName();
Object type = cmd.getType();
Object state = cmd.getState();
@@ -1159,7 +1159,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
public Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>>
listHostsForMigrationOfVM(Long vmId, Long startIndex, Long pageSize) {
// access check - only root admin can migrate VM
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Caller is not a root admin, permission denied to migrate the VM");
@@ -1345,7 +1345,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(Long volumeId) {
// Access check - only root administrator can migrate volumes.
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Caller is not a root admin, permission denied to migrate the volume");
@@ -1540,7 +1540,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
Object keyword = cmd.getKeyword();
Object allocationState = cmd.getAllocationState();
String zoneType = cmd.getZoneType();
- zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), zoneId);
+ zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
Filter searchFilter = new Filter(HostPodVO.class, "dataCenterId", true, cmd.getStartIndex(), cmd.getPageSizeVal());
@@ -1796,7 +1796,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public Set<Pair<Long, Long>> listIsos(ListIsosCmd cmd) throws IllegalArgumentException, InvalidParameterValueException {
TemplateFilter isoFilter = TemplateFilter.valueOf(cmd.getIsoFilter());
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Map<String, String> tags = cmd.getTags();
boolean listAll = false;
@@ -1829,7 +1829,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
TemplateFilter templateFilter = TemplateFilter.valueOf(cmd.getTemplateFilter());
Long id = cmd.getId();
Map<String, String> tags = cmd.getTags();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
boolean listAll = false;
if (templateFilter != null && templateFilter == TemplateFilter.all) {
@@ -1975,7 +1975,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
Boolean passwordEnabled = cmd.isPasswordEnabled();
Boolean bootable = cmd.isBootable();
Integer sortKey = cmd.getSortKey();
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
// verify that template exists
VMTemplateVO template = _templateDao.findById(id);
@@ -2078,7 +2078,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
List<Long> permittedAccounts = new ArrayList<Long>();
ListProjectResourcesCriteria listProjectResourcesCriteria = null;
if (isAllocated) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
cmd.getDomainId(), cmd.isRecursive(), null);
@@ -2269,9 +2269,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException,
ConcurrentOperationException {
- User caller = _userDao.findById(UserContext.current().getCallingUserId());
+ User caller = _userDao.findById(CallContext.current().getCallingUserId());
- _itMgr.advanceStop(systemVm.getUuid(), isForced, caller, UserContext.current().getCallingAccount());
+ _itMgr.advanceStop(systemVm.getUuid(), isForced, caller, CallContext.current().getCallingAccount());
return _consoleProxyDao.findById(systemVm.getId());
}
@@ -2343,7 +2343,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
// check permissions
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
_accountMgr.checkAccess(caller, domain);
// domain name is unique under the parent domain
@@ -2427,7 +2427,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
Object type = cmd.getType();
Object keyword = cmd.getKeyword();
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), null);
+ Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
}
@@ -2453,14 +2453,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public boolean archiveAlerts(ArchiveAlertsCmd cmd) {
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), null);
+ Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
boolean result = _alertDao.archiveAlert(cmd.getIds(), cmd.getType(), cmd.getOlderThan(), zoneId);
return result;
}
@Override
public boolean deleteAlerts(DeleteAlertsCmd cmd) {
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), null);
+ Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
boolean result = _alertDao.deleteAlert(cmd.getIds(), cmd.getType(), cmd.getOlderThan(), zoneId);
return result;
}
@@ -2476,7 +2476,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
if (clusterId != null) {
throw new InvalidParameterValueException("Currently clusterId param is not suppoerted");
}
- zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), zoneId);
+ zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
List<SummedCapacity> summedCapacities = new ArrayList<SummedCapacity>();
if (zoneId == null && podId == null) {// Group by Zone, capacity type
@@ -2585,7 +2585,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
Long clusterId = cmd.getClusterId();
Boolean fetchLatest = cmd.getFetchLatest();
- zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), zoneId);
+ zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
if (fetchLatest != null && fetchLatest) {
_alertMgr.recalculateCapacity();
}
@@ -3151,9 +3151,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
private SecondaryStorageVmVO stopSecondaryStorageVm(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException,
OperationTimedoutException, ConcurrentOperationException {
- User caller = _userDao.findById(UserContext.current().getCallingUserId());
+ User caller = _userDao.findById(CallContext.current().getCallingUserId());
- _itMgr.advanceStop(systemVm.getUuid(), isForced, caller, UserContext.current().getCallingAccount());
+ _itMgr.advanceStop(systemVm.getUuid(), isForced, caller, CallContext.current().getCallingAccount());
return _secStorageVmDao.findById(systemVm.getId());
}
@@ -3175,7 +3175,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(ListSystemVMsCmd cmd) {
String type = cmd.getSystemVmType();
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCallingAccount(), cmd.getZoneId());
+ Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), cmd.getZoneId());
String zoneType = cmd.getZoneType();
Long id = cmd.getId();
String name = cmd.getSystemVmName();
@@ -3368,7 +3368,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public ArrayList<String> getCloudIdentifierResponse(long userId) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
// verify that user exists
User user = _accountMgr.getUserIncludingRemoved(userId);
@@ -3461,7 +3461,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
Long zoneId = cmd.getZoneId();
AsyncJob job = null; // FIXME: cmd.getJob();
String mode = cmd.getMode();
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
if (!_accountMgr.isRootAdmin(account.getType()) && ApiDBUtils.isExtractionDisabled()) {
throw new PermissionDeniedException("Extraction has been disabled by admin");
@@ -3657,7 +3657,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public InstanceGroupVO updateVmGroup(UpdateVMGroupCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Long groupId = cmd.getId();
String groupName = cmd.getGroupName();
@@ -3836,7 +3836,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public SSHKeyPair createSSHKeyPair(CreateSSHKeyPairCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
String accountName = cmd.getAccountName();
Long domainId = cmd.getDomainId();
Long projectId = cmd.getProjectId();
@@ -3860,7 +3860,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public boolean deleteSSHKeyPair(DeleteSSHKeyPairCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
String accountName = cmd.getAccountName();
Long domainId = cmd.getDomainId();
Long projectId = cmd.getProjectId();
@@ -3888,7 +3888,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
String name = cmd.getName();
String fingerPrint = cmd.getFingerprint();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
@@ -3920,7 +3920,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
@ActionEvent(eventType = EventTypes.EVENT_REGISTER_SSH_KEYPAIR, eventDescription = "registering ssh keypair", async = true)
public SSHKeyPair registerSSHKeyPair(RegisterSSHKeyPairCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
Account owner = _accountMgr.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
@@ -3958,7 +3958,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public String getVMPassword(GetVMPasswordCmd cmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
UserVmVO vm = _userVmDao.findById(cmd.getId());
if (vm == null) {
@@ -4105,7 +4105,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
if (_hypervisorCapabilitiesDao.update(id, hpvCapabilities)) {
hpvCapabilities = _hypervisorCapabilitiesDao.findById(id);
- UserContext.current().setEventDetails("Hypervisor Capabilities id=" + hpvCapabilities.getId());
+ CallContext.current().setEventDetails("Hypervisor Capabilities id=" + hpvCapabilities.getId());
return hpvCapabilities;
} else {
return null;
@@ -4134,7 +4134,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
private VirtualMachine upgradeStoppedSystemVm(Long systemVmId, Long serviceOfferingId){
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(systemVmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
if (systemVm == null) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index a807a90..a1ac495 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -47,6 +47,7 @@ import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaint
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
+import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
@@ -147,7 +148,6 @@ import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.User;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.NumbersUtil;
@@ -785,7 +785,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
"unable to find zone by id " + zoneId);
}
// Check if zone is disabled
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
if (Grouping.AllocationState.Disabled == zone.getAllocationState()
&& !_accountMgr.isRootAdmin(account.getType())) {
throw new PermissionDeniedException(
@@ -1372,9 +1372,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
public PrimaryDataStoreInfo preparePrimaryStorageForMaintenance(
Long primaryStorageId) throws ResourceUnavailableException,
InsufficientCapacityException {
- Long userId = UserContext.current().getCallingUserId();
+ Long userId = CallContext.current().getCallingUserId();
User user = _userDao.findById(userId);
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
boolean restart = true;
StoragePoolVO primaryStorage = null;
@@ -1425,9 +1425,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
CancelPrimaryStorageMaintenanceCmd cmd)
throws ResourceUnavailableException {
Long primaryStorageId = cmd.getId();
- Long userId = UserContext.current().getCallingUserId();
+ Long userId = CallContext.current().getCallingUserId();
User user = _userDao.findById(userId);
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
StoragePoolVO primaryStorage = null;
primaryStorage = _storagePoolDao.findById(primaryStorageId);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StoragePoolAutomationImpl.java b/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
index 8b23628..6154a3b 100644
--- a/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
+++ b/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
@@ -25,6 +25,7 @@ import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
+import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
@@ -44,7 +45,6 @@ import com.cloud.storage.dao.StoragePoolWorkDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.user.Account;
import com.cloud.user.User;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.ConsoleProxyVO;
@@ -101,9 +101,9 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
@Override
public boolean maintain(DataStore store) {
- Long userId = UserContext.current().getCallingUserId();
+ Long userId = CallContext.current().getCallingUserId();
User user = _userDao.findById(userId);
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
StoragePoolVO pool = primaryDataStoreDao.findById(store.getId());
try {
StoragePool storagePool = (StoragePool) store;
@@ -257,9 +257,9 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
@Override
public boolean cancelMaintain(DataStore store) {
// Change the storage state back to up
- Long userId = UserContext.current().getCallingUserId();
+ Long userId = CallContext.current().getCallingUserId();
User user = _userDao.findById(userId);
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
StoragePoolVO poolVO = primaryDataStoreDao.findById(store.getId());
StoragePool pool = (StoragePool)store;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index b9cb453..3284eb3 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -47,6 +47,7 @@ import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UpdateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
+import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@@ -146,7 +147,6 @@ import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.ResourceLimitService;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.uservm.UserVm;
@@ -374,7 +374,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume", async = true)
public VolumeVO uploadVolume(UploadVolumeCmd cmd)
throws ResourceAllocationException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
long ownerId = cmd.getEntityOwnerId();
Account owner = _accountDao.findById(ownerId);
Long zoneId = cmd.getZoneId();
@@ -746,7 +746,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
// TODO Auto-generated catch block
e.printStackTrace();
}
- UserContext.current().setEventDetails("Volume Id: " + volume.getId());
+ CallContext.current().setEventDetails("Volume Id: " + volume.getId());
// Increment resource count during allocation; if actual creation fails,
// decrement it
@@ -816,7 +816,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
public VolumeVO allocVolume(CreateVolumeCmd cmd)
throws ResourceAllocationException {
// FIXME: some of the scheduled event stuff might be missing here...
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
long ownerId = cmd.getEntityOwnerId();
Boolean displayVolumeEnabled = cmd.getDisplayVolume();
@@ -1000,7 +1000,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
_usageEventDao.persist(usageEvent);
}
- UserContext.current().setEventDetails("Volume Id: " + volume.getId());
+ CallContext.current().setEventDetails("Volume Id: " + volume.getId());
// Increment resource count during allocation; if actual creation fails,
// decrement it
@@ -1134,7 +1134,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
if (newDiskOffering.getDomainId() == null) {
// do nothing as offering is public
} else {
- _configMgr.checkDiskOfferingAccess(UserContext.current()
+ _configMgr.checkDiskOfferingAccess(CallContext.current()
.getCallingAccount(), newDiskOffering);
}
@@ -1163,7 +1163,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
}
/* does the caller have the authority to act on this volume? */
- _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true,
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true,
volume);
UserVmVO userVm = _userVmDao.findById(volume.getInstanceId());
@@ -1616,7 +1616,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
Long vmId = command.getVirtualMachineId();
Long volumeId = command.getId();
Long deviceId = command.getDeviceId();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
// Check that the volume ID is valid
VolumeInfo volume = volFactory.getVolume(volumeId);
@@ -1813,7 +1813,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
@Override
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_DETACH, eventDescription = "detaching volume", async = true)
public Volume detachVolumeFromVM(DetachVolumeCmd cmmd) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
if ((cmmd.getId() == null && cmmd.getDeviceId() == null && cmmd
.getVirtualMachineId() == null)
|| (cmmd.getId() != null && (cmmd.getDeviceId() != null || cmmd
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
index 3f7c190..1d85652 100755
--- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
+++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
@@ -31,6 +31,8 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
+import org.apache.cloudstack.context.CallContext;
+
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
@@ -103,7 +105,6 @@ import com.cloud.storage.template.TemplateConstants;
import com.cloud.user.Account;
import com.cloud.user.AccountService;
import com.cloud.user.User;
-import com.cloud.user.UserContext;
import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
@@ -1209,7 +1210,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
//release elastic IP here
IPAddressVO ip = _ipAddressDao.findByAssociatedVmId(profile.getId());
if (ip != null && ip.getSystem()) {
- UserContext ctx = UserContext.current();
+ CallContext ctx = CallContext.current();
try {
_rulesMgr.disableStaticNat(ip.getId(), ctx.getCallingAccount(), ctx.getCallingUserId(), true);
} catch (Exception ex) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 0237769..6e218f8 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -31,6 +31,7 @@ import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd;
+import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
@@ -108,7 +109,6 @@ import com.cloud.user.AccountVO;
import com.cloud.user.DomainManager;
import com.cloud.user.ResourceLimitService;
import com.cloud.user.User;
-import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.DateUtil;
import com.cloud.utils.DateUtil.IntervalType;
@@ -272,7 +272,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
boolean backedUp = false;
// does the caller have the authority to act on this volume
- _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, volume);
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
SnapshotInfo snap = this.snapshotFactory.getSnapshot(snapshotId);
@@ -459,7 +459,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
}
private Long getSnapshotUserId() {
- Long userId = UserContext.current().getCallingUserId();
+ Long userId = CallContext.current().getCallingUserId();
if (userId == null) {
return User.UID_SYSTEM;
}
@@ -508,7 +508,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
@DB
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_DELETE, eventDescription = "deleting snapshot", async = true)
public boolean deleteSnapshot(long snapshotId) {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
// Verify parameters
SnapshotInfo snapshotCheck = this.snapshotFactory.getSnapshot(snapshotId);
@@ -575,14 +575,14 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
String zoneType = cmd.getZoneType();
Map<String, String> tags = cmd.getTags();
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
// Verify parameters
if (volumeId != null) {
VolumeVO volume = _volsDao.findById(volumeId);
if (volume != null) {
- _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, volume);
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
}
}
@@ -777,7 +777,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
throw new InvalidParameterValueException("Failed to create snapshot policy, unable to find a volume with id " + volumeId);
}
- _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, volume);
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
if (volume.getState() != Volume.State.Ready) {
throw new InvalidParameterValueException("VolumeId: " + volumeId + " is not in " + Volume.State.Ready + " state but " + volume.getState() + ". Cannot take snapshot.");
@@ -875,7 +875,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
if (volume == null) {
throw new InvalidParameterValueException("Unable to find a volume with id " + volumeId);
}
- _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, volume);
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
Pair<List<SnapshotPolicyVO>, Integer> result = _snapshotPolicyDao.listAndCountByVolumeId(volumeId);
return new Pair<List<? extends SnapshotPolicy>, Integer>(result.first(), result.second());
}
@@ -912,7 +912,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
public List<SnapshotScheduleVO> findRecurringSnapshotSchedule(ListRecurringSnapshotScheduleCmd cmd) {
Long volumeId = cmd.getVolumeId();
Long policyId = cmd.getSnapshotPolicyId();
- Account account = UserContext.current().getCallingAccount();
+ Account account = CallContext.current().getCallingAccount();
// Verify parameters
VolumeVO volume = _volsDao.findById(volumeId);
@@ -971,7 +971,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
@Override
public SnapshotVO allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException {
- Account caller = UserContext.current().getCallingAccount();
+ Account caller = CallContext.current().getCallingAccount();
VolumeVO volume = _volsDao.findById(volumeId);
if (volume == null) {
@@ -1111,7 +1111,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
throw new InvalidParameterValueException("Policy id given: " + policy + " does not belong to a valid volume");
}
- _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, volume);
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
}
boolean success = true;