-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring to use Java backed code to invoke Native SOLR Admin Console
- Loading branch information
Showing
8 changed files
with
113 additions
and
96 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
...ry/src/main/java/org/orderofthebee/addons/support/tools/repo/search/SolrAdminConsole.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...c/main/java/org/orderofthebee/addons/support/tools/repo/search/SolrAdminNativeClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.orderofthebee.addons.support.tools.repo.search; | ||
|
||
/** | ||
* SOLR Admin HTTP Client for native SOLR services. | ||
* This interface describes operations not covered by the <a href="https://docs.alfresco.com/search-services/latest/admin/restapi/">Alfresco REST API for SOLR</a> | ||
* | ||
* @author Angel Borroy | ||
*/ | ||
public interface SolrAdminNativeClient { | ||
|
||
/** | ||
* Get count of documents that require path indexing in SOLR. | ||
* @param coreName name of the core: alfresco, archive | ||
* @return Number of documents that require path indexing | ||
*/ | ||
long getCascadeTrackerPendingCount(String coreName); | ||
|
||
} |
58 changes: 0 additions & 58 deletions
58
...n/java/org/orderofthebee/addons/support/tools/repo/search/solr6/SolrAdminConsoleImpl.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
...a/org/orderofthebee/addons/support/tools/repo/search/solr6/SolrAdminNativeClientImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.orderofthebee.addons.support.tools.repo.search.solr6; | ||
|
||
import org.apache.commons.httpclient.HttpClient; | ||
import org.apache.commons.httpclient.methods.GetMethod; | ||
import org.json.simple.JSONObject; | ||
import org.json.simple.parser.JSONParser; | ||
import org.orderofthebee.addons.support.tools.repo.search.SolrAdminNativeClient; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
/** | ||
* SOLR Admin HTTP Client for native SOLR services. | ||
* This class provides access to requests not covered by the <a href="https://docs.alfresco.com/search-services/latest/admin/restapi/">Alfresco REST API for SOLR</a> | ||
* | ||
* @author Angel Borroy | ||
*/ | ||
public class SolrAdminNativeClientImpl implements SolrAdminNativeClient { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(SolrAdminNativeClientImpl.class); | ||
|
||
private HttpClient httpClient; | ||
|
||
private String baseUrl; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public long getCascadeTrackerPendingCount(String coreName) { | ||
try { | ||
GetMethod getMethod = new GetMethod( | ||
httpClient.getHostConfiguration().getHostURL() + baseUrl + "/" + coreName + "/select" | ||
+ "?fl=" + URLEncoder.encode("*,[cached]", StandardCharsets.UTF_8.toString()) | ||
+ "&q=" + URLEncoder.encode("{!term f=int@s_@cascade}1", StandardCharsets.UTF_8.toString()) | ||
+ "&wt=json"); | ||
httpClient.executeMethod(getMethod); | ||
JSONObject json = (JSONObject) new JSONParser().parse(getMethod.getResponseBodyAsString()); | ||
JSONObject response = (JSONObject) json.get("response"); | ||
return (long) response.get("numFound"); | ||
} catch (Exception e) { | ||
LOGGER.error(e.getMessage(), e); | ||
return -1; | ||
} | ||
} | ||
|
||
public void setHttpClient(HttpClient httpClient) { | ||
this.httpClient = httpClient; | ||
} | ||
|
||
public void setBaseUrl(String baseUrl) { | ||
this.baseUrl = baseUrl; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters