cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject [08/17] git commit: updated refs/heads/resize-root to caf9de6
Date Tue, 04 Mar 2014 21:27:43 GMT
Revert "CLOUDSTACK-5872: Async response from addAccountToProject doesn't contain useful information"

This reverts commit ebcaec8632dbd92c071317f3190915244a287afb.
Reverting as it breaks API compatibility


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

Branch: refs/heads/resize-root
Commit: fd43cf151663c48fe29f97323490d53a7c0f9d5b
Parents: 6726b7f
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Mar 3 12:44:08 2014 -0800
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Mar 3 12:44:08 2014 -0800

----------------------------------------------------------------------
 api/src/com/cloud/projects/ProjectService.java  |  6 ++--
 .../user/account/AddAccountToProjectCmd.java    |  7 ++--
 .../account/DeleteAccountFromProjectCmd.java    |  7 ++--
 .../project/UpdateProjectInvitationCmd.java     |  8 ++---
 .../src/com/cloud/projects/ProjectManager.java  |  2 +-
 .../com/cloud/projects/ProjectManagerImpl.java  | 34 ++++++++++----------
 .../cloud/projects/MockProjectManagerImpl.java  | 16 ++++-----
 7 files changed, 38 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd43cf15/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 53dd44b..dc882ef 100644
