mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RestWrapper for Solr Admin API (#34)
This commit is contained in:
@@ -42,6 +42,7 @@ import org.alfresco.rest.requests.search.SearchSQLAPI;
|
|||||||
import org.alfresco.rest.requests.search.SearchSQLJDBC;
|
import org.alfresco.rest.requests.search.SearchSQLJDBC;
|
||||||
import org.alfresco.rest.requests.search.ShardInfoAPI;
|
import org.alfresco.rest.requests.search.ShardInfoAPI;
|
||||||
import org.alfresco.rest.requests.search.SolrAPI;
|
import org.alfresco.rest.requests.search.SolrAPI;
|
||||||
|
import org.alfresco.rest.requests.search.SolrAdminAPI;
|
||||||
import org.alfresco.rest.requests.workflowAPI.RestWorkflowAPI;
|
import org.alfresco.rest.requests.workflowAPI.RestWorkflowAPI;
|
||||||
import org.alfresco.utility.LogFactory;
|
import org.alfresco.utility.LogFactory;
|
||||||
import org.alfresco.utility.Utility;
|
import org.alfresco.utility.Utility;
|
||||||
@@ -956,6 +957,11 @@ public class RestWrapper extends DSLWrapper<RestWrapper>
|
|||||||
return new SolrAPI(this);
|
return new SolrAPI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SolrAdminAPI withSolrAdminAPI()
|
||||||
|
{
|
||||||
|
return new SolrAdminAPI(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@link RestDiscoveryAPI} using the rest Discovery API as prefix: {@link /alfresco/api/discovery}
|
* @return {@link RestDiscoveryAPI} using the rest Discovery API as prefix: {@link /alfresco/api/discovery}
|
||||||
*/
|
*/
|
||||||
|
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Alfresco Software Limited.
|
||||||
|
* This file is part of Alfresco
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.rest.requests.search;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.rest.core.RestRequest;
|
||||||
|
import org.alfresco.rest.core.RestResponse;
|
||||||
|
import org.alfresco.rest.core.RestWrapper;
|
||||||
|
import org.alfresco.rest.requests.ModelRequest;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
|
||||||
|
import io.restassured.RestAssured;
|
||||||
|
import io.restassured.http.Header;
|
||||||
|
import io.restassured.http.Headers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for SOLR Admin REST API
|
||||||
|
*
|
||||||
|
* @author aborroy
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SolrAdminAPI extends ModelRequest<SolrAdminAPI>
|
||||||
|
{
|
||||||
|
public SolrAdminAPI(RestWrapper restWrapper)
|
||||||
|
{
|
||||||
|
super(restWrapper);
|
||||||
|
RestAssured.basePath = "solr/admin";
|
||||||
|
|
||||||
|
restWrapper.configureSolrEndPoint();
|
||||||
|
restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RestResponse getAction(String action) throws Exception
|
||||||
|
{
|
||||||
|
List<Header> headers = new ArrayList<Header>();
|
||||||
|
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,
|
||||||
|
"cores?action=" + action + "&wt=json&{parameters}", restWrapper.getParameters());
|
||||||
|
return restWrapper.process(request);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user