use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.
the class ApiDBUtils method newAccountResponse.
public static AccountResponse newAccountResponse(ResponseView view, AccountJoinVO ve) {
AccountResponse response = s_accountJoinDao.newAccountResponse(view, ve);
// Populate account role information
if (ve.getRoleId() != null) {
Role role = s_roleService.findRole(ve.getRoleId());
if (role != null) {
response.setRoleId(role.getUuid());
response.setRoleType(role.getRoleType());
response.setRoleName(role.getName());
}
}
return response;
}
use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.
the class LdapCreateAccountCmd method execute.
@Override
public void execute() throws ServerApiException {
if (getAccountType() == null && getRoleId() == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Both account type and role ID are not provided");
}
final CallContext callContext = getCurrentContext();
String finalAccountName = getAccountName();
Long finalDomainId = getDomainId();
callContext.setEventDetails("Account Name: " + finalAccountName + ", Domain Id:" + finalDomainId);
try {
final LdapUser user = _ldapManager.getUser(username);
validateUser(user);
final UserAccount userAccount = createCloudstackUserAccount(user, finalAccountName, finalDomainId);
if (userAccount != null) {
final AccountResponse response = _responseGenerator.createUserAccountResponse(ResponseView.Full, userAccount);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user account");
}
} catch (NoLdapUserMatchingQueryException e) {
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, "No LDAP user exists with the username of " + username);
}
}
use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.
the class DisableAccountCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
CallContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId());
Account result = _regionService.disableAccount(this);
if (result != null) {
AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account");
}
}
use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.
the class EnableAccountCmd method execute.
@Override
public void execute() {
Account result = _regionService.enableAccount(this);
if (result != null) {
AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable account");
}
}
Aggregations