diff options
author | r.bogacki <r.bogacki@samsung.com> | 2019-06-11 10:07:07 +0200 |
---|---|---|
committer | r.bogacki <r.bogacki@samsung.com> | 2019-06-11 10:07:18 +0200 |
commit | c73fbf69cd7e66feca1ebfb35b8516bb183c585b (patch) | |
tree | 47d0a2a8a423c9ec08cc6addfbbe5ebe9ca89711 /mso-api-handlers/mso-api-handler-infra/src | |
parent | 33ce1d167c0daba899887b8ecd16b8a508cf12a0 (diff) |
Improvements in ServiceInstances
Improvements in ServiceInstances according to the Sonar analysis.
-Fixed imports.
-Removed unnecessary code.
-Refactored diamond operators.
Issue-ID: SO-2008
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Change-Id: Ieb03f5b3fb52432091170402237ba4e23ed70e5d
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src')
-rw-r--r-- | mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 68fa6e4f56..a397676ee2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -203,7 +203,7 @@ public class ServiceInstances { @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<String, String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", serviceInstanceId); return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); @@ -759,10 +759,9 @@ public class ServiceInstances { public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException { - String serviceInstanceId = (instanceIdMap == null) ? null : instanceIdMap.get("serviceInstanceId"); + String serviceInstanceId; Boolean aLaCarte = null; - long startTime = System.currentTimeMillis(); - ServiceInstancesRequest sir = null; + ServiceInstancesRequest sir; String apiVersion = version.substring(1); sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); @@ -914,7 +913,6 @@ public class ServiceInstances { String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException { String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID); Boolean aLaCarte = true; - long startTime = System.currentTimeMillis(); String apiVersion = version.substring(1); ServiceInstancesRequest sir = new ServiceInstancesRequest(); sir.setInstanceGroupId(instanceGroupId); @@ -1231,8 +1229,7 @@ public class ServiceInstances { return mapFlatMapToNameValue(userParams); } - private Service serviceMapper(Map<String, Object> params) - throws JsonProcessingException, IOException, JsonParseException, JsonMappingException { + private Service serviceMapper(Map<String, Object> params) throws IOException { ObjectMapper obj = new ObjectMapper(); String input = obj.writeValueAsString(params.get("service")); return obj.readValue(input, Service.class); @@ -1269,7 +1266,7 @@ public class ServiceInstances { instanceList = servInstReq.getRequestDetails().getRelatedInstanceList(); } - Recipe recipe = null; + Recipe recipe; String defaultSource = requestHandlerUtils.getDefaultModel(servInstReq); String modelCustomizationId = modelInfo.getModelCustomizationId(); String modelCustomizationName = modelInfo.getModelCustomizationName(); @@ -1559,13 +1556,11 @@ public class ServiceInstances { private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException { - String serviceInstanceId = (instanceIdMap == null) ? null : instanceIdMap.get("serviceInstanceId"); + String serviceInstanceId; Boolean aLaCarte = null; String apiVersion = version.substring(1); boolean inProgress = false; - - long startTime = System.currentTimeMillis(); - ServiceInstancesRequest sir = null; + ServiceInstancesRequest sir; sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); |