2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.rest.retired;
24 import java.util.ArrayList;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.ws.rs.DELETE;
28 import javax.ws.rs.GET;
29 import javax.ws.rs.POST;
30 import javax.ws.rs.PUT;
31 import javax.ws.rs.Path;
32 import javax.ws.rs.PathParam;
33 import javax.ws.rs.core.Context;
34 import javax.ws.rs.core.HttpHeaders;
35 import javax.ws.rs.core.Response;
36 import javax.ws.rs.core.UriInfo;
38 import io.swagger.jaxrs.PATCH;
40 import org.onap.aai.exceptions.AAIException;
41 import org.onap.aai.logging.ErrorLogHelper;
42 import org.onap.aai.restcore.RESTAPI;
43 import org.onap.aai.util.AAIConfig;
46 * The Class RetiredConsumer.
48 public abstract class RetiredConsumer extends RESTAPI {
51 * Creates the message get.
53 * @param versionParam the version param
54 * @param headers the headers
55 * @param info the info
57 * @return the response
61 public Response createMessageGet(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
62 return createMessage(versionParam, headers, info, req);
66 * Creates the message delete.
68 * @param versionParam the version param
69 * @param headers the headers
70 * @param info the info
72 * @return the response
76 public Response createMessageDelete(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
77 return createMessage(versionParam, headers, info, req);
81 * Creates the message post.
83 * @param versionParam the version param
84 * @param headers the headers
85 * @param info the info
87 * @return the response
91 public Response createMessagePost(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
92 return createMessage(versionParam, headers, info, req);
97 public Response createMessagePatch(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
98 return createMessage(versionParam, headers, info, req);
101 * Creates the message put.
103 * @param versionParam the version param
104 * @param headers the headers
105 * @param info the info
107 * @return the response
111 public Response createMessagePut(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
112 return createMessage(versionParam, headers, info, req);
117 * Creates the message.
119 * @param versionParam the version param
120 * @param headers the headers
121 * @param info the info
123 * @return the response
125 private Response createMessage(String versionParam, HttpHeaders headers, UriInfo info, HttpServletRequest req) {
126 AAIException e = new AAIException("AAI_3007");
128 ArrayList<String> templateVars = new ArrayList<String>();
130 if (templateVars.size() == 0) {
131 templateVars.add("PUT");
132 templateVars.add(info.getPath().toString());
133 templateVars.add(versionParam);
134 templateVars.add(AAIConfig.get("aai.default.api.version", ""));
137 Response response = Response
138 .status(e.getErrorObject().getHTTPResponseCode())
139 .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
140 templateVars)).build();