use of com.cloud.api.response.UserResponse in project CloudStack-archive by CloudStack-extras.
the class CreateUserCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("UserName: " + getUserName() + ", FirstName :" + getFirstName() + ", LastName: " + getLastName());
User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId());
if (user != null) {
UserResponse response = _responseGenerator.createUserResponse(user);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a user");
}
}
use of com.cloud.api.response.UserResponse in project CloudStack-archive by CloudStack-extras.
the class UpdateUserCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("UserId: " + getId());
UserAccount user = _accountService.updateUser(this);
if (user != null) {
UserResponse response = _responseGenerator.createUserResponse(user);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update user");
}
}
use of com.cloud.api.response.UserResponse in project CloudStack-archive by CloudStack-extras.
the class ListUsersCmd method execute.
@Override
public void execute() {
List<? extends UserAccount> result = _accountService.searchForUsers(this);
ListResponse<UserResponse> response = new ListResponse<UserResponse>();
List<UserResponse> userResponses = new ArrayList<UserResponse>();
for (UserAccount user : result) {
UserResponse userResponse = _responseGenerator.createUserResponse(user);
userResponses.add(userResponse);
}
response.setResponses(userResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.UserResponse in project cosmic by MissionCriticalCloud.
the class GetUserCmd method execute.
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final UserAccount result = _accountService.getUserByApiKey(getApiKey());
if (result != null) {
final UserResponse response = _responseGenerator.createUserResponse(result);
if (StringUtils.isNotBlank(response.getSecretKey())) {
response.setSecretKey("SecretKey only visible when generating a new key");
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new InvalidParameterValueException("User with specified API key does not exist");
}
}
use of com.cloud.api.response.UserResponse in project cosmic by MissionCriticalCloud.
the class ListUsersCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final ListResponse<UserResponse> response = _queryService.searchForUsers(this);
response.setResponseName(getCommandName());
List<UserResponse> responseList = response.getResponses();
if (responseList != null && responseList.size() > 0) {
for (UserResponse userResponse : responseList) {
if (StringUtils.isNotBlank(userResponse.getSecretKey())) {
userResponse.setSecretKey("SecretKey only visible when generating a new key");
}
}
}
this.setResponseObject(response);
}
Aggregations