Revert "CLOUDSTACK-5872: Async response from addAccountToProject doesn't contain useful information"

This reverts commit ebcaec8632.
Reverting as it breaks API compatibility
This commit is contained in:
Alena Prokharchyk 2014-03-03 12:44:08 -08:00
parent 6726b7fee0
commit fd43cf1516
7 changed files with 38 additions and 42 deletions

View File

@ -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);

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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);

View File

@ -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

View File

@ -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