summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-04-24 14:19:43 +0900
committerParshad Patel <pars.patel@samsung.com>2019-04-24 16:51:22 +0900
commitfa628a20ef151d4b89302dd767f28415c774caf8 (patch)
tree0fdf8444b9a12ecfe78bd91d64e0eb4bfe9bc823 /vid-app-common/src
parent22b961325bf83be59607b65b8e0117604834687b (diff)
Fix sonar issue in vid-app-common
Fix Either log or rethrow this exception Fix "serviceInstanceId" is already a string, there's no need to call "toString()" on it Fix Replace this if-then-else statement by a single return statement Issue-ID: VID-464 Change-Id: I87652f6aeecf668757f668535377f2ff9a95a7cf Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'vid-app-common/src')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java2
3 files changed, 15 insertions, 13 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
index fc5a85c04..814959020 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
@@ -149,8 +149,6 @@ public class ChangeManagementServiceImpl implements ChangeManagementService {
}
}
-
- // AH:TODO: return ChangeManagementResponse
return null;
}
@@ -162,15 +160,15 @@ public class ChangeManagementServiceImpl implements ChangeManagementService {
return currentRequestDetails.getVnfInstanceId();
}
- protected String extractServiceInstanceId(RequestDetails currentRequestDetails, String requestType) {
- try {
- String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0).getRelatedInstance().getInstanceId();
- serviceInstanceId.toString(); //throw exception in case that serviceInstanceId is null...
- return serviceInstanceId;
- } catch (Exception e) {
+ protected String extractServiceInstanceId(RequestDetails currentRequestDetails,
+ String requestType) {
+ String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0)
+ .getRelatedInstance().getInstanceId();
+ if (serviceInstanceId == null) {
logger.error("Failed to extract serviceInstanceId");
throw new BadRequestException("No instanceId in request " + requestType);
}
+ return serviceInstanceId;
}
@Override
@@ -227,6 +225,7 @@ public class ChangeManagementServiceImpl implements ChangeManagementService {
dataAccessService.saveDomainObject(vnfList.get(0), null);
} catch (NonUniqueObjectException e) {
//In case the relation already exists, we continue running on the list
+ logger.debug("NonUniqueObjectException in addVnfWorkflowRelation", e);
}
}
return vnfWorkflowRelationResponse;
@@ -340,8 +339,11 @@ public class ChangeManagementServiceImpl implements ChangeManagementService {
}
private boolean validateJsonOutput(org.json.JSONObject json) {
- if (!json.has(PRIMARY_KEY) || !json.getJSONObject(PRIMARY_KEY).keySet().containsAll(REQUIRED_KEYS))
- return false;
- return true;
+ boolean isValid = true;
+ if (!json.has(PRIMARY_KEY)
+ || !json.getJSONObject(PRIMARY_KEY).keySet().containsAll(REQUIRED_KEYS)) {
+ isValid = false;
+ }
+ return isValid;
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java
index 8dc19cfa9..d885f205e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java
@@ -79,7 +79,7 @@ public class CloudOwnerServiceImpl implements CloudOwnerService {
lcpCloudRegionId = msoRequest.extractValueByPathUsingAdditionalProperties(LCP_CLOUD_REGION_ID_PATH, String.class);
}
catch (NotFoundException exception) {
- LOGGER.debug("Can't find lcp region in RequestDetails. Assume no cloudOwner enrichment is needed. Reason: "+exception.getMessage());
+ LOGGER.debug("Can't find lcp region in RequestDetails. Assume no cloudOwner enrichment is needed. Reason: ", exception);
return;
}
String cloudOwner = aaiClient.getCloudOwnerByCloudRegionId(lcpCloudRegionId);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java
index db40ce23c..790dbfa55 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java
@@ -61,7 +61,7 @@ public class RoleGenaratorServiceImpl implements RoleGeneratorService {
}
catch (Exception e) {
- Log.error("There was an error in updating roles "+e.getMessage());
+ Log.error("There was an error in updating roles ", e);
}
return query;
}