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.be.servlets;
23 import com.jcabi.aspects.Loggable;
24 import org.openecomp.sdc.be.config.Configuration;
25 import org.openecomp.sdc.be.config.ConfigurationManager;
26 import org.openecomp.sdc.common.api.Constants;
27 import org.openecomp.sdc.common.servlets.BasicServlet;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 import javax.servlet.ServletContext;
32 import javax.servlet.http.HttpServletRequest;
34 import javax.ws.rs.core.Context;
35 import javax.ws.rs.core.MediaType;
38 * Root resource (exposed at "/" path)
40 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
42 public class ConfigMgrServlet extends BasicServlet {
44 private static final Logger log = LoggerFactory.getLogger(ConfigMgrServlet.class);
48 @Produces(MediaType.APPLICATION_JSON)
49 public String getConfig(@Context final HttpServletRequest request, @QueryParam("type") String type) {
53 ServletContext context = request.getSession().getServletContext();
55 ConfigurationManager configurationManager = (ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR);
57 if (type == null || type.equals("configuration")) {
59 Configuration configuration = configurationManager.getConfiguration();
60 if (configuration == null) {
61 log.warn("Configuration of type {} was not found", Configuration.class);
63 log.info("The value returned from getConfig is {}", configuration);
65 result = gson.toJson(configuration);
76 @Produces(MediaType.TEXT_PLAIN)
77 @Consumes(MediaType.APPLICATION_JSON)
78 public String setConfig1(@Context final HttpServletRequest request, Configuration configuration) {
80 log.debug("{}", configuration);
88 @Produces(MediaType.TEXT_PLAIN)
89 @Consumes(MediaType.APPLICATION_JSON)
90 public void setConfig2(@Context final HttpServletRequest request, Configuration configuration) {
92 log.debug("{}", configuration);
98 @Produces(MediaType.TEXT_PLAIN)
99 @Consumes(MediaType.APPLICATION_JSON)
100 public String setConfig3(@Context final HttpServletRequest request, Configuration configuration) {
102 log.debug("{}", configuration);
110 @Produces(MediaType.TEXT_PLAIN)
111 @Consumes(MediaType.APPLICATION_JSON)
112 public void setConfig4(@Context final HttpServletRequest request, Configuration configuration) {
114 log.debug("{}", configuration);