bug 8847: createUser api - "account" parameter is required now

status 8847: resolved fixed
This commit is contained in:
alena 2011-03-09 10:19:12 -08:00
parent 670afd2331
commit 5129df106b
2 changed files with 8 additions and 3 deletions

View File

@ -40,7 +40,7 @@ public class CreateUserCmd extends BaseCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="Creates the user under the specified account. If no account is specified, the username will be used as the account name.")
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, required=true, description="Creates the user under the specified account. If no account is specified, the username will be used as the account name.")
private String accountName;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="Creates the user under the specified domain. Has to be accompanied with the account parameter")

View File

@ -1101,10 +1101,15 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
String timeZone = cmd.getTimezone();
Long accountId = null;
//default domain to ROOT if not specified
if (domainId == null) {
domainId = Domain.ROOT_DOMAIN;
}
Account account = _accountDao.findActiveAccount(accountName, domainId);
if( account == null){
throw new InvalidParameterValueException("Unable to find account to create user");
if(account == null){
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain id=" + domainId + " to create user");
}else{
accountId = account.getAccountId();
}