2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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=========================================================
21 package org.openecomp.sdc.fe.servlets;
23 import org.openecomp.sdc.common.api.Constants;
24 import org.openecomp.sdc.fe.config.FeEcompErrorManager;
25 import org.openecomp.sdc.fe.impl.PluginStatusBL;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 import javax.servlet.ServletContext;
30 import javax.servlet.http.HttpServletRequest;
31 import javax.ws.rs.GET;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.Produces;
34 import javax.ws.rs.core.Context;
35 import javax.ws.rs.core.MediaType;
36 import javax.ws.rs.core.Response;
37 import javax.ws.rs.core.Response.Status;
40 * Root resource (exposed at "/" path)
43 public class ConfigServlet extends LoggingServlet {
45 private static final Logger log = LoggerFactory.getLogger(ConfigServlet.class.getName());
50 @Produces(MediaType.APPLICATION_JSON)
51 public Response getPluginsConfiguration(@Context final HttpServletRequest request) {
54 logFeRequest(request);
56 ServletContext context = request.getSession().getServletContext();
58 PluginStatusBL pluginStatusBL = (PluginStatusBL) context.getAttribute(Constants.PLUGIN_BL_COMPONENT);
60 String result = pluginStatusBL.checkPluginsListAvailability();
62 Response response = Response.status(Status.OK).entity(result).build();
64 logFeResponse(request, response);
67 } catch (Exception e) {
68 FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Response");
69 log.error("Unexpected FE response logging error :", e);
70 return Response.status(Status.OK).entity(null).build();
75 protected void inHttpRequest(HttpServletRequest httpRequest) {
76 log.info("{} {} {}", httpRequest.getMethod(), httpRequest.getRequestURI(), httpRequest.getProtocol());
80 * Extracted for purpose of clear method name, for logback %M parameter
81 * @param response http response
83 protected void outHttpResponse(Response response) {
84 log.info("SC=\"{}\"", response.getStatus());