]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6826: Finalized /index endpoint to support both fulltext and elasticsearch...
authorRichard Millet <remillet@yahoo.com>
Tue, 2 Jul 2019 20:36:21 +0000 (13:36 -0700)
committerRichard Millet <remillet@yahoo.com>
Tue, 2 Jul 2019 20:36:21 +0000 (13:36 -0700)
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml
services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java
services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoRepositoryClientImpl.java
services/index/service/src/main/java/org/collectionspace/services/index/IndexResource.java

index d18308b38282eeeda32fa9207cbf5107ebbc8fb2..cd664d914d915d136ba85b155d679414ef67a4f8 100644 (file)
                        </service:validatorHandler>
                        <service:properties xmlns:service="http://collectionspace.org/services/config/service">
                                <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <types:key>fulltextquery</types:key>
-                         <types:value>SELECT ecm:uuid, ecm:primaryType FROM Document WHERE ecm:isProxy = 0 AND ecm:currentLifeCycleState &lt;&gt; 'deleted' ORDER BY ecm:uuid</types:value>
+                         <types:key>fulltext</types:key>
+                         <types:value>SELECT ecm:uuid, ecm:primaryType FROM Document WHERE ecm:isProxy = 0 ORDER BY ecm:uuid</types:value>
+                       </types:item>
+                       <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                         <types:key>elasticsearch</types:key>
+                         <types:value>SELECT ecm:uuid, ecm:primaryType FROM Document WHERE ecm:isProxy = 0 ORDER BY ecm:uuid</types:value>
                        </types:item>
                        </service:properties>
                        <service:object xmlns:service="http://collectionspace.org/services/config/service" name="Index"
index 86330a49f7c32c31ea091e6f21013763c4f9ca2f..ec3edd4659ccec865677323e1820cad20a7859db 100644 (file)
@@ -112,10 +112,10 @@ public abstract class NuxeoBasedResource
         
         if (success == false) {
             Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
-                    ServiceMessages.REINDEX_FAILED + ServiceMessages.resourceNotReindexedMsg(csid)).type("text/plain").build();
+                    ServiceMessages.REINDEX_FAILED + ServiceMessages.indexResourceNotFoundMsg(indexid)).type("text/plain").build();
             throw new CSWebApplicationException(response);
         }
-               
+
                return result;
     }
     
@@ -127,25 +127,23 @@ public abstract class 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;
-               
+
         try {
             RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) 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;
     }
     
index 11494f4661b989cce84bc27821538fd8270e6123..39d7a6e75fa1b05a311b3902a3f29c9dc0025404 100644 (file)
@@ -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);
index 3c7aaf7d2cee817634da2b3340ba34f5bf34328e..6c15294e68ae21ab7c4869d851771e265d866e5d 100644 (file)
@@ -302,9 +302,14 @@ public class NuxeoRepositoryClientImpl implements RepositoryClient<PoxPayloadIn,
      */
     private boolean reindexElasticsearch(DocumentHandler handler, String csid, String indexid) throws NuxeoDocumentException, TransactionException {
        boolean result = false;
+        if (!Framework.isBooleanPropertyTrue("elasticsearch.enabled")) {
+               logger.info("Request to reindex Elasticsearch failed because Elasticsearch is not enabled.");
+               return result;
+        }
+        
         CoreSessionInterface repoSession = null;
         ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = handler.getServiceContext();
-        
+
         try {
             ElasticSearchIndexing esi = Framework.getService(ElasticSearchIndexing.class);
             ElasticSearchAdmin esa = Framework.getService(ElasticSearchAdmin.class);
index b6bad20b9cbf9da61c0807e83c3a0781421b47fd..b237b92044b3435b9c9fc60cd09f9600e304427e 100644 (file)
@@ -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);
         }