incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: CLOUDSTACK-84: fixed NPE that used to happen on API layer when list resource of the project was called when project was going through removal process.
Date Fri, 05 Oct 2012 21:32:34 GMT
Updated Branches:
  refs/heads/4.0 735def2c5 -> d5b86d814


CLOUDSTACK-84: fixed NPE that used to happen on API layer when list resource of the project
was called when project was going through removal process.


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

Branch: refs/heads/4.0
Commit: d5b86d8149454f9cc174cd6a29d3fe2603a7dd93
Parents: 735def2
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Fri Oct 5 14:20:22 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Fri Oct 5 14:23:48 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/projects/ProjectService.java     |    2 ++
 server/src/com/cloud/api/ApiDBUtils.java           |    4 ++++
 server/src/com/cloud/api/ApiResponseHelper.java    |    8 ++++----
 .../src/com/cloud/projects/ProjectManagerImpl.java |    5 +++++
 server/src/com/cloud/projects/dao/ProjectDao.java  |    2 ++
 .../src/com/cloud/projects/dao/ProjectDaoImpl.java |    8 ++++++++
 6 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d5b86d81/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 c792f26..5834f1c 100644
--- a/api/src/com/cloud/projects/ProjectService.java
+++ b/api/src/com/cloud/projects/ProjectService.java
@@ -93,4 +93,6 @@ public interface ProjectService {
     Project enableProject(long projectId);
 
     boolean deleteProjectInvitation(long invitationId);
+    
+    Project findByProjectAccountIdIncludingRemoved(long projectAccountId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d5b86d81/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 7126931..3fac7a7 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -733,6 +733,10 @@ public class ApiDBUtils {
         return _projectMgr.findByProjectAccountId(projectAccountId);
     }
     
+    public static Project findProjectByProjectAccountIdIncludingRemoved(long projectAccountId)
{
+        return _projectMgr.findByProjectAccountIdIncludingRemoved(projectAccountId);
+    }
+    
     public static Project findProjectById(long projectId) {
         return _projectMgr.getProject(projectId);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d5b86d81/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 b20aede..2b6a31b 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2746,7 +2746,7 @@ public class ApiResponseHelper implements ResponseGenerator {
                 regularAccounts.add(accountName);
             } else {
                 // convert account to projectIds
-                Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
+                Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
 
                 if (project.getUuid() != null && !project.getUuid().isEmpty())
                     projectIds.add(project.getUuid());
@@ -3343,7 +3343,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
             // find the project
-            Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
+            Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
             response.setProjectId(project.getId());
             response.setProjectName(project.getName());
         } else {
@@ -3359,7 +3359,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         Account account = ApiDBUtils.findAccountByIdIncludingRemoved(accountId);
         if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
             // find the project
-            Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
+            Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
             response.setProjectId(project.getId());
             response.setProjectName(project.getName());
         } else {
@@ -3670,7 +3670,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
             if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
                 // find the project
-                Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
+                Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
                 response.setProjectId(project.getId());
                 response.setProjectName(project.getName());
             } else {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d5b86d81/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 7371201..77b778e 100755
--- a/server/src/com/cloud/projects/ProjectManagerImpl.java
+++ b/server/src/com/cloud/projects/ProjectManagerImpl.java
@@ -516,6 +516,11 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
     }
     
     @Override
+    public ProjectVO findByProjectAccountIdIncludingRemoved(long projectAccountId) {
+        return _projectDao.findByProjectAccountIdIncludingRemoved(projectAccountId);
+    }
+    
+    @Override
     public Project findByNameAndDomainId(String name, long domainId) {
         return _projectDao.findByNameAndDomain(name, domainId);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d5b86d81/server/src/com/cloud/projects/dao/ProjectDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectDao.java b/server/src/com/cloud/projects/dao/ProjectDao.java
index 045d6ca..e741f24 100644
--- a/server/src/com/cloud/projects/dao/ProjectDao.java
+++ b/server/src/com/cloud/projects/dao/ProjectDao.java
@@ -31,5 +31,7 @@ public interface ProjectDao extends GenericDao<ProjectVO, Long> {
     ProjectVO findByProjectAccountId(long projectAccountId);
 
     List<ProjectVO> listByState(Project.State state);
+    
+    ProjectVO findByProjectAccountIdIncludingRemoved(long projectAccountId);
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d5b86d81/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectDaoImpl.java b/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
index e194876..81e170a 100644
--- a/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
+++ b/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
@@ -108,4 +108,12 @@ public class ProjectDaoImpl extends GenericDaoBase<ProjectVO, Long>
implements P
         sc.setParameters("state", state);
         return listBy(sc);
     }
+    
+    @Override
+    public ProjectVO findByProjectAccountIdIncludingRemoved(long projectAccountId) {
+        SearchCriteria<ProjectVO> sc = AllFieldsSearch.create();
+        sc.setParameters("projectAccountId", projectAccountId);
+
+        return findOneIncludingRemovedBy(sc);
+    }
 }


Mime
View raw message