mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Refactor ListProjectInvitationsCmd and ProjectInvitationResponse.
This commit is contained in:
parent
3661f7f992
commit
472f4f91b9
@ -20,6 +20,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
@ -85,7 +86,7 @@ public interface ProjectService {
|
||||
|
||||
Pair<List<ProjectAccountJoinVO>, Integer> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal);
|
||||
|
||||
Pair<List<? extends ProjectInvitation>, Integer> listProjectInvitations(Long id, Long projectId, String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive,
|
||||
Pair<List<ProjectInvitationJoinVO>, Integer> listProjectInvitations(Long id, Long projectId, String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive,
|
||||
boolean listAll);
|
||||
|
||||
boolean updateInvitation(long projectId, String accountName, String token, boolean accept);
|
||||
|
||||
@ -154,6 +154,7 @@ import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
@ -309,6 +310,8 @@ public interface ResponseGenerator {
|
||||
|
||||
ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite);
|
||||
|
||||
List<ProjectInvitationResponse> createProjectInvitationResponse(ProjectInvitationJoinVO... invites);
|
||||
|
||||
SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine systemVM);
|
||||
|
||||
SwiftResponse createSwiftResponse(Swift swift);
|
||||
|
||||
@ -28,6 +28,8 @@ import org.apache.cloudstack.api.Implementation;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
@ -83,15 +85,13 @@ public class ListProjectInvitationsCmd extends BaseListAccountResourcesCmd {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Pair<List<? extends ProjectInvitation>, Integer> invites = _projectService.listProjectInvitations(id, projectId,
|
||||
Pair<List<ProjectInvitationJoinVO>, Integer> invites = _projectService.listProjectInvitations(id, projectId,
|
||||
this.getAccountName(), this.getDomainId(), state, activeOnly, this.getStartIndex(), this.getPageSizeVal(),
|
||||
this.isRecursive(), this.listAll());
|
||||
ListResponse<ProjectInvitationResponse> response = new ListResponse<ProjectInvitationResponse>();
|
||||
List<ProjectInvitationResponse> projectInvitationResponses = new ArrayList<ProjectInvitationResponse>();
|
||||
for (ProjectInvitation invite : invites.first()) {
|
||||
ProjectInvitationResponse projectResponse = _responseGenerator.createProjectInvitationResponse(invite);
|
||||
projectInvitationResponses.add(projectResponse);
|
||||
}
|
||||
List<ProjectInvitationResponse> projectInvitationResponses =
|
||||
_responseGenerator.createProjectInvitationResponse(invites.first().toArray(new ProjectInvitationJoinVO[invites.first().size()]));
|
||||
|
||||
response.setResponses(projectInvitationResponses, invites.second());
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
|
||||
@ -23,18 +23,18 @@ import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ProjectInvitationResponse extends BaseResponse implements ControlledEntityResponse{
|
||||
public class ProjectInvitationResponse extends BaseResponse implements ControlledViewEntityResponse{
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the id of the invitation")
|
||||
private IdentityProxy id = new IdentityProxy("project_invitations");
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the id of the project")
|
||||
private IdentityProxy projectId = new IdentityProxy("projects");
|
||||
private String projectId;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT) @Param(description="the name of the project")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id the project belongs to")
|
||||
private IdentityProxy domainId = new IdentityProxy("domain");
|
||||
private String domainId;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name where the project belongs to")
|
||||
private String domainName;
|
||||
@ -48,20 +48,20 @@ public class ProjectInvitationResponse extends BaseResponse implements Controlle
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="the invitation state")
|
||||
private String invitationState;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setProjectId(Long projectId) {
|
||||
this.projectId.setValue(projectId);
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId.setValue(domainId);
|
||||
public void setDomainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public void setDomainName(String domain) {
|
||||
|
||||
@ -0,0 +1,232 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.view.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
@Entity
|
||||
@Table(name="project_invitation_view")
|
||||
public class ProjectInvitationJoinVO extends BaseViewVO implements ControlledViewEntity {
|
||||
|
||||
@Column(name="id", updatable=false, nullable = false)
|
||||
private long id;
|
||||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name = "email")
|
||||
private String email;
|
||||
|
||||
@Column(name = "state")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private State state;
|
||||
|
||||
@Column(name = GenericDao.CREATED_COLUMN)
|
||||
private Date created;
|
||||
|
||||
@Column(name="account_id")
|
||||
private long accountId;
|
||||
|
||||
@Column(name="account_uuid")
|
||||
private String accountUuid;
|
||||
|
||||
@Column(name="account_name")
|
||||
private String accountName;
|
||||
|
||||
@Column(name="account_type")
|
||||
private short accountType;
|
||||
|
||||
@Column(name="domain_id")
|
||||
private long domainId;
|
||||
|
||||
@Column(name="domain_uuid")
|
||||
private String domainUuid;
|
||||
|
||||
@Column(name="domain_name")
|
||||
private String domainName;
|
||||
|
||||
@Column(name="domain_path")
|
||||
private String domainPath;
|
||||
|
||||
@Column(name="project_id")
|
||||
private long projectId;
|
||||
|
||||
@Column(name="project_uuid")
|
||||
private String projectUuid;
|
||||
|
||||
@Column(name="project_name")
|
||||
private String projectName;
|
||||
|
||||
public ProjectInvitationJoinVO() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomainUuid() {
|
||||
return domainUuid;
|
||||
}
|
||||
|
||||
public void setDomainUuid(String domainUuid) {
|
||||
this.domainUuid = domainUuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public long getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public void setProjectId(long projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectUuid() {
|
||||
return projectUuid;
|
||||
}
|
||||
|
||||
public void setProjectUuid(String projectUuid) {
|
||||
this.projectUuid = projectUuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccountUuid() {
|
||||
return accountUuid;
|
||||
}
|
||||
|
||||
public void setAccountUuid(String accountUuid) {
|
||||
this.accountUuid = accountUuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(short accountType) {
|
||||
this.accountType = accountType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomainPath() {
|
||||
return domainPath;
|
||||
}
|
||||
|
||||
public void setDomainPath(String domainPath) {
|
||||
this.domainPath = domainPath;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -27,6 +27,7 @@ import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
@ -36,6 +37,7 @@ import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
@ -118,8 +120,10 @@ import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectAccount;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.projects.ProjectService;
|
||||
import com.cloud.projects.dao.ProjectAccountJoinDao;
|
||||
import com.cloud.projects.dao.ProjectInvitationJoinDao;
|
||||
import com.cloud.projects.dao.ProjectJoinDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.Criteria;
|
||||
@ -270,6 +274,7 @@ public class ApiDBUtils {
|
||||
private static UserAccountJoinDao _userAccountJoinDao;
|
||||
private static ProjectJoinDao _projectJoinDao;
|
||||
private static ProjectAccountJoinDao _projectAccountJoinDao;
|
||||
private static ProjectInvitationJoinDao _projectInvitationJoinDao;
|
||||
|
||||
static {
|
||||
_ms = (ManagementServer) ComponentLocator.getComponent(ManagementServer.Name);
|
||||
@ -345,6 +350,7 @@ public class ApiDBUtils {
|
||||
_userAccountJoinDao = locator.getDao(UserAccountJoinDao.class);
|
||||
_projectJoinDao = locator.getDao(ProjectJoinDao.class);
|
||||
_projectAccountJoinDao = locator.getDao(ProjectAccountJoinDao.class);
|
||||
_projectInvitationJoinDao = locator.getDao(ProjectInvitationJoinDao.class);
|
||||
|
||||
|
||||
// Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
|
||||
@ -1052,4 +1058,13 @@ public class ApiDBUtils {
|
||||
return _projectAccountJoinDao.newProjectAccountView(proj);
|
||||
}
|
||||
|
||||
public static ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO proj) {
|
||||
return _projectInvitationJoinDao.newProjectInvitationResponse(proj);
|
||||
}
|
||||
|
||||
public static ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj) {
|
||||
return _projectInvitationJoinDao.newProjectInvitationView(proj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -117,6 +117,7 @@ import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
|
||||
import org.apache.cloudstack.api.view.vo.EventJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
|
||||
@ -2873,26 +2874,22 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
|
||||
@Override
|
||||
public ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite) {
|
||||
ProjectInvitationResponse response = new ProjectInvitationResponse();
|
||||
response.setId(invite.getId());
|
||||
response.setProjectId(invite.getProjectId());
|
||||
response.setProjectName(ApiDBUtils.findProjectById(invite.getProjectId()).getName());
|
||||
response.setInvitationState(invite.getState().toString());
|
||||
|
||||
if (invite.getForAccountId() != null) {
|
||||
Account account = ApiDBUtils.findAccountById(invite.getForAccountId());
|
||||
response.setAccountName(account.getAccountName());
|
||||
|
||||
} else {
|
||||
response.setEmail(invite.getEmail());
|
||||
}
|
||||
|
||||
populateDomain(response, invite.getInDomainId());
|
||||
|
||||
response.setObjectName("projectinvitation");
|
||||
return response;
|
||||
ProjectInvitationJoinVO vInvite = ApiDBUtils.newProjectInvitationView(invite);
|
||||
return ApiDBUtils.newProjectInvitationResponse(vInvite);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ProjectInvitationResponse> createProjectInvitationResponse(ProjectInvitationJoinVO... invites) {
|
||||
List<ProjectInvitationResponse> respList = new ArrayList<ProjectInvitationResponse>();
|
||||
for (ProjectInvitationJoinVO v : invites){
|
||||
respList.add(ApiDBUtils.newProjectInvitationResponse(v));
|
||||
}
|
||||
return respList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine vm) {
|
||||
SystemVmInstanceResponse vmResponse = new SystemVmInstanceResponse();
|
||||
|
||||
@ -139,6 +139,7 @@ import com.cloud.projects.ProjectManagerImpl;
|
||||
import com.cloud.projects.dao.ProjectAccountDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectInvitationDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectInvitationJoinDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectJoinDaoImpl;
|
||||
import com.cloud.resource.ResourceManagerImpl;
|
||||
import com.cloud.resourcelimit.ResourceLimitManagerImpl;
|
||||
@ -233,6 +234,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
||||
addDao("UserAccountJoinDao", UserAccountJoinDaoImpl.class);
|
||||
addDao("ProjectJoinDao", ProjectJoinDaoImpl.class);
|
||||
addDao("ProjectAccountJoinDao", ProjectAccountJoinDaoImpl.class);
|
||||
addDao("ProjectInvitationJoinDao", ProjectInvitationJoinDaoImpl.class);
|
||||
ComponentInfo<? extends GenericDao<?, ? extends Serializable>> info = addDao("ServiceOfferingDao", ServiceOfferingDaoImpl.class);
|
||||
info.addParameter("cache.size", "50");
|
||||
info.addParameter("cache.time.to.live", "600");
|
||||
|
||||
@ -39,6 +39,7 @@ import javax.mail.internet.InternetAddress;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
|
||||
import org.apache.log4j.Logger;
|
||||
@ -64,6 +65,7 @@ import com.cloud.projects.dao.ProjectAccountDao;
|
||||
import com.cloud.projects.dao.ProjectAccountJoinDao;
|
||||
import com.cloud.projects.dao.ProjectDao;
|
||||
import com.cloud.projects.dao.ProjectInvitationDao;
|
||||
import com.cloud.projects.dao.ProjectInvitationJoinDao;
|
||||
import com.cloud.projects.dao.ProjectJoinDao;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.tags.ResourceTagVO;
|
||||
@ -127,6 +129,8 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
||||
@Inject
|
||||
private ProjectInvitationDao _projectInvitationDao;
|
||||
@Inject
|
||||
private ProjectInvitationJoinDao _projectInvitationJoinDao;
|
||||
@Inject
|
||||
protected ResourceTagDao _resourceTagDao;
|
||||
|
||||
protected boolean _invitationRequired = false;
|
||||
@ -875,7 +879,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<? extends ProjectInvitation>, Integer> listProjectInvitations(Long id, Long projectId,
|
||||
public Pair<List<ProjectInvitationJoinVO>, Integer> listProjectInvitations(Long id, Long projectId,
|
||||
String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive, boolean listAll) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
@ -886,17 +890,17 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
||||
isRecursive = domainIdRecursiveListProject.second();
|
||||
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
|
||||
|
||||
Filter searchFilter = new Filter(ProjectInvitationVO.class, "id", true, startIndex, pageSizeVal);
|
||||
SearchBuilder<ProjectInvitationVO> sb = _projectInvitationDao.createSearchBuilder();
|
||||
_accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
Filter searchFilter = new Filter(ProjectInvitationJoinVO.class, "id", true, startIndex, pageSizeVal);
|
||||
SearchBuilder<ProjectInvitationJoinVO> sb = _projectInvitationJoinDao.createSearchBuilder();
|
||||
_accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
sb.and("projectId", sb.entity().getProjectId(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||
sb.and("created", sb.entity().getCreated(), SearchCriteria.Op.GT);
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
|
||||
SearchCriteria<ProjectInvitationVO> sc = sb.create();
|
||||
_accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
SearchCriteria<ProjectInvitationJoinVO> sc = sb.create();
|
||||
_accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
|
||||
if (projectId != null){
|
||||
@ -916,8 +920,8 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
||||
sc.setParameters("created", new Date((DateUtil.currentGMTTime().getTime()) - _invitationTimeOut));
|
||||
}
|
||||
|
||||
Pair<List<ProjectInvitationVO>, Integer> result = _projectInvitationDao.searchAndCount(sc, searchFilter);
|
||||
return new Pair<List<? extends ProjectInvitation>, Integer>(result.first(), result.second());
|
||||
return _projectInvitationJoinDao.searchAndCount(sc, searchFilter);
|
||||
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.projects.dao;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface ProjectInvitationJoinDao extends GenericDao<ProjectInvitationJoinVO, Long> {
|
||||
|
||||
ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO proj);
|
||||
|
||||
ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj);
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.projects.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Local(value={ProjectInvitationJoinDao.class})
|
||||
public class ProjectInvitationJoinDaoImpl extends GenericDaoBase<ProjectInvitationJoinVO, Long> implements ProjectInvitationJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(ProjectInvitationJoinDaoImpl.class);
|
||||
|
||||
|
||||
private SearchBuilder<ProjectInvitationJoinVO> vrIdSearch;
|
||||
|
||||
protected ProjectInvitationJoinDaoImpl() {
|
||||
|
||||
vrIdSearch = createSearchBuilder();
|
||||
vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
vrIdSearch.done();
|
||||
|
||||
this._count = "select count(distinct id) from project_invitation_view WHERE ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO invite) {
|
||||
ProjectInvitationResponse response = new ProjectInvitationResponse();
|
||||
response.setId(invite.getUuid());
|
||||
response.setProjectId(invite.getProjectUuid());
|
||||
response.setProjectName(invite.getProjectName());
|
||||
response.setInvitationState(invite.getState().toString());
|
||||
|
||||
if (invite.getAccountName() != null) {
|
||||
response.setAccountName(invite.getAccountName());
|
||||
} else {
|
||||
response.setEmail(invite.getEmail());
|
||||
}
|
||||
|
||||
response.setDomainId(invite.getDomainUuid());
|
||||
response.setDomainName(invite.getDomainName());
|
||||
|
||||
response.setObjectName("projectinvitation");
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj) {
|
||||
SearchCriteria<ProjectInvitationJoinVO> sc = vrIdSearch.create();
|
||||
sc.setParameters("id", proj.getId());
|
||||
List<ProjectInvitationJoinVO> grps = searchIncludingRemoved(sc, null, null, false);
|
||||
assert grps != null && grps.size() == 1 : "No project invitation found for id " + proj.getId();
|
||||
return grps.get(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -23,6 +23,7 @@ import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
|
||||
import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
@ -116,7 +117,7 @@ public class MockProjectManagerImpl implements ProjectManager, Manager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<? extends ProjectInvitation>, Integer> listProjectInvitations(Long id,
|
||||
public Pair<List<ProjectInvitationJoinVO>, Integer> listProjectInvitations(Long id,
|
||||
Long projectId, String accountName, Long domainId, String state,
|
||||
boolean activeOnly, Long startIndex, Long pageSizeVal,
|
||||
boolean isRecursive, boolean listAll) {
|
||||
|
||||
@ -2944,3 +2944,27 @@ from project_account
|
||||
inner join account on project_account.account_id = account.id
|
||||
inner join domain on account.domain_id=domain.id
|
||||
inner join projects on projects.id = project_account.project_id;
|
||||
|
||||
DROP VIEW IF EXISTS `cloud`.`project_invitation_view`;
|
||||
CREATE VIEW project_invitation_view AS
|
||||
select
|
||||
project_invitations.id,
|
||||
project_invitations.uuid,
|
||||
project_invitations.email,
|
||||
project_invitations.created,
|
||||
project_invitations.state,
|
||||
projects.id project_id,
|
||||
projects.uuid project_uuid,
|
||||
projects.name project_name,
|
||||
account.id account_id,
|
||||
account.uuid account_uuid,
|
||||
account.account_name,
|
||||
account.type account_type,
|
||||
domain.id domain_id,
|
||||
domain.uuid domain_uuid,
|
||||
domain.name domain_name,
|
||||
domain.path domain_path
|
||||
from project_invitations
|
||||
left join account on project_invitations.account_id = account.id
|
||||
left join domain on project_invitations.domain_id=domain.id
|
||||
left join projects on projects.id = project_invitations.project_id;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user