bug 6649: when listing domains, accept -1 as 'list all.' Fix listDomainChildren response to return haschild, handle haschild as a boolean rather than a string.

status 6649: resolved fixed
This commit is contained in:
Kris McQueen 2010-10-19 13:48:55 -07:00
parent 5466e10fa3
commit 0267a306c8
5 changed files with 23 additions and 3 deletions

View File

@ -38,7 +38,11 @@ public abstract class BaseListCmd extends BaseCmd {
Long pageSize = DEFAULT_PAGE_SIZE;
Integer pageSizeInt = getPageSize();
if (pageSizeInt != null) {
pageSize = pageSizeInt.longValue();
if (pageSizeInt.longValue() == -1) {
pageSize = null;
} else {
pageSize = pageSizeInt.longValue();
}
}
return pageSize;
}
@ -46,6 +50,10 @@ public abstract class BaseListCmd extends BaseCmd {
public Long getStartIndex() {
Long startIndex = Long.valueOf(0);
Long pageSizeVal = getPageSizeVal();
if (pageSizeVal == null) {
return null; // there's no limit, so start index is irrelevant
}
if (page != null) {
int pageNum = page.intValue();
if (pageNum > 0) {

View File

@ -85,6 +85,7 @@ public class ListDomainChildrenCmd extends BaseListCmd {
domainResponse.setDomainName(domain.getName());
domainResponse.setId(domain.getId());
domainResponse.setLevel(domain.getLevel());
domainResponse.setHasChild(domain.getChildCount() > 0);
domainResponse.setParentDomainId(domain.getParent());
if (domain.getParent() != null) {
domainResponse.setParentDomainName(ApiDBUtils.findDomainById(domain.getParent()).getName());

View File

@ -36,6 +36,9 @@ public class DomainResponse extends BaseResponse {
@SerializedName("parentdomainname") @Param(description="the domain name of the parent domain")
private String parentDomainName;
@SerializedName("haschild") @Param(description="whether the domain has one or more sub-domains")
private Boolean hasChild;
public Long getId() {
return id;
}
@ -75,4 +78,12 @@ public class DomainResponse extends BaseResponse {
public void setParentDomainName(String parentDomainName) {
this.parentDomainName = parentDomainName;
}
public Boolean getHasChild() {
return hasChild;
}
public void setHasChild(Boolean hasChild) {
this.hasChild = hasChild;
}
}

View File

@ -74,7 +74,7 @@ function showDomainsTab() {
if (domains != null && domains.length > 0) {
for (var i = 0; i < domains.length; i++) {
drawNode(domains[i], level, container);
if(domains[i].haschild=="true")
if(domains[i].haschild==true)
drawTree(domains[i].id, (level+1), $("#domain_children_container_"+domains[i].id));
}
}

View File

@ -552,7 +552,7 @@ $(document).ready(function() {
dataType: "json",
async: false,
success: function(json) {
domainJSONToTemplate(json.createdomainresponse.domain[0], template);
domainJSONToTemplate(json.createdomainresponse, template);
loadingImg.hide();
rowContainer.show();
},