From af74670b7268eb48059710a4d3a21d1f086fe854 Mon Sep 17 00:00:00 2001 From: JamesHillyard Date: Wed, 22 Dec 2021 12:12:56 +0000 Subject: [PATCH] Revert "Merge pull request #5323 from jGauravGupta/FISH-123" This reverts commit e1cec751f07718f774a4dabbff101ca9da278ae7. --- .../payara/admingui/microprofile/Strings.properties | 2 -- .../microprofile/specs/openAPIConfiguration.jsf | 8 +------- .../impl/admin/GetOpenApiConfigurationCommand.java | 4 +--- .../impl/admin/OpenApiServiceConfiguration.java | 10 +--------- .../impl/admin/SetOpenApiConfigurationCommand.java | 6 ------ .../{ => impl}/rest/app/OpenApiApplication.java | 8 ++++++-- .../impl/rest/app/provider/QueryFormatFilter.java | 2 +- .../impl/rest/app/provider/writer/YamlWriter.java | 2 +- .../impl/rest/app/service/OpenApiResource.java | 2 +- .../init/OpenApiServletContainerInitializer.java | 12 +++++------- 10 files changed, 17 insertions(+), 39 deletions(-) rename appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/{ => impl}/rest/app/OpenApiApplication.java (87%) diff --git a/appserver/admingui/microprofile-console-plugin/src/main/resources/fish/payara/admingui/microprofile/Strings.properties b/appserver/admingui/microprofile-console-plugin/src/main/resources/fish/payara/admingui/microprofile/Strings.properties index 05af38e6699..a7877dcb276 100644 --- a/appserver/admingui/microprofile-console-plugin/src/main/resources/fish/payara/admingui/microprofile/Strings.properties +++ b/appserver/admingui/microprofile-console-plugin/src/main/resources/fish/payara/admingui/microprofile/Strings.properties @@ -104,8 +104,6 @@ openAPI.configuration.securityEnabled=Enable Secure Access openAPI.configuration.securityEnabledHelp=If checked, /openapi endpoint can be accessed only via HTTPS and disables the HTTP method with 403 HTTP response. And you will be required to log in before accessing the OpenAPI endpoint. openAPI.configuration.roles=Roles: openAPI.configuration.rolesHelp=Separate multiple roles with comma -openAPI.configuration.endpoint=EndPoint -openAPI.configuration.endpointHelp=The context root used to expose the OpenAPI. openAPI.configuration.virtualServers=Virtual Servers: openAPI.configuration.virtualServersHelp=Associates an Internet domain name with a physical server. diff --git a/appserver/admingui/microprofile-console-plugin/src/main/resources/microprofile/specs/openAPIConfiguration.jsf b/appserver/admingui/microprofile-console-plugin/src/main/resources/microprofile/specs/openAPIConfiguration.jsf index 2e17884f244..05b7e4fbc06 100644 --- a/appserver/admingui/microprofile-console-plugin/src/main/resources/microprofile/specs/openAPIConfiguration.jsf +++ b/appserver/admingui/microprofile-console-plugin/src/main/resources/microprofile/specs/openAPIConfiguration.jsf @@ -2,7 +2,7 @@ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - Copyright (c) [2018-2021] Payara Foundation and/or its affiliates. All rights reserved. + Copyright (c) [2018-2019] Payara Foundation and/or its affiliates. All rights reserved. The contents of this file are subject to the terms of either the GNU General Public License Version 2 only ("GPL") or the Common Development @@ -113,12 +113,6 @@ helpText="$resource{i18n_microprofile.openAPI.configuration.rolesHelp}"> - - - diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/GetOpenApiConfigurationCommand.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/GetOpenApiConfigurationCommand.java index ff92088f97c..0cbf836669f 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/GetOpenApiConfigurationCommand.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/GetOpenApiConfigurationCommand.java @@ -76,7 +76,7 @@ }) public class GetOpenApiConfigurationCommand implements AdminCommand { - private final String[] OUTPUT_HEADERS = {"Enabled", "EndPoint", "VirtualServers", "CorsHeaders", "Security Enabled", "Roles"}; + private final String[] OUTPUT_HEADERS = {"Enabled", "VirtualServers", "CorsHeaders", "Security Enabled", "Roles"}; @Inject private Target targetUtil; @@ -101,7 +101,6 @@ public void execute(AdminCommandContext context) { ColumnFormatter columnFormatter = new ColumnFormatter(OUTPUT_HEADERS); Object[] outputValues = { openApiConfig.getEnabled(), - openApiConfig.getEndpoint(), openApiConfig.getVirtualServers(), openApiConfig.getCorsHeaders(), openApiConfig.getSecurityEnabled(), @@ -113,7 +112,6 @@ public void execute(AdminCommandContext context) { Map extraPropertiesMap = new HashMap<>(); extraPropertiesMap.put("enabled", openApiConfig.getEnabled()); - extraPropertiesMap.put("endpoint", openApiConfig.getEndpoint()); extraPropertiesMap.put("virtualServers", openApiConfig.getVirtualServers()); extraPropertiesMap.put("corsHeaders", openApiConfig.getCorsHeaders()); extraPropertiesMap.put("securityenabled", openApiConfig.getSecurityEnabled()); diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/OpenApiServiceConfiguration.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/OpenApiServiceConfiguration.java index 5e404b85908..29a496a1eb7 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/OpenApiServiceConfiguration.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/OpenApiServiceConfiguration.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2018-2021] Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) [2018-2019] Payara Foundation and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -58,14 +58,6 @@ public interface OpenApiServiceConfiguration extends ConfigExtension { String getEnabled(); void setEnabled(String value) throws PropertyVetoException; - - /** - * @return a String value defines the endpoint of openapi service. - */ - @Attribute(defaultValue = "openapi") - String getEndpoint(); - - void setEndpoint(String value) throws PropertyVetoException; /** * Defines if CORS headers are set on the OpenApi response. diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/SetOpenApiConfigurationCommand.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/SetOpenApiConfigurationCommand.java index 9f2d00b45fd..22b82aaa575 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/SetOpenApiConfigurationCommand.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/admin/SetOpenApiConfigurationCommand.java @@ -85,9 +85,6 @@ public class SetOpenApiConfigurationCommand extends SetSecureMicroprofileConfigu @Param(name = "enabled", optional = true) private Boolean enabled; - @Param(name = "endpoint", optional = true) - private String endpoint; - @Param(name = "virtualServers", optional = true) private String virtualServers; @@ -129,9 +126,6 @@ public void execute(AdminCommandContext context) { if (enabled != null) { configProxy.setEnabled(Boolean.toString(enabled)); } - if (endpoint != null) { - configProxy.setEndpoint(endpoint); - } if (virtualServers != null) { configProxy.setVirtualServers(virtualServers); } diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/rest/app/OpenApiApplication.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/OpenApiApplication.java similarity index 87% rename from appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/rest/app/OpenApiApplication.java rename to appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/OpenApiApplication.java index 6f7368ba083..40f47a2e8c6 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/rest/app/OpenApiApplication.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/OpenApiApplication.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2018-2021] Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) [2018--2020] Payara Foundation and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -37,18 +37,22 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package fish.payara.microprofile.openapi.rest.app; +package fish.payara.microprofile.openapi.impl.rest.app; +import static fish.payara.microprofile.openapi.impl.rest.app.OpenApiApplication.OPEN_API_APPLICATION_PATH; import fish.payara.microprofile.openapi.impl.rest.app.provider.CorsHeadersFilter; import fish.payara.microprofile.openapi.impl.rest.app.provider.QueryFormatFilter; import fish.payara.microprofile.openapi.impl.rest.app.provider.writer.JsonWriter; import fish.payara.microprofile.openapi.impl.rest.app.provider.writer.YamlWriter; import fish.payara.microprofile.openapi.impl.rest.app.service.OpenApiResource; +import jakarta.ws.rs.ApplicationPath; import static jakarta.ws.rs.core.MediaType.TEXT_PLAIN; import org.glassfish.jersey.server.ResourceConfig; +@ApplicationPath(OPEN_API_APPLICATION_PATH) public class OpenApiApplication extends ResourceConfig { + public static final String OPEN_API_APPLICATION_PATH = "/openapi"; public static final String APPLICATION_YAML = TEXT_PLAIN; public OpenApiApplication() { diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/provider/QueryFormatFilter.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/provider/QueryFormatFilter.java index 30838ad5ce5..323452214b9 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/provider/QueryFormatFilter.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/provider/QueryFormatFilter.java @@ -39,7 +39,7 @@ */ package fish.payara.microprofile.openapi.impl.rest.app.provider; -import static fish.payara.microprofile.openapi.rest.app.OpenApiApplication.APPLICATION_YAML; +import static fish.payara.microprofile.openapi.impl.rest.app.OpenApiApplication.APPLICATION_YAML; import java.io.IOException; import java.util.Collections; import java.util.HashMap; diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/provider/writer/YamlWriter.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/provider/writer/YamlWriter.java index acf2dda3cc3..4d87bcff491 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/provider/writer/YamlWriter.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/provider/writer/YamlWriter.java @@ -39,7 +39,7 @@ */ package fish.payara.microprofile.openapi.impl.rest.app.provider.writer; -import static fish.payara.microprofile.openapi.rest.app.OpenApiApplication.APPLICATION_YAML; +import static fish.payara.microprofile.openapi.impl.rest.app.OpenApiApplication.APPLICATION_YAML; import fish.payara.microprofile.openapi.impl.rest.app.provider.ObjectMapperFactory; import jakarta.ws.rs.Produces; import jakarta.ws.rs.ext.Provider; diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/service/OpenApiResource.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/service/OpenApiResource.java index ff7dc6ab64f..e2b946669b1 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/service/OpenApiResource.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/app/service/OpenApiResource.java @@ -44,7 +44,7 @@ import fish.payara.microprofile.openapi.impl.model.OpenAPIImpl; import fish.payara.microprofile.openapi.impl.processor.BaseProcessor; -import static fish.payara.microprofile.openapi.rest.app.OpenApiApplication.APPLICATION_YAML; +import static fish.payara.microprofile.openapi.impl.rest.app.OpenApiApplication.APPLICATION_YAML; import java.io.IOException; import static java.util.logging.Level.WARNING; diff --git a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/init/OpenApiServletContainerInitializer.java b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/init/OpenApiServletContainerInitializer.java index 054c761da2d..b6598d6f0b0 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/init/OpenApiServletContainerInitializer.java +++ b/appserver/payara-appserver-modules/microprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/rest/init/OpenApiServletContainerInitializer.java @@ -40,7 +40,8 @@ package fish.payara.microprofile.openapi.impl.rest.init; import fish.payara.microprofile.openapi.impl.admin.OpenApiServiceConfiguration; -import fish.payara.microprofile.openapi.rest.app.OpenApiApplication; +import fish.payara.microprofile.openapi.impl.rest.app.OpenApiApplication; +import static fish.payara.microprofile.openapi.impl.rest.app.OpenApiApplication.OPEN_API_APPLICATION_PATH; import static java.util.Arrays.asList; import java.util.HashSet; import java.util.Map; @@ -54,7 +55,6 @@ import static jakarta.servlet.annotation.ServletSecurity.TransportGuarantee.CONFIDENTIAL; import static org.glassfish.common.util.StringHelper.isEmpty; import org.glassfish.internal.api.Globals; -import org.glassfish.jersey.servlet.ServletContainer; import org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer; /** @@ -70,16 +70,16 @@ public void onStartup(Set> c, ServletContext ctx) throws ServletExcepti if (!"".equals(ctx.getContextPath())) { return; } - OpenApiServiceConfiguration configuration = Globals.getDefaultHabitat().getService(OpenApiServiceConfiguration.class); // Check if there is already an endpoint for OpenAPI Map registrations = ctx.getServletRegistrations(); for (ServletRegistration reg : registrations.values()) { - if (reg.getMappings().contains(configuration.getEndpoint())) { + if (reg.getMappings().contains(OPEN_API_APPLICATION_PATH)) { return; } } + OpenApiServiceConfiguration configuration = Globals.getDefaultHabitat().getService(OpenApiServiceConfiguration.class); String virtualServers = configuration.getVirtualServers(); if (!isEmpty(virtualServers) && !asList(virtualServers.split(",")).contains(ctx.getVirtualServerName())) { @@ -89,9 +89,7 @@ public void onStartup(Set> c, ServletContext ctx) throws ServletExcepti // Start the OpenAPI application new JerseyServletContainerInitializer().onStartup(new HashSet<>(asList(OpenApiApplication.class)), ctx); - ServletContainer servletContainer = new ServletContainer(new OpenApiApplication()); - ServletRegistration.Dynamic reg = ctx.addServlet("microprofile-openapi-servlet", servletContainer); - reg.addMapping("/" + configuration.getEndpoint() + "/*"); + ServletRegistration.Dynamic reg = (ServletRegistration.Dynamic) ctx.getServletRegistrations().get(OpenApiApplication.class.getName()); if (Boolean.parseBoolean(configuration.getSecurityEnabled())) { String[] roles = configuration.getRoles().split(","); reg.setServletSecurity(new ServletSecurityElement(new HttpConstraintElement(CONFIDENTIAL, roles)));