cdea726ef05d5a27f7ba5b1fc12947e138520ae2
[aai/gizmo.git] / src / main / java / org / onap / crud / service / JaxrsEchoService.java
1 /**
2  * ============LICENSE_START=======================================================
3  * Gizmo
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *    http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  *
22  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23  */
24 package org.onap.crud.service;
25
26 import org.onap.aai.cl.api.Logger;
27 import org.onap.aai.cl.eelf.LoggerFactory;
28 import org.onap.crud.logging.LoggingUtil;
29
30 import javax.servlet.http.HttpServletRequest;
31 import javax.ws.rs.GET;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.PathParam;
34 import javax.ws.rs.Produces;
35 import javax.ws.rs.core.Context;
36 import javax.ws.rs.core.HttpHeaders;
37 import javax.ws.rs.core.Response;
38 import javax.ws.rs.core.Response.Status;
39 import javax.ws.rs.core.UriInfo;
40
41
42 public class JaxrsEchoService {
43
44   private static Logger logger = LoggerFactory.getInstance()
45       .getLogger(JaxrsEchoService.class.getName());
46   private static Logger auditLogger = LoggerFactory.getInstance()
47       .getAuditLogger(JaxrsEchoService.class.getName());
48
49   @GET
50   @Path("echo/{input}")
51   @Produces("text/plain")
52   public String ping(@PathParam("input") String input,
53                      @Context HttpHeaders headers,
54                      @Context UriInfo info,
55                      @Context HttpServletRequest req) {
56
57     LoggingUtil.initMdcContext(req, headers);
58     LoggingUtil.logRestRequest(logger, auditLogger, req, Response.status(Status.OK)
59         .entity("OK").build());
60
61     return "Hello, " + input + ".";
62   }
63 }