Account account = new Account(); Contact contact = new Contact(); account.addToContact(contact); em.persist(account); em.flush(); assertNotNull(account.getId()); assertNotNull(account.getContacts().get(0).getId()); assertEquals(1, account.getContacts().size()); account.removeFromContact(contact); em.merge(account); em.flush(); assertEquals(0, account.getContacts().size());
@Override public long getEntityOwnerId() { Account activeAccountByName = _accountService.getActiveAccountByName(accountName, domainId); if (activeAccountByName != null) { return activeAccountByName.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; }
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; }
private void enableUserInCloudStack(UserAccount user) { if(user != null && (user.getState().equalsIgnoreCase(Account.State.disabled.toString()))) { _accountManager.enableUser(user.getId()); } }
private void disableUserInCloudStack(UserAccount user) { if (user != null) { _accountManager.disableUser(user.getId()); } }
@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; } });
private void resourceCountIncrement(long accountId, Boolean displayVm, Long cpu, Long memory) { _resourceLimitMgr.incrementResourceCount(accountId, ResourceType.user_vm, displayVm); _resourceLimitMgr.incrementResourceCount(accountId, ResourceType.cpu, displayVm, cpu); _resourceLimitMgr.incrementResourceCount(accountId, ResourceType.memory, displayVm, memory); }
private void resourceLimitCheck(Account owner, Boolean displayVm, Long cpu, Long memory) throws ResourceAllocationException { _resourceLimitMgr.checkResourceLimit(owner, ResourceType.user_vm, displayVm); _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, displayVm, cpu); _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, displayVm, memory); }
private void resourceCountDecrement(long accountId, Boolean displayVm, Long cpu, Long memory) { _resourceLimitMgr.decrementResourceCount(accountId, ResourceType.user_vm, displayVm); _resourceLimitMgr.decrementResourceCount(accountId, ResourceType.cpu, displayVm, cpu); _resourceLimitMgr.decrementResourceCount(accountId, ResourceType.memory, displayVm, memory); }
/** * {@inheritDoc} */ @Override public Account enableAccount(String accountName, Long domainId, Long accountId) { return _accountMgr.enableAccount(accountName, domainId, accountId); }
/** * {@inheritDoc} */ @Override public boolean deleteUser(DeleteUserCmd cmd) { return _accountMgr.deleteUser(cmd); }
/** * {@inheritDoc} */ @Override public UserAccount updateUser(UpdateUserCmd cmd) { return _accountMgr.updateUser(cmd); }
/** * {@inheritDoc} */ @Override public boolean deleteUserAccount(long accountId) { return _accountMgr.deleteUserAccount(accountId); }
/** * {@inheritDoc} */ @Override public Account updateAccount(UpdateAccountCmd cmd) { return _accountMgr.updateAccount(cmd); }
@Override public long getEntityOwnerId() { return _accountService.getActiveAccountByName(accountName, domainId).getAccountId(); }
@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; }
private void removeUserInCloudStack(UserAccount user) { if (user != null) { _accountManager.disableUser(user.getId()); } }