diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-12-14 14:04:04 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-12-14 14:04:04 +0100 |
commit | cbe15ae1bd3f9bb6849cdf6e2684dcf85ce5298b (patch) | |
tree | da009450679256dc147cc62c30a8ae66c37766dc /configserver | |
parent | 60b73052b8fb2191c53871cc8faefa4e521c5eb7 (diff) |
Wrap anonymous JSONResponse implementation
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java index 9966f9c0770..0b461b10963 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java @@ -88,7 +88,7 @@ public class ApplicationHandler extends HttpHandler { if (isReindexingRequest(request)) { applicationRepository.modifyReindexing(applicationId, reindexing -> reindexing.enabled(false)); - return new JSONResponse(Response.Status.OK) { { object.setString("message", "Reindexing disabled"); } }; + return createMessageResponse("Reindexing disabled"); } if (applicationRepository.delete(applicationId)) @@ -218,7 +218,7 @@ public class ApplicationHandler extends HttpHandler { if (isReindexingRequest(request)) { applicationRepository.modifyReindexing(applicationId, reindexing -> reindexing.enabled(true)); - return new JSONResponse(Response.Status.OK) { { object.setString("message", "Reindexing enabled"); } }; + return createMessageResponse("Reindexing enabled"); } throw new NotFoundException("Illegal POST request '" + request.getUri() + "'"); @@ -247,7 +247,7 @@ public class ApplicationHandler extends HttpHandler { : "document types " + String.join(", ", types) + " in ") + "clusters " + String.join(", ", clusters) + " of ") + "application " + applicationId; - return new JSONResponse(Response.Status.OK) { { object.setString("message", message); } }; + return createMessageResponse(message); } private HttpResponse getReindexingStatus(ApplicationId applicationId) { @@ -491,4 +491,8 @@ public class ApplicationHandler extends HttpHandler { } + private static JSONResponse createMessageResponse(String message) { + return new JSONResponse(Response.Status.OK) { { object.setString("message", message); } }; + } + } |