Format ONAP-XACML and add JUnit
[policy/engine.git] / ONAP-XACML / src / main / java / org / onap / policy / xacml / std / pap / StdPAPPolicy.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-XACML
4  * ================================================================================
5  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.xacml.std.pap;
23
24 import java.io.Serializable;
25 import java.net.URI;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30 import org.onap.policy.xacml.api.pap.OnapPAPPolicy;
31
32 public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
33     private static final long serialVersionUID = 5260230629397322000L;
34
35     private String policyName = null;
36     private String oldPolicyFileName = null;
37     private String policyDescription = null;
38     private String onapName = null;
39     private String configName = null;
40     private Map<String, String> dynamicFieldConfigAttributes = new HashMap<>();
41     private Map<String, String> treatments = new HashMap<>();
42     private Map<String, String> dropDownMap = new HashMap<>();
43     private Map<String, String> dynamicSettingsMap = new HashMap<>();
44     private List<String> dynamicRuleAlgorithmLabels;
45     private List<String> dynamicRuleAlgorithmCombo;
46     private List<String> dynamicRuleAlgorithmField1;
47     private List<String> dynamicRuleAlgorithmField2;
48     private transient List<Object> dynamicVariableList;
49     private List<String> dataTypeList;
50     private String configBodyData = null;
51     private String policyID = null;
52     private String ruleID = null;
53     private String brmsController;
54     private List<String> brmsDependency;
55     private String configType = null;
56     private Boolean editPolicy = false;
57     private Boolean draft = false;
58     private String version = null;
59     private String domain = null;
60     private String configPolicyType = null;
61     private String jsonBody = null;
62     private String serviceType = null;
63     private Integer highestVersion = null;
64     private URI location = null;
65     private String actionPerformer = null;
66     private String actionAttribute = null;
67     private String actionBody = null;
68     private String actionDictHeader = null;
69     private String actionDictType = null;
70     private String actionDictUrl = null;
71     private String actionDictMethod = null;
72     private String uuid = null;
73     private String msLocation = null;
74     private String priority = null;
75     private transient Map<String, String> drlRuleAndUIParams = null;
76     private String deleteCondition = null;
77     private String dictionaryType = null;
78     private String dictionary = null;
79     private String dictionaryFields = null;
80     private String providerComboBox = null;
81     private String riskType = null;
82     private String guard = null;
83     private String riskLevel;
84     private String ttlDate = null;
85     private String rawXacmlPolicy = null;
86
87     public StdPAPPolicy() {
88         //
89         // Default empty constructor
90         //
91     }
92
93     // Constructor for sending location when pushing policies
94     public StdPAPPolicy(URI location) {
95         this.location = location;
96     }
97
98     /**
99      * Constructor for Validating Config Policies.
100      *
101      * @param policyName String
102      * @param body String
103      * @param configType String
104      * @param configPolicyType String
105      */
106     public StdPAPPolicy(String policyName, String body, String configType, String configPolicyType) {
107         this.policyName = policyName;
108         this.configBodyData = body;
109         this.configType = configType;
110         this.configPolicyType = configPolicyType;
111     }
112
113     /**
114      * Constructor.
115      * Create Config Policies from API and Admin Console
116      * Updating Config Policies from the API
117      * Create/Update Action Policies from API
118      * Create/Update Decision Policies
119      *
120      * @param stdPAPPolicyParams Input params object
121      */
122     public StdPAPPolicy(StdPAPPolicyParams stdPAPPolicyParams) {
123         this.configPolicyType = stdPAPPolicyParams.getConfigPolicyType();
124         this.policyName = stdPAPPolicyParams.getPolicyName();
125         this.policyDescription = stdPAPPolicyParams.getDescription();
126         this.onapName = stdPAPPolicyParams.getOnapName();
127         this.providerComboBox = stdPAPPolicyParams.getProviderComboBox();
128         this.configName = stdPAPPolicyParams.getConfigName();
129         this.dynamicFieldConfigAttributes = stdPAPPolicyParams.getDynamicFieldConfigAttributes();
130         this.dynamicSettingsMap = stdPAPPolicyParams.getDynamicSettingsMap();
131         this.configType = stdPAPPolicyParams.getConfigType();
132         this.configBodyData = stdPAPPolicyParams.getConfigBodyData();
133         this.editPolicy = stdPAPPolicyParams.getEditPolicy();
134         this.domain = stdPAPPolicyParams.getDomain();
135         this.highestVersion = stdPAPPolicyParams.getHighestVersion();
136         this.riskLevel = stdPAPPolicyParams.getRiskLevel();
137         this.riskType = stdPAPPolicyParams.getRiskType();
138         this.guard = stdPAPPolicyParams.getGuard();
139         this.ttlDate = stdPAPPolicyParams.getTtlDate();
140         this.dynamicRuleAlgorithmLabels = stdPAPPolicyParams.getDynamicRuleAlgorithmLabels();
141         this.dynamicRuleAlgorithmCombo = stdPAPPolicyParams.getDynamicRuleAlgorithmCombo();
142         this.dynamicRuleAlgorithmField1 = stdPAPPolicyParams.getDynamicRuleAlgorithmField1();
143         this.dynamicRuleAlgorithmField2 = stdPAPPolicyParams.getDynamicRuleAlgorithmField2();
144         this.dynamicVariableList = stdPAPPolicyParams.getDynamicVariableList();
145         this.dataTypeList = stdPAPPolicyParams.getDataTypeList();
146         this.dropDownMap = stdPAPPolicyParams.getDropDownMap();
147         this.actionPerformer = stdPAPPolicyParams.getActionPerformer();
148         this.actionAttribute = stdPAPPolicyParams.getActionAttribute();
149         this.treatments = stdPAPPolicyParams.getTreatments();
150         this.policyID = stdPAPPolicyParams.getPolicyID();
151         this.ruleID = stdPAPPolicyParams.getRuleID();
152         this.version = stdPAPPolicyParams.getVersion();
153         this.jsonBody = stdPAPPolicyParams.getJsonBody();
154         this.brmsController = stdPAPPolicyParams.getBrmsController();
155         this.brmsDependency = stdPAPPolicyParams.getBrmsDependency();
156         this.drlRuleAndUIParams = stdPAPPolicyParams.getDrlRuleAndUIParams();
157         this.serviceType = stdPAPPolicyParams.getServiceType();
158         this.oldPolicyFileName = stdPAPPolicyParams.getOldPolicyFileName();
159         this.draft = stdPAPPolicyParams.isDraft();
160         this.uuid = stdPAPPolicyParams.getUuid();
161         this.msLocation = stdPAPPolicyParams.getMsLocation();
162         this.priority = stdPAPPolicyParams.getPriority();
163         this.deleteCondition = stdPAPPolicyParams.getDeleteCondition();
164         this.dictionaryType = stdPAPPolicyParams.getDictionaryType();
165         this.dictionary = stdPAPPolicyParams.getDictionary();
166         this.dictionaryFields = stdPAPPolicyParams.getDictionaryFields();
167         this.rawXacmlPolicy = stdPAPPolicyParams.getRawXacmlPolicy();
168     }
169
170     @Override
171     public String getPolicyName() {
172         return policyName;
173     }
174
175     @Override
176     public String getPolicyDescription() {
177         return policyDescription;
178     }
179
180     @Override
181     public String getOnapName() {
182         return onapName;
183     }
184
185     @Override
186     public String getConfigName() {
187         return configName;
188     }
189
190     @Override
191     public Map<String, String> getDynamicFieldConfigAttributes() {
192         return dynamicFieldConfigAttributes;
193     }
194
195     @Override
196     public String getConfigBodyData() {
197         return configBodyData;
198     }
199
200     @Override
201     public String getPolicyID() {
202         return policyID;
203     }
204
205     @Override
206     public String getRuleID() {
207         return ruleID;
208     }
209
210     @Override
211     public String getConfigType() {
212         return configType;
213     }
214
215     @Override
216     public Boolean isEditPolicy() {
217         return editPolicy;
218     }
219
220     @Override
221     public Boolean isDraft() {
222         return draft;
223     }
224
225     @Override
226     public String getVersion() {
227         return version;
228     }
229
230     @Override
231     public String getDomainDir() {
232         return domain;
233     }
234
235     @Override
236     public String getConfigPolicyType() {
237         return configPolicyType;
238     }
239
240     @Override
241     public String getJsonBody() {
242         return jsonBody;
243     }
244
245     @Override
246     public Integer getHighestVersion() {
247         return highestVersion;
248     }
249
250     @Override
251     public URI getLocation() {
252         return location;
253     }
254
255     @Override
256     public List<String> getDynamicRuleAlgorithmLabels() {
257         return dynamicRuleAlgorithmLabels;
258     }
259
260     @Override
261     public List<String> getDynamicRuleAlgorithmCombo() {
262         return dynamicRuleAlgorithmCombo;
263     }
264
265     @Override
266     public List<String> getDynamicRuleAlgorithmField1() {
267         return dynamicRuleAlgorithmField1;
268     }
269
270     @Override
271     public List<String> getDynamicRuleAlgorithmField2() {
272         return dynamicRuleAlgorithmField2;
273     }
274
275     @Override
276     public String getActionPerformer() {
277         return actionPerformer;
278     }
279
280     @Override
281     public String getActionAttribute() {
282         return actionAttribute;
283     }
284
285     @Override
286     public String getActionBody() {
287         return actionBody;
288     }
289
290     @Override
291     public Map<String, String> getDropDownMap() {
292         return dropDownMap;
293     }
294
295     @Override
296     public String getActionDictHeader() {
297         return actionDictHeader;
298     }
299
300     @Override
301     public String getActionDictType() {
302         return actionDictType;
303     }
304
305     @Override
306     public String getActionDictUrl() {
307         return actionDictUrl;
308     }
309
310     @Override
311     public String getActionDictMethod() {
312         return actionDictMethod;
313     }
314
315     @Override
316     public Map<String, String> getDynamicSettingsMap() {
317         return dynamicSettingsMap;
318     }
319
320     @Override
321     public List<Object> getDynamicVariableList() {
322         return dynamicVariableList;
323     }
324
325     @Override
326     public List<String> getDataTypeList() {
327         return dataTypeList;
328     }
329
330     @Override
331     public String getOldPolicyFileName() {
332         return oldPolicyFileName;
333     }
334
335     @Override
336     public String getServiceType() {
337         return serviceType;
338     }
339
340     @Override
341     public String getUuid() {
342         return uuid;
343     }
344
345     @Override
346     public String getMsLocation() {
347         return msLocation;
348     }
349
350     @Override
351     public String getPriority() {
352         return priority;
353     }
354
355     @Override
356     public String getDeleteCondition() {
357         return deleteCondition;
358     }
359
360     @Override
361     public String getDictionaryType() {
362         return dictionaryType;
363     }
364
365     @Override
366     public String getDictionary() {
367         return dictionary;
368     }
369
370     @Override
371     public String getTTLDate() {
372         return ttlDate;
373     }
374
375     @Override
376     public String getDictionaryFields() {
377         return dictionaryFields;
378     }
379
380     @Override
381     public String getRiskType() {
382         return riskType;
383     }
384
385     @Override
386     public String getRiskLevel() {
387         return riskLevel;
388     }
389
390     @Override
391     public String getGuard() {
392         return guard;
393     }
394
395     @Override
396     public Map<String, String> getTreatments() {
397         return treatments;
398     }
399
400     @Override
401     public String toString() {
402         return "StdPAPPolicy [policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="
403                 + onapName + ", configName=" + configName + ", dynamicFieldConfigAttributes="
404                 + dynamicFieldConfigAttributes + ", configBodyData=" + configBodyData + ", policyID=" + policyID
405                 + ", ruleID=" + ruleID + ", configType=" + configType + ", editPolicy=" + ", version=" + ", domain="
406                 + domain + ", configPolicyType=" + configPolicyType + ", jsonBody=" + jsonBody + ", highestVersion="
407                 + highestVersion + ", location=" + location + ",dynamicRuleAlgorithmLabels="
408                 + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmCombo=" + dynamicRuleAlgorithmCombo
409                 + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2="
410                 + dynamicRuleAlgorithmField2 + ",actionPerformer=" + actionPerformer + ",actionAttribute="
411                 + actionAttribute + ",actionBody=" + actionBody + ",dropDownMap=" + dropDownMap + ",actionDictHeader="
412                 + actionDictHeader + ",actionDictType=" + actionDictType + ",actionDictUrl=" + actionDictUrl
413                 + ",actionDictMethod=" + actionDictMethod + ",dynamicSettingsMap=" + dynamicSettingsMap + ","
414                 + "dynamicVariableList=" + dynamicVariableList + ",providerComboBox=" + providerComboBox
415                 + ",dataTypeList=" + dataTypeList + ",draft=" + ",oldPolicyFileName=" + oldPolicyFileName + ","
416                 + "serviceType=" + serviceType + ",uuid=" + uuid + ",msLocation=" + msLocation + ",priority=" + priority
417                 + ",deleteCondition=" + deleteCondition + ",dictionaryType=" + dictionaryType + ",dictionary="
418                 + dictionary + ",dictionaryFields=" + dictionaryFields + ",uuid=" + uuid + "," + "msLocation="
419                 + msLocation + ",priority=" + priority + ",deleteCondition=" + deleteCondition + ",riskType=" + riskType
420                 + ",riskLevel=" + riskLevel + ",guard=" + guard + ",ttlDate=" + ttlDate + ",treatments=" + treatments
421                 + "]";
422     }
423
424     // Methods needed for JSON Deserialization
425     public void setPolicyName(String policyName) {
426         this.policyName = policyName;
427     }
428
429     public void setPolicyDescription(String policyDescription) {
430         this.policyDescription = policyDescription;
431     }
432
433     public void setOnapName(String onapName) {
434         this.onapName = onapName;
435     }
436
437     public void setConfigName(String configName) {
438         this.configName = configName;
439     }
440
441     public void setDynamicFieldConfigAttributes(Map<String, String> dynamicFieldConfigAttributes) {
442         this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes;
443     }
444
445     public void setConfigBodyData(String configBodyData) {
446         this.configBodyData = configBodyData;
447     }
448
449     public void setPolicyID(String policyID) {
450         this.policyID = policyID;
451     }
452
453     public void setRuleID(String ruleID) {
454         this.ruleID = ruleID;
455     }
456
457     public void setConfigType(String configType) {
458         this.configType = configType;
459     }
460
461     public void setEditPolicy(Boolean editPolicy) {
462         this.editPolicy = editPolicy;
463     }
464
465     public void setVersion(String version) {
466         this.version = version;
467     }
468
469     public void setDomainDir(String domain) {
470         this.domain = domain;
471     }
472
473     public void setConfigPolicyType(String configPolicyType) {
474         this.configPolicyType = configPolicyType;
475     }
476
477     public void setJsonBody(String jsonBody) {
478         this.jsonBody = jsonBody;
479     }
480
481     public void setHighestVersion(Integer highestVersion) {
482         this.highestVersion = highestVersion;
483     }
484
485     public void setLocation(URI location) {
486         this.location = location;
487     }
488
489     public void setDynamicRuleAlgorithmLabels(List<String> dynamicRuleAlgorithmLabels) {
490         this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
491     }
492
493     public void setDynamicRuleAlgorithmCombo(List<String> dynamicRuleAlgorithmCombo) {
494         this.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo;
495     }
496
497     public void setDynamicRuleAlgorithmField1(List<String> dynamicRuleAlgorithmField1) {
498         this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
499     }
500
501     public void setDynamicRuleAlgorithmField2(List<String> dynamicRuleAlgorithmField2) {
502         this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
503     }
504
505     public void setActionPerformer(String actionPerformer) {
506         this.actionPerformer = actionPerformer;
507     }
508
509     public void setActionAttribute(String actionAttribute) {
510         this.actionAttribute = actionAttribute;
511     }
512
513     public void setActionBody(String actionBody) {
514         this.actionBody = actionBody;
515     }
516
517     public void setDropDownMap(Map<String, String> dropDownMap) {
518         this.dropDownMap = dropDownMap;
519     }
520
521     public void setActionDictHeader(String actionDictHeader) {
522         this.actionDictHeader = actionDictHeader;
523     }
524
525     public void setActionDictType(String actionDictType) {
526         this.actionDictType = actionDictType;
527     }
528
529     public void setActionDictUrl(String actionDictUrl) {
530         this.actionDictUrl = actionDictUrl;
531     }
532
533     public void setActionDictMethod(String actionDictMethod) {
534         this.actionDictMethod = actionDictMethod;
535     }
536
537     public void setDynamicSettingsMap(Map<String, String> dynamicSettingsMap) {
538         this.dynamicSettingsMap = dynamicSettingsMap;
539     }
540
541     public void setDynamicVariableList(List<Object> dynamicVariableList) {
542         this.dynamicVariableList = dynamicVariableList;
543     }
544
545     public void setDataTypeList(List<String> dataTypeList) {
546         this.dataTypeList = dataTypeList;
547     }
548
549     public void setDraft(Boolean draft) {
550         this.draft = draft;
551     }
552
553     public void setOldPolicyFileName(String oldPolicyFileName) {
554         this.oldPolicyFileName = oldPolicyFileName;
555     }
556
557     public void setServiceType(String serviceType) {
558         this.serviceType = serviceType;
559     }
560
561     public Map<String, String> getDrlRuleAndUIParams() {
562         return drlRuleAndUIParams;
563     }
564
565     public void setDrlRuleAndUIParams(Map<String, String> drlRuleAndUIParams) {
566         this.drlRuleAndUIParams = drlRuleAndUIParams;
567     }
568
569     public void setUuid(String uuid) {
570         this.uuid = uuid;
571     }
572
573     public void setMsLocation(String msLocation) {
574         this.msLocation = msLocation;
575     }
576
577     public void setPriority(String priority) {
578         this.priority = priority;
579     }
580
581     public void setDeleteCondition(String deleteCondition) {
582         this.deleteCondition = deleteCondition;
583     }
584
585     public void setDictionaryType(String dictionaryType) {
586         this.dictionaryType = dictionaryType;
587     }
588
589     public void setDictionary(String dictionary) {
590         this.dictionary = dictionary;
591     }
592
593     public void setDictionaryFields(String dictionaryFields) {
594         this.dictionaryFields = dictionaryFields;
595     }
596
597     public String getProviderComboBox() {
598         return providerComboBox;
599     }
600
601     public void setProviderComboBox(String providerComboBox) {
602         this.providerComboBox = providerComboBox;
603     }
604
605     public void setRiskType(String riskType) {
606         this.riskType = riskType;
607     }
608
609     public void setRiskLevel(String riskLevel) {
610         this.riskLevel = riskLevel;
611     }
612
613     public void setGuard(String guard) {
614         this.guard = guard;
615     }
616
617     public void setTTLDate(String ttlDate) {
618         this.ttlDate = ttlDate;
619     }
620
621     public String getBrmsController() {
622         return brmsController;
623     }
624
625     public void setBrmsController(String brmsController) {
626         this.brmsController = brmsController;
627     }
628
629     public List<String> getBrmsDependency() {
630         return brmsDependency;
631     }
632
633     public void setBrmsDependency(List<String> brmsDependency) {
634         this.brmsDependency = brmsDependency;
635     }
636
637     public void setTreatments(Map<String, String> treatments) {
638         this.treatments = treatments;
639     }
640
641     public String getRawXacmlPolicy() {
642         return rawXacmlPolicy;
643     }
644
645     public void setRawXacmlPolicy(String rawXacmlPolicy) {
646         this.rawXacmlPolicy = rawXacmlPolicy;
647     }
648 }