-
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.
Merge pull request #1 from aborroy/feature/preview-search-details
Feature/preview search details
- Loading branch information
Showing
6 changed files
with
137 additions
and
34 deletions.
There are no files selected for viewing
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); | ||
|
||
} |
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; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
repository/src/main/resources/alfresco/subsystems/Search/ootbee-support-tools-context.xml
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,21 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd"> | ||
|
||
<bean id="solrAdminNativeClient.proxy" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory"> | ||
<property name="sourceApplicationContextFactory"> | ||
<ref bean="solrAdminNativeClient.subsystem.search" /> | ||
</property> | ||
<property name="sourceBeanName"> | ||
<value>solrAdminNativeClient</value> | ||
</property> | ||
<property name="interfaces"> | ||
<list> | ||
<value>org.orderofthebee.addons.support.tools.repo.search.SolrAdminNativeClient</value> | ||
</list> | ||
</property> | ||
</bean> | ||
|
||
</beans> |
14 changes: 14 additions & 0 deletions
14
...tory/src/main/resources/alfresco/subsystems/Search/solr6/ootbee-support-tools-context.xml
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,14 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd"> | ||
|
||
<bean id="solrAdminNativeClient" class="org.orderofthebee.addons.support.tools.repo.search.solr6.SolrAdminNativeClientImpl"> | ||
<property name="httpClient"> | ||
<bean factory-bean="solrHttpClientFactory" factory-method="getHttpClient" /> | ||
</property> | ||
<property name="baseUrl" value="${solr.baseUrl}" /> | ||
</bean> | ||
|
||
</beans> |
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