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