diff --git a/repository/src/main/java/org/orderofthebee/addons/support/tools/repo/search/SolrAdminNativeClient.java b/repository/src/main/java/org/orderofthebee/addons/support/tools/repo/search/SolrAdminNativeClient.java new file mode 100644 index 0000000..8fa42b3 --- /dev/null +++ b/repository/src/main/java/org/orderofthebee/addons/support/tools/repo/search/SolrAdminNativeClient.java @@ -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 Alfresco REST API for SOLR + * + * @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); + +} diff --git a/repository/src/main/java/org/orderofthebee/addons/support/tools/repo/search/solr6/SolrAdminNativeClientImpl.java b/repository/src/main/java/org/orderofthebee/addons/support/tools/repo/search/solr6/SolrAdminNativeClientImpl.java new file mode 100644 index 0000000..6a71f04 --- /dev/null +++ b/repository/src/main/java/org/orderofthebee/addons/support/tools/repo/search/solr6/SolrAdminNativeClientImpl.java @@ -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 Alfresco REST API for SOLR + * + * @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; + } + +} diff --git a/repository/src/main/resources/alfresco/subsystems/Search/ootbee-support-tools-context.xml b/repository/src/main/resources/alfresco/subsystems/Search/ootbee-support-tools-context.xml new file mode 100644 index 0000000..93055d1 --- /dev/null +++ b/repository/src/main/resources/alfresco/subsystems/Search/ootbee-support-tools-context.xml @@ -0,0 +1,21 @@ + + + + + + + + + solrAdminNativeClient + + + + org.orderofthebee.addons.support.tools.repo.search.SolrAdminNativeClient + + + + + \ No newline at end of file diff --git a/repository/src/main/resources/alfresco/subsystems/Search/solr6/ootbee-support-tools-context.xml b/repository/src/main/resources/alfresco/subsystems/Search/solr6/ootbee-support-tools-context.xml new file mode 100644 index 0000000..156d62d --- /dev/null +++ b/repository/src/main/resources/alfresco/subsystems/Search/solr6/ootbee-support-tools-context.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/repository/src/main/resources/alfresco/templates/webscripts/org/orderofthebee/support-tools/admin/ootbee-support-tools/solr-tracking.get.html.ftl b/repository/src/main/resources/alfresco/templates/webscripts/org/orderofthebee/support-tools/admin/ootbee-support-tools/solr-tracking.get.html.ftl index 0128b19..7f31376 100644 --- a/repository/src/main/resources/alfresco/templates/webscripts/org/orderofthebee/support-tools/admin/ootbee-support-tools/solr-tracking.get.html.ftl +++ b/repository/src/main/resources/alfresco/templates/webscripts/org/orderofthebee/support-tools/admin/ootbee-support-tools/solr-tracking.get.html.ftl @@ -68,25 +68,27 @@ Copyright (C) 2005 - 2020 Alfresco Software Limited. -
- <@section label=msg("solr-tracking.section.detail.title") /> -
- <@field value="${trackingSummary[coreName]['MetadataTracker Active']?string(msg('solr-tracking.true'), msg('solr-tracking.false'))}" label=msg("solr-tracking.section.detail.metadata.title") description=msg("solr-tracking.section.detail.metadata.description")/> - <@field value="${trackingSummary[coreName]['ContentTracker Active']?string(msg('solr-tracking.true'), msg('solr-tracking.false'))}" label=msg("solr-tracking.section.detail.content.title") description=msg("solr-tracking.section.detail.content.description")/> - <@field value="${trackingSummary[coreName]['AclTracker Active']?string(msg('solr-tracking.true'), msg('solr-tracking.false'))}" label=msg("solr-tracking.section.detail.acl.title") description=msg("solr-tracking.section.detail.acl.description")/> - <@field value="${(cascadeTracker[coreName]['numFound'] > 0)?string(msg('solr-tracking.true'), msg('solr-tracking.false'))}" label=msg("solr-tracking.section.detail.cascade.title") description=msg("solr-tracking.section.detail.cascade.description")/> -
-
- <@field value="${trackingSummary[coreName]['Approx transactions remaining']?c}" label=msg("solr-tracking.section.detail.metadata.count.title") description=msg("solr-tracking.section.detail.metadata.count.description") /> - <#if trackingSummary[coreName]['FTS']['Node count whose content needs to be updated']?has_content> - <@field value="${trackingSummary[coreName]['FTS']['Node count whose content needs to be updated']?c}" label=msg("solr-tracking.section.detail.content.count.title") description=msg("solr-tracking.section.detail.content.count.description")/> - <#else> - <@field value="${(trackingSummary[coreName]['FTS']['Node count with FTSStatus New'] + trackingSummary[coreName]['FTS']['Node count with FTSStatus Dirty'])?c}" label=msg("solr-tracking.section.detail.content.count.title") description=msg("solr-tracking.section.detail.content.count.description")/> - - <@field value="${trackingSummary[coreName]['Approx change sets remaining']?c}" label=msg("solr-tracking.section.detail.acl.count.title") description=msg("solr-tracking.section.detail.acl.count.description") /> - <@field value="${cascadeTracker[coreName]['numFound']?c}" label=msg("solr-tracking.section.detail.cascade.count.title") description=msg("solr-tracking.section.detail.cascade.count.description") /> +
+ + <@section label=msg("solr-tracking.section.detail.title") /> +
+ <@field value="${trackingSummary[coreName]['MetadataTracker Active']?string(msg('solr-tracking.true'), msg('solr-tracking.false'))}" label=msg("solr-tracking.section.detail.metadata.title") description=msg("solr-tracking.section.detail.metadata.description")/> + <@field value="${trackingSummary[coreName]['ContentTracker Active']?string(msg('solr-tracking.true'), msg('solr-tracking.false'))}" label=msg("solr-tracking.section.detail.content.title") description=msg("solr-tracking.section.detail.content.description")/> + <@field value="${trackingSummary[coreName]['AclTracker Active']?string(msg('solr-tracking.true'), msg('solr-tracking.false'))}" label=msg("solr-tracking.section.detail.acl.title") description=msg("solr-tracking.section.detail.acl.description")/> + <@field value="${(cascadeTracker[coreName] > 0)?string(msg('solr-tracking.true'), msg('solr-tracking.false'))}" label=msg("solr-tracking.section.detail.cascade.title") description=msg("solr-tracking.section.detail.cascade.description")/> +
+
+ <@field value="${trackingSummary[coreName]['Approx transactions remaining']?c}" label=msg("solr-tracking.section.detail.metadata.count.title") description=msg("solr-tracking.section.detail.metadata.count.description") /> + <#if trackingSummary[coreName]['FTS']['Node count whose content needs to be updated']?has_content> + <@field value="${trackingSummary[coreName]['FTS']['Node count whose content needs to be updated']?c}" label=msg("solr-tracking.section.detail.content.count.title") description=msg("solr-tracking.section.detail.content.count.description")/> + <#else> + <@field value="${(trackingSummary[coreName]['FTS']['Node count with FTSStatus New'] + trackingSummary[coreName]['FTS']['Node count with FTSStatus Dirty'])?c}" label=msg("solr-tracking.section.detail.content.count.title") description=msg("solr-tracking.section.detail.content.count.description")/> + + <@field value="${trackingSummary[coreName]['Approx change sets remaining']?c}" label=msg("solr-tracking.section.detail.acl.count.title") description=msg("solr-tracking.section.detail.acl.count.description") /> + <@field value="${cascadeTracker[coreName]?c}" label=msg("solr-tracking.section.detail.cascade.count.title") description=msg("solr-tracking.section.detail.cascade.count.description") /> +
+
-
diff --git a/repository/src/main/resources/alfresco/templates/webscripts/org/orderofthebee/support-tools/admin/ootbee-support-tools/solr-tracking.lib.js b/repository/src/main/resources/alfresco/templates/webscripts/org/orderofthebee/support-tools/admin/ootbee-support-tools/solr-tracking.lib.js index f3bd1ec..b841afd 100644 --- a/repository/src/main/resources/alfresco/templates/webscripts/org/orderofthebee/support-tools/admin/ootbee-support-tools/solr-tracking.lib.js +++ b/repository/src/main/resources/alfresco/templates/webscripts/org/orderofthebee/support-tools/admin/ootbee-support-tools/solr-tracking.lib.js @@ -57,7 +57,7 @@ function buildPropertyGetter(ctxt) /* exported loadSolrSummaryAndStatus */ function loadSolrSummaryAndStatus() { - var ctxt, propertyGetter, indexSubsystem, solrContextFactory, solrContext, solrAdminClient, args, trackingSummaryResponse, trackingSummary, trackingStatusResponse, trackingStatus, coreNames; + var ctxt, propertyGetter, indexSubsystem, solrContextFactory, solrContext, solrAdminClient, solrAdminNativeClient, args, trackingSummaryResponse, trackingSummary, trackingStatusResponse, trackingStatus, coreNames; ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext(); propertyGetter = buildPropertyGetter(ctxt); @@ -93,25 +93,16 @@ function loadSolrSummaryAndStatus() }); model.coreNames = coreNames; - if (/^solr([6])?$/.test(indexSubsystem)) { - - model.cascadeTracker = []; - + if (/^solr([6])?$/.test(indexSubsystem)) + { + solrAdminNativeClient = solrContext + .getBean('solrAdminNativeClient', Packages.org.orderofthebee.addons.support.tools.repo.search.SolrAdminNativeClient); + model.cascadeTracker = []; for (var i in coreNames) { if (i) { - var solrHttpClientFactory = solrContext.getBean('solrHttpClientFactory', Packages.org.alfresco.httpclient.HttpClientFactory); - var getMethod = - new Packages.org.apache.commons.httpclient.methods.GetMethod( - solrHttpClientFactory.getHttpClient().getHostConfiguration().getHostURL() + - '/solr/' + coreNames[i] + '/select?' + - '?fl=' + encodeURIComponent('*,[cached]') + - '&q=' + encodeURIComponent('{!term f=int@s_@cascade}1') + - '&wt=json'); - solrHttpClientFactory.getHttpClient().executeMethod(getMethod); - model.cascadeTracker[coreNames[i]] = JSON.parse(getMethod.getResponseBodyAsString()).response; + model.cascadeTracker[coreNames[i]] = solrAdminNativeClient.getCascadeTrackerPendingCount(coreNames[i]); } } - } }