From 2c149b412e70d2b52fc4dbcb54f7b5a3e01c7430 Mon Sep 17 00:00:00 2001 From: Angel Borroy <48685308+aborroy@users.noreply.github.com> Date: Fri, 13 Nov 2020 09:54:13 +0100 Subject: [PATCH] SEARCH-2460: Additional methods to perform operations and queries in SOLR (#99) --- .../rest/requests/search/SolrAPI.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAPI.java index 2367cc2409..26aa99750c 100644 --- a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAPI.java +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAPI.java @@ -67,6 +67,17 @@ public class SolrAPI extends ModelRequest return restWrapper.processTextResponse(request); } + /** + * Executes an action (like "delete") on SOLR alfresco core + * @param urlActionPath some action name (like "delete") + * @param queryBody parameters for the action + */ + public RestTextResponse postAction(String urlActionPath, String queryBody) throws Exception + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, queryBody, urlActionPath); + return restWrapper.processTextResponse(request); + } + public RestTextResponse getSelectQuery() throws Exception { List
headers = new ArrayList
(); @@ -77,4 +88,19 @@ public class SolrAPI extends ModelRequest RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "select?q={parameters}", restWrapper.getParameters()); return restWrapper.processTextResponse(request); } + + /** + * Executes a query in SOLR using JSON format for the results + */ + public RestTextResponse getSelectQueryJson() throws Exception + { + List
headers = new ArrayList
(); + headers.add(new Header("Content-Type", "application/json")); + Headers header = new Headers(headers); + restWrapper.setResponseHeaders(header); + restWrapper.configureRequestSpec().setUrlEncodingEnabled(false); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "select?q={parameters}&wt=json", restWrapper.getParameters()); + return restWrapper.processTextResponse(request); + } + }