diff options
author | Jim Hahn <jrh3@att.com> | 2019-08-05 14:17:01 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-08-13 09:24:52 -0400 |
commit | 9e8023a455633c7daf0dd291c6268986e39352d7 (patch) | |
tree | dc25ae63c4a042a7f16c53d8c50ebcdb4493f5cb /controlloop/common/feature-controlloop-trans/src/main | |
parent | 177b67a70f99e0125fec7732f39c18840409f968 (diff) |
Fix sonar issues in drools-applications
Addressed sonar issue, "Move constants to a class or enum.", by
moving the "manager" object from the ControlLoopMetrics interface
into a utility class, ControlLoopMetricsManager.
Addressed sonar issue, "duplicated blocks of code must be removed.",
by refactoring PolicyGuardYamlToXacml, extracing common functions.
Addressed sonar issue, "Remove this unused import", in
RestControlLoopManager.
Addressed sonar issue, "Refactor this method to throw at most one
checked exception", in event manager.
Fixed likely new sonar issue with assigning to a parameter.
Moved logging line to more appropriate place.
Addressed reviewer comment:
Use "replace" instead of "replaceAll", thus avoiding escaping
Change-Id: I47db957c83c1b3e2bd2330474e261987c6f0aac6
Issue-ID: POLICY-1967
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/feature-controlloop-trans/src/main')
3 files changed, 40 insertions, 6 deletions
diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java index a7c8f11df..3cc02446a 100644 --- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java +++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java @@ -31,11 +31,6 @@ import org.onap.policy.drools.system.PolicyController; public interface ControlLoopMetrics { /** - * Singleton manager object. - */ - ControlLoopMetrics manager = new CacheBasedControlLoopMetricsManager(); - - /** * Gets all transaction identifiers being monitored. * * @return transaction id list diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java index b4057dfae..26627eb1c 100644 --- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java +++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java @@ -70,7 +70,7 @@ public class ControlLoopMetricsFeature implements PolicyControllerFeatureApi { @Override public boolean beforeDeliver(PolicyController controller, CommInfrastructure protocol, String topic, Object event) { if (event instanceof VirtualControlLoopNotification) { - ControlLoopMetrics.manager.transactionEvent(controller, (VirtualControlLoopNotification) event); + ControlLoopMetricsManager.getManager().transactionEvent(controller, (VirtualControlLoopNotification) event); } /* do not take ownership */ diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsManager.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsManager.java new file mode 100644 index 000000000..c4ae11bdf --- /dev/null +++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsManager.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.drools.apps.controlloop.feature.trans; + +import lombok.Getter; + +/** + * Control Loop Metrics Tracker. + */ +public class ControlLoopMetricsManager { + + /** + * Singleton manager object. + */ + @Getter + private static final ControlLoopMetrics manager = new CacheBasedControlLoopMetricsManager(); + + private ControlLoopMetricsManager() { + // do nothing + } +} |