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");
}
}
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");
}
}
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");
}
}
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()));
}
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;
}
Aggregations