bug 8682: implemented search by id in listPortForwardingRules

status 8682: resolved fixed
This commit is contained in:
alena 2011-02-24 09:55:03 -08:00
parent 8eb665246e
commit b0aabc1b20
2 changed files with 13 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.FirewallRuleResponse;
import com.cloud.api.response.ListResponse;
import com.cloud.network.rules.PortForwardingRule;
@ -39,6 +40,8 @@ public class ListPortForwardingRulesCmd extends BaseListCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="Lists rule with the specified ID.")
private Long id;
@Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.LONG, description="the id of IP address of the port forwarding services")
private Long ipAddressId;
@ -64,6 +67,10 @@ public class ListPortForwardingRulesCmd extends BaseListCmd {
public Long getIpAddressId() {
return ipAddressId;
}
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -582,6 +582,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd) {
Account caller = UserContext.current().getCaller();
Long ipId = cmd.getIpAddressId();
Long id = cmd.getId();
String path = null;
Pair<String, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId());
@ -603,6 +604,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
Filter filter = new Filter(PortForwardingRuleVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal());
SearchBuilder<PortForwardingRuleVO> sb = _forwardingDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), Op.EQ);
sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.EQ);
sb.and("domainId", sb.entity().getDomainId(), Op.EQ);
@ -617,6 +619,10 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
SearchCriteria<PortForwardingRuleVO> sc = sb.create();
if (id != null) {
sc.setParameters("id", id);
}
if (ipId != null) {
sc.setParameters("ip", ipId);
}