Search in sources :

Example 6 with UserResponse

use of org.apache.cloudstack.api.response.UserResponse in project cloudstack by apache.

the class CreateUserCmd method execute.

@Override
public void execute() {
    validateParams();
    CallContext.current().setEventDetails("UserName: " + getUserName() + ", FirstName :" + getFirstName() + ", LastName: " + getLastName());
    User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId(), getUserUUID());
    if (user != null) {
        UserResponse response = _responseGenerator.createUserResponse(user);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user");
    }
}
Also used : UserResponse(org.apache.cloudstack.api.response.UserResponse) User(com.cloud.user.User) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 7 with UserResponse

use of org.apache.cloudstack.api.response.UserResponse in project cloudstack by apache.

the class DisableUserCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("UserId: " + getId());
    UserAccount user = _regionService.disableUser(this);
    if (user != null) {
        UserResponse response = _responseGenerator.createUserResponse(user);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable user");
    }
}
Also used : UserResponse(org.apache.cloudstack.api.response.UserResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) UserAccount(com.cloud.user.UserAccount)

Example 8 with UserResponse

use of org.apache.cloudstack.api.response.UserResponse in project cloudstack by apache.

the class GetUserCmd method execute.

@Override
public void execute() {
    UserAccount result = _accountService.getUserByApiKey(getApiKey());
    if (result != null) {
        UserResponse response = _responseGenerator.createUserResponse(result);
        response.setResponseName(getCommandName());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new InvalidParameterValueException("User with specified API key does not exist");
    }
}
Also used : UserResponse(org.apache.cloudstack.api.response.UserResponse) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) UserAccount(com.cloud.user.UserAccount)

Example 9 with UserResponse

use of org.apache.cloudstack.api.response.UserResponse in project cloudstack by apache.

the class ListUsersCmd method updateUserResponse.

private void updateUserResponse(List<UserResponse> response) {
    for (UserResponse userResponse : response) {
        ResourceIcon resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.User, userResponse.getObjectId());
        if (resourceIcon == null) {
            resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.Account, userResponse.getAccountId());
            if (resourceIcon == null) {
                continue;
            }
        }
        ResourceIconResponse iconResponse = _responseGenerator.createResourceIconResponse(resourceIcon);
        userResponse.setResourceIconResponse(iconResponse);
    }
}
Also used : UserResponse(org.apache.cloudstack.api.response.UserResponse) ResourceIconResponse(org.apache.cloudstack.api.response.ResourceIconResponse) ResourceIcon(com.cloud.server.ResourceIcon)

Example 10 with UserResponse

use of org.apache.cloudstack.api.response.UserResponse in project cloudstack by apache.

the class UpdateUserCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("UserId: " + getId());
    UserAccount user = _regionService.updateUser(this);
    if (user != null) {
        UserResponse response = _responseGenerator.createUserResponse(user);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update user");
    }
}
Also used : UserResponse(org.apache.cloudstack.api.response.UserResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) UserAccount(com.cloud.user.UserAccount)

Aggregations

UserResponse (org.apache.cloudstack.api.response.UserResponse)20 LdapUserResponse (org.apache.cloudstack.api.response.LdapUserResponse)8 UserAccount (com.cloud.user.UserAccount)5 ServerApiException (org.apache.cloudstack.api.ServerApiException)5 UserAccountJoinVO (com.cloud.api.query.vo.UserAccountJoinVO)3 ArrayList (java.util.ArrayList)3 AccountResponse (org.apache.cloudstack.api.response.AccountResponse)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)1 ResourceIcon (com.cloud.server.ResourceIcon)1 Account (com.cloud.user.Account)1 User (com.cloud.user.User)1 List (java.util.List)1 Role (org.apache.cloudstack.acl.Role)1 ResourceIconResponse (org.apache.cloudstack.api.response.ResourceIconResponse)1 LdapUser (org.apache.cloudstack.ldap.LdapUser)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1