From 3aa883a4f82a1c8357bb69d1f414ace36b1c1262 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Tue, 2 Jul 2019 13:36:21 -0700 Subject: [PATCH] CSPACE-6826: Finalized /index endpoint to support both fulltext and elasticsearch reindexing. --- .../tenants/tenant-bindings-proto-unified.xml | 8 ++++++-- .../services/common/NuxeoBasedResource.java | 16 +++++++--------- .../services/common/ServiceMessages.java | 5 +++++ .../client/java/NuxeoRepositoryClientImpl.java | 7 ++++++- .../services/index/IndexResource.java | 4 ++-- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml index d18308b38..cd664d914 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml @@ -385,8 +385,12 @@ - fulltextquery - SELECT ecm:uuid, ecm:primaryType FROM Document WHERE ecm:isProxy = 0 AND ecm:currentLifeCycleState <> 'deleted' ORDER BY ecm:uuid + fulltext + SELECT ecm:uuid, ecm:primaryType FROM Document WHERE ecm:isProxy = 0 ORDER BY ecm:uuid + + + elasticsearch + SELECT ecm:uuid, ecm:primaryType FROM Document WHERE ecm:isProxy = 0 ORDER BY ecm:uuid ctx = (RemoteServiceContext) createServiceContext(uriInfo); - docType = ctx.getTenantQualifiedDoctype(); // this will used in the error message if an error occurs DocumentHandler handler = createDocumentHandler(ctx); success = getRepositoryClient(ctx).reindex(handler, indexid); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.REINDEX_FAILED); } - + if (success == false) { Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( - ServiceMessages.REINDEX_FAILED + ServiceMessages.resourceNotReindexedMsg(docType)).type("text/plain").build(); + ServiceMessages.REINDEX_FAILED + ServiceMessages.resourceTypeNotReindexedMsg(indexid)).type("text/plain").build(); throw new CSWebApplicationException(response); } - + return result; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java index 11494f466..39d7a6e75 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java @@ -67,6 +67,11 @@ public class ServiceMessages { public static String resourceNotFoundMsg(String csid) { return String.format("The resource identified by CSID '%s' was not found.", csid); } + + public static String indexResourceNotFoundMsg(String indexId) { + return String.format("The index resource '%s' was not found.", indexId); + } + public static String resourceNotReindexedMsg(String csid) { return String.format("The resource identified by CSID '%s' could not be reindexed. See the service logs for details.", csid); diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoRepositoryClientImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoRepositoryClientImpl.java index 3c7aaf7d2..6c15294e6 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoRepositoryClientImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoRepositoryClientImpl.java @@ -302,9 +302,14 @@ public class NuxeoRepositoryClientImpl implements RepositoryClient ctx = handler.getServiceContext(); - + try { ElasticSearchIndexing esi = Framework.getService(ElasticSearchIndexing.class); ElasticSearchAdmin esa = Framework.getService(ElasticSearchAdmin.class); diff --git a/services/index/service/src/main/java/org/collectionspace/services/index/IndexResource.java b/services/index/service/src/main/java/org/collectionspace/services/index/IndexResource.java index b6bad20b9..b237b9204 100644 --- a/services/index/service/src/main/java/org/collectionspace/services/index/IndexResource.java +++ b/services/index/service/src/main/java/org/collectionspace/services/index/IndexResource.java @@ -102,7 +102,7 @@ public class IndexResource extends NuxeoBasedResource { @Context UriInfo uriInfo, @PathParam("indexid") String indexid) { uriInfo = new UriInfoWrapper(uriInfo); - Response result = Response.noContent().build(); + Response result = Response.ok().build(); boolean success = false; String docType = null; @@ -117,7 +117,7 @@ public class IndexResource extends NuxeoBasedResource { if (success == false) { Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( - ServiceMessages.REINDEX_FAILED + ServiceMessages.resourceNotReindexedMsg(docType)).type("text/plain").build(); + ServiceMessages.REINDEX_FAILED + ServiceMessages.indexResourceNotFoundMsg(indexid)).type("text/plain").build(); throw new CSWebApplicationException(response); } -- 2.47.3