Search in sources :

Example 11 with UserResponse

use of com.cloud.api.response.UserResponse in project CloudStack-archive by CloudStack-extras.

the class LockUserCmd method execute.

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

Example 12 with UserResponse

use of com.cloud.api.response.UserResponse in project CloudStack-archive by CloudStack-extras.

the class DisableUserCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("UserId: " + getId());
    UserAccount user = _accountService.disableUser(getId());
    if (user != null) {
        UserResponse response = _responseGenerator.createUserResponse(user);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.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 13 with UserResponse

use of com.cloud.api.response.UserResponse in project CloudStack-archive by CloudStack-extras.

the class EnableUserCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("UserId: " + getId());
    UserAccount user = _accountService.enableUser(getId());
    if (user != null) {
        UserResponse response = _responseGenerator.createUserResponse(user);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.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 14 with UserResponse

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

the class ListUsersCmdTest method testExecuteWithDefault.

@Test
public void testExecuteWithDefault() {
    final String secretKey = "Very secret key";
    ListResponse<UserResponse> responseList = new ListResponse<>();
    UserResponse response = new UserResponse();
    response.setSecretKey(secretKey);
    responseList.setResponses(Arrays.asList(response));
    when(queryService.searchForUsers(listUsersCmd)).thenReturn(responseList);
    listUsersCmd.execute();
    responseList = (ListResponse) listUsersCmd.getResponseObject();
    response = responseList.getResponses().get(0);
    assertFalse("SecretKey was revealed in ResponseObject, wasn't masked", secretKey.equals(response.getSecretKey()));
}
Also used : UserResponse(com.cloud.api.response.UserResponse) ListResponse(com.cloud.api.response.ListResponse) Test(org.junit.Test)

Example 15 with UserResponse

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

the class UserAccountJoinDaoImpl method newUserResponse.

@Override
public UserResponse newUserResponse(final UserAccountJoinVO usr) {
    final UserResponse userResponse = new UserResponse();
    userResponse.setAccountId(usr.getAccountUuid());
    userResponse.setAccountName(usr.getAccountName());
    userResponse.setAccountType(usr.getAccountType());
    userResponse.setCreated(usr.getCreated());
    userResponse.setDomainId(usr.getDomainUuid());
    userResponse.setDomainName(usr.getDomainName());
    userResponse.setEmail(usr.getEmail());
    userResponse.setFirstname(usr.getFirstname());
    userResponse.setId(usr.getUuid());
    userResponse.setLastname(usr.getLastname());
    userResponse.setState(usr.getState().toString());
    userResponse.setTimezone(usr.getTimezone());
    userResponse.setUsername(usr.getUsername());
    userResponse.setApiKey(usr.getApiKey());
    userResponse.setIsDefault(usr.isDefault());
    if (StringUtils.isNotBlank(usr.getSecretKey())) {
        userResponse.setSecretKey("SecretKey only visible when generating a new key");
    } else {
        userResponse.setSecretKey(usr.getSecretKey());
    }
    // set async job
    if (usr.getJobId() != null) {
        userResponse.setJobId(usr.getJobUuid());
        userResponse.setJobStatus(usr.getJobStatus());
    }
    userResponse.setObjectName("user");
    return userResponse;
}
Also used : UserResponse(com.cloud.api.response.UserResponse)

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