@Override public long getAccountId() { return _caller.getAccountId(); }
@Override public Boolean doInTransaction(TransactionStatus status) { boolean success = doSetUserStatus(userId, State.enabled); // make sure the account is enabled too success = success && enableAccount(user.getAccountId()); return success; } });
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
public long getEntityOwnerId(){ User user = _entityMgr.findById(User.class, getID()); if(user != null){ return user.getAccountId(); } else return Account.ACCOUNT_ID_SYSTEM; } public void execute(){
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public boolean checkAccess(User user, ControlledEntity entity) throws PermissionDeniedException { Account account = _accountDao.findById(user.getAccountId()); return checkAccess(account, entity, null); }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public String getEventDescription() { User user = _responseGenerator.findUserById(getId()); return (user != null ? ("deleting User " + user.getUsername() + " (id: " + user.getId() + ") and accountId = " + user.getAccountId()) : "user delete, but this user does not exist in the system"); }
@Override public boolean checkAccess(User user, Domain domain) throws PermissionDeniedException { if (user.getRemoved() != null) { throw new PermissionDeniedException(user + " is no longer active."); } Account account = _accountDao.findById(user.getAccountId()); return checkAccess(account, domain); }
public boolean verifyUser(Long userId) { // copy from ApiServer.java, a bit ugly here User user = _accountMgr.getUserIncludingRemoved(userId); Account account = null; if (user != null) { account = _accountMgr.getAccount(user.getAccountId()); } if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled) || (account == null) || !account.getState().equals(Account.State.enabled)) { s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API"); return false; } return true; }
@Override public boolean verifyUser(final Long userId) { final User user = accountMgr.getUserIncludingRemoved(userId); Account account = null; if (user != null) { account = accountMgr.getAccount(user.getAccountId()); } if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled) || (account == null) || !account.getState().equals(Account.State.enabled)) { s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API"); return false; } return true; }
@Override public boolean destroy(final Network config, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(config.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { return true; } boolean result = true; // NOTE that we need to pass caller account to destroyRouter, otherwise // it will fail permission check there. Context passed in from // deleteNetwork is the network account, // not caller account final Account callerAccount = _accountMgr.getAccount(context.getCaller().getAccountId()); for (final DomainRouterVO router : routers) { result = result && _routerMgr.destroyRouter(router.getId(), callerAccount, context.getCaller().getId()) != null; } return result; }
public long getAccountId() { if (accountId != null) { return accountId; } Account account = null; if (autoscaleUserId != null) { User user = _entityMgr.findById(User.class, autoscaleUserId); account = _entityMgr.findById(Account.class, user.getAccountId()); } else { account = CallContext.current().getCallingAccount(); } accountId = account.getAccountId(); domainId = account.getDomainId(); return accountId; }
@Override public void execute() { User callerUser = _accountService.getActiveUser(CallContext.current().getCallingUserId()); Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId()); Vpc result = _networkService.migrateVpcNetwork(getId(), getVpcOfferingId(), getTierNetworkOfferings(), callerAccount, callerUser, getResume()); if (result != null) { VpcResponse response = _responseGenerator.createVpcResponse(ResponseObject.ResponseView.Restricted, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate vpc"); } }
@Override public void execute() { User callerUser = _accountService.getActiveUser(CallContext.current().getCallingUserId()); Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId()); Network network = _networkService.getNetwork(id); if (network == null) { throw new InvalidParameterValueException("Couldn't find network by id"); } Network result = _networkService.migrateGuestNetwork(getId(), getNetworkOfferingId(), callerAccount, callerUser, getResume()); if (result != null) { NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Restricted, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network"); } }
@Override public void execute() throws InsufficientCapacityException, ConcurrentOperationException{ User callerUser = _accountService.getActiveUser(CallContext.current().getCallingUserId()); Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId()); Network network = _networkService.getNetwork(id); if (network == null) { throw new InvalidParameterValueException("Couldn't find network by id"); } Network result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr(), getDisplayNetwork(), getCustomId(), getUpdateInSequence(),getForced()); if (result != null) { NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network"); } }