HUB Resource
[externalapi/nbi.git] / src / main / java / org / onap / nbi / apis / hub / MyAspect.java
1 /**
2  *     Copyright (c) 2018 Orange
3  *
4  *     Licensed under the Apache License, Version 2.0 (the "License");
5  *     you may not use this file except in compliance with the License.
6  *     You may obtain a copy of the License at
7  *
8  *         http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *     Unless required by applicable law or agreed to in writing, software
11  *     distributed under the License is distributed on an "AS IS" BASIS,
12  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *     See the License for the specific language governing permissions and
14  *     limitations under the License.
15  */
16 package org.onap.nbi.apis.hub;
17
18 import org.aspectj.lang.JoinPoint;
19 import org.aspectj.lang.annotation.AfterReturning;
20 import org.aspectj.lang.annotation.Aspect;
21 import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
22 import org.onap.nbi.apis.serviceorder.model.StateType;
23 import org.springframework.beans.factory.annotation.Configurable;
24 import org.springframework.stereotype.Component;
25
26 @Aspect
27 @Component
28 @Configurable
29 public class MyAspect {
30
31     @AfterReturning(value = "execution(* org.onap.nbi.apis.serviceorder.service.ServiceOrderService" +
32             ".createServiceOrder(..))", returning = "serviceOrderCreated")
33     public void whenCreateServiceOrder(ServiceOrder serviceOrderCreated) {
34         if(StateType.ACKNOWLEDGED.equals(serviceOrderCreated.getState())) {
35             //  Notif createServiceOrder
36         }
37     }
38
39     @AfterReturning(value = "execution(* org.onap.nbi.apis.serviceorder.service.ServiceOrderService" +
40             ".updateOrderState(..))", returning = "serviceOrderUpdated")
41     public void whenUpdateServiceOrderState(ServiceOrder serviceOrderUpdated) {
42         if(StateType.COMPLETED.equals(serviceOrderUpdated.getState())||
43                 StateType.FAILED.equals(serviceOrderUpdated.getState())) {
44             // Notif updateServiceOrder
45         }
46     }
47
48     @AfterReturning(value = "execution(* org.onap.nbi.apis.serviceorder.service.ServiceOrderService" +
49             ".updateOrderItemState(..))")
50     public void whenUpdateServiceOrderItemState(JoinPoint joinPoint) {
51         Object[] signatureArgs = joinPoint.getArgs();
52
53         if(signatureArgs != null && signatureArgs.length == 3) {
54             StateType serviceOrderItemState = (StateType) signatureArgs[2];
55             //  Notif updateServiceOrderItem
56
57         }
58     }
59 }