XACML Platform Enhancements
[policy/engine.git] / ONAP-XACML / src / main / java / org / onap / policy / xacml / std / pap / StdPAPPolicy.java
index 264b2b7..2f752a0 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP-XACML
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,7 +36,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
     private String policyDescription = null;
     private String onapName = null;
     private String configName = null;
-    private Map<String, String> dyanamicFieldConfigAttributes = new HashMap<>();
+    private Map<String, String> dynamicFieldConfigAttributes = new HashMap<>();
     private Map<String, String> treatments = new HashMap<>();
     private Map<String, String> dropDownMap = new HashMap<>();
     private Map<String, String> dynamicSettingsMap = new HashMap<>();
@@ -80,7 +81,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
     private String guard = null;
     private String riskLevel;
     private String ttlDate = null;
-
+    private String rawXacmlPolicy = null;
 
     public StdPAPPolicy() {
         //
@@ -101,16 +102,23 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
         this.configPolicyType = configPolicyType;
     }
 
-    //Constructor for Create Config Policies from API and Admin Console
-    //Constructor for Updating Config Policies from the API
-    //convenience constructor
+    /**
+     * Constructor for
+     *  Create Config Policies from API and Admin Console
+     *  Updating Config Policies from the API
+     *  Create/Update Action Policies from API
+     *  Create/Update Decision Policies
+     * @param stdPAPPolicyParams Input params object
+     */
     public StdPAPPolicy(StdPAPPolicyParams stdPAPPolicyParams) {
         this.configPolicyType=stdPAPPolicyParams.getConfigPolicyType();
         this.policyName = stdPAPPolicyParams.getPolicyName();
         this.policyDescription = stdPAPPolicyParams.getDescription();
         this.onapName = stdPAPPolicyParams.getOnapName();
+        this.providerComboBox = stdPAPPolicyParams.getProviderComboBox();
         this.configName = stdPAPPolicyParams.getConfigName();
-        this.dyanamicFieldConfigAttributes = stdPAPPolicyParams.getAttributes();
+        this.dynamicFieldConfigAttributes = stdPAPPolicyParams.getDynamicFieldConfigAttributes();
+        this.dynamicSettingsMap = stdPAPPolicyParams.getDynamicSettingsMap();
         this.configType = stdPAPPolicyParams.getConfigType();
         this.configBodyData = stdPAPPolicyParams.getConfigBodyData();
         this.editPolicy = stdPAPPolicyParams.getEditPolicy();
@@ -120,348 +128,34 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
         this.riskType = stdPAPPolicyParams.getRiskType();
         this.guard = stdPAPPolicyParams.getGuard();
         this.ttlDate = stdPAPPolicyParams.getTtlDate();
-    }
-
-    //Constructor for Create/Update Action Policies from API
-    public StdPAPPolicy(String policyName, String description, Map<String, String> attributes,
-                        List<String> dynamicRuleAlgorithmLabels, List<String> dynamicRuleAlgorithmCombo,
-                        List<String> dynamicRuleAlgorithmField1, List<String> dynamicRuleAlgorithmField2,
-                        String actionPerformer, String actionAttribute, Boolean editPolicy,
-                        String domain, int highestVersion) {
-
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.dyanamicFieldConfigAttributes = attributes;
-        this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
-        this.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo;
-        this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
-        this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
-        this.actionPerformer = actionPerformer;
-        this.actionAttribute = actionAttribute;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.highestVersion = highestVersion;
-
-    }
-
-    //Constructor for Create/Update Decision Policies
-    public StdPAPPolicy(String policyName, String description, String onapName, String providerComboBox,
-                        Map<String, String> attributes, Map<String, String> settings, Map<String, String> treatments,
-                        List<String> dynamicRuleAlgorithmLabels, List<String> dynamicRuleAlgorithmCombo,
-                        List<String> dynamicRuleAlgorithmField1,
-                        List<String> dynamicRuleAlgorithmField2, Map<String, String> dropDownMap,
-                        List<Object> dynamicVariableList,
-                        List<String> dataTypeList, Boolean editPolicy, String domain, int highestVersion) {
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.onapName = onapName;
-        this.setProviderComboBox(providerComboBox);
-        this.dyanamicFieldConfigAttributes = attributes;
-        this.dynamicSettingsMap = settings;
-        this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
-        this.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo;
-        this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
-        this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
-        this.dynamicVariableList = dynamicVariableList;
-        this.dataTypeList = dataTypeList;
-        this.dropDownMap = dropDownMap;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.highestVersion = highestVersion;
-        this.treatments = treatments;
-    }
-
-    //convenience constructor
-    public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
-                        String configName, Map<String, String> attributes, String body, String policyID,
-                        String ruleID, String configType, Boolean editPolicy, String version, String domain,
-                        String riskLevel, String riskType, String guard, String ttlDate) {
-        this(configPolicyType, policyName, description, onapName, configName, attributes, body, policyID,
-                ruleID, configType, editPolicy, version, domain, 1, riskLevel, riskType, guard, ttlDate);
-    }
-
-    //Constructor for Updating Config Policies from Admin Console
-    public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
-                        String configName, Map<String, String> attributes, String body, String policyID,
-                        String ruleID, String configType, Boolean editPolicy, String version, String domain,
-                        int highestVersion, String riskLevel, String riskType, String guard, String ttlDate) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.onapName = onapName;
-        this.configName = configName;
-        this.dyanamicFieldConfigAttributes = attributes;
-        this.configBodyData = body;
-        this.policyID = policyID;
-        this.ruleID = ruleID;
-        this.configType = configType;
-        this.editPolicy = editPolicy;
-        this.version = version;
-        this.domain = domain;
-        this.highestVersion = highestVersion;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-    }
-
-
-    //Constructor for Creating Config Firewall Policies
-    public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName,
-                        Boolean editPolicy, String domain, String jsonBody, Integer highestVersion, String riskLevel,
-                        String riskType, String guard, String ttlDate) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.configName = configName;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.jsonBody = jsonBody;
-        this.highestVersion = highestVersion;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-
-    }
-
-    //Constructor for Creating Goc Policies
-    public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName,
-                        Boolean editPolicy, String domain, String jsonBody, Integer highestVersion, String eCompName,
-                        String riskLevel, String riskType, String guard, String ttlDate) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.configName = configName;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.jsonBody = jsonBody;
-        this.highestVersion = highestVersion;
-        this.onapName = eCompName;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-    }
-
-    //Constructor for Creating BRMS Policies from the Admin Console
-    public StdPAPPolicy(String configPolicyType, String policyName, String description,
-                        String configName, Boolean editPolicy, String domain,
-                        Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
-                        String configBodyData, String riskLevel, String riskType, String guard, String ttlDate,
-                        String brmsController, List<String> brmsDependency) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.configName = configName;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
-        this.highestVersion = highestVersion;
-        this.onapName = eCompName;
-        this.configBodyData = configBodyData;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-        this.brmsController = brmsController;
-        this.brmsDependency = brmsDependency;
-    }
-
-    //Constructor for Creating BRMS Param Policies from the Admin Console
-    public StdPAPPolicy(String configPolicyType, String policyName, String description,
-                        String configName, Boolean editPolicy, String domain,
-                        Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
-                        String configBodyData, Map<String, String> drlRuleAndUIParams, String riskLevel,
-                        String riskType, String guard, String ttlDate, String brmsController,
-                        List<String> brmsDependency) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.configName = configName;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
-        this.highestVersion = highestVersion;
-        this.onapName = eCompName;
-        this.configBodyData = configBodyData;
-        this.drlRuleAndUIParams = drlRuleAndUIParams;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-        this.brmsController = brmsController;
-        this.brmsDependency = brmsDependency;
-    }
-
-    //Constructor for Creating CloseLoop_Fault and Performance Metric Policies
-    public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
-                        String jsonBody, Boolean draft, String oldPolicyFileName, String serviceType,
-                        Boolean editPolicy,
-                        String domain, Integer highestVersion, String riskLevel, String riskType, String guard,
-                        String ttlDate) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.onapName = onapName;
-        this.jsonBody = jsonBody;
-        this.draft = draft;
-        this.oldPolicyFileName = oldPolicyFileName;
-        this.serviceType = serviceType;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.highestVersion = highestVersion;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-    }
-
-    //Constructor for Updating Config Firewall Policies from the Admin Console
-    public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName,
-                        Boolean editPolicy, String domain, String policyID,
-                        String ruleID, String version, String jsonBody, Integer highestVersion, String riskLevel,
-                        String riskType, String guard, String ttlDate) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.configName = configName;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.policyID = policyID;
-        this.ruleID = ruleID;
-        this.version = version;
-        this.jsonBody = jsonBody;
-        this.highestVersion = highestVersion;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-    }
-
-    //Constructor for Micro Service Creating/Updating Policies from the Admin Console
-    public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
-                        String configName, String serviceType, String uuid,
-                        String msLocation, String jsonBody, String priority, String version, Boolean editPolicy,
-                        String domain, int highestVersion, String riskLevel,
-                        String riskType, String guard, String ttlDate) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.onapName = onapName;
-        this.configName = configName;
-        this.serviceType = serviceType;
-        this.uuid = uuid;
-        this.msLocation = msLocation;
-        this.priority = priority;
-        this.version = version;
-        this.jsonBody = jsonBody;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.highestVersion = highestVersion;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-    }
-
-    //Constructor for Updating Goc Policies from the Admin Console
-    public StdPAPPolicy(String configPolicyType, String policyName, String description,
-                        String configName, Boolean editPolicy, String domain,
-                        String policyID, String ruleID, String version,
-                        String jsonBody, Integer highestVersion, String eCompName, String riskLevel, String riskType,
-                        String guard, String ttlDate) {
-
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.configName = configName;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.policyID = policyID;
-        this.ruleID = ruleID;
-        this.version = version;
-        this.jsonBody = jsonBody;
-        this.highestVersion = highestVersion;
-        this.onapName = eCompName;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-    }
-
-    //Constructor for Updating Brms Policies from the Admin Console
-    public StdPAPPolicy(String configPolicyType, String policyName, String description,
-                        String configName, Boolean editPolicy, String domain,
-                        String policyID, String ruleID, String version,
-                        Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
-                        String configBodyData, String riskLevel, String riskType, String guard, String ttlDate
-    ) {
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.configName = configName;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.policyID = policyID;
-        this.ruleID = ruleID;
-        this.version = version;
-        this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
-        this.highestVersion = highestVersion;
-        this.onapName = eCompName;
-        this.configBodyData = configBodyData;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-    }
-
-    //Constructor for Updating Brms Param Policies from the Admin Console
-    public StdPAPPolicy(String configPolicyType, String policyName, String description,
-                        String configName, Boolean editPolicy, String domain,
-                        String policyID, String ruleID, String version,
-                        Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
-                        Map<String, String> drlRuleAndUIParams, String riskLevel, String riskType, String guard,
-                        String ttlDate
-    ) {
-        this.configPolicyType = configPolicyType;
-        this.policyName = policyName;
-        this.policyDescription = description;
-        this.configName = configName;
-        this.editPolicy = editPolicy;
-        this.domain = domain;
-        this.policyID = policyID;
-        this.ruleID = ruleID;
-        this.version = version;
-        this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
-        this.highestVersion = highestVersion;
-        this.onapName = eCompName;
-        this.drlRuleAndUIParams = drlRuleAndUIParams;
-        this.riskLevel = riskLevel;
-        this.riskType = riskType;
-        this.guard = guard;
-        this.ttlDate = ttlDate;
-    }
-
-    // Constructor for deleting policies from the API
-    public StdPAPPolicy(String policyName, String deleteCondition) {
-        this.policyName = policyName;
-        this.deleteCondition = deleteCondition;
-    }
-
-    // Constructor for creating dictionary items from the API>
-    public StdPAPPolicy(String dictionaryType, String dictionary, String dictionaryFields) {
-        this.dictionaryType = dictionaryType;
-        this.dictionary = dictionary;
-        this.dictionaryFields = dictionaryFields;
+        this.dynamicRuleAlgorithmLabels = stdPAPPolicyParams.getDynamicRuleAlgorithmLabels();
+        this.dynamicRuleAlgorithmCombo = stdPAPPolicyParams.getDynamicRuleAlgorithmCombo();
+        this.dynamicRuleAlgorithmField1 = stdPAPPolicyParams.getDynamicRuleAlgorithmField1();
+        this.dynamicRuleAlgorithmField2 = stdPAPPolicyParams.getDynamicRuleAlgorithmField2();
+        this.dynamicVariableList = stdPAPPolicyParams.getDynamicVariableList();
+        this.dataTypeList = stdPAPPolicyParams.getDataTypeList();
+        this.dropDownMap = stdPAPPolicyParams.getDropDownMap();
+        this.actionPerformer = stdPAPPolicyParams.getActionPerformer();
+        this.actionAttribute = stdPAPPolicyParams.getActionAttribute();
+        this.treatments = stdPAPPolicyParams.getTreatments();
+        this.policyID = stdPAPPolicyParams.getPolicyID();
+        this.ruleID = stdPAPPolicyParams.getRuleID();
+        this.version = stdPAPPolicyParams.getVersion();
+        this.jsonBody = stdPAPPolicyParams.getJsonBody();
+        this.brmsController = stdPAPPolicyParams.getBrmsController();
+        this.brmsDependency = stdPAPPolicyParams.getBrmsDependency();
+        this.drlRuleAndUIParams = stdPAPPolicyParams.getDrlRuleAndUIParams();
+        this.serviceType = stdPAPPolicyParams.getServiceType();
+        this.oldPolicyFileName = stdPAPPolicyParams.getOldPolicyFileName();
+        this.draft = stdPAPPolicyParams.isDraft();
+        this.uuid = stdPAPPolicyParams.getUuid();
+        this.msLocation = stdPAPPolicyParams.getMsLocation();
+        this.priority = stdPAPPolicyParams.getPriority();
+        this.deleteCondition = stdPAPPolicyParams.getDeleteCondition();
+        this.dictionaryType = stdPAPPolicyParams.getDictionaryType();
+        this.dictionary = stdPAPPolicyParams.getDictionary();
+        this.dictionaryFields = stdPAPPolicyParams.getDictionaryFields();
+        this.rawXacmlPolicy = stdPAPPolicyParams.getRawXacmlPolicy();
     }
 
     @Override
