From f35d8b583e74aaade7725b53988f73dafe1ddf9d Mon Sep 17 00:00:00 2001 From: "r.bogacki" Date: Thu, 21 Feb 2019 11:01:22 +0100 Subject: Fixed major Sonar issues in ServicePluginFactory Removed not used variable. Removed unnecessary castings. Cleaned diamond operators. Removed commented out block of code. Change-Id: I0adca822f6dcb9efaa1ea96c9ff9092a7a2baa84 Issue-ID: SO-1552 Signed-off-by: Robert Bogacki --- .../workflow/service/ServicePluginFactory.java | 37 +++++++++------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'bpmn/so-bpmn-infrastructure-common/src') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 48c78632dd..477dc34dbd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -127,7 +129,7 @@ public class ServicePluginFactory { return newRequest; } - List addResourceList = new ArrayList(); + List addResourceList = new ArrayList<>(); addResourceList.addAll(serviceDecomposition.getServiceResources()); serviceDecomposition.setVnfResources(null); @@ -237,7 +239,7 @@ public class ServicePluginFactory { String url = getInventoryOSSEndPoint(); url += "/oss/inventory?location=" + UriUtils.encode(locationAddress,"UTF-8"); String responseContent = sendRequest(url, "GET", ""); - List accessTPs = new ArrayList(); + List accessTPs = new ArrayList<>(); if (null != responseContent) { accessTPs = getJsonObject(responseContent, List.class); } @@ -246,8 +248,8 @@ public class ServicePluginFactory { @SuppressWarnings("unchecked") private void putResourceRequestInputs(Map resource, Map resourceInputs) { - Map resourceParametersObject = new HashMap(); - Map resourceRequestInputs = new HashMap(); + Map resourceParametersObject = new HashMap<>(); + Map resourceRequestInputs = new HashMap<>(); resourceRequestInputs.put("requestInputs", resourceInputs); resourceParametersObject.put("parameters", resourceRequestInputs); @@ -428,7 +430,6 @@ public class ServicePluginFactory { // this method check if pInterface is remote private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) { - Map keys = uri.getURIKeys(); String uriString = uri.build().toString(); if (uriString != null) { @@ -555,14 +556,14 @@ public class ServicePluginFactory { } private List queryTerminalPointsFromServiceProviderSystem(String srcLocation, String dstLocation) { - Map locationSrc = new HashMap(); + Map locationSrc = new HashMap<>(); locationSrc.put("location", srcLocation); - Map locationDst = new HashMap(); + Map locationDst = new HashMap<>(); locationDst.put("location", dstLocation); - List> locations = new ArrayList>(); + List> locations = new ArrayList<>(); locations.add(locationSrc); locations.add(locationDst); - List returnList = new ArrayList(); + List returnList = new ArrayList<>(); String reqContent = getJsonString(locations); String url = getThirdSPEndPoint(); String responseContent = sendRequest(url, "POST", reqContent); @@ -604,7 +605,7 @@ public class ServicePluginFactory { Map serviceObject = (Map) uuiObject.get("service"); Map serviceParametersObject = (Map) serviceObject.get("parameters"); Map serviceRequestInputs = (Map) serviceParametersObject.get("requestInputs"); - Map oofQueryObject = new HashMap(); + Map oofQueryObject = new HashMap<>(); List resources = (List) serviceParametersObject.get("resources"); oofQueryObject.put("src-access-provider-id", serviceRequestInputs.get("inner-src-access-provider-id")); oofQueryObject.put("src-access-client-id", serviceRequestInputs.get("inner-src-access-client-id")); @@ -620,7 +621,7 @@ public class ServicePluginFactory { String url = getOOFCalcEndPoint(); String responseContent = sendRequest(url, "POST", oofRequestReq); - List returnList = new ArrayList(); + List returnList = new ArrayList<>(); if (null != responseContent) { returnList = getJsonObject(responseContent, List.class); } @@ -635,7 +636,7 @@ public class ServicePluginFactory { } private Map getReturnRoute(List returnList){ - Map returnRoute = new HashMap(); + Map returnRoute = new HashMap<>(); for(Object returnVpn :returnList){ Map returnVpnInfo = (Map) returnVpn; String accessTopoId = (String)returnVpnInfo.get("access-topology-id"); @@ -664,11 +665,11 @@ public class ServicePluginFactory { private Map getResourceParams(Execution execution, String resourceCustomizationUuid, String serviceParameters) { List resourceList = jsonUtil.StringArrayToList(execution, - (String) JsonUtils.getJsonValue(serviceParameters, "resources")); + JsonUtils.getJsonValue(serviceParameters, "resources")); // Get the right location str for resource. default is an empty array. String resourceInputsFromUui = ""; for (String resource : resourceList) { - String resCusUuid = (String) JsonUtils.getJsonValue(resource, "resourceCustomizationUuid"); + String resCusUuid = JsonUtils.getJsonValue(resource, "resourceCustomizationUuid"); if (resourceCustomizationUuid.equals(resCusUuid)) { String resourceParameters = JsonUtils.getJsonValue(resource, "parameters"); resourceInputsFromUui = JsonUtils.getJsonValue(resourceParameters, "requestInputs"); @@ -738,14 +739,6 @@ public class ServicePluginFactory { method = httpDelete; } - // now have no auth - // String userCredentials = - // SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, - // Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); - // String authorization = "Basic " + - // DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - // method.setHeader("Authorization", authorization); - httpResponse = client.execute(method); String responseContent = null; if (null != httpResponse && httpResponse.getEntity() != null) { -- cgit 1.2.3-korg