Merge "Modify JAVA Env Setting"
[aai/esr-server.git] / esr-mgr / src / main / java / org / onap / aai / esr / resource / ThirdpartySdncManager.java
1 /**
2  * Copyright 2016-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.resource;
17
18 import com.codahale.metrics.annotation.Timed;
19 import io.swagger.annotations.Api;
20 import io.swagger.annotations.ApiOperation;
21 import io.swagger.annotations.ApiParam;
22 import io.swagger.annotations.ApiResponse;
23 import io.swagger.annotations.ApiResponses;
24 import org.eclipse.jetty.http.HttpStatus;
25 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
26 import org.onap.aai.esr.util.ExtsysUtil;
27 import org.onap.aai.esr.wrapper.ThirdpartySdncWrapper;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30 import javax.ws.rs.Consumes;
31 import javax.ws.rs.DELETE;
32 import javax.ws.rs.GET;
33 import javax.ws.rs.POST;
34 import javax.ws.rs.PUT;
35 import javax.ws.rs.Path;
36 import javax.ws.rs.PathParam;
37 import javax.ws.rs.Produces;
38 import javax.ws.rs.core.MediaType;
39 import javax.ws.rs.core.Response;
40
41
42 @Path("/sdncontrollers")
43 @Api(tags = {"ThirdParty sdnc Management "})
44 public class ThirdpartySdncManager {
45
46     private static final Logger LOGGER = LoggerFactory.getLogger(ThirdpartySdncManager.class);
47
48     private static ExtsysUtil extsysUtil = new ExtsysUtil();
49
50     /**
51      * query all thirdParty sdnc.
52      */
53     @GET
54     @ApiOperation(value = "get all thirdParty sdnc ")
55     @Produces(MediaType.APPLICATION_JSON)
56     @ApiResponses(value = {
57             @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
58             @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
59                     message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
60             @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
61                     response = String.class)})
62     @Timed
63     public Response queryThirdpartySdncList() {
64         LOGGER.info("start query all thirdParty sdnc!");
65         return ThirdpartySdncWrapper.getInstance().queryThirdpartySdncList();
66     }
67
68     /**
69      * query thirdParty sdnc by id.
70      */
71     @Path("/{thirdPartySdncId}")
72     @GET
73     @ApiOperation(value = "get thirdParty sdnc by id")
74     @Produces(MediaType.APPLICATION_JSON)
75     @ApiResponses(value = {
76             @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
77             @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
78                     message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
79             @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
80                     response = String.class)})
81     @Timed
82     public Response queryThirdpartySdncById(
83             @ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) {
84         LOGGER.info("start query thirdparty sdnc by id." + thirdPartySdncId);
85         return ThirdpartySdncWrapper.getInstance().queryThirdpartySdncById(thirdPartySdncId);
86     }
87
88     /**
89      * delete thirdparty sdnc by id.
90      */
91     @Path("/{thirdPartySdncId}")
92     @DELETE
93     @ApiOperation(value = "delete a thirdparty sdnc")
94     @ApiResponses(value = {
95             @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
96             @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
97                     message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
98             @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
99                     response = String.class)})
100     @Timed
101     public Response delThirdpartySdnc(
102             @ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) {
103         LOGGER.info("start delete thirdparty sdnc .id:" + thirdPartySdncId);
104         return ThirdpartySdncWrapper.getInstance().delThirdpartySdnc(thirdPartySdncId);
105     }
106
107     /**
108      * update thirdParty sdnc by id.
109      */
110     @PUT
111     @Path("/{thirdPartySdncId}")
112     @Consumes(MediaType.APPLICATION_JSON)
113     @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
114     @ApiOperation(value = "update a thirdParty Sdnc")
115     @ApiResponses(value = {
116             @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
117             @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
118                     message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
119             @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
120                     response = String.class)})
121     @Timed
122     public Response updateThirdpartySdnc(
123             @ApiParam(value = "thirdpartySdnc", required = true) ThirdpartySdncRegisterInfo thirdPartySdnc,
124             @ApiParam(value = "sdnc id", required = true) @PathParam("thirdPartySdncId") String thirdPartySdncId) {
125         LOGGER.info("start update sdnc .id:" + thirdPartySdncId + " info:" + extsysUtil.objectToString(thirdPartySdnc));
126         return ThirdpartySdncWrapper.getInstance().updateThirdpartySdnc(thirdPartySdnc, thirdPartySdncId);
127     }
128
129     /**
130      * thirdParty sdnc register.
131      */
132     @POST
133     @Consumes(MediaType.APPLICATION_JSON)
134     @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
135     @ApiOperation(value = "register a thirdparty sdnc")
136     @ApiResponses(value = {
137             @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
138             @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
139                     message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
140             @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
141                     response = String.class)})
142     @Timed
143     public Response registerThirdpatySdnc(
144             @ApiParam(value = "thirdPartySdnc", required = true) ThirdpartySdncRegisterInfo thirdPartySdnc) {
145         LOGGER.info("start register sdnc" + " info:" + extsysUtil.objectToString(thirdPartySdnc));
146         return ThirdpartySdncWrapper.getInstance().registerThirdpartySdnc(thirdPartySdnc);
147     }
148 }