public ProjectAccountVO(Project project, long accountId, Role accountRole) { this.accountId = accountId; this.accountRole = accountRole; this.projectId = project.getId(); this.projectAccountId = project.getProjectAccountId(); }
@Override public String getProjectCanonicalName(ProjectVO project) { return project.getName(); }
public static Account getProjectOwner(long projectId) { return s_projectMgr.getProjectOwner(projectId); }
public ProjectInvitation generateTokenBasedInvitation(Project project, String email, String token) { //verify if the invitation was already generated if (activeInviteExists(project, null, email)) { throw new InvalidParameterValueException("There is already a pending invitation for email " + email + " to the project id=" + project); } ProjectInvitation projectInvitation = _projectInvitationDao.persist(new ProjectInvitationVO(project.getId(), null, project.getDomainId(), email, token)); try { _emailInvite.sendInvite(token, email, project.getId()); } catch (Exception ex) { s_logger.warn("Failed to send project id=" + project + " invitation to the email " + email + "; removing the invitation record from the db", ex); _projectInvitationDao.remove(projectInvitation.getId()); return null; } return projectInvitation; }
@Override public Boolean doInTransaction(TransactionStatus status) { boolean result = true; s_logger.debug("Unassigning all accounts from project " + project + " as a part of project cleanup..."); List<? extends ProjectAccount> projectAccounts = _projectAccountDao.listByProjectId(project.getId()); for (ProjectAccount projectAccount : projectAccounts) { result = result && unassignAccountFromProject(projectAccount.getProjectId(), projectAccount.getAccountId()); } s_logger.debug("Removing all invitations for the project " + project + " as a part of project cleanup..."); _projectInvitationDao.cleanupInvitations(project.getId()); return result; } });
public ProjectInvitation createAccountInvitation(Project project, Long accountId) { if (activeInviteExists(project, accountId, null)) { throw new InvalidParameterValueException("There is already a pending invitation for account id=" + accountId + " to the project id=" + project); } ProjectInvitation invitation = _projectInvitationDao.persist(new ProjectInvitationVO(project.getId(), accountId, project.getDomainId(), null, null)); return invitation; }
@Override public void create() throws ResourceAllocationException { CallContext.current().setEventDetails("Project Name: " + getName()); Project project = _projectService.createProject(getName(), getDisplayText(), getAccountName(), getDomainId()); if (project != null) { this.setEntityId(project.getId()); this.setEntityUuid(project.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a project"); } }
@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(); }
public static Project findProjectById(long projectId) { return s_projectMgr.getProject(projectId); }
@Override public void doInTransactionWithoutResult(TransactionStatus status) { project.setState(Project.State.Active); _projectDao.update(projectId, project); _accountMgr.enableAccount(project.getProjectAccountId()); } });
@Override public Boolean doInTransaction(TransactionStatus status) { s_logger.debug("Marking project id=" + project.getId() + " with state " + State.Disabled + " as a part of project delete..."); project.setState(State.Disabled); boolean updateResult = _projectDao.update(project.getId(), project); //owner can be already removed at this point, so adding the conditional check Account projectOwner = getProjectOwner(project.getId()); if (projectOwner != null) { _resourceLimitMgr.decrementResourceCount(projectOwner.getId(), ResourceType.project); } return updateResult; } });
@Override @ActionEvent(eventType = EventTypes.EVENT_PROJECT_DELETE, eventDescription = "deleting project", async = true) public boolean deleteProject(long projectId) { CallContext ctx = CallContext.current(); ProjectVO project = getProject(projectId); //verify input parameters if (project == null) { throw new InvalidParameterValueException("Unable to find project by id " + projectId); } _accountMgr.checkAccess(ctx.getCallingAccount(), AccessType.ModifyProject, true, _accountMgr.getAccount(project.getProjectAccountId())); return deleteProject(ctx.getCallingAccount(), ctx.getCallingUserId(), project); }
public static Project findProjectByProjectAccountId(long projectAccountId) { return s_projectMgr.findByProjectAccountId(projectAccountId); }
@Override public ProjectAccount assignAccountToProject(Project project, long accountId, ProjectAccount.Role accountRole) { return _projectAccountDao.persist(new ProjectAccountVO(project, accountId, accountRole)); }
@Override public Account getProjectOwner(long projectId) { ProjectAccount prAcct = _projectAccountDao.getProjectOwner(projectId); if (prAcct != null) { return _accountMgr.getAccount(prAcct.getAccountId()); } return null; }
public static Project findProjectByProjectAccountIdIncludingRemoved(long projectAccountId) { return s_projectMgr.findByProjectAccountIdIncludingRemoved(projectAccountId); }
@Override public boolean start() { _executor.scheduleWithFixedDelay(new ExpiredInvitationsCleanup(), _projectCleanupExpInvInterval, _projectCleanupExpInvInterval, TimeUnit.SECONDS); return true; }
public static long getProjectOwnwerId(long projectId) { return s_projectMgr.getProjectOwner(projectId).getId(); }