pzampino commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r608927174
##########
File path:
gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
}
+
+ @Override
+ public Map<String, Collection<String>> getHomePageProfiles() {
+ final Map<String, Collection<String>> profiles =
getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+ this.forEach(config -> {
+ if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+
profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()),
getTrimmedStringCollection(config.getKey()));
+ }
+ });
+ return profiles;
+ }
+
+ private Map<String, Collection<String>> getPreConfiguredProfiles() {
+ final Map<String, Collection<String>> profiles = new HashMap<>();
+ profiles.put("full", Arrays.asList("gpi_version", "gpi_cert",
"gpi_admin_ui", "gpi_admin_api", "gpi_md_api", "gpi_tokens"));
Review comment:
Why not reference the constants in the Profile class?
I might go so far as to define the arrays as constants too.
```
static final String[] PROFILE_FULL = {PROFILE_GPI_VERSION, PROFILE_GPI_CERT,
PROFILE_GPI_ADMIN_UI, PROFILE_GPI_ADMIN_API, PROFILE_GPI_META_API,
PROFILE_GPI_TOKENS};
static final String[] PROFILE_THIN = {PROFILE_GPI_VERSION, PROFILE_GPI_CERT};
static final String[] PROFILE_TOKEN = {PROFILE_GPI_VERSION,
PROFILE_GPI_TOKENS};
```
##########
File path:
gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
##########
@@ -250,4 +253,18 @@ private ServiceModel getServiceModel(HttpServletRequest
request, String gatewayP
return serviceModel;
}
+ @GET
+ @Produces({ APPLICATION_JSON })
+ @Path("profiles/{profile}")
+ public String getProfile(@PathParam("profile") String profileName) {
+ final GatewayConfig config = (GatewayConfig)
request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
+ final Map<String, Collection<String>> configuredProfiles =
config.getHomePageProfiles();
+ if (configuredProfiles.containsKey(profileName)) {
Review comment:
Are profile names case-sensitive?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]