Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import io.airlift.log.Logger;
import io.trino.gateway.ha.clustermonitor.ClusterStats;
Expand Down Expand Up @@ -90,7 +89,7 @@ public Response updateEntity(
EntityType entityType = EntityType.valueOf(entityTypeStr);
try {
switch (entityType) {
case GATEWAY_BACKEND:
case GATEWAY_BACKEND -> {
//TODO: make the gateway backend database sensitive
ProxyBackendConfiguration backend =
OBJECT_MAPPER.readValue(jsonPayload, ProxyBackendConfiguration.class);
Expand All @@ -105,13 +104,13 @@ public Response updateEntity(
ClusterStats.builder(backend.getName())
.trinoStatus(trinoStatus)
.build());
break;
case RESOURCE_GROUP:
}
case RESOURCE_GROUP -> {
ResourceGroupsDetail resourceGroupDetails = OBJECT_MAPPER.readValue(jsonPayload,
ResourceGroupsDetail.class);
resourceGroupsManager.updateResourceGroup(resourceGroupDetails, database);
break;
case SELECTOR:
}
case SELECTOR -> {
SelectorsDetail selectorDetails = OBJECT_MAPPER.readValue(jsonPayload,
SelectorsDetail.class);
List<SelectorsDetail> oldSelectorDetails =
Expand All @@ -123,8 +122,7 @@ public Response updateEntity(
else {
resourceGroupsManager.createSelector(selectorDetails, database);
}
break;
default:
}
}
}
catch (IOException e) {
Expand All @@ -143,15 +141,10 @@ public Response getAllEntitiesForType(
{
EntityType entityType = EntityType.valueOf(entityTypeStr);

switch (entityType) {
case GATEWAY_BACKEND:
return Response.ok(gatewayBackendManager.getAllBackends()).build();
case RESOURCE_GROUP:
return Response.ok(resourceGroupsManager.readAllResourceGroups(database)).build();
case SELECTOR:
return Response.ok(resourceGroupsManager.readAllSelectors(database)).build();
default:
}
return Response.ok(ImmutableList.of()).build();
return switch (entityType) {
case GATEWAY_BACKEND -> Response.ok(gatewayBackendManager.getAllBackends()).build();
case RESOURCE_GROUP -> Response.ok(resourceGroupsManager.readAllResourceGroups(database)).build();
case SELECTOR -> Response.ok(resourceGroupsManager.readAllSelectors(database)).build();
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@ public boolean authorize(LbPrincipal principal,
String role,
@Nullable ContainerRequestContext ctx)
{
switch (role) {
case "ADMIN":
return hasRole(principal, role, configuration.getAdmin());
case "USER":
return hasRole(principal, role, configuration.getUser());
case "API":
return hasRole(principal, role, configuration.getApi());
default:
log.warn("User '%s' with role %s has no regex match based on ldap search",
principal.getName(), role);
return false;
}
return switch (role) {
case "ADMIN" -> hasRole(principal, role, configuration.getAdmin());
case "USER" -> hasRole(principal, role, configuration.getUser());
case "API" -> hasRole(principal, role, configuration.getApi());
default -> {
log.warn("User '%s' with role %s has no regex match based on ldap search", principal.getName(), role);
yield false;
}
};
}

private static boolean hasRole(LbPrincipal principal, String role, String regex)
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
-Xep:InvalidThrows:ERROR \
-Xep:JavaTimeDefaultTimeZone:ERROR \
-Xep:MissingOverride:ERROR \
-Xep:StatementSwitchToExpressionSwitch:ERROR \
-Xep:StringCaseLocaleUsage:ERROR \
-Xep:TraditionalSwitchExpression:ERROR \
-Xep:TypeParameterUnusedInFormals:ERROR \
Expand Down