Get policy type from policy-api
[policy/xacml-pdp.git] / main / src / main / java / org / onap / policy / pdpx / main / parameters / XacmlPdpParameterGroup.java
index 167a2c4..5731a7b 100644 (file)
@@ -21,6 +21,8 @@
 
 package org.onap.policy.pdpx.main.parameters;
 
+import lombok.Getter;
+import lombok.Setter;
 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
 import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
 import org.onap.policy.common.parameters.GroupValidationResult;
@@ -32,12 +34,18 @@ import org.onap.policy.common.utils.validation.ParameterValidationUtils;
  * Class to hold all parameters needed for xacml pdp component.
  *
  */
+@Getter
 public class XacmlPdpParameterGroup implements ParameterGroup {
     private static final String PARAM_REST_SERVER = "restServerParameters";
+    private static final String PARAM_POLICY_API = "policyApiParameters";
     private static final String PARAM_TOPIC_PARAMETER_GROUP = "topicParameterGroup";
     private static final String PARAM_APPLICATION_PATH = "applicationPath";
+
+    @Setter
     private String name;
+
     private RestServerParameters restServerParameters;
+    private RestServerParameters policyApiParameters;
     private TopicParameterGroup topicParameterGroup;
     private String applicationPath;
 
@@ -47,60 +55,15 @@ public class XacmlPdpParameterGroup implements ParameterGroup {
      * @param name the parameter group name
      */
     public XacmlPdpParameterGroup(final String name, final RestServerParameters restServerParameters,
-            final TopicParameterGroup topicParameterGroup, final String applicationPath) {
+                    final RestServerParameters policyApiParameters, final TopicParameterGroup topicParameterGroup,
+                    final String applicationPath) {
         this.name = name;
         this.restServerParameters = restServerParameters;
+        this.policyApiParameters = policyApiParameters;
         this.topicParameterGroup = topicParameterGroup;
         this.applicationPath = applicationPath;
     }
 
-    /**
-     * Return the name of this parameter group instance.
-     *
-     * @return name the parameter group name
-     */
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Set the name of this parameter group instance.
-     *
-     * @param name the parameter group name
-     */
-    @Override
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /**
-     * Return the restServerParameters of this parameter group instance.
-     *
-     * @return the restServerParameters
-     */
-    public RestServerParameters getRestServerParameters() {
-        return restServerParameters;
-    }
-
-    /**
-     * Return the topicParameterGroup of this parameter group instance.
-     *
-     * @return the topicParameterGroup
-     */
-    public TopicParameterGroup getTopicParameterGroup() {
-        return topicParameterGroup;
-    }
-
-    /**
-     * Returns the path where applications will store their data.
-     *
-     * @return String to the path
-     */
-    public String getApplicationPath() {
-        return applicationPath;
-    }
-
     /**
      * Validate the parameter group.
      *
@@ -118,6 +81,14 @@ public class XacmlPdpParameterGroup implements ParameterGroup {
         } else {
             validationResult.setResult(PARAM_REST_SERVER, restServerParameters.validate());
         }
+        if (policyApiParameters == null) {
+            validationResult.setResult(PARAM_POLICY_API, ValidationStatus.INVALID,
+                    "must have policyApiParameters to configure xacml pdp rest server");
+        } else {
+            // set the name - this only really matters for validation messages
+            policyApiParameters.setName(PARAM_POLICY_API);
+            validationResult.setResult(PARAM_POLICY_API, policyApiParameters.validate());
+        }
         if (topicParameterGroup == null) {
             validationResult.setResult(PARAM_TOPIC_PARAMETER_GROUP, ValidationStatus.INVALID,
                     "must have topicParameterGroup to configure xacml pdp topic sink and source");