Support for kafka within xacml tutorial
[policy/xacml-pdp.git] / applications / monitoring / src / main / java / org / onap / policy / xacml / pdp / application / monitoring / MonitoringPdpApplication.java
index ada347e..626c916 100644 (file)
@@ -2,7 +2,8 @@
  * ============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.
+ * Modifications Copyright (C) 2021, 2024 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +24,6 @@
 package org.onap.policy.xacml.pdp.application.monitoring;
 
 import com.att.research.xacml.api.Response;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -31,7 +31,7 @@ import java.util.Map.Entry;
 import org.apache.commons.lang3.tuple.Pair;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
 import org.onap.policy.models.decisions.concepts.DecisionResponse;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
 import org.onap.policy.pdp.xacml.application.common.std.StdCombinedPolicyResultsTranslator;
 import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
@@ -55,36 +55,24 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider
 
     public static final String VERSION_100 = "1.0.0";
 
-    private StdCombinedPolicyResultsTranslator translator = new StdCombinedPolicyResultsTranslator();
-    private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
+    private final StdCombinedPolicyResultsTranslator translator = new StdCombinedPolicyResultsTranslator();
 
     /**
      * Constructor.
      */
     public MonitoringPdpApplication() {
+        super();
+
+        applicationName = "monitoring";
+        actions = List.of("configure");
         //
-        // By default this supports just Monitoring policy types
+        // By default, this supports just Monitoring policy types
         //
-        supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(ONAP_MONITORING_BASE_POLICY_TYPE, VERSION_100));
-    }
-
-    @Override
-    public String applicationName() {
-        return "monitoring";
-    }
-
-    @Override
-    public List<String> actionDecisionsSupported() {
-        return Arrays.asList("configure");
-    }
-
-    @Override
-    public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
-        return supportedPolicyTypes;
+        supportedPolicyTypes.add(new ToscaConceptIdentifier(ONAP_MONITORING_BASE_POLICY_TYPE, VERSION_100));
     }
 
     @Override
-    public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+    public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
         //
         // For Monitoring, we will attempt to support all versions
         // of the policy type. Since we are only packaging a decision
@@ -100,7 +88,7 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider
         // Make the decision
         //
         Pair<DecisionResponse, Response> decisionPair = super.makeDecision(request, requestQueryParams);
-        DecisionResponse decisionResponse = decisionPair.getKey();
+        var decisionResponse = decisionPair.getKey();
         //
         // Abbreviate results if needed
         //
@@ -131,7 +119,7 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider
      *
      * @param queryParams - http request query parameters
      */
-    private boolean checkAbbreviateResults(Map<String, String[]> queryParams) {
+    protected boolean checkAbbreviateResults(Map<String, String[]> queryParams) {
         if (queryParams != null && !queryParams.isEmpty()) {
             // Check if query params contains "abbrev" flag
             if (queryParams.containsKey("abbrev")) {