@Override
public Pair<List<? extends DedicatedResourceVO>, Integer> listDedicatedHosts(ListDedicatedHostsCmd cmd) {
Long hostId = cmd.getHostId();
Long domainId = cmd.getDomainId();
String accountName = cmd.getAccountName();
Long affinityGroupId = cmd.getAffinityGroupId();
Long startIndex = cmd.getStartIndex();
Long pageSize = cmd.getPageSizeVal();
Long accountId = null;
if (accountName != null) {
if (domainId != null) {
Account account = _accountDao.findActiveAccount(accountName, domainId);
if (account != null) {
accountId = account.getId();
}
} else {
throw new InvalidParameterValueException("Please specify the domain id of the account: " + accountName);
}
}
Filter searchFilter = new Filter(DedicatedResourceVO.class, "id", true, startIndex, pageSize);
Pair<List<DedicatedResourceVO>, Integer> result = _dedicatedDao.searchDedicatedHosts(hostId, domainId, accountId, affinityGroupId, searchFilter);
return new Pair<List<? extends DedicatedResourceVO>, Integer>(result.first(), result.second());
}