Realize the PNF registration API
[aai/esr-server.git] / esr-mgr / src / main / java / org / onap / aai / esr / wrapper / PnfManagerWrapper.java
1 /**
2  * Copyright 2018 ZTE Corporation.
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.aai.esr.wrapper;
17
18 import javax.ws.rs.core.Response;
19 import org.onap.aai.esr.entity.aai.Pnf;
20 import org.onap.aai.esr.entity.rest.PnfRegisterInfo;
21 import org.onap.aai.esr.exception.ExceptionUtil;
22 import org.onap.aai.esr.exception.ExtsysException;
23 import org.onap.aai.esr.externalservice.aai.NetworkProxy;
24 import org.onap.aai.esr.util.PnfManagerUtil;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 public class PnfManagerWrapper {
29     private static PnfManagerWrapper pnfManagerWrapper;
30     private static final Logger LOG = LoggerFactory.getLogger(PnfManagerWrapper.class);
31
32 //    private static PnfManagerUtil pnfManagerUtil = new PnfManagerUtil();
33     private static NetworkProxy networkProxy = new NetworkProxy();
34
35     /**
36      * get PnfManagerWrapper instance.
37      * 
38      * @return pnf manager wrapper instance
39      */
40     public static PnfManagerWrapper getInstance() {
41         if (pnfManagerWrapper == null) {
42             pnfManagerWrapper = new PnfManagerWrapper(networkProxy);
43         }
44         return pnfManagerWrapper;
45     }
46     
47     public PnfManagerWrapper(NetworkProxy networkProxy){
48         PnfManagerWrapper.networkProxy = networkProxy;
49     }
50
51     /**
52      * @return
53      */
54     public Response queryPnfList() {
55         // TODO Auto-generated method stub
56         return null;
57     }
58
59     /**
60      * @param pnfId
61      * @return
62      */
63     public Response queryPnfById(String pnfId) {
64         // TODO Auto-generated method stub
65         return null;
66     }
67
68     /**
69      * @param pnfId
70      * @return
71      */
72     public Response delPnf(String pnfId) {
73         // TODO Auto-generated method stub
74         return null;
75     }
76
77     /**
78      * @param pnf
79      * @param pnfId
80      * @return
81      */
82     public Response updatePnf(PnfRegisterInfo pnf, String pnfId) {
83         // TODO Auto-generated method stub
84         return null;
85     }
86
87     /**
88      * @param pnf
89      * @return
90      */
91     public Response registerPnf(PnfRegisterInfo pnfRegisterInfo) {
92         Pnf pnf = PnfManagerUtil.pnfRegisterInfo2pnf(pnfRegisterInfo);
93         String pnfName = pnf.getPnfName();
94         try {
95             networkProxy.registerPnf(pnfName, pnf);
96             return Response.ok().build();
97         } catch (ExtsysException e) {
98             LOG.error("Register PNF failed !", e);
99             throw ExceptionUtil.buildExceptionResponse(e.getMessage());
100         }
101     }
102 }