listPublicIpAddresses - when do search by keyword, apply keyword to account search

This commit is contained in:
alena 2011-03-09 16:23:57 -08:00
parent 4f4683ec93
commit b5a36df966
1 changed files with 15 additions and 5 deletions

View File

@ -2431,6 +2431,7 @@ public class ManagementServerImpl implements ManagementServer {
Account account = UserContext.current().getCaller();
Long domainId = cmd.getDomainId();
String accountName = cmd.getAccountName();
Object keyword = cmd.getKeyword();
Long accountId = null;
@ -2448,13 +2449,20 @@ public class ManagementServerImpl implements ManagementServer {
} else {
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
}
}
}
} else {
domainId = ((account == null) ? DomainVO.ROOT_DOMAIN : account.getDomainId());
}
} else {
accountId = account.getId();
}
if (accountId == null && keyword != null) {
Account userAccount = _accountDao.findActiveAccount((String)keyword, domainId);
if (userAccount != null) {
accountId = userAccount.getId();
}
}
Boolean isAllocated = cmd.isAllocatedOnly();
if (isAllocated == null) {
@ -2466,7 +2474,6 @@ public class ManagementServerImpl implements ManagementServer {
Object zone = cmd.getZoneId();
Object address = cmd.getIpAddress();
Object vlan = cmd.getVlanId();
Object keyword = cmd.getKeyword();
Object forVirtualNetwork = cmd.isForVirtualNetwork();
Object ipId = cmd.getId();
@ -2474,7 +2481,6 @@ public class ManagementServerImpl implements ManagementServer {
sb.and("accountIdEQ", sb.entity().getAllocatedToAccountId(), SearchCriteria.Op.EQ);
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
sb.and("address", sb.entity().getAddress(), SearchCriteria.Op.EQ);
sb.and("addressLike", sb.entity().getAddress(), SearchCriteria.Op.LIKE);
sb.and("vlanDbId", sb.entity().getVlanId(), SearchCriteria.Op.EQ);
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
@ -2485,6 +2491,10 @@ public class ManagementServerImpl implements ManagementServer {
sb.join("domainSearch", domainSearch, sb.entity().getAllocatedInDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
}
if (keyword != null && address == null) {
sb.and("addressLIKE", sb.entity().getAddress(), SearchCriteria.Op.LIKE);
}
if (forVirtualNetwork != null) {
SearchBuilder<VlanVO> vlanSearch = _vlanDao.createSearchBuilder();
vlanSearch.and("vlanType", vlanSearch.entity().getVlanType(), SearchCriteria.Op.EQ);
@ -2516,8 +2526,8 @@ public class ManagementServerImpl implements ManagementServer {
sc.setParameters("id", ipId);
}
if ((address == null) && (keyword != null)) {
sc.setParameters("addressLike", "%" + keyword + "%");
if (address == null && keyword != null) {
sc.setParameters("addressLIKE", "%" + keyword + "%");
}
if (address != null) {