24ad9bb0af1f90ec5b7abcb8fa2f02f72de8788e
[policy/apex-pdp.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 import org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus;
21 import org.onap.policy.apex.examples.aadm.concepts.IpAddressStatus;
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 ipAddress = inFields["UE_IP_ADDRESS"];
28 if (ipAddress == null ) {
29     ipAddress = inFields["IMSI_IP"];
30
31     if (ipAddress == null ) {
32         logger.debug("Incoming event must specify parameter UE_IP_ADDRESS or parameter IMSI_IP");
33         return false;
34     }
35 }
36
37 imsi = inFields["IMSI"];
38 if (imsi == null ) {
39     logger.debug("Incoming event must specify parameter IMSI");
40     return false;
41 }
42
43 eNodeBID = inFields["ENODEB_ID"];
44 if (eNodeBID == null ) {
45     logger.debug("Incoming event must specify parameter ENODEB_ID");
46     return false;
47 }
48
49 IpAddressStatus ipAddressStatus = getContextAlbum("IPAddressStatusAlbum").get(ipAddress);
50 if (ipAddressStatus == null) {
51     ipAddressStatus = new IpAddressStatus(ipAddress); 
52     ipAddressStatus.setImsi(imsi);
53     getContextAlbum("IPAddressStatusAlbum").put(ipAddressStatus.getIpAddress(), ipAddressStatus);
54     logger.debug("added new IP address " + getContextAlbum("IPAddressStatusAlbum").get(ipAddress));
55 }
56 else {
57     logger.debug("found IP address " + ipAddressStatus);
58 }
59
60 ImsiStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)imsi);
61 if (imsiStatus == null) {
62     imsiStatus = new ImsiStatus(imsi);
63     imsiStatus.setENodeBId(eNodeBID);
64     getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getImsi(), imsiStatus);
65     logger.debug("added new IMSI " + imsi + " to IMSI status map")
66 }
67
68 ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get((String)eNodeBID);
69 if (eNodeBStatus == null) {
70     eNodeBStatus = new ENodeBStatus(eNodeBID);
71     getContextAlbum("ENodeBStatusAlbum").put(eNodeBStatus.getENodeB(), eNodeBStatus);
72     logger.debug("added new ENodeB " + eNodeBID + " to ENodeB status map")
73 }
74
75 return true;