aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseshukm <seshu.kumar.m@huawei.com>2017-09-11 14:29:25 +0530
committerseshukm <seshu.kumar.m@huawei.com>2017-09-11 14:29:25 +0530
commit3fa63b90661cea6d0563038f9f31f17a58a6f3c8 (patch)
treea4841680fec22c56f74b48c7d089ca4ce37785c2
parent72e876272ca11e521e733d447b719aeab3ebd736 (diff)
Fix for SONAR critical issues
Issue Id : SO-117 Change-Id: I7774a2d35f46398c3c3d6a9b4da97a0a52ef941e Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java13
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java8
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java17
3 files changed, 25 insertions, 13 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java
index 666509e1c3..f40c7d9882 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +24,11 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.openecomp.mso.cloud.authentication.AuthenticationWrapper;
+import org.openecomp.mso.logger.MsoLogger;
public abstract class IdentityAuthenticationTypeAbstract {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
// This map will prevent duplicates (as if it was an Enum).
// Without this, using an instance specific field for the class could allow
// different classes bound to the same entry name.
@@ -42,7 +45,7 @@ public abstract class IdentityAuthenticationTypeAbstract {
entries.put(identityType, this);
AuthenticationWrapper.register(this.toString(), wrapperClass);
} catch (IllegalAccessException | InstantiationException e) {
- // Do not add the class if an exception occurs as we won't get the class anyway
+ LOGGER.debug("Exception in Identity Authentication",e);
}
}
@@ -72,4 +75,12 @@ public abstract class IdentityAuthenticationTypeAbstract {
return ((this.identityType != null) && (other != null) && (other instanceof IdentityAuthenticationTypeAbstract) && (this.identityType.equals(other.toString())));
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((identityType == null) ? 0 : identityType.hashCode());
+ return result;
+ }
+
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java
index a4cd124f14..ad909a73c7 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,4 +75,11 @@ public abstract class IdentityServerTypeAbstract {
return ((this.serverType != null) && (other != null) && (other instanceof IdentityServerTypeAbstract) && (this.serverType.equals(other.toString())));
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((serverType == null) ? 0 : serverType.hashCode());
+ return result;
+ }
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
index b950c1b5c8..8db4548bad 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -519,9 +520,7 @@ public class RequestsDatabase {
}
session.getTransaction ().commit ();
} finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
+ session.close ();
msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateSiteStatus", null);
}
}
@@ -588,9 +587,7 @@ public class RequestsDatabase {
}
session.getTransaction().commit();
} finally {
- if(session != null && session.isOpen()) {
- session.close();
- }
+ session.close();
msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
"Successfully", "RequestDB", "updateOperationStatus", null);
}
@@ -663,9 +660,7 @@ public class RequestsDatabase {
}
session.getTransaction().commit();
} finally {
- if(session != null && session.isOpen()) {
- session.close();
- }
+ session.close();
msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
"Successfully", "RequestDB", "updateResOperStatus", null);
}
@@ -720,9 +715,7 @@ public class RequestsDatabase {
}
updateOperationStatus(serviceOperStatus);
} finally {
- if(session != null && session.isOpen()) {
- session.close();
- }
+ session.close();
msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
"Successfully", "RequestDB", "updateResOperStatus", null);
}