api: Fix NullPointerException in ApiResponseHelper for DomainResponse

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
This commit is contained in:
Rohit Yadav 2012-12-18 17:15:00 -08:00
parent 22ee4200c3
commit 434258080f
1 changed files with 4 additions and 1 deletions

View File

@ -440,7 +440,10 @@ public class ApiResponseHelper implements ResponseGenerator {
domainResponse.setId(domain.getUuid());
domainResponse.setLevel(domain.getLevel());
domainResponse.setNetworkDomain(domain.getNetworkDomain());
domainResponse.setParentDomainId(ApiDBUtils.findDomainById(domain.getParent()).getUuid());
Domain parentDomain = ApiDBUtils.findDomainById(domain.getParent());
if (parentDomain != null) {
domainResponse.setParentDomainId(parentDomain.getUuid());
}
StringBuilder domainPath = new StringBuilder("ROOT");
(domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1);
domainResponse.setPath(domainPath.toString());