--- a/api/src/com/cloud/projects/ProjectService.java
+++ b/api/src/com/cloud/projects/ProjectService.java
@@ -69,11 +69,11 @@ public interface ProjectService {
 
     Project updateProject(long id, String displayText, String newOwnerName) throws ResourceAllocationException;
 
-    Project addAccountToProject(long projectId, String accountName, String email);
+    boolean addAccountToProject(long projectId, String accountName, String email);
 
-    Project deleteAccountFromProject(long projectId, String accountName);
+    boolean deleteAccountFromProject(long projectId, String accountName);
 
-    Project updateInvitation(long projectId, String accountName, String token, boolean accept);
+    boolean updateInvitation(long projectId, String accountName, String token, boolean accept);
 
     Project activateProject(long projectId);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd43cf15/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java
b/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java
index 8372b05..ef36038 100644
--- a/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java
@@ -88,10 +88,9 @@ public class AddAccountToProjectCmd extends BaseAsyncCmd {
         }
 
         CallContext.current().setEventDetails("Project id: " + projectId + "; accountName
" + accountName);
-        Project project = _projectService.addAccountToProject(getProjectId(), getAccountName(),
getEmail());
-        if (project != null) {
-            ProjectResponse response = _responseGenerator.createProjectResponse(project);
-            response.setResponseName(getCommandName());
+        boolean result = _projectService.addAccountToProject(getProjectId(), getAccountName(),
getEmail());
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
             this.setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add account
to the project");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd43cf15/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java
b/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java
index 4c6721a..5c89173 100644
--- a/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java
@@ -77,10 +77,9 @@ public class DeleteAccountFromProjectCmd extends BaseAsyncCmd {
     @Override
     public void execute() {
         CallContext.current().setEventDetails("Project id: " + projectId + "; accountName
" + accountName);
-        Project project = _projectService.deleteAccountFromProject(projectId, accountName);
-        if (project != null) {
-            ProjectResponse response = _responseGenerator.createProjectResponse(project);
-            response.setResponseName(getCommandName());
+        boolean result = _projectService.deleteAccountFromProject(projectId, accountName);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
             this.setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete account
from the project");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd43cf15/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java
b/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java
index 0ceb4ac..79e3f8a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java
@@ -16,7 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.project;
 
-import com.cloud.projects.Project;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
@@ -95,10 +94,9 @@ public class UpdateProjectInvitationCmd extends BaseAsyncCmd {
     @Override
     public void execute() {
         CallContext.current().setEventDetails("Project id: " + projectId + "; accountName
" + accountName + "; accept " + getAccept());
-        Project project = _projectService.updateInvitation(projectId, accountName, token,
getAccept());
-        if (project != null) {
-            ProjectResponse response = _responseGenerator.createProjectResponse(project);
-            response.setResponseName(getCommandName());
+        boolean result = _projectService.updateInvitation(projectId, accountName, token,
getAccept());
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
             this.setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to join the
project");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd43cf15/server/src/com/cloud/projects/ProjectManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/ProjectManager.java b/server/src/com/cloud/projects/ProjectManager.java
index 538104b..f568146 100644
--- a/server/src/com/cloud/projects/ProjectManager.java
+++ b/server/src/com/cloud/projects/ProjectManager.java
@@ -25,7 +25,7 @@ public interface ProjectManager extends ProjectService {
 
     boolean canModifyProjectAccount(Account caller, long accountId);
 
-    Project deleteAccountFromProject(long projectId, long accountId);
+    boolean deleteAccountFromProject(long projectId, long accountId);
 
     List<Long> listPermittedProjectAccounts(long accountId);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd43cf15/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 a3c7eda..5a0ed1c 100755
--- a/server/src/com/cloud/projects/ProjectManagerImpl.java
+++ b/server/src/com/cloud/projects/ProjectManagerImpl.java
@@ -373,10 +373,10 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager
{
 
     @Override
     @DB
-    public Project deleteAccountFromProject(final long projectId, final long accountId) {
-        return Transaction.execute(new TransactionCallback<Project>() {
+    public boolean deleteAccountFromProject(final long projectId, final long accountId) {
+        return Transaction.execute(new TransactionCallback<Boolean>() {
             @Override
-            public Project doInTransaction(TransactionStatus status) {
+            public Boolean doInTransaction(TransactionStatus status) {
                 boolean success = true;
 
                 //remove account
@@ -392,7 +392,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager
{
                     }
                 }
 
-                return success ? getProject(projectAccount.getProjectId()) : null;
+                return success;
             }
         });
     }
@@ -514,7 +514,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager
{
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_PROJECT_ACCOUNT_ADD, eventDescription = "adding
account to project", async = true)
-    public Project addAccountToProject(long projectId, String accountName, String email)
{
+    public boolean addAccountToProject(long projectId, String accountName, String email)
{
         Account caller = CallContext.current().getCallingAccount();
 
         //check that the project exists
@@ -556,7 +556,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager
{
             ProjectAccount projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId,
account.getId());
             if (projectAccount != null) {
                 s_logger.debug("Account " + accountName + " already added to the project
id=" + projectId);
-                return project;
+                return true;
             }
         }
 
@@ -567,21 +567,21 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager
{
                 throw new InvalidParameterValueException("Account information is required
for assigning account to the project");
             }
             if (assignAccountToProject(project, account.getId(), ProjectAccount.Role.Regular)
!= null) {
-                return project;
+                return true;
             } else {
                 s_logger.warn("Failed to add account " + accountName + " to project id="
+ projectId);
-                return null;
+                return false;
             }
         }
     }
 
-    private Project inviteAccountToProject(Project project, Account account, String email)
{
+    private boolean inviteAccountToProject(Project project, Account account, String email)
{
         if (account != null) {
             if (createAccountInvitation(project, account.getId()) != null) {
-                return project;
+                return true;
             } else {
                 s_logger.warn("Failed to generate invitation for account " + account.getAccountName()
+ " to project id=" + project);
-                return null;
+                return false;
             }
         }
 
@@ -589,19 +589,19 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager
{
             //generate the token
             String token = generateToken(10);
             if (generateTokenBasedInvitation(project, email, token) != null) {
-                return project;
+                return true;
             } else {
                 s_logger.warn("Failed to generate invitation for email " + email + " to project
id=" + project);
-                return null;
+                return false;
             }
         }
 
-        return null;
+        return false;
     }
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_PROJECT_ACCOUNT_REMOVE, eventDescription =
"removing account from project", async = true)
-    public Project deleteAccountFromProject(long projectId, String accountName) {
+    public boolean deleteAccountFromProject(long projectId, String accountName) {
         Account caller = CallContext.current().getCallingAccount();
 
         //check that the project exists
@@ -725,7 +725,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager
{
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_PROJECT_INVITATION_UPDATE, eventDescription
= "updating project invitation", async = true)
-    public Project updateInvitation(final long projectId, String accountName, String token,
final boolean accept) {
+    public boolean updateInvitation(final long projectId, String accountName, String token,
final boolean accept) {
         Account caller = CallContext.current().getCallingAccount();
         Long accountId = null;
         boolean result = true;
@@ -806,7 +806,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager
{
             throw new InvalidParameterValueException("Unable to find invitation for account
name=" + accountName + " to the project id=" + projectId);
         }
 
-        return result ? project : null;
+        return result;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd43cf15/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 7afd671..dc377ff 100644
--- a/server/test/com/cloud/projects/MockProjectManagerImpl.java
+++ b/server/test/com/cloud/projects/MockProjectManagerImpl.java
@@ -87,21 +87,21 @@ public class MockProjectManagerImpl extends ManagerBase implements ProjectManage
     }
 
     @Override
-    public Project addAccountToProject(long projectId, String accountName, String email)
{
+    public boolean addAccountToProject(long projectId, String accountName, String email)
{
         // TODO Auto-generated method stub
-        return null;
+        return false;
     }
 
     @Override
-    public Project deleteAccountFromProject(long projectId, String accountName) {
+    public boolean deleteAccountFromProject(long projectId, String accountName) {
         // TODO Auto-generated method stub
-        return null;
+        return false;
     }
 
     @Override
-    public Project updateInvitation(long projectId, String accountName, String token, boolean
accept) {
+    public boolean updateInvitation(long projectId, String accountName, String token, boolean
accept) {
         // TODO Auto-generated method stub
-        return null;
+        return false;
     }
 
     @Override
@@ -165,9 +165,9 @@ public class MockProjectManagerImpl extends ManagerBase implements ProjectManage
     }
 
     @Override
-    public Project deleteAccountFromProject(long projectId, long accountId) {
+    public boolean deleteAccountFromProject(long projectId, long accountId) {
         // TODO Auto-generated method stub
-        return null;
+        return false;
     }
 
     @Override


Mime
View raw message