CLOUDSTACK-4289, CLOUDSTACK-4290, CLOUDSTACK-4291 : Check for null when populated UUID while listing usage records.

Filed CLOUDSTACK-4299 to make these entities always available.

Conflicts:
	server/src/com/cloud/api/ApiResponseHelper.java
This commit is contained in:
Kishan Kavala 2013-08-13 18:49:56 +05:30
parent 9cc74429bd
commit 29a399b9ae
1 changed files with 9 additions and 3 deletions

View File

@ -3381,11 +3381,15 @@ public class ApiResponseHelper implements ResponseGenerator {
} else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
//Load Balancer Policy ID
LoadBalancerVO lb = _entityMgr.findById(LoadBalancerVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(lb.getUuid());
if(lb != null){
usageRecResponse.setUsageId(lb.getUuid());
}
} else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
//Port Forwarding Rule ID
PortForwardingRuleVO pf = _entityMgr.findById(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(pf.getUuid());
if(pf != null){
usageRecResponse.setUsageId(pf.getUuid());
}
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
//Network Offering Id
@ -3397,7 +3401,9 @@ public class ApiResponseHelper implements ResponseGenerator {
} else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
//VPN User ID
VpnUserVO vpnUser = _entityMgr.findById(VpnUserVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(vpnUser.getUuid());
if(vpnUser != null){
usageRecResponse.setUsageId(vpnUser.getUuid());
}
} else if(usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP){
//Security Group Id