Changed constants collections to immutable 86/85486/3
authorWitold Ficio Kopel <w.kopel@samsung.com>
Tue, 16 Apr 2019 14:59:38 +0000 (16:59 +0200)
committerWitold Ficio Kopel <w.kopel@samsung.com>
Wed, 17 Apr 2019 12:58:08 +0000 (14:58 +0200)
Fix to three Sonar vulnerabilites.
Changed mutable collections of constants (exposed by utility class) to
immutable.

Change-Id: I3b301eac20b52df72a6d1318483b7b931e750313
Issue-ID: SO-1794
Signed-off-by: Witold Ficio Kopel <w.kopel@samsung.com>
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java

index 7bf68ff..e16bf90 100644 (file)
@@ -28,9 +28,7 @@ import com.woorea.openstack.heat.model.CreateStackParam;
 import com.woorea.openstack.heat.model.Stack;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Arrays;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Scanner;
 import javax.ws.rs.core.Response;
@@ -64,6 +62,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
+import com.google.common.collect.ImmutableSet;
 
 @Component
 public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
@@ -75,8 +74,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
     public static final String VF_MODULE_ID = "vf_module_id";
     public static final String TEMPLATE_TYPE = "template_type";
     public static final String MULTICLOUD_QUERY_BODY_NULL = "multicloudQueryBody is null";
-    public static final List<String> MULTICLOUD_INPUTS =
-            Arrays.asList(OOF_DIRECTIVES, SDNC_DIRECTIVES, USER_DIRECTIVES, TEMPLATE_TYPE);
+    public static final ImmutableSet<String> MULTICLOUD_INPUTS =
+            ImmutableSet.of(OOF_DIRECTIVES, SDNC_DIRECTIVES, USER_DIRECTIVES, TEMPLATE_TYPE);
 
     private static final Logger logger = LoggerFactory.getLogger(MsoMulticloudUtils.class);
 
index 01519fa..4cf5131 100644 (file)
@@ -2,6 +2,8 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
+ * 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
@@ -20,8 +22,7 @@
 
 package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
 
-import static com.google.common.collect.Sets.newHashSet;
-import java.util.Set;
+import com.google.common.collect.ImmutableSet;
 import org.onap.vnfmadapter.v1.model.OperationStateEnum;
 import org.onap.vnfmadapter.v1.model.OperationStatusRetrievalStatusEnum;
 
@@ -51,11 +52,11 @@ public class Constants {
     public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/";
 
 
-    public static final Set<OperationStateEnum> OPERATION_FINISHED_STATES =
-            newHashSet(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK);
+    public static final ImmutableSet<OperationStateEnum> OPERATION_FINISHED_STATES =
+            ImmutableSet.of(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK);
 
-    public static final Set<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = newHashSet(
-            OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS);
+    public static final ImmutableSet<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = ImmutableSet
+            .of(OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS);
 
     public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus";