Search in sources :

Example 16 with UserResponse

use of com.cloud.api.response.UserResponse in project cosmic by MissionCriticalCloud.

the class CreateUserCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    validateParams();
    CallContext.current().setEventDetails("UserName: " + getUserName() + ", FirstName :" + getFirstName() + ", LastName: " + getLastName());
    final User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId(), getUserUUID());
    if (user != null) {
        final 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(com.cloud.api.response.UserResponse) User(com.cloud.user.User) ServerApiException(com.cloud.api.ServerApiException)

Example 17 with UserResponse

use of com.cloud.api.response.UserResponse in project cosmic by MissionCriticalCloud.

the class DisableUserCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("UserId: " + getId());
    final UserAccount user = _regionService.disableUser(this);
    if (user != null) {
        final 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(com.cloud.api.response.UserResponse) ServerApiException(com.cloud.api.ServerApiException) UserAccount(com.cloud.user.UserAccount)

Example 18 with UserResponse

use of com.cloud.api.response.UserResponse in project cosmic by MissionCriticalCloud.

the class EnableUserCmd method execute.

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

Example 19 with UserResponse

use of com.cloud.api.response.UserResponse in project cosmic by MissionCriticalCloud.

the class LockUserCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final UserAccount user = _accountService.lockUser(getId());
    if (user != null) {
        final UserResponse response = _responseGenerator.createUserResponse(user);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to lock user");
    }
}
Also used : UserResponse(com.cloud.api.response.UserResponse) ServerApiException(com.cloud.api.ServerApiException) UserAccount(com.cloud.user.UserAccount)

Aggregations

UserResponse (com.cloud.api.response.UserResponse)19 ServerApiException (com.cloud.api.ServerApiException)10 UserAccount (com.cloud.user.UserAccount)10 ListResponse (com.cloud.api.response.ListResponse)3 Test (org.junit.Test)3 User (com.cloud.user.User)2 ListUsersCmd (com.cloud.api.command.admin.user.ListUsersCmd)1 UserAccountJoinVO (com.cloud.api.query.vo.UserAccountJoinVO)1 AccountResponse (com.cloud.api.response.AccountResponse)1 LdapUserResponse (com.cloud.api.response.LdapUserResponse)1 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)1 ArrayList (java.util.ArrayList)1