Use lombok in apex-pdp #5
[policy/apex-pdp.git] / examples / examples-aadm / src / main / resources / org / onap / policy / apex / examples / aadm / model / mvel / AADMDoSProvenActTaskTaskLogic.mvel
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21 import org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus;
22 import org.onap.policy.apex.examples.aadm.concepts.ImsiStatus;
23
24 logger.debug(subject.id + ":" + subject.taskName + " execution logic");
25 logger.debug(inFields);
26
27 outFields["ACTTASK"] = "act";
28 outFields["TRIGGER_SPEC"] = "XSTREAM_AADM_ACT_EVENT";
29 outFields["MAJ_MIN_MAINT_VERSION"] = "0.0.1";
30 outFields["PROBE_ON"] = true;
31 outFields["TCP_ON"] = false;
32 outFields["IMSI"] = inFields["IMSI"];
33
34 if (inFields["IMSI_IP"] != null) {
35     outFields["IMSI_IP"] = inFields["IMSI_IP"];
36 }
37 else{
38     outFields["IMSI_IP"] = inFields["UE_IP_ADDRESS"];
39 }
40
41 if (inFields["NW_IP"] != null) {
42     outFields["NW_IP"] = inFields["NW_IP"];
43 }
44 else{
45     outFields["NW_IP"] = inFields["SGW_IP_ADDRESS"];
46 }
47
48 ImsiStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]);
49 logger.debug(imsiStatus);
50
51 ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBId());
52 eNodeBStatus.setBeingProbed(false);
53
54 leaveProbingOn = false;
55 for (ENodeBStatus enbStatus : getContextAlbum("ENodeBStatusAlbum").values) {
56     if (enbStatus.isBeingProbed()) {
57         leaveProbingOn = true;
58     }
59 }
60
61 if (!leaveProbingOn) {
62     outFields["PROBE_ON"] = false;
63     outFields["TCP_ON"] = false;
64 }
65
66 eNodeBStatus.decrementDosCount();
67 logger.debug(eNodeBStatus.getENodeB() + ": dosCount is " + eNodeBStatus.getDosCount());
68
69 imsiStatus.setAnomalous(false);
70
71 logger.debug("imsi: " + imsiStatus.getImsi() + " anamalous " + imsiStatus.isAnomalous());
72
73 getContextAlbum("IMSIStatusAlbum")  .put(imsiStatus.getImsi(),     imsiStatus);
74 getContextAlbum("ENodeBStatusAlbum").put(eNodeBStatus.getENodeB(), eNodeBStatus);
75
76 outFields["THRESHOLD"]    = 0;
77 outFields["PROFILE"]      = "";
78 outFields["VERSION"]      = "0.0.1";
79 outFields["BLACKLIST_ON"] = false;
80
81 return true;