2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 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 package org.onap.aai.rest.retired;
22 import java.util.ArrayList;
24 import javax.servlet.http.HttpServletRequest;
25 import javax.ws.rs.DELETE;
26 import javax.ws.rs.GET;
27 import javax.ws.rs.POST;
28 import javax.ws.rs.PUT;
29 import javax.ws.rs.Path;
30 import javax.ws.rs.PathParam;
31 import javax.ws.rs.core.Context;
32 import javax.ws.rs.core.HttpHeaders;
33 import javax.ws.rs.core.Response;
34 import javax.ws.rs.core.UriInfo;
36 import io.swagger.jaxrs.PATCH;
38 import org.onap.aai.exceptions.AAIException;
39 import org.onap.aai.logging.ErrorLogHelper;
40 import org.onap.aai.restcore.RESTAPI;
41 import org.onap.aai.util.AAIConfig;
44 * The Class RetiredConsumer.
46 public abstract class RetiredConsumer extends RESTAPI {
49 * Creates the message get.
51 * @param versionParam the version param
52 * @param headers the headers
53 * @param info the info
55 * @return the response
59 public Response createMessageGet(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
60 return createMessage(versionParam, headers, info, req);
64 * Creates the message delete.
66 * @param versionParam the version param
67 * @param headers the headers
68 * @param info the info
70 * @return the response
74 public Response createMessageDelete(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
75 return createMessage(versionParam, headers, info, req);
79 * Creates the message post.
81 * @param versionParam the version param
82 * @param headers the headers
83 * @param info the info
85 * @return the response
89 public Response createMessagePost(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
90 return createMessage(versionParam, headers, info, req);
95 public Response createMessagePatch(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
96 return createMessage(versionParam, headers, info, req);
99 * Creates the message put.
101 * @param versionParam the version param
102 * @param headers the headers
103 * @param info the info
105 * @return the response
109 public Response createMessagePut(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
110 return createMessage(versionParam, headers, info, req);
115 * Creates the message.
117 * @param versionParam the version param
118 * @param headers the headers
119 * @param info the info
121 * @return the response
123 private Response createMessage(String versionParam, HttpHeaders headers, UriInfo info, HttpServletRequest req) {
124 AAIException e = new AAIException("AAI_3007");
126 ArrayList<String> templateVars = new ArrayList<String>();
128 if (templateVars.size() == 0) {
129 templateVars.add("PUT");
130 templateVars.add(info.getPath().toString());
131 templateVars.add(versionParam);
132 templateVars.add(AAIConfig.get("aai.default.api.version", ""));
135 Response response = Response
136 .status(e.getErrorObject().getHTTPResponseCode())
137 .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
138 templateVars)).build();