Merge "Resolved the Sonar issues"
[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  * Modified 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
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     }
149
150     //Constructor for Creating BRMS Param Policies from the Admin Console
151     public StdPAPPolicy(String configPolicyType, String policyName, String description,
152                         String configName, Boolean editPolicy, String domain,
153                         Map<String, String> dynamicFieldConfigAttributes, Integer highestVersion, String eCompName,
154                         String configBodyData, Map<String, String> drlRuleAndUIParams, String riskLevel,
155                         String riskType, String guard, String ttlDate, String brmsController,
156                         List<String> brmsDependency) {
157
158         this.configPolicyType = configPolicyType;
159         this.policyName = policyName;
160         this.policyDescription = description;
161         this.configName = configName;
162         this.editPolicy = editPolicy;
163         this.domain = domain;
164         this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes;
165         this.highestVersion = highestVersion;
166         this.onapName = eCompName;
167         this.configBodyData = configBodyData;
168         this.drlRuleAndUIParams = drlRuleAndUIParams;
169         this.riskLevel = riskLevel;
170         this.riskType = riskType;
171         this.guard = guard;
172         this.ttlDate = ttlDate;
173         this.brmsController = brmsController;
174         this.brmsDependency = brmsDependency;
175     }
176
177     //Constructor for Creating CloseLoop_Fault and Performance Metric Policies
178     public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
179                         String jsonBody, Boolean draft, String oldPolicyFileName, String serviceType,
180                         Boolean editPolicy,
181                         String domain, Integer highestVersion, String riskLevel, String riskType, String guard,
182                         String ttlDate) {
183
184         this.configPolicyType = configPolicyType;
185         this.policyName = policyName;
186         this.policyDescription = description;
187         this.onapName = onapName;
188         this.jsonBody = jsonBody;
189         this.draft = draft;
190         this.oldPolicyFileName = oldPolicyFileName;
191         this.serviceType = serviceType;
192         this.editPolicy = editPolicy;
193         this.domain = domain;
194         this.highestVersion = highestVersion;
195         this.riskLevel = riskLevel;
196         this.riskType = riskType;
197         this.guard = guard;
198         this.ttlDate = ttlDate;
199     }
200
201     //Constructor for Micro Service Creating/Updating Policies from the Admin Console
202     public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
203                         String configName, String serviceType, String uuid,
204                         String msLocation, String jsonBody, String priority, String version, Boolean editPolicy,
205                         String domain, int highestVersion, String riskLevel,
206                         String riskType, String guard, String ttlDate) {
207
208         this.configPolicyType = configPolicyType;
209         this.policyName = policyName;
210         this.policyDescription = description;
211         this.onapName = onapName;
212         this.configName = configName;
213         this.serviceType = serviceType;
214         this.uuid = uuid;
215         this.msLocation = msLocation;
216         this.priority = priority;
217         this.version = version;
218         this.jsonBody = jsonBody;
219         this.editPolicy = editPolicy;
220         this.domain = domain;
221         this.highestVersion = highestVersion;
222         this.riskLevel = riskLevel;
223         this.riskType = riskType;
224         this.guard = guard;
225         this.ttlDate = ttlDate;
226     }
227
228     // Constructor for deleting policies from the API
229     public StdPAPPolicy(String policyName, String deleteCondition) {
230         this.policyName = policyName;
231         this.deleteCondition = deleteCondition;
232     }
233
234     // Constructor for creating dictionary items from the API>
235     public StdPAPPolicy(String dictionaryType, String dictionary, String dictionaryFields) {
236         this.dictionaryType = dictionaryType;
237         this.dictionary = dictionary;
238         this.dictionaryFields = dictionaryFields;
239     }
240
241     @Override
242     public String getPolicyName() {
243         return policyName;
244     }
245
246     @Override
247     public String getPolicyDescription() {
248         return policyDescription;
249     }
250
251     @Override
252     public String getOnapName() {
253         return onapName;
254     }
255
256     @Override
257     public String getConfigName() {
258         return configName;
259     }
260
261     @Override
262     public Map<String, String> getDynamicFieldConfigAttributes() {
263         return dynamicFieldConfigAttributes;
264     }
265
266     @Override
267     public String getConfigBodyData() {
268         return configBodyData;
269     }
270
271     @Override
272     public String getPolicyID() {
273         return policyID;
274     }
275
276     @Override
277     public String getRuleID() {
278         return ruleID;
279     }
280
281     @Override
282     public String getConfigType() {
283         return configType;
284     }
285
286     @Override
287     public Boolean isEditPolicy() {
288         return editPolicy;
289     }
290
291     @Override
292     public Boolean isDraft() {
293         return draft;
294     }
295
296     @Override
297     public String getVersion() {
298         return version;
299     }
300
301     @Override
302     public String getDomainDir() {
303         return domain;
304     }
305
306     @Override
307     public String getConfigPolicyType() {
308         return configPolicyType;
309     }
310
311     @Override
312     public String getJsonBody() {
313         return jsonBody;
314     }
315
316     @Override
317     public Integer getHighestVersion() {
318         return highestVersion;
319     }
320
321     @Override
322     public URI getLocation() {
323         return location;
324     }
325
326     @Override
327     public List<String> getDynamicRuleAlgorithmLabels() {
328         return dynamicRuleAlgorithmLabels;
329     }
330
331     @Override
332     public List<String> getDynamicRuleAlgorithmCombo() {
333         return dynamicRuleAlgorithmCombo;
334     }
335
336     @Override
337     public List<String> getDynamicRuleAlgorithmField1() {
338         return dynamicRuleAlgorithmField1;
339     }
340
341     @Override
342     public List<String> getDynamicRuleAlgorithmField2() {
343         return dynamicRuleAlgorithmField2;
344     }
345
346     @Override
347     public String getActionPerformer() {
348         return actionPerformer;
349     }
350
351     @Override
352     public String getActionAttribute() {
353         return actionAttribute;
354     }
355
356     @Override
357     public String getActionBody() {
358         return actionBody;
359     }
360
361     @Override
362     public Map<String, String> getDropDownMap() {
363         return dropDownMap;
364     }
365
366     @Override
367     public String getActionDictHeader() {
368         return actionDictHeader;
369     }
370
371     @Override
372     public String getActionDictType() {
373         return actionDictType;
374     }
375
376     @Override
377     public String getActionDictUrl() {
378         return actionDictUrl;
379     }
380
381     @Override
382     public String getActionDictMethod() {
383         return actionDictMethod;
384     }
385
386     @Override
387     public Map<String, String> getDynamicSettingsMap() {
388         return dynamicSettingsMap;
389     }
390
391     @Override
392     public List<Object> getDynamicVariableList() {
393         return dynamicVariableList;
394     }
395
396     @Override
397     public List<String> getDataTypeList() {
398         return dataTypeList;
399     }
400
401     @Override
402     public String getOldPolicyFileName() {
403         return oldPolicyFileName;
404     }
405
406     @Override
407     public String getServiceType() {
408         return serviceType;
409     }
410
411     @Override
412     public String getUuid() {
413         return uuid;
414     }
415
416     @Override
417     public String getMsLocation() {
418         return msLocation;
419     }
420
421     @Override
422     public String getPriority() {
423         return priority;
424     }
425
426     @Override
427     public String getDeleteCondition() {
428         return deleteCondition;
429     }
430
431     @Override
432     public String getDictionaryType() {
433         return dictionaryType;
434     }
435
436     @Override
437     public String getDictionary() {
438         return dictionary;
439     }
440
441     @Override
442     public String getTTLDate() {
443         return ttlDate;
444     }
445
446     @Override
447     public String getDictionaryFields() {
448         return dictionaryFields;
449     }
450
451     @Override
452     public String getRiskType() {
453         return riskType;
454     }
455
456     @Override
457     public String getRiskLevel() {
458         return riskLevel;
459     }
460
461     @Override
462     public String getGuard() {
463         return guard;
464     }
465
466     @Override
467     public Map<String, String> getTreatments() {
468         return treatments;
469     }
470
471     @Override
472     public String toString() {
473         return "StdPAPPolicy [policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="
474                 + onapName + ", configName=" + configName + ", dynamicFieldConfigAttributes=" +
475                 dynamicFieldConfigAttributes + ", configBodyData=" + configBodyData
476                 + ", policyID=" + policyID + ", ruleID=" + ruleID + ", configType=" + configType + ", editPolicy=" +
477                 ", version=" + ", domain=" + domain
478                 + ", configPolicyType=" + configPolicyType + ", jsonBody=" + jsonBody + ", highestVersion=" +
479                 highestVersion + ", location=" + location
480                 + ",dynamicRuleAlgorithmLabels=" + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmCombo=" +
481                 dynamicRuleAlgorithmCombo
482                 + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2=" +
483                 dynamicRuleAlgorithmField2
484                 + ",actionPerformer=" + actionPerformer + ",actionAttribute=" + actionAttribute + ",actionBody=" +
485                 actionBody + ",dropDownMap=" + dropDownMap
486                 + ",actionDictHeader=" + actionDictHeader + ",actionDictType=" + actionDictType + ",actionDictUrl=" +
487                 actionDictUrl
488                 + ",actionDictMethod=" + actionDictMethod + ",dynamicSettingsMap=" + dynamicSettingsMap + "," +
489                 "dynamicVariableList=" + dynamicVariableList + ",providerComboBox=" + providerComboBox
490                 + ",dataTypeList=" + dataTypeList + ",draft=" + ",oldPolicyFileName=" + oldPolicyFileName + "," +
491                 "serviceType=" + serviceType
492                 + ",uuid=" + uuid + ",msLocation=" + msLocation + ",priority=" + priority + ",deleteCondition=" +
493                 deleteCondition + ",dictionaryType=" + dictionaryType
494                 + ",dictionary=" + dictionary + ",dictionaryFields=" + dictionaryFields + ",uuid=" + uuid + "," +
495                 "msLocation=" + msLocation + ",priority="
496                 + priority + ",deleteCondition=" + deleteCondition + ",riskType=" + riskType + ",riskLevel=" +
497                 riskLevel + ",guard=" + guard + ",ttlDate=" + ttlDate
498                 + ",treatments=" + treatments + "]";
499     }
500
501     // Methods needed for JSON Deserialization
502     public void setPolicyName(String policyName) {
503         this.policyName = policyName;
504     }
505
506     public void setPolicyDescription(String policyDescription) {
507         this.policyDescription = policyDescription;
508     }
509
510     public void setOnapName(String onapName) {
511         this.onapName = onapName;
512     }
513
514     public void setConfigName(String configName) {
515         this.configName = configName;
516     }
517
518     public void setDynamicFieldConfigAttributes(
519             Map<String, String> dynamicFieldConfigAttributes) {
520         this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes;
521     }
522
523     public void setConfigBodyData(String configBodyData) {
524         this.configBodyData = configBodyData;
525     }
526
527     public void setPolicyID(String policyID) {
528         this.policyID = policyID;
529     }
530
531     public void setRuleID(String ruleID) {
532         this.ruleID = ruleID;
533     }
534
535     public void setConfigType(String configType) {
536         this.configType = configType;
537     }
538
539     public void setEditPolicy(Boolean editPolicy) {
540         this.editPolicy = editPolicy;
541     }
542
543     public void setVersion(String version) {
544         this.version = version;
545     }
546
547     public void setDomainDir(String domain) {
548         this.domain = domain;
549     }
550
551     public void setConfigPolicyType(String configPolicyType) {
552         this.configPolicyType = configPolicyType;
553     }
554
555     public void setJsonBody(String jsonBody) {
556         this.jsonBody = jsonBody;
557     }
558
559     public void setHighestVersion(Integer highestVersion) {
560         this.highestVersion = highestVersion;
561     }
562
563     public void setLocation(URI location) {
564         this.location = location;
565     }
566
567     public void setDynamicRuleAlgorithmLabels(
568             List<String> dynamicRuleAlgorithmLabels) {
569         this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
570     }
571
572     public void setDynamicRuleAlgorithmCombo(List<String> dynamicRuleAlgorithmCombo) {
573         this.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo;
574     }
575
576     public void setDynamicRuleAlgorithmField1(
577             List<String> dynamicRuleAlgorithmField1) {
578         this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
579     }
580
581     public void setDynamicRuleAlgorithmField2(
582             List<String> dynamicRuleAlgorithmField2) {
583         this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
584     }
585
586     public void setActionPerformer(String actionPerformer) {
587         this.actionPerformer = actionPerformer;
588     }
589
590     public void setActionAttribute(String actionAttribute) {
591         this.actionAttribute = actionAttribute;
592     }
593
594     public void setActionBody(String actionBody) {
595         this.actionBody = actionBody;
596     }
597
598     public void setDropDownMap(Map<String, String> dropDownMap) {
599         this.dropDownMap = dropDownMap;
600     }
601
602     public void setActionDictHeader(String actionDictHeader) {
603         this.actionDictHeader = actionDictHeader;
604     }
605
606     public void setActionDictType(String actionDictType) {
607         this.actionDictType = actionDictType;
608     }
609
610     public void setActionDictUrl(String actionDictUrl) {
611         this.actionDictUrl = actionDictUrl;
612     }
613
614     public void setActionDictMethod(String actionDictMethod) {
615         this.actionDictMethod = actionDictMethod;
616     }
617
618     public void setDynamicSettingsMap(Map<String, String> dynamicSettingsMap) {
619         this.dynamicSettingsMap = dynamicSettingsMap;
620     }
621
622     public void setDynamicVariableList(List<Object> dynamicVariableList) {
623         this.dynamicVariableList = dynamicVariableList;
624     }
625
626     public void setDataTypeList(List<String> dataTypeList) {
627         this.dataTypeList = dataTypeList;
628     }
629
630     public void setDraft(Boolean draft) {
631         this.draft = draft;
632     }
633
634     public void setOldPolicyFileName(String oldPolicyFileName) {
635         this.oldPolicyFileName = oldPolicyFileName;
636     }
637
638     public void setServiceType(String serviceType) {
639         this.serviceType = serviceType;
640     }
641
642     public Map<String, String> getDrlRuleAndUIParams() {
643         return drlRuleAndUIParams;
644     }
645
646     public void setDrlRuleAndUIParams(Map<String, String> drlRuleAndUIParams) {
647         this.drlRuleAndUIParams = drlRuleAndUIParams;
648     }
649
650     public void setUuid(String uuid) {
651         this.uuid = uuid;
652     }
653
654     public void setMsLocation(String msLocation) {
655         this.msLocation = msLocation;
656     }
657
658     public void setPriority(String priority) {
659         this.priority = priority;
660     }
661
662     public void setDeleteCondition(String deleteCondition) {
663         this.deleteCondition = deleteCondition;
664     }
665
666     public void setDictionaryType(String dictionaryType) {
667         this.dictionaryType = dictionaryType;
668     }
669
670     public void setDictionary(String dictionary) {
671         this.dictionary = dictionary;
672     }
673
674     public void setDictionaryFields(String dictionaryFields) {
675         this.dictionaryFields = dictionaryFields;
676     }
677
678     public String getProviderComboBox() {
679         return providerComboBox;
680     }
681
682     public void setProviderComboBox(String providerComboBox) {
683         this.providerComboBox = providerComboBox;
684     }
685
686     public void setRiskType(String riskType) {
687         this.riskType = riskType;
688     }
689
690     public void setRiskLevel(String riskLevel) {
691         this.riskLevel = riskLevel;
692     }
693
694     public void setGuard(String guard) {
695         this.guard = guard;
696     }
697
698     public void setTTLDate(String ttlDate) {
699         this.ttlDate = ttlDate;
700     }
701
702     public String getBrmsController() {
703         return brmsController;
704     }
705
706     public void setBrmsController(String brmsController) {
707         this.brmsController = brmsController;
708     }
709
710     public List<String> getBrmsDependency() {
711         return brmsDependency;
712     }
713
714     public void setBrmsDependency(List<String> brmsDependency) {
715         this.brmsDependency = brmsDependency;
716     }
717
718     public void setTreatments(Map<String, String> treatments) {
719         this.treatments = treatments;
720     }
721 }