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());
protected LogContext(User user, Account account, String logContextId) { this.user = user; userId = user.getId(); this.account = account; accountId = account.getId(); this.logContextId = logContextId; }
@Override public void onPublishMessage(String senderAddress, String subject, Object args) { try { final Account account = accountDao.findByIdIncludingRemoved((Long) args); if(!removeUserAccount(account)) { LOG.warn(String.format("Failed to remove account to Cloudian while removing CloudStack account=%s, id=%s", account.getAccountName(), account.getId())); } } catch (final Exception e) { LOG.error("Caught exception while removing account in Cloudian: ", e); } } });
@Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); if (account != null) { return account.getId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccount().getId(); } }
@Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); if (account != null) { return account.getId(); } return Account.ACCOUNT_ID_SYSTEM; }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccount().getId(); } }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccount().getId(); } }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccount().getId(); } }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccount().getId(); } }
@Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); if (account != null) { return account.getId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); if (account != null) { return account.getId(); } return Account.ACCOUNT_ID_SYSTEM; }
@Override public long getEntityOwnerId() { Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true); if (accountId == null) { accountId = CallContext.current().getCallingAccount().getId(); } return accountId; }
@Override public long getEntityOwnerId() { Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } return accountId; }
@Override public long getEntityOwnerId() { Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } return accountId; }
@Override public long getEntityOwnerId() { Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } return accountId; }
@Override public long getEntityOwnerId() { Project project = _projectService.getProject(id); //verify input parameters if (project == null) { throw new InvalidParameterValueException("Unable to find project by id " + id); } return _projectService.getProjectOwner(id).getId(); }
@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 GlobalLoadBalancerRuleVO doInTransaction(TransactionStatus status) { GlobalLoadBalancerRuleVO newGslbRule = new GlobalLoadBalancerRuleVO(name, description, domainName, algorithm, stickyMethod, serviceType, regionId, gslbOwner.getId(), gslbOwner.getDomainId(), GlobalLoadBalancerRule.State.Staged); _gslbRuleDao.persist(newGslbRule); UsageEventUtils.publishUsageEvent(EventTypes.EVENT_GLOBAL_LOAD_BALANCER_CREATE, newGslbRule.getAccountId(), 0, newGslbRule.getId(), name, GlobalLoadBalancerRule.class.getName(), newGslbRule.getUuid()); return newGslbRule; } });
@Override public PublicIp assignSourceNatIpAddressToVpc(final Account owner, final Vpc vpc) throws InsufficientAddressCapacityException, ConcurrentOperationException { final long dcId = vpc.getZoneId(); final IPAddressVO sourceNatIp = getExistingSourceNatInVpc(owner.getId(), vpc.getId()); PublicIp ipToReturn = null; if (sourceNatIp != null) { ipToReturn = PublicIp.createFromAddrAndVlan(sourceNatIp, _vlanDao.findById(sourceNatIp.getVlanId())); } else { ipToReturn = _ipAddrMgr.assignDedicateIpAddress(owner, null, vpc.getId(), dcId, true); } return ipToReturn; }