@Override public Boolean doInTransaction(TransactionStatus status) { boolean result = true; ProjectInvitation.State newState = accept ? ProjectInvitation.State.Completed : ProjectInvitation.State.Declined; //update invitation s_logger.debug("Marking invitation " + inviteFinal + " with state " + newState); inviteFinal.setState(newState); result = _projectInvitationDao.update(inviteFinal.getId(), inviteFinal); if (result && accept) { //check if account already exists for the project (was added before invitation got accepted) ProjectAccount projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, accountIdFinal); if (projectAccount != null) { s_logger.debug("Account " + accountNameFinal + " already added to the project id=" + projectId); } else { assignAccountToProject(project, accountIdFinal, ProjectAccount.Role.Regular); } } else { s_logger.warn("Failed to update project invitation " + inviteFinal + " with state " + newState); } return result; } });
@Override public Project doInTransaction(TransactionStatus status) { //Create an account associated with the project StringBuilder acctNm = new StringBuilder("PrjAcct-"); acctNm.append(name).append("-").append(ownerFinal.getDomainId()); Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.ACCOUNT_TYPE_PROJECT, null, domainId, null, null, UUID.randomUUID().toString()); Project project = _projectDao.persist(new ProjectVO(name, displayText, ownerFinal.getDomainId(), projectAccount.getId())); //assign owner to the project assignAccountToProject(project, ownerFinal.getId(), ProjectAccount.Role.Admin); if (project != null) { CallContext.current().setEventDetails("Project id=" + project.getId()); CallContext.current().putContextParameter(Project.class, project.getUuid()); } //Increment resource count _resourceLimitMgr.incrementResourceCount(ownerFinal.getId(), ResourceType.project); return project; } });
throw new InvalidParameterValueException("Account information is required for assigning account to the project"); if (assignAccountToProject(project, account.getId(), ProjectAccount.Role.Regular) != null) { return true; } else {