diff options
author | ezhil <ezhrajam@in.ibm.com> | 2018-12-18 20:00:50 +0530 |
---|---|---|
committer | ezhil <ezhrajam@in.ibm.com> | 2018-12-18 20:01:16 +0530 |
commit | 94d30765aea03290b3e0fbb5ab4a5a9b347968ef (patch) | |
tree | d07b26511919e186c8248aec04ef72a9a7d47724 | |
parent | ce68f67d008c292f36d440f2dc473ba23d673fce (diff) |
Fixed sonar issue in ResourceAllocator.java
Fixed major sonar issue
Issue-ID: CCSDK-836
Change-Id: I8bc5229f24f7a6c5668f52fc1ab3b8e13387edb1
Signed-off-by: ezhil <ezhrajam@in.ibm.com>
-rw-r--r-- | resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java index e31ce7ec2..c0cf774a8 100644 --- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java +++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright (C) 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -146,7 +147,7 @@ public class ResourceAllocator implements SvcLogicResource { ResourceData rd = endPointAllocator.getResource(rt.resourceTargetType, rt.resourceTargetId, rr.resourceName, rr.resourceEntityTypeFilter, rr.resourceEntityIdFilter, rr.resourceShareGroupFilter); setResourceDataInResponse(Collections.singletonList(rd), rsList); - } else if ((rr!=null && rr.resourceTargetTypeFilter != null || rr.resourceTargetIdFilter != null) + } else if ((rr!=null && (rr.resourceTargetTypeFilter != null || rr.resourceTargetIdFilter != null)) && rr.resourceName != null) { List<ResourceData> rdlist = endPointAllocator.getResourcesForTarget(rr.resourceTargetTypeFilter, rr.resourceTargetIdFilter, rr.resourceName); @@ -294,7 +295,7 @@ public class ResourceAllocator implements SvcLogicResource { StrUtil.info(log, rt); StrUtil.info(log, rr); - boolean change = requestType.equalsIgnoreCase("change"); + boolean change = "change".equalsIgnoreCase(requestType); List<ResourceData> rlist = endPointAllocator.allocateResources(serviceModel, sd, rt, rr, checkOnly, change); @@ -302,7 +303,7 @@ public class ResourceAllocator implements SvcLogicResource { setResourceDataInContext(ctx, prefix, rlist); for (ResourceData rd : rlist) { - if (!rd.status.equals("Success")) { + if (!"Success".equals(rd.status)) { log.info("Capacity not found for: " + sd.resourceEntityType + "::" + sd.resourceEntityId); return QueryStatus.NOT_FOUND; } @@ -322,7 +323,7 @@ public class ResourceAllocator implements SvcLogicResource { StrUtil.info(log, rt); StrUtil.info(log, rr); - boolean change = requestType.equalsIgnoreCase("change"); + boolean change = "change".equalsIgnoreCase(requestType); List<ResourceData> rlist = endPointAllocator.allocateResources(serviceModel, sd, rt, rr, rr.checkOnly, change); @@ -330,7 +331,7 @@ public class ResourceAllocator implements SvcLogicResource { setResourceDataInResponse(rlist, rsList); for (ResourceData rd : rlist) { - if (!rd.status.equals("Success")) { + if (!"Success".equals(rd.status)) { log.info("Capacity not found for: " + sd.resourceEntityType + "::" + sd.resourceEntityId); return AllocationStatus.ResourceNotFound; } @@ -350,19 +351,19 @@ public class ResourceAllocator implements SvcLogicResource { res.status = rd.status; if (rd.data != null && !rd.data.isEmpty()) { for (String kk : rd.data.keySet()) { - if (kk.equalsIgnoreCase("allocated")) { + if ("allocated".equalsIgnoreCase(kk)) { res.resourceAllocated = String.valueOf(rd.data.get(kk)); } - if (kk.equalsIgnoreCase("used")) { + if ("used".equalsIgnoreCase(kk)) { res.resourceUsed = String.valueOf(rd.data.get(kk)); } - if (kk.equalsIgnoreCase("available")) { + if ("available".equalsIgnoreCase(kk)) { res.resourceAvailable = String.valueOf(rd.data.get(kk)); } - if (kk.equalsIgnoreCase("limit")) { + if ("limit".equalsIgnoreCase(kk)) { res.resourceLimit = String.valueOf(rd.data.get(kk)); } |