Fix sonar bugs and vulnerabilities in apex-pdp 61/57061/4
authorramverma <ram.krishna.verma@ericsson.com>
Fri, 20 Jul 2018 15:52:38 +0000 (16:52 +0100)
committerramverma <ram.krishna.verma@ericsson.com>
Mon, 23 Jul 2018 11:13:51 +0000 (12:13 +0100)
Change-Id: I7ecabd3705de4a5352d5a98d1ab3a01677172651
Issue-ID: POLICY-954
Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ApexServicesRestParameters.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ArtifactKeyTestEntity.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/entities/ReferenceKeyTestEntity.java

index 17f0eac..ab81d4b 100644 (file)
@@ -37,7 +37,7 @@ public class ApexServicesRestParameters {
     private static final String DEFAULT_STATIC_PATH = "/";
 
     // Package that will field REST requests
-    public static final String[] DEFAULT_PACKAGES = new String[] { "org.onap.policy.apex.client.deployment.rest",
+    private static final String[] DEFAULT_PACKAGES = new String[] { "org.onap.policy.apex.client.deployment.rest",
             "org.onap.policy.apex.client.editor.rest", "org.onap.policy.apex.client.monitoring.rest" };
 
     // The services parameters
index e801ae7..49802c2 100644 (file)
@@ -28,9 +28,9 @@ import javax.persistence.Entity;
 import javax.persistence.Table;
 import javax.xml.bind.annotation.XmlElement;
 
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
 
 @Entity
@@ -59,10 +59,12 @@ public class ArtifactKeyTestEntity extends AxConcept {
         this.doubleValue = doubleValue;
     }
 
+    @Override
     public AxArtifactKey getKey() {
         return key;
     }
 
+    @Override
     public List<AxKey> getKeys() {
         return Arrays.asList((AxKey) getKey());
     }
@@ -125,38 +127,42 @@ public class ArtifactKeyTestEntity extends AxConcept {
 
     @Override
     public boolean equals(final Object obj) {
-        if (obj == null)
+        if (obj == null) {
             return false;
-        if (this == obj)
+        }
+        if (this == obj) {
             return true;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
         if (key == null) {
-            if (other.key != null)
+            if (other.key != null) {
                 return false;
-        } else if (!key.equals(other.key))
-            return false;
-        if (doubleValue != other.doubleValue)
+            }
+        } else if (!key.equals(other.key)) {
             return false;
-        return true;
+        }
+        return (Double.compare(doubleValue, other.doubleValue) == 0);
     }
 
     @Override
     public int compareTo(final AxConcept otherObj) {
-        if (otherObj == null)
+        if (otherObj == null) {
             return -1;
-        if (this == otherObj)
+        }
+        if (this == otherObj) {
             return 0;
+        }
         final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
         if (key == null) {
-            if (other.key != null)
+            if (other.key != null) {
                 return 1;
-        } else if (!key.equals(other.key))
+            }
+        } else if (!key.equals(other.key)) {
             return key.compareTo(other.key);
-        if (doubleValue != other.doubleValue)
-            return new Double(doubleValue).compareTo(other.doubleValue);
-
-        return 0;
+        }
+        return Double.compare(doubleValue, other.doubleValue);
     }
 }
index 14c3628..6f27633 100644 (file)
@@ -62,10 +62,12 @@ public class ReferenceKeyTestEntity extends AxConcept {
         this.doubleValue = doubleValue;
     }
 
+    @Override
     public AxReferenceKey getKey() {
         return key;
     }
 
+    @Override
     public List<AxKey> getKeys() {
         return Arrays.asList((AxKey) getKey());
     }
@@ -128,38 +130,42 @@ public class ReferenceKeyTestEntity extends AxConcept {
 
     @Override
     public boolean equals(final Object obj) {
-        if (obj == null)
+        if (obj == null) {
             return false;
-        if (this == obj)
+        }
+        if (this == obj) {
             return true;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) obj;
         if (key == null) {
-            if (other.key != null)
+            if (other.key != null) {
                 return false;
-        } else if (!key.equals(other.key))
-            return false;
-        if (doubleValue != other.doubleValue)
+            }
+        } else if (!key.equals(other.key)) {
             return false;
-        return true;
+        }
+        return (Double.compare(doubleValue, other.doubleValue) == 0);
     }
 
     @Override
     public int compareTo(final AxConcept otherObj) {
-        if (otherObj == null)
+        if (otherObj == null) {
             return -1;
-        if (this == otherObj)
+        }
+        if (this == otherObj) {
             return 0;
+        }
         final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) otherObj;
         if (key == null) {
-            if (other.key != null)
+            if (other.key != null) {
                 return 1;
-        } else if (!key.equals(other.key))
+            }
+        } else if (!key.equals(other.key)) {
             return key.compareTo(other.key);
-        if (doubleValue != other.doubleValue)
-            return new Double(doubleValue).compareTo(other.doubleValue);
-
-        return 0;
+        }
+        return Double.compare(doubleValue, other.doubleValue);
     }
 }