incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: Refactor ListProjectInvitationsCmd and ProjectInvitationResponse.
Date Wed, 12 Dec 2012 17:16:37 GMT
Updated Branches:
  refs/heads/api_refactoring 3661f7f99 -> 472f4f91b


Refactor ListProjectInvitationsCmd and ProjectInvitationResponse.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/472f4f91
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/472f4f91
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/472f4f91

Branch: refs/heads/api_refactoring
Commit: 472f4f91b9af18802d34e3a8631441b1752c18f3
Parents: 3661f7f
Author: Min Chen <min.chen@citrix.com>
Authored: Tue Dec 11 22:36:25 2012 -0800
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Wed Dec 12 09:04:43 2012 -0800

----------------------------------------------------------------------
 api/src/com/cloud/projects/ProjectService.java     |    3 +-
 .../apache/cloudstack/api/ResponseGenerator.java   |    3 +
 .../user/project/ListProjectInvitationsCmd.java    |   12 +-
 .../api/response/ProjectInvitationResponse.java    |   20 +-
 .../api/view/vo/ProjectInvitationJoinVO.java       |  232 +++++++++++++++
 server/src/com/cloud/api/ApiDBUtils.java           |   15 +
 server/src/com/cloud/api/ApiResponseHelper.java    |   27 +-
 .../configuration/DefaultComponentLibrary.java     |    2 +
 .../src/com/cloud/projects/ProjectManagerImpl.java |   20 +-
 .../projects/dao/ProjectInvitationJoinDao.java     |   29 ++
 .../projects/dao/ProjectInvitationJoinDaoImpl.java |   86 ++++++
 .../com/cloud/projects/MockProjectManagerImpl.java |    3 +-
 setup/db/create-schema.sql                         |   24 ++
 13 files changed, 435 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/api/src/com/cloud/projects/ProjectService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/projects/ProjectService.java b/api/src/com/cloud/projects/ProjectService.java
index 1e58a9b..0f58ef9 100644
--- a/api/src/com/cloud/projects/ProjectService.java
+++ b/api/src/com/cloud/projects/ProjectService.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index 97fd6d9..ccdf93c 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java
b/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java
index 206a9a9..6b6a7a7 100644
--- a/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java
@@ -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());
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/api/src/org/apache/cloudstack/api/response/ProjectInvitationResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/ProjectInvitationResponse.java b/api/src/org/apache/cloudstack/api/response/ProjectInvitationResponse.java
index 80202a5..1c616d1 100644
--- a/api/src/org/apache/cloudstack/api/response/ProjectInvitationResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/ProjectInvitationResponse.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/api/src/org/apache/cloudstack/api/view/vo/ProjectInvitationJoinVO.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/vo/ProjectInvitationJoinVO.java b/api/src/org/apache/cloudstack/api/view/vo/ProjectInvitationJoinVO.java
new file mode 100644
index 0000000..b33df04
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/vo/ProjectInvitationJoinVO.java
@@ -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;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 459df8d..d5cce52 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -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);
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 604df81..1e2b87d 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -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());
+        ProjectInvitationJoinVO vInvite = ApiDBUtils.newProjectInvitationView(invite);
+        return ApiDBUtils.newProjectInvitationResponse(vInvite);
+    }
 
-        } else {
-            response.setEmail(invite.getEmail());
-        }
 
-        populateDomain(response, invite.getInDomainId());
 
-        response.setObjectName("projectinvitation");
-        return response;
+    @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();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index 0dcdfd2..2dd46fd 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -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");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/server/src/com/cloud/projects/ProjectManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/ProjectManagerImpl.java b/server/src/com/cloud/projects/ProjectManagerImpl.java
index c84395d..7c97af2 100755
--- a/server/src/com/cloud/projects/ProjectManagerImpl.java
+++ b/server/src/com/cloud/projects/ProjectManagerImpl.java
@@ -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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/server/src/com/cloud/projects/dao/ProjectInvitationJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectInvitationJoinDao.java b/server/src/com/cloud/projects/dao/ProjectInvitationJoinDao.java
new file mode 100644
index 0000000..2ee7de0
--- /dev/null
+++ b/server/src/com/cloud/projects/dao/ProjectInvitationJoinDao.java
@@ -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);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/server/src/com/cloud/projects/dao/ProjectInvitationJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectInvitationJoinDaoImpl.java b/server/src/com/cloud/projects/dao/ProjectInvitationJoinDaoImpl.java
new file mode 100644
index 0000000..0ee0ef8
--- /dev/null
+++ b/server/src/com/cloud/projects/dao/ProjectInvitationJoinDaoImpl.java
@@ -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);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/server/test/com/cloud/projects/MockProjectManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/projects/MockProjectManagerImpl.java b/server/test/com/cloud/projects/MockProjectManagerImpl.java
index 6529d12..3911ceb 100644
--- a/server/test/com/cloud/projects/MockProjectManagerImpl.java
+++ b/server/test/com/cloud/projects/MockProjectManagerImpl.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/472f4f91/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index 8e8c448..9891371 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -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;


Mime
View raw message