use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.
the class UpdateAccountCmd method execute.
@Override
public void execute() {
Account result = _accountService.updateAccount(this);
if (result != null) {
AccountResponse response = _responseGenerator.createAccountResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account");
}
}
use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.
the class EnableAccountCmd method execute.
@Override
public void execute() {
Account result = _accountService.enableAccount(getAccountName(), getDomainId(), getId());
if (result != null) {
AccountResponse response = _responseGenerator.createAccountResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable account");
}
}
use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.
the class ListAccountsCmd method execute.
@Override
public void execute() {
List<? extends Account> accounts = _accountService.searchForAccounts(this);
ListResponse<AccountResponse> response = new ListResponse<AccountResponse>();
List<AccountResponse> accountResponses = new ArrayList<AccountResponse>();
for (Account account : accounts) {
AccountResponse acctResponse = _responseGenerator.createAccountResponse(account);
acctResponse.setObjectName("account");
accountResponses.add(acctResponse);
}
response.setResponses(accountResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.
the class CreateAccountCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId());
UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), getDomainId(), getNetworkDomain(), getDetails());
if (userAccount != null) {
AccountResponse response = _responseGenerator.createUserAccountResponse(userAccount);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a user account");
}
}
use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.
the class DisableAccountCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
UserContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId());
Account result = null;
if (lockRequested)
result = _accountService.lockAccount(getAccountName(), getDomainId(), getId());
else
result = _accountService.disableAccount(getAccountName(), getDomainId(), getId());
if (result != null) {
AccountResponse response = _responseGenerator.createAccountResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account");
}
}
Aggregations