diff options
Diffstat (limited to 'policy-management/src/main/java/org')
2 files changed, 14 insertions, 18 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java index d2196680..810cb65b 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 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. @@ -20,12 +20,13 @@ package org.onap.policy.drools.controller; +import com.google.re2j.Pattern; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import lombok.NonNull; import org.onap.policy.common.endpoints.event.comm.Topic; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.TopicSink; @@ -49,10 +50,8 @@ import org.slf4j.LoggerFactory; */ class IndexedDroolsControllerFactory implements DroolsControllerFactory { - /** - * logger. - */ private static final Logger logger = LoggerFactory.getLogger(IndexedDroolsControllerFactory.class); + private static final Pattern COMMA_SPACE_PAT = Pattern.compile("\\s*,\\s*"); /** * Policy Controller Name Index. @@ -299,13 +298,10 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory { } private List<PotentialCoderFilter> getFilterExpressions(Properties properties, String propertyPrefix, - String eventClasses) { + @NonNull String eventClasses) { List<PotentialCoderFilter> classes2Filters = new ArrayList<>(); - - List<String> topicClasses = new ArrayList<>(Arrays.asList(eventClasses.split("\\s*,\\s*"))); - - for (String theClass : topicClasses) { + for (String theClass : COMMA_SPACE_PAT.split(eventClasses)) { // 4. for each coder class, get the filter expression diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java index e14b1620..44b07a5c 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,8 @@ package org.onap.policy.drools.system.internal; +import com.google.re2j.Pattern; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Properties; @@ -64,6 +64,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen * Logger. */ private static final Logger logger = LoggerFactory.getLogger(AggregatedPolicyController.class); + private static final Pattern COMMA_SPACE_PAT = Pattern.compile("\\s*,\\s*"); /** * identifier for this policy controller. @@ -111,14 +112,14 @@ public class AggregatedPolicyController implements PolicyController, TopicListen /** * Policy Types. */ - private List<ToscaConceptIdentifier> policyTypes; + private final List<ToscaConceptIdentifier> policyTypes; /** * Constructor version mainly used for bootstrapping at initialization time a policy engine * controller. * * @param name controller name - * @param properties + * @param properties controller properties * * @throws IllegalArgumentException when invalid arguments are provided */ @@ -170,8 +171,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen return policyTypeIds; } - List<String> ptiPropList = new ArrayList<>(Arrays.asList(ptiPropValue.split("\\s*,\\s*"))); - for (String pti : ptiPropList) { + for (String pti : COMMA_SPACE_PAT.split(ptiPropValue)) { String[] ptv = pti.split(":"); if (ptv.length == 1) { policyTypeIds.add(new ToscaConceptIdentifier(ptv[0], @@ -217,7 +217,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen @Override public boolean updateDrools(DroolsConfiguration newDroolsConfiguration) { DroolsController controller = this.droolsController.get(); - DroolsConfiguration oldDroolsConfiguration = new DroolsConfiguration(controller.getArtifactId(), + var oldDroolsConfiguration = new DroolsConfiguration(controller.getArtifactId(), controller.getGroupId(), controller.getVersion()); if (oldDroolsConfiguration.getGroupId().equalsIgnoreCase(newDroolsConfiguration.getGroupId()) @@ -242,7 +242,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen DroolsControllerConstants.getFactory().destroy(controller); } - boolean success = true; + var success = true; try { this.properties.setProperty(DroolsPropertyConstants.RULES_GROUPID, newDroolsConfiguration.getGroupId()); this.properties.setProperty(DroolsPropertyConstants.RULES_ARTIFACTID, |