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.components.impl.aaf.AafPermission;
25 import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
26 import org.openecomp.sdc.be.config.Configuration;
27 import org.openecomp.sdc.be.config.ConfigurationManager;
28 import org.openecomp.sdc.common.api.Constants;
29 import org.openecomp.sdc.common.log.wrappers.Logger;
30 import org.openecomp.sdc.common.servlets.BasicServlet;
32 import javax.servlet.ServletContext;
33 import javax.servlet.http.HttpServletRequest;
34 import javax.ws.rs.Consumes;
35 import javax.ws.rs.GET;
36 import javax.ws.rs.POST;
37 import javax.ws.rs.PUT;
38 import javax.ws.rs.Path;
39 import javax.ws.rs.Produces;
40 import javax.ws.rs.QueryParam;
41 import javax.ws.rs.core.Context;
42 import javax.ws.rs.core.MediaType;
45 * Root resource (exposed at "/" path)
47 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
49 public class ConfigMgrServlet extends BasicServlet {
51 private static final Logger log = Logger.getLogger(ConfigMgrServlet.class);
55 @Produces(MediaType.APPLICATION_JSON)
56 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
57 public String getConfig(@Context final HttpServletRequest request, @QueryParam("type") String type) {
61 ServletContext context = request.getSession().getServletContext();
63 ConfigurationManager configurationManager = (ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR);
65 if (type == null || type.equals("configuration")) {
67 Configuration configuration = configurationManager.getConfiguration();
68 if (configuration == null) {
69 log.warn("Configuration of type {} was not found", Configuration.class);
71 log.info("The value returned from getConfig is {}", configuration);
73 result = gson.toJson(configuration);
84 @Produces(MediaType.TEXT_PLAIN)
85 @Consumes(MediaType.APPLICATION_JSON)
86 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
87 public String setConfig1(@Context final HttpServletRequest request, Configuration configuration) {
89 log.debug("{}", configuration);
97 @Produces(MediaType.TEXT_PLAIN)
98 @Consumes(MediaType.APPLICATION_JSON)
99 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
100 public void setConfig2(@Context final HttpServletRequest request, Configuration configuration) {
102 log.debug("{}", configuration);
108 @Produces(MediaType.TEXT_PLAIN)
109 @Consumes(MediaType.APPLICATION_JSON)
110 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
111 public String setConfig3(@Context final HttpServletRequest request, Configuration configuration) {
113 log.debug("{}", configuration);
121 @Produces(MediaType.TEXT_PLAIN)
122 @Consumes(MediaType.APPLICATION_JSON)
123 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
124 public void setConfig4(@Context final HttpServletRequest request, Configuration configuration) {
126 log.debug("{}", configuration);