aboutsummaryrefslogtreecommitdiffstats
path: root/policy-utils/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-08-05 15:27:16 -0400
committerJim Hahn <jrh3@att.com>2019-08-13 15:58:15 -0400
commita156cf3cbad6512510ae9a02a13c0408f901c734 (patch)
tree0a69bffb2a6c9f961bda1408153cf44f360c6a17 /policy-utils/src/main
parent62d1ff054b0ec6348ab6f7415063fdaa3f425215 (diff)
Fix sonar issues in drools-pdp
Address sonar issue, "Move constants to a class or enum", by moving them from interfaces to classes: ActiveStandbyFeatureApi StateManagementFeatureApi PolicyResourceLockFeatureApi PolicySessionFeatureApi DroolsController DroolsControllerFeatureApi PolicyControllerFeatureApi PolicyEngineFeatureApi HealthCheck SystemPersistence EventProtocolCoder PolicyController PolicyEngine TestTransaction MdcTransaction Address sonar issue, "Move constants to a class or enum", by change the interface to a class: DroolsProperties Address sonar issue, "Override the "equals" method in this class", by adding equals & hashCode to: DroolsPdpEntity DroolsPdpImpl Use lombok for a number of getters & setters. Address sonar issue, "Define a constant instead of duplicating this literal" in: DroolsPdpsElectionHandler JpaDroolsPdpsConnector MavenDroolsController GenericEventProtocolCoder GsonProtocolCoderToolset RestManager Address sonar issue, "Remove the parentheses around the parameter" in: MavenDroolsController Address sonar issue, "Replace this lambda with a method reference" in: LifecycleFsm Address sonar issue, "Move this constructor to comply with Java Code Conventions" in: LifecycleStateRunning Address sonar issue, "Replace this 'switch' statement by 'if' statements to increase readability", as specified in: PolicyEngineManager Address sonar issue, "Rename field to prevent any misunderstanding/clash with field" in: MdcTransactionImpl Address sonar issue, "Either log or rethrow this exception", in: RestManager Address sonar issue, "Rename this constant name to" uppercase, by replacing enums with static lists in: RestManager Addressed review comments: Fixed license dates. Renamed getSiteName/setSiteName methods to getSite/setSite in the interface to match the field names in the implementation classes. Renamed *Instance classes to *Constants. Next round of review comments. Change-Id: I1c26af9f194833dd773f2b25dc5f60cde163201c Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-utils/src/main')
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java151
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java180
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java58
3 files changed, 224 insertions, 165 deletions
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
index e3b2f8a8..d56e63e6 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
@@ -20,7 +20,6 @@
package org.onap.policy.drools.utils.logging;
import java.time.Instant;
-import org.onap.policy.common.utils.network.NetworkUtil;
/**
* MDC Transaction Utility Class.
@@ -49,156 +48,6 @@ import org.onap.policy.common.utils.network.NetworkUtil;
* <p>https://wiki.onap.org/pages/viewpage.action?pageId=20087036
*/
public interface MdcTransaction {
- /*
- * The fields must match the naming given at
- * https://wiki.onap.org/pages/viewpage.action?pageId=20087036
- */
-
- /**
- * End to end transaction ID. Subtransactions will inherit this value from the transaction.
- */
- String REQUEST_ID = "RequestID";
-
- /**
- * Invocation ID, ie. SubTransaction ID.
- */
- String INVOCATION_ID = "InvocationID";
-
- /**
- * Service Name. Both transactions and subtransactions will have its own copy.
- */
- String SERVICE_NAME = "ServiceName";
-
- /**
- * Partner Name Subtransactions will inherit this value from the transaction.
- */
- String PARTNER_NAME = "PartnerName";
-
- /**
- * Start Timestamp. Both transactions and subtransactions will have its own copy.
- */
- String BEGIN_TIMESTAMP = "BeginTimestamp";
-
- /**
- * End Timestamp. Both transactions and subtransactions will have its own copy.
- */
- String END_TIMESTAMP = "EndTimestamp";
-
- /**
- * Elapsed Time. Both transactions and subtransactions will have its own copy.
- */
- String ELAPSED_TIME = "ElapsedTime";
-
- /**
- * Elapsed Time. Both transactions and subtransactions will have its own copy.
- */
- String SERVICE_INSTANCE_ID = "ServiceInstanceID";
-
- /**
- * Virtual Server Name. Subtransactions will inherit this value from the transaction.
- */
- String VIRTUAL_SERVER_NAME = "VirtualServerName";
-
- /**
- * Status Code Both transactions and subtransactions will have its own copy.
- */
- String STATUS_CODE = "StatusCode";
-
- /**
- * Response Code Both transactions and subtransactions will have its own copy.
- */
- String RESPONSE_CODE = "ResponseCode";
-
- /**
- * Response Description Both transactions and subtransactions will have its own copy.
- */
- String RESPONSE_DESCRIPTION = "ResponseDescription";
-
- /**
- * Instance UUID Both transactions and subtransactions will have its own copy.
- */
- String INSTANCE_UUID = "InstanceUUID";
-
- /**
- * Severity Both transactions and subtransactions will have its own copy.
- */
- String SEVERITY = "Severity";
-
- /**
- * Target Entity Both transactions and subtransactions will have its own copy.
- */
- String TARGET_ENTITY = "TargetEntity";
-
- /**
- * Target Service Name Both transactions and subtransactions will have its own copy.
- */
- String TARGET_SERVICE_NAME = "TargetServiceName";
-
- /**
- * Server Subtransactions inherit this value. if (this.getSources().size() == 1)
- * this.getSources().get(0).getTopic();
- */
- String SERVER = "Server";
-
- /**
- * Server IP Address Subtransactions inherit this value.
- */
- String SERVER_IP_ADDRESS = "ServerIpAddress";
-
- /**
- * Server FQDN Subtransactions inherit this value.
- */
- String SERVER_FQDN = "ServerFQDN";
-
- /**
- * Client IP Address Both transactions and subtransactions will have its own copy.
- */
- String CLIENT_IP_ADDRESS = "ClientIPAddress";
-
- /**
- * Process Key Both transactions and subtransactions will have its own copy.
- */
- String PROCESS_KEY = "ProcessKey";
-
- /**
- * Remote Host Both transactions and subtransactions will have its own copy.
- */
- String REMOTE_HOST = "RemoteHost";
-
- /**
- * Alert Severity Both transactions and subtransactions will have its own copy.
- */
- String ALERT_SEVERITY = "AlertSeverity";
-
- /**
- * Target Virtual Entity Both transactions and subtransactions will have its own copy.
- */
- String TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity";
-
- /**
- * Default Service Name.
- */
- String DEFAULT_SERVICE_NAME = "PDP-D";
-
- /**
- * Default Host Name.
- */
- String DEFAULT_HOSTNAME = NetworkUtil.getHostname();
-
- /**
- * Default Host IP.
- */
- String DEFAULT_HOSTIP = NetworkUtil.getHostIp();
-
- /**
- * Status Code Complete.
- */
- String STATUS_CODE_COMPLETE = "COMPLETE";
-
- /**
- * Status Code Error.
- */
- String STATUS_CODE_FAILURE = "ERROR";
/**
* reset subtransaction data.
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
new file mode 100644
index 00000000..ba335958
--- /dev/null
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * policy-utils
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.policy.drools.utils.logging;
+
+import org.onap.policy.common.utils.network.NetworkUtil;
+
+public class MdcTransactionConstants {
+ /*
+ * The fields must match the naming given at
+ * https://wiki.onap.org/pages/viewpage.action?pageId=20087036
+ */
+
+ /**
+ * End to end transaction ID. Subtransactions will inherit this value from the transaction.
+ */
+ public static final String REQUEST_ID = "RequestID";
+
+ /**
+ * Invocation ID, ie. SubTransaction ID.
+ */
+ public static final String INVOCATION_ID = "InvocationID";
+
+ /**
+ * Service Name. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String SERVICE_NAME = "ServiceName";
+
+ /**
+ * Partner Name Subtransactions will inherit this value from the transaction.
+ */
+ public static final String PARTNER_NAME = "PartnerName";
+
+ /**
+ * Start Timestamp. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String BEGIN_TIMESTAMP = "BeginTimestamp";
+
+ /**
+ * End Timestamp. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String END_TIMESTAMP = "EndTimestamp";
+
+ /**
+ * Elapsed Time. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String ELAPSED_TIME = "ElapsedTime";
+
+ /**
+ * Elapsed Time. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String SERVICE_INSTANCE_ID = "ServiceInstanceID";
+
+ /**
+ * Virtual Server Name. Subtransactions will inherit this value from the transaction.
+ */
+ public static final String VIRTUAL_SERVER_NAME = "VirtualServerName";
+
+ /**
+ * Status Code Both transactions and subtransactions will have its own copy.
+ */
+ public static final String STATUS_CODE = "StatusCode";
+
+ /**
+ * Response Code Both transactions and subtransactions will have its own copy.
+ */
+ public static final String RESPONSE_CODE = "ResponseCode";
+
+ /**
+ * Response Description Both transactions and subtransactions will have its own copy.
+ */
+ public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
+
+ /**
+ * Instance UUID Both transactions and subtransactions will have its own copy.
+ */
+ public static final String INSTANCE_UUID = "InstanceUUID";
+
+ /**
+ * Severity Both transactions and subtransactions will have its own copy.
+ */
+ public static final String SEVERITY = "Severity";
+
+ /**
+ * Target Entity Both transactions and subtransactions will have its own copy.
+ */
+ public static final String TARGET_ENTITY = "TargetEntity";
+
+ /**
+ * Target Service Name Both transactions and subtransactions will have its own copy.
+ */
+ public static final String TARGET_SERVICE_NAME = "TargetServiceName";
+
+ /**
+ * Server Subtransactions inherit this value. if (this.getSources().size() == 1)
+ * this.getSources().get(0).getTopic();
+ */
+ public static final String SERVER = "Server";
+
+ /**
+ * Server IP Address Subtransactions inherit this value.
+ */
+ public static final String SERVER_IP_ADDRESS = "ServerIpAddress";
+
+ /**
+ * Server FQDN Subtransactions inherit this value.
+ */
+ public static final String SERVER_FQDN = "ServerFQDN";
+
+ /**
+ * Client IP Address Both transactions and subtransactions will have its own copy.
+ */
+ public static final String CLIENT_IP_ADDRESS = "ClientIPAddress";
+
+ /**
+ * Process Key Both transactions and subtransactions will have its own copy.
+ */
+ public static final String PROCESS_KEY = "ProcessKey";
+
+ /**
+ * Remote Host Both transactions and subtransactions will have its own copy.
+ */
+ public static final String REMOTE_HOST = "RemoteHost";
+
+ /**
+ * Alert Severity Both transactions and subtransactions will have its own copy.
+ */
+ public static final String ALERT_SEVERITY = "AlertSeverity";
+
+ /**
+ * Target Virtual Entity Both transactions and subtransactions will have its own copy.
+ */
+ public static final String TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity";
+
+ /**
+ * Default Service Name.
+ */
+ public static final String DEFAULT_SERVICE_NAME = "PDP-D";
+
+ /**
+ * Default Host Name.
+ */
+ public static final String DEFAULT_HOSTNAME = NetworkUtil.getHostname();
+
+ /**
+ * Default Host IP.
+ */
+ public static final String DEFAULT_HOSTIP = NetworkUtil.getHostIp();
+
+ /**
+ * Status Code Complete.
+ */
+ public static final String STATUS_CODE_COMPLETE = "COMPLETE";
+
+ /**
+ * Status Code Error.
+ */
+ public static final String STATUS_CODE_FAILURE = "ERROR";
+
+
+ private MdcTransactionConstants() {
+ // do nothing
+ }
+}
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
index 7289cd7a..f10343e2 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
@@ -20,6 +20,36 @@
package org.onap.policy.drools.utils.logging;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.ALERT_SEVERITY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.BEGIN_TIMESTAMP;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CLIENT_IP_ADDRESS;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_HOSTIP;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_HOSTNAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_SERVICE_NAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.ELAPSED_TIME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.END_TIMESTAMP;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.INSTANCE_UUID;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.INVOCATION_ID;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.PARTNER_NAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.PROCESS_KEY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.REMOTE_HOST;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.REQUEST_ID;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.RESPONSE_CODE;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.RESPONSE_DESCRIPTION;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVER;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVER_FQDN;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVER_IP_ADDRESS;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVICE_INSTANCE_ID;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVICE_NAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SEVERITY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.STATUS_CODE;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.STATUS_CODE_COMPLETE;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.STATUS_CODE_FAILURE;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.TARGET_ENTITY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.TARGET_SERVICE_NAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.TARGET_VIRTUAL_ENTITY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.VIRTUAL_SERVER_NAME;
+
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
@@ -46,7 +76,7 @@ class MdcTransactionImpl implements MdcTransaction {
private String invocationId;
private String virtualServerName;
- private String server;
+ private String serverName;
private String serverIpAddress;
private String serverFqdn;
@@ -63,7 +93,7 @@ class MdcTransactionImpl implements MdcTransaction {
private String statusCode;
private String responseCode;
private String responseDescription;
- private String severity;
+ private String theSeverity;
private String alertSeverity;
private String targetEntity;
@@ -207,8 +237,8 @@ class MdcTransactionImpl implements MdcTransaction {
MDC.put(VIRTUAL_SERVER_NAME, this.virtualServerName);
}
- if (this.server != null) {
- MDC.put(SERVER, this.server);
+ if (this.serverName != null) {
+ MDC.put(SERVER, this.serverName);
}
if (this.serverIpAddress != null) {
@@ -267,8 +297,8 @@ class MdcTransactionImpl implements MdcTransaction {
MDC.put(RESPONSE_DESCRIPTION, this.responseDescription);
}
- if (this.severity != null) {
- MDC.put(SEVERITY, this.severity);
+ if (this.theSeverity != null) {
+ MDC.put(SEVERITY, this.theSeverity);
}
if (this.alertSeverity != null) {
@@ -365,7 +395,7 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public String getServer() {
- return this.server;
+ return this.serverName;
}
@Override
@@ -486,7 +516,7 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public MdcTransaction setSeverity(String severity) {
- this.severity = severity;
+ this.theSeverity = severity;
return this;
}
@@ -535,7 +565,7 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public String getSeverity() {
- return severity;
+ return theSeverity;
}
@Override
@@ -587,12 +617,12 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public MdcTransaction setServer(String server) {
if (server == null || server.isEmpty()) {
- this.server = DEFAULT_HOSTNAME;
+ this.serverName = DEFAULT_HOSTNAME;
} else {
- this.server = server;
+ this.serverName = server;
}
- MDC.put(SERVER, this.server);
+ MDC.put(SERVER, this.serverName);
return this;
}
@@ -669,7 +699,7 @@ class MdcTransactionImpl implements MdcTransaction {
sb.append(", partner='").append(partner).append('\'');
sb.append(", invocationId='").append(invocationId).append('\'');
sb.append(", virtualServerName='").append(virtualServerName).append('\'');
- sb.append(", server='").append(server).append('\'');
+ sb.append(", server='").append(serverName).append('\'');
sb.append(", serverIpAddress='").append(serverIpAddress).append('\'');
sb.append(", serverFqdn='").append(serverFqdn).append('\'');
sb.append(", serviceName='").append(serviceName).append('\'');
@@ -682,7 +712,7 @@ class MdcTransactionImpl implements MdcTransaction {
sb.append(", statusCode='").append(statusCode).append('\'');
sb.append(", responseCode='").append(responseCode).append('\'');
sb.append(", responseDescription='").append(responseDescription).append('\'');
- sb.append(", severity='").append(severity).append('\'');
+ sb.append(", severity='").append(theSeverity).append('\'');
sb.append(", alertSeverity='").append(alertSeverity).append('\'');
sb.append(", targetEntity='").append(targetEntity).append('\'');
sb.append(", targetServiceName='").append(targetServiceName).append('\'');