From bffceee21ca6ed4b45b315a7e81ecf3e879f031c Mon Sep 17 00:00:00 2001 From: "Brian M. Long" Date: Mon, 12 Jan 2026 11:50:19 -0500 Subject: [PATCH] added index endpoint --- .../asie/rest/IndexAcsNodeWebScript.java | 24 +++++++ .../alfresco/asie/service/IndexService.java | 43 +++++++++++++ .../alfresco/asie/spi/IndexCallback.java | 12 ++++ .../alfresco/asie/indexAcsNode.post.desc.xml | 63 +++++++++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 shared/src/main/java/com/inteligr8/alfresco/asie/rest/IndexAcsNodeWebScript.java create mode 100644 shared/src/main/java/com/inteligr8/alfresco/asie/service/IndexService.java create mode 100644 shared/src/main/java/com/inteligr8/alfresco/asie/spi/IndexCallback.java create mode 100644 shared/src/main/resources/alfresco/extension/templates/webscripts/com/inteligr8/alfresco/asie/indexAcsNode.post.desc.xml diff --git a/shared/src/main/java/com/inteligr8/alfresco/asie/rest/IndexAcsNodeWebScript.java b/shared/src/main/java/com/inteligr8/alfresco/asie/rest/IndexAcsNodeWebScript.java new file mode 100644 index 0000000..750d931 --- /dev/null +++ b/shared/src/main/java/com/inteligr8/alfresco/asie/rest/IndexAcsNodeWebScript.java @@ -0,0 +1,24 @@ +package com.inteligr8.alfresco.asie.rest; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.inteligr8.alfresco.asie.service.IndexService; +import com.inteligr8.alfresco.asie.spi.ActionCallback; + +@Component(value = "webscript.com.inteligr8.alfresco.asie.indexAcsNode.post") +public class IndexAcsNodeWebScript extends AbstractAcsNodeActionWebScript { + + @Autowired + private IndexService indexSerivce; + + @Override + protected void executeAction(long nodeDbId, ActionCallback callback, long fullQueueTimeout, TimeUnit fullQueueUnit, + long execTimeout, TimeUnit execUnit) throws TimeoutException, InterruptedException { + this.indexSerivce.index(nodeDbId, callback, 10L, TimeUnit.SECONDS, 30L, TimeUnit.SECONDS); + } + +} diff --git a/shared/src/main/java/com/inteligr8/alfresco/asie/service/IndexService.java b/shared/src/main/java/com/inteligr8/alfresco/asie/service/IndexService.java new file mode 100644 index 0000000..354e2d9 --- /dev/null +++ b/shared/src/main/java/com/inteligr8/alfresco/asie/service/IndexService.java @@ -0,0 +1,43 @@ +package com.inteligr8.alfresco.asie.service; + +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.springframework.stereotype.Component; + +import com.inteligr8.alfresco.asie.api.CoreAdminApi; +import com.inteligr8.alfresco.asie.model.ActionCoreResponse; +import com.inteligr8.alfresco.asie.model.core.IndexRequest; +import com.inteligr8.alfresco.asie.spi.ActionCallback; +import com.inteligr8.solr.model.Action; + +@Component +public class IndexService extends AbstractNodeActionService { + + @Override + protected String getActionName() { + return "index"; + } + + @Override + protected String getThreadNamePrefix() { + return "solr-index"; + } + + @Override + protected ActionCoreResponse execute(CoreAdminApi api, String core, long nodeDbId) { + IndexRequest apiRequest = new IndexRequest().withCore(core).withNodeId(nodeDbId); + return api.index(apiRequest); + } + + public Future index(long nodeDbId, ActionCallback callback) throws InterruptedException { + return super.action(nodeDbId, callback); + } + + public void index(long nodeDbId, ActionCallback callback, long fullQueueTimeout, TimeUnit fullQueueUnit, + long execTimeout, TimeUnit execUnit) throws TimeoutException, InterruptedException { + super.action(nodeDbId, callback, fullQueueTimeout, fullQueueUnit, execTimeout, execUnit); + } + +} diff --git a/shared/src/main/java/com/inteligr8/alfresco/asie/spi/IndexCallback.java b/shared/src/main/java/com/inteligr8/alfresco/asie/spi/IndexCallback.java new file mode 100644 index 0000000..9a87794 --- /dev/null +++ b/shared/src/main/java/com/inteligr8/alfresco/asie/spi/IndexCallback.java @@ -0,0 +1,12 @@ +package com.inteligr8.alfresco.asie.spi; + +import com.inteligr8.alfresco.asie.model.ShardInstance; + +public interface IndexCallback extends ActionCallback { + + @Override + default void unknownResult(ShardInstance instance) { + throw new IllegalStateException(); + } + +} diff --git a/shared/src/main/resources/alfresco/extension/templates/webscripts/com/inteligr8/alfresco/asie/indexAcsNode.post.desc.xml b/shared/src/main/resources/alfresco/extension/templates/webscripts/com/inteligr8/alfresco/asie/indexAcsNode.post.desc.xml new file mode 100644 index 0000000..adff6c3 --- /dev/null +++ b/shared/src/main/resources/alfresco/extension/templates/webscripts/com/inteligr8/alfresco/asie/indexAcsNode.post.desc.xml @@ -0,0 +1,63 @@ + + + + Index ACS Node in ASIE Indexes + Inteligr8 ASIE + Index the specified ACS node in the ASIE indexes. + This call will attempt to index the ACS node on all applicable Solr nodes. + The index operation could be synchronous or asynchronous and could fail on any Solr node. + If any Solr node failed synchronously in the execution, then expect a status code of 500. + The response body will still be identical to the 200/202 status codes. + If any Solr node is executing the index asynchronously and there are no synchronous failures, then expect a status code of 202.

+

The following path parameters are supported:

+
+
nodeId
+
An ACS node ID.
+
+

The following response body should be expected in most cases (200, 202, and 500 status codes):

+
+			{
+				"nodeDbId": number,
+				"success": [
+					"solrHostSync:8983/solr",
+					...
+				],
+				"scheduled": [
+					"solrHostAsync:8983/solr",
+					...
+				],
+				"error": [
+					"solrHostThatFailed:8983/solr": {
+						"message": "string"
+					},
+					...
+				]
+			}
+		
+

The following status codes should be expected:

+
+
200
+
OK
+
202
+
Accepted
+
400
+
The path or query parameters are invalid
+
+ ]]>
+ + + /inteligr8/asie/acs/node/{nodeId}/index + any + + + user + + + + false + false + + +
\ No newline at end of file