@Override public AccountVO getSystemAccount() { if (_systemAccount == null) { _systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM); } return _systemAccount; }
@Override public Account getActiveAccountById(long accountId) { return _accountDao.findById(accountId); }
public static long findCorrectResourceLimit(ResourceType type, long accountId) { AccountVO account = s_accountDao.findById(accountId); if (account == null) { return -1; } return s_resourceLimitMgr.findCorrectResourceLimitForAccount(account, type); }
public static long getResourceCount(ResourceType type, long accountId) { AccountVO account = s_accountDao.findById(accountId); if (account == null) { return -1; } return s_resourceLimitMgr.getResourceCount(account, type); }
@Override public boolean isNormalUser(long accountId) { AccountVO acct = _accountDao.findById(accountId); if (acct != null && acct.getType() == Account.ACCOUNT_TYPE_NORMAL) { return true; } return false; }
@Override public String getAccountNetworkDomain(long accountId, long zoneId) { String networkDomain = _accountDao.findById(accountId).getNetworkDomain(); if (networkDomain == null) { // get domain level network domain return getDomainNetworkDomain(_accountDao.findById(accountId).getDomainId(), zoneId); } return networkDomain; }
@Override public boolean checkAccess(User user, ControlledEntity entity) throws PermissionDeniedException { Account account = _accountDao.findById(user.getAccountId()); return checkAccess(account, entity, null); }
public boolean isInternalAccount(long accountId) { Account account = _accountDao.findById(accountId); if (account == null) { return false; //account is deleted or does not exist } if (isRootAdmin(accountId) || (account.getType() == Account.ACCOUNT_ID_SYSTEM)) { return true; } return false; }
@Override public boolean moveUser(long id, Long domainId, long accountId) { UserVO user = getValidUserVO(id); Account oldAccount = _accountDao.findById(user.getAccountId()); checkAccountAndAccess(user, oldAccount); Account newAccount = _accountDao.findById(accountId); checkIfNotMovingAcrossDomains(domainId, newAccount); return moveUser(user, accountId); }
private ProjectVO getProject(long accountId) { Account account = _accountDao.findById(accountId); if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) { return _projectDao.findByProjectAccountId(account.getId()); } return null; }
@Override public String getProjectName(long accountId) { Account account = _accountDao.findById(accountId); if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) { ProjectVO project = _projectDao.findByProjectAccountId(account.getId()); if (project != null) { return project.getName(); } } return VNC_DEFAULT_PROJECT; }
@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); }
@Override public List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName) { Account caller = CallContext.current().getCallingAccount(); Account owner = _accountDao.findById(vpnOwnerId); _accountMgr.checkAccess(caller, null, true, owner); return _vpnUsersDao.listByAccount(vpnOwnerId); }
private void checkAccountAndDomain(Long accountId, Long domainId) { DomainVO domain = _domainDao.findById(domainId); if (domain == null) { throw new InvalidParameterValueException("Unable to find the domain by id " + domainId + ", please specify valid domainId"); } //check if account belongs to the domain id if (accountId != null) { AccountVO account = _accountDao.findById(accountId); if (account == null || domainId != account.getDomainId()) { throw new InvalidParameterValueException("Please specify the domain id of the account id " + accountId); } } }
@Override public SecurityGroupVO createDefaultSecurityGroup(Long accountId) { SecurityGroupVO groupVO = _securityGroupDao.findByAccountAndName(accountId, SecurityGroupManager.DEFAULT_GROUP_NAME); if (groupVO == null) { Account accVO = _accountDao.findById(accountId); if (accVO != null) { return createSecurityGroup(SecurityGroupManager.DEFAULT_GROUP_NAME, SecurityGroupManager.DEFAULT_GROUP_DESCRIPTION, accVO.getDomainId(), accVO.getId(), accVO.getAccountName()); } } return groupVO; }
private boolean addTemplateToZone(VMTemplateVO template, long dstZoneId, long sourceZoneid) throws ResourceAllocationException{ long tmpltId = template.getId(); DataCenterVO dstZone = _dcDao.findById(dstZoneId); DataCenterVO sourceZone = _dcDao.findById(sourceZoneid); AccountVO account = _accountDao.findById(template.getAccountId()); _resourceLimitMgr.checkResourceLimit(account, ResourceType.template); try { _tmpltDao.addTemplateToZone(template, dstZoneId); return true; } catch (Exception ex) { s_logger.debug("failed to copy template from Zone: " + sourceZone.getUuid() + " to Zone: " + dstZone.getUuid()); } return false; }
@Override @ActionEvent(eventType = EventTypes.EVENT_USER_DELETE, eventDescription = "deleting User") public boolean deleteUser(DeleteUserCmd deleteUserCmd) { UserVO user = getValidUserVO(deleteUserCmd.getId()); Account account = _accountDao.findById(user.getAccountId()); // don't allow to delete the user from the account of type Project checkAccountAndAccess(user, account); return _userDao.remove(deleteUserCmd.getId()); }
private long getCreateSolidFireAccountId(SolidFireUtil.SolidFireConnection sfConnection, long csAccountId, long storagePoolId) { AccountDetailVO accountDetail = SolidFireUtil.getAccountDetail(csAccountId, storagePoolId, accountDetailsDao); if (accountDetail == null || accountDetail.getValue() == null) { AccountVO account = accountDao.findById(csAccountId); String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId()); SolidFireUtil.SolidFireAccount sfAccount = SolidFireUtil.getAccount(sfConnection, sfAccountName); if (sfAccount == null) { sfAccount = createSolidFireAccount(sfConnection, sfAccountName); } SolidFireUtil.updateCsDbWithSolidFireAccountInfo(account.getId(), sfAccount, storagePoolId, accountDetailsDao); accountDetail = SolidFireUtil.getAccountDetail(csAccountId, storagePoolId, accountDetailsDao); } return Long.parseLong(accountDetail.getValue()); }
@Override @ActionEvent(eventType = EventTypes.EVENT_USER_MOVE, eventDescription = "moving User to a new account") public boolean moveUser(MoveUserCmd cmd) { final Long id = cmd.getId(); UserVO user = getValidUserVO(id); Account oldAccount = _accountDao.findById(user.getAccountId()); checkAccountAndAccess(user, oldAccount); long domainId = oldAccount.getDomainId(); long newAccountId = getNewAccountId(domainId, cmd.getAccountName(), cmd.getAccountId()); return moveUser(user, newAccountId); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateTakeVolumeSnapshot(VmWorkTakeVolumeSnapshot work) throws Exception { Account account = _accountDao.findById(work.getAccountId()); orchestrateTakeVolumeSnapshot(work.getVolumeId(), work.getPolicyId(), work.getSnapshotId(), account, work.isQuiesceVm(), work.getLocationType(), work.isAsyncBackup()); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(work.getSnapshotId())); }