JAMES-2575 extract parameter name to constant
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b3604a96 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b3604a96 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b3604a96 Branch: refs/heads/master Commit: b3604a96ad6b2ec2ca7cf0d1d56ff083ba689b7a Parents: ab9791f Author: Michael Schnitzler <[email protected]> Authored: Mon Oct 29 16:29:45 2018 +0100 Committer: Benoit Tellier <[email protected]> Committed: Wed Oct 31 08:48:29 2018 +0700 ---------------------------------------------------------------------- .../apache/james/webadmin/routes/HealthCheckRoutes.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/b3604a96/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/HealthCheckRoutes.java ---------------------------------------------------------------------- diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/HealthCheckRoutes.java b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/HealthCheckRoutes.java index 45df88b..2c28015 100644 --- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/HealthCheckRoutes.java +++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/routes/HealthCheckRoutes.java @@ -57,6 +57,8 @@ public class HealthCheckRoutes implements PublicRoutes { private static final Logger LOGGER = LoggerFactory.getLogger(HealthCheckRoutes.class); public static final String HEALTHCHECK = "/healthcheck"; + + private static final String PARAM_COMPONENT_NAME = "componentName"; private final JsonTransformer jsonTransformer; private final Set<HealthCheck> healthChecks; @@ -75,7 +77,7 @@ public class HealthCheckRoutes implements PublicRoutes { @Override public void define(Service service) { service.get(HEALTHCHECK, this::validateHealthchecks, jsonTransformer); - service.get(HEALTHCHECK + "/checks/:componentName", this::performHealthCheckForComponent, jsonTransformer); + service.get(HEALTHCHECK + "/checks/:" + PARAM_COMPONENT_NAME, this::performHealthCheckForComponent, jsonTransformer); } @GET @@ -94,11 +96,11 @@ public class HealthCheckRoutes implements PublicRoutes { } @GET - @Path("/checks/{componentName}") + @Path("/checks/{" + PARAM_COMPONENT_NAME + "}") @ApiOperation(value = "Perform the component's health check") @ApiImplicitParams({ @ApiImplicitParam( - name = "componentName", + name = PARAM_COMPONENT_NAME, required = true, paramType = "path", dataType = "String", @@ -107,7 +109,7 @@ public class HealthCheckRoutes implements PublicRoutes { value = "The URL encoded name of the component to check.") }) public Object performHealthCheckForComponent(Request request, Response response) { - String componentName = request.params("componentName"); + String componentName = request.params(PARAM_COMPONENT_NAME); Optional<HealthCheck> optHealthCheck = healthChecks.stream() .filter(c -> c.componentName().getName().equals(componentName)) .findFirst(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