@@ -486,7 +180,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
 
     @Override
     public Map<String, String> getDynamicFieldConfigAttributes() {
-        return dyanamicFieldConfigAttributes;
+        return dynamicFieldConfigAttributes;
     }
 
     @Override
@@ -697,8 +391,8 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
     @Override
     public String toString() {
         return "StdPAPPolicy [policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="
-                + onapName + ", configName=" + configName + ", dyanamicFieldConfigAttributes=" +
-                dyanamicFieldConfigAttributes + ", configBodyData=" + configBodyData
+                + onapName + ", configName=" + configName + ", dynamicFieldConfigAttributes=" +
+                dynamicFieldConfigAttributes + ", configBodyData=" + configBodyData
                 + ", policyID=" + policyID + ", ruleID=" + ruleID + ", configType=" + configType + ", editPolicy=" +
                 ", version=" + ", domain=" + domain
                 + ", configPolicyType=" + configPolicyType + ", jsonBody=" + jsonBody + ", highestVersion=" +
@@ -741,9 +435,9 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
         this.configName = configName;
     }
 
-    public void setDyanamicFieldConfigAttributes(
-            Map<String, String> dyanamicFieldConfigAttributes) {
-        this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
+    public void setDynamicFieldConfigAttributes(
+            Map<String, String> dynamicFieldConfigAttributes) {
+        this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes;
     }
 
     public void setConfigBodyData(String configBodyData) {
@@ -944,4 +638,12 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
     public void setTreatments(Map<String, String> treatments) {
         this.treatments = treatments;
     }
+    
+    public String getRawXacmlPolicy() {
+        return rawXacmlPolicy;
+    }
+
+    public void setRawXacmlPolicy(String rawXacmlPolicy) {
+        this.rawXacmlPolicy = rawXacmlPolicy;
+    }
 }