From 1367b73c1d1d761939f5893c711f87716a7baad0 Mon Sep 17 00:00:00 2001 From: ilanap Date: Tue, 26 Nov 2019 11:53:36 +0200 Subject: Add API to retrieve UI configuration Added configuration file with the menu configuration from catalog-ui. Added to the configuration manager. to chef and to the ui rest APIs. Issue-ID: SDC-2663 Signed-off-by: ilanap Change-Id: Ia5e014a273238981241821c0d81b0455bd662b28 Signed-off-by: ilanap --- .../openecomp/sdc/fe/servlets/ConfigServlet.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'catalog-fe/src/main') diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java index 138318bb61..08b7c43397 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java @@ -23,6 +23,10 @@ package org.openecomp.sdc.fe.servlets; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.fe.config.FeEcompErrorManager; import org.openecomp.sdc.fe.impl.PluginStatusBL; +import org.openecomp.sdc.fe.config.ConfigurationManager; +import org.openecomp.sdc.fe.config.WorkspaceConfiguration; +import org.openecomp.sdc.exception.NotFoundException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +49,37 @@ public class ConfigServlet extends LoggingServlet { private static final Logger LOGGER = LoggerFactory.getLogger(ConfigServlet.class.getName()); + @GET + @Path("/ui/workspace") + @Produces(MediaType.APPLICATION_JSON) + public Response getUIWorkspaceConfiguration(@Context final HttpServletRequest request) { + + try { + logFeRequest(request); + + ServletContext context = request.getSession().getServletContext(); + + ConfigurationManager configurationManager = (ConfigurationManager) context + .getAttribute(Constants.CONFIGURATION_MANAGER_ATTR); + + WorkspaceConfiguration configuration = configurationManager.getWorkspaceConfiguration(); + if (configuration == null) { + throw new NotFoundException(WorkspaceConfiguration.class.getSimpleName()); + } + LOGGER.info("The value returned from getConfig is {}", configuration); + String result = gson.toJson(configuration); + Response response = Response.status(Status.OK).entity(result).build(); + logFeResponse(request, response); + + return response; + } catch (Exception e) { + FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Response"); + LOGGER.error("Unexpected FE response logging error :", e); + return Response.status(Status.INTERNAL_SERVER_ERROR).entity("{}").build(); + } + + } + @GET @Path("/ui/plugins") -- cgit 1.2.3-korg