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 io.swagger.v3.oas.annotations.servers.Server;
25 import io.swagger.v3.oas.annotations.servers.Servers;
26 import io.swagger.v3.oas.annotations.tags.Tag;
27 import io.swagger.v3.oas.annotations.tags.Tags;
28 import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
29 import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
30 import org.openecomp.sdc.be.config.Configuration;
31 import org.openecomp.sdc.be.config.ConfigurationManager;
32 import org.openecomp.sdc.common.api.Constants;
33 import org.openecomp.sdc.common.log.wrappers.Logger;
34 import org.openecomp.sdc.common.servlets.BasicServlet;
36 import javax.servlet.ServletContext;
37 import javax.servlet.http.HttpServletRequest;
38 import javax.ws.rs.Consumes;
39 import javax.ws.rs.GET;
40 import javax.ws.rs.POST;
41 import javax.ws.rs.PUT;
42 import javax.ws.rs.Path;
43 import javax.ws.rs.Produces;
44 import javax.ws.rs.QueryParam;
45 import javax.ws.rs.core.Context;
46 import javax.ws.rs.core.MediaType;
49 * Root resource (exposed at "/" path)
51 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
52 @Tags({@Tag(name = "SDCE-2 APIs")})
53 @Servers({@Server(url = "/sdc2/rest")})
55 public class ConfigMgrServlet extends BasicServlet {
57 private static final Logger log = Logger.getLogger(ConfigMgrServlet.class);
61 @Produces(MediaType.APPLICATION_JSON)
62 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
63 public String getConfig(@Context final HttpServletRequest request, @QueryParam("type") String type) {
67 ServletContext context = request.getSession().getServletContext();
69 ConfigurationManager configurationManager = (ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR);
71 if (type == null || type.equals("configuration")) {
73 Configuration configuration = configurationManager.getConfiguration();
74 if (configuration == null) {
75 log.warn("Configuration of type {} was not found", Configuration.class);
77 log.info("The value returned from getConfig is {}", configuration);
79 result = gson.toJson(configuration);
90 @Produces(MediaType.TEXT_PLAIN)
91 @Consumes(MediaType.APPLICATION_JSON)
92 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
93 public String setConfig1(@Context final HttpServletRequest request, Configuration configuration) {
95 log.debug("{}", configuration);
103 @Produces(MediaType.TEXT_PLAIN)
104 @Consumes(MediaType.APPLICATION_JSON)
105 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
106 public void setConfig2(@Context final HttpServletRequest request, Configuration configuration) {
108 log.debug("{}", configuration);
114 @Produces(MediaType.TEXT_PLAIN)
115 @Consumes(MediaType.APPLICATION_JSON)
116 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
117 public String setConfig3(@Context final HttpServletRequest request, Configuration configuration) {
119 log.debug("{}", configuration);
127 @Produces(MediaType.TEXT_PLAIN)
128 @Consumes(MediaType.APPLICATION_JSON)
129 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
130 public void setConfig4(@Context final HttpServletRequest request, Configuration configuration) {
132 log.debug("{}", configuration);