mirror of https://github.com/apache/cloudstack.git
bug 12591: fixed updateDomain
status 12591: resolved fixed
This commit is contained in:
parent
c600f1b606
commit
4cb6fcc17a
|
|
@ -54,7 +54,7 @@ public class UpdateAccountCmd extends BaseCmd{
|
|||
@Parameter(name=ApiConstants.NEW_NAME, type=CommandType.STRING, required=true, description="new name for the account")
|
||||
private String newName;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the account's networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the account's networks; empty string will update domainName with NULL value")
|
||||
private String networkDomain;
|
||||
|
||||
@Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class UpdateDomainCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="updates domain with this name")
|
||||
private String domainName;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the domain's networks")
|
||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the domain's networks; empty string will update domainName with NULL value")
|
||||
private String networkDomain;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class UpdateZoneCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.DHCP_PROVIDER, type=CommandType.STRING, description="the dhcp Provider for the Zone")
|
||||
private String dhcpProvider;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN, type=CommandType.STRING, description="Network domain name for the networks in the zone")
|
||||
@Parameter(name=ApiConstants.DOMAIN, type=CommandType.STRING, description="Network domain name for the networks in the zone; empty string will update domain with NULL value")
|
||||
private String domain;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS_SEARCH_ORDER, type=CommandType.LIST, collectionType = CommandType.STRING, description="the dns search order list")
|
||||
|
|
|
|||
|
|
@ -1353,14 +1353,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
// validate network domain
|
||||
if (networkDomain != null) {
|
||||
if (networkDomain != null && !networkDomain.isEmpty()) {
|
||||
if (!NetUtils.verifyDomainName(networkDomain)) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
|
||||
+ "and the hyphen ('-'); can't start or end with \"-\"");
|
||||
}
|
||||
} else {
|
||||
networkDomain = zone.getDomain();
|
||||
}
|
||||
|
||||
boolean checkForDuplicates = !zoneName.equals(oldZoneName);
|
||||
|
|
@ -1380,7 +1378,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
zone.setDns2(dns2);
|
||||
zone.setInternalDns1(internalDns1);
|
||||
zone.setInternalDns2(internalDns2);
|
||||
zone.setDomain(networkDomain);
|
||||
|
||||
if (networkDomain != null) {
|
||||
if (networkDomain.isEmpty()) {
|
||||
zone.setDomain(null);
|
||||
} else {
|
||||
zone.setDomain(networkDomain);
|
||||
}
|
||||
}
|
||||
|
||||
// update a private zone to public; not vice versa
|
||||
if (isPublic != null && isPublic) {
|
||||
|
|
|
|||
|
|
@ -2155,13 +2155,15 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
sc.addAnd("name", SearchCriteria.Op.EQ, domainName);
|
||||
List<DomainVO> domains = _domainDao.search(sc, null);
|
||||
|
||||
if (!domains.isEmpty()) {
|
||||
boolean sameDomain = (domains.size() == 1 && domains.get(0).getId() == domainId);
|
||||
|
||||
if (!domains.isEmpty() && !sameDomain) {
|
||||
throw new InvalidParameterValueException("Failed to update domain id=" + domainId + "; domain with name " + domainName + " already exists in the system");
|
||||
}
|
||||
}
|
||||
|
||||
//validate network domain
|
||||
if (networkDomain != null){
|
||||
if (networkDomain != null && !networkDomain.isEmpty()){
|
||||
if (!NetUtils.verifyDomainName(networkDomain)) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
|
||||
|
|
@ -2181,7 +2183,11 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
if (networkDomain != null) {
|
||||
domain.setNetworkDomain(networkDomain);
|
||||
if (networkDomain.isEmpty()) {
|
||||
domain.setNetworkDomain(null);
|
||||
} else {
|
||||
domain.setNetworkDomain(networkDomain);
|
||||
}
|
||||
}
|
||||
_domainDao.update(domainId, domain);
|
||||
|
||||
|
|
|
|||
|
|
@ -1052,7 +1052,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @DB
|
||||
public AccountVO updateAccount(UpdateAccountCmd cmd) {
|
||||
Long accountId = cmd.getId();
|
||||
Long domainId = cmd.getDomainId();
|
||||
|
|
@ -1095,7 +1095,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
+ duplicateAcccount.getId());
|
||||
}
|
||||
|
||||
if (networkDomain != null) {
|
||||
if (networkDomain != null && !networkDomain.isEmpty()) {
|
||||
if (!NetUtils.verifyDomainName(networkDomain)) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
|
||||
|
|
@ -1107,15 +1107,24 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
acctForUpdate.setAccountName(newAccountName);
|
||||
|
||||
if (networkDomain != null) {
|
||||
acctForUpdate.setNetworkDomain(networkDomain);
|
||||
if (networkDomain.isEmpty()) {
|
||||
acctForUpdate.setNetworkDomain(null);
|
||||
} else {
|
||||
acctForUpdate.setNetworkDomain(networkDomain);
|
||||
}
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
success = _accountDao.update(account.getId(), acctForUpdate);
|
||||
|
||||
if (details != null) {
|
||||
if (details != null && success) {
|
||||
_accountDetailsDao.update(account.getId(), details);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
||||
if (success) {
|
||||
return _accountDao.findById(account.getId());
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue