Realize thirdparty sdnc register API.
[aai/esr-server.git] / esr-mgr / src / main / java / org / onap / aai / esr / wrapper / ThirdpatySdncWrapper.java
1 /**
2  * Copyright 2017 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 java.util.ArrayList;
19
20 import javax.ws.rs.core.Response;
21
22 import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
23 import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
24 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
25 import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
26 import org.onap.aai.esr.util.ThirdpartySdncManagerUtil;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 public class ThirdpatySdncWrapper {
31
32   private static ThirdpatySdncWrapper thirdpatySdncWrapper;
33   private static final Logger LOG = LoggerFactory.getLogger(ThirdpatySdncWrapper.class);
34
35   /**
36    * get ThirdpatySdncWrapper instance.
37    * @return ThirdpatySdnc manager wrapper instance
38    */
39   public static ThirdpatySdncWrapper getInstance() {
40     if (thirdpatySdncWrapper == null) {
41       thirdpatySdncWrapper = new ThirdpatySdncWrapper();
42     }
43     return thirdpatySdncWrapper;
44   }
45   
46   public Response registerThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc) {
47     CommonRegisterResponse result = new CommonRegisterResponse();
48     EsrThirdpartySdncDetail esrSdncDetail = new EsrThirdpartySdncDetail();
49     esrSdncDetail = ThirdpartySdncManagerUtil.sdncRegisterInfo2EsrSdnc(thirdpartySdnc);
50     String sdncId = esrSdncDetail.getThirdpartySdncId();
51     try {
52       ExternalSystemProxy.registerSdnc(sdncId, esrSdncDetail);
53       result.setId(sdncId);
54       return Response.ok(result).build();
55     } catch (Exception e) {
56       e.printStackTrace();
57       LOG.error("Register thirdParty SDNC failed !" + e.getMessage());
58       return Response.serverError().build();
59     }
60     
61   }
62
63   public Response updateThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc) {
64     //TODO
65     return Response.ok().build();
66   }
67   
68   public Response queryThirdpartySdncList() {
69     //TODO
70     ArrayList<ThirdpartySdncRegisterInfo> thirdpartySdncList = new ArrayList<ThirdpartySdncRegisterInfo>();
71     return Response.ok(thirdpartySdncList).build();
72   }
73   
74   public Response queryThirdpartySdncById(String thirdpartySdncId) {
75     ThirdpartySdncRegisterInfo thirdpartySdnc = new ThirdpartySdncRegisterInfo();
76     //TODO
77     return Response.ok(thirdpartySdnc).build();
78   }
79   
80   public Response delThirdpartySdnc(String thirdpartySdncId) {
81     //TODO
82     return Response.noContent().build();
83   }
84 